Summary: Cluster construction information is provided by the different Processing Unit containers, and is abstracted in a class called
ClusterInfo, which is injected into the Spring application context.
OverviewOne of the core ideas of the OpenSpaces Processing Unit is the fact that the topology the Processing Unit is deployed in, is decided in deploy-time. Therefore, when building a Processing Unit, there is almost no need to be aware of the actual cluster topology that the Processing Unit is deployed under.
When constructing an embedded space, information regarding its cluster topology is required. In OpenSpaces, cluster construction*** information is provided by the different Processing Unit containers. The information itself is abstracted in a class called ClusterInfo, which is injected into the Spring application context (encapsulated within the Processing Unit). ClusterInfoThe ClusterInfo class holds the following information:
ClusterInfoAwareIn a similar manner to the Spring ApplicationContextAware interface, that allows beans to be injected with Spring's ApplicationContext by implementing the interface; OpenSpaces provides the ClusterInfoAware interface: public interface ClusterInfoAware { /** * Sets the cluster information. * * <p>Note, the cluster information is obtained externally from the applicaiton context which means * that this feature need to be supported by specific containers (and is not supported by plain * Spring application context). This means that beans that implement {@link ClusterInfoAware} * should take into account the fact that the cluster info provided might be null. * * @param clusterInfo * The cluster information to be injected */ void setClusterInfo(ClusterInfo clusterInfo); } All built-in Processing Unit containers provide support for the ClusterInfo and ClusterInfoAware interfaces by default. Built-in OpenSpaces components make use of this feature. User-defined beans can make use of this information as well (for example, to connect to a specific database based on the ID of the Processing Unit instance). @ClusterInfoContext
public class MyBean { @ClusterInfoContext private ClusterInfo clusterInfo; ... } Space Construction and ClusterInfoThe Space component implements the ClusterInfoAware, and uses it in order to construct an embedded space by mapping ClusterInfo properties to Space URL properties (if provided). Here is a mapping from ClusterInfo to Space URL properties:
ClusterInfo XML InjectionWhen using one of the built-in containers, ClusterInfo can also be used within the Spring XML configuration. In a similar manner, properties can be injected. Here is an example of how they can be used: <bean id="myBean" class="MyBean"> <property name="connectionUrl" value="testconnection_${clusterInfo.runnimgNumber}" /> </bean> In the above example, the value of the connectionUrl and property of MyBean are built based on the runningNumber provided by the ClusterInfo interface. Here is a list mapping the ClusterInfo properties to their equivalent {...} values.
Processing Unit Container InjectionEvery Processing Unit container supports injection of ClusterInfo in a common manner. When running the container or deploying a Processing Unit to it, the -cluster command-line parameter should be supported: The -cluster option has the following optional parameters:
***Link required |
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |