Building DSS cluster |
Using the distributed hierarchical cluster method of SuperMap iServer 6R, one can join multiple cost-effective low-end servers to achieve the computatioinal ability of a high-end server. To construct a simple cluster, enable the cluster service and add a GIS application to the cluster service.
SuperMap iServer can cluster not only default maps and data services but also user-extended domain spatial services (DSS).
DSS consists of domain components and service interfaces. To ensure correct DSS clustering, developers need to implement the nameMapping element noted in @Component when develop domain components. The nameMapping element assigns an implementation type for the com.supermap.services.components.NameMapping interface. The implementation type is used for extracting the service ability of the service component.
The NameMapping interface has one method-getNames(Object object)-used to extract the service ability of a service component(object). It returns a List<String>. DSSs have the same service abilities will be load balanced in SuperMap iServer 6R clusters and provide that service ability together.
The configuration process of a DSS cluster is the same as the one of a default cluster. It can be done with the WebManager of SuperMap iServer 6R. After deploying the DSSs on multiple computers, select one as the cluster server (i.e. enable clustering in the window "Cluster>Enable cluster services"), and add the other machines to the cluster server (i.e. add reporters to the item cluster service report in the window "Cluster>Join a cluster")
Using the weather query DSS example (see *), cluster the weather query DSSs.
The following codes implement CityNameMapping (that implements a NameMapping interface), configure it to the com.supermap.sample.temperature.Temperature service component, and use it to extract the service ability of the DSS service:
@Component(providerTypes={MapProvider.class, TemperatureProvider.class}, optional=false,nameMapping=CityNameMapping.class) public class Temperature implements ComponentContextAware{ …… }
For detailed explanations about the annotation of Component, please see the implementation of Javadoc: com.supermap.services.components.Component. CityNameMapping is implemented as follows:
/** * <p> * City name mapping interface, used to extract the information in "TemperatureComponent". Here it extracts city names that have weather reports available. * </p> */ public class CityNameMapping implements NameMapping { @Override public List<String> getNames(Object object) { if(object instanceof Temperature) { return ((Temperature)object).getCityNames(); } else { return new ArrayList<String>(); } } }
Here, the weather query DSS uses the city names that have their weather reports available as identifiers for DSS service abilities, which can be obtained using the Temperature.getCityNames() method of the service component.
If one deploys weather query DSSs with the same service ability on two SuperMap iServer servers--C1 and S1 and accesses the following links:"http://C1:8090/iserver/services/Temperature/restjsr/Beijing" and "http://S1:8090/iserver/services/Temperature/restjsr/Beijing", both operations can get the weather report for "Beijing". The result (using C1 as an example) is shown as follows:
Using C1 as a cluster server and S1 as a child node, one can construct a simple cluster. To enable C1's cluster service, one needs to access the following link: "http://C1:8090/iserver/services/manager", open the WebManager of C1, go to the "Cluster>Enable cluster services" window, and click on the "Enable clusters" button. To report to C1, the user should open S1's WebManager, go to the "Cluster>Join a cluster" window, click on "Add a reporter", and use the following link as the reporter address: "http://C1:8090/iserver/services/cluster". Now the weather query DSS cluster has been completely set up.
After completing the cluster setup, one can access C1's weather query services, e.g. accessing "http://C1:8090/iserver/services/Temperature/restjsr/Beijing", and see that both servers--C1 and S1--provide services (this can be proven by checking the cache directory of S1 after multiple accesses).