WebSphere eXtreme Scale includes application programming interfaces (APIs) and system programming interfaces for embedding eXtreme Scale servers and clients within your existing Java applications. The following topic describes the available embedded server APIs.
You can use several properties to configure the eXtreme Scale server instance, which you can retrieve from the ServerFactory.getServerProperties method. The ServerProperties object is a singleton, so each call to the getServerProperties method retrieves the same instance.
You can create a new server with the following code.
Server server = ServerFactory.getInstance();
All properties set before the first invocation of getInstance are used to initialize the server.
You can set the server properties until the ServerFactory.getInstance is called for the first time. The first call of the getInstance method instantiates the eXtreme Scale server, and reads all the configured properties. Setting the properties after creation has no effect. the following example shows how to set properties prior to instantiating a Server instance.
// Get the server properties associated with this process. ServerProperties serverProperties = ServerFactory.getServerProperties(); // Set the server name for this process. serverProperties.setServerName("EmbeddedServerA"); // Set the name of the zone this process is contained in. serverProperties.setZoneName("EmbeddedZone1"); // Set the end point information required to bootstrap to the catalog service. serverProperties.setCatalogServiceBootstrap("localhost:2809"); // Set the ORB listener host name to use to bind to. serverProperties.setListenerHost("host.local.domain"); // Set the ORB listener port to use to bind to. serverProperties.setListenerPort(9010); // Turn off all MBeans for this process. serverProperties.setMBeansEnabled(false); Server server = ServerFactory.getInstance();
CatalogServerProperties catalogServerProperties = ServerFactory.getCatalogProperties(); catalogServerProperties.setCatalogServer(true); Server server = ServerFactory.getInstance();
Issue the Server.createContainer method for any JVM to host multiple eXtreme Scale containers. The following code shows how to instantiate an eXtreme Scale container:
Server server = ServerFactory.getInstance(); DeploymentPolicy policy = DeploymentPolicyFactory.createDeploymentPolicy( new File("META-INF/embeddedDeploymentPolicy.xml").toURI().toURL(), new File("META-INF/embeddedObjectGrid.xml").toURI().toURL()); Container container = server.createContainer(policy);
You can start all the services together, which is useful for development and also practical in production. By starting the services together, a single process does all of the following: Starts the catalog service, starts a set of containers, and runs the client connection logic. Starting the services in this way sorts out programming issues prior to deploying in a distributed environment. The following code shows how to instantiate a self-contained eXtreme Scale server:
CatalogServerProperties catalogServerProperties = ServerFactory.getCatalogProperties(); catalogServerProperties.setCatalogServer(true); Server server = ServerFactory.getInstance(); DeploymentPolicy policy = DeploymentPolicyFactory.createDeploymentPolicy( new File("META-INF/embeddedDeploymentPolicy.xml").toURI().toURL(), new File("META-INF/embeddedObjectGrid.xml").toURI().toURL()); Container container = server.createContainer(policy);
The configuration for eXtreme Scale is set up automatically when you install WebSphere® Extended Deployment DataGrid in a WebSphere Application Server environment. You are not required to set any properties before you access the server to create a container. The following code shows how to instantiate an eXtreme Scale server in WebSphere Application Server:
Server server = ServerFactory.getInstance(); DeploymentPolicy policy = DeploymentPolicyFactory.createDeploymentPolicy( new File("META-INF/embeddedDeploymentPolicy.xml").toURI().toURL(), new File("META-INF/embeddedObjectGrid.xml").toURI().toURL); Container container = server.createContainer(policy);