3.5.7.1 Java

Create the Cluster Object

A cluster, in terms of Oracle VM, is a child object of a server pool. The WsDevClient class in the sample code includes an example where a cluster object is created for the server pool created in the previous example. The sample code follows:

// Create a new cluster
Cluster testCluster = new Cluster();
testCluster.setName(testClusterName);

final Job clusterCreateJob = api.serverPoolCreateCluster(testPoolId, testCluster);
System.out.println("create cluster job id: " + clusterCreateJob.getId());
testClusterId = waitForJobComplete(api, clusterCreateJob, Cluster.class);

A cluster object only requires that a name is set for the object instance. Once this has been done, the serverPoolCreateCluster method is called from the OvmWsSoapClient class. Note that two parameters are passed to this method: the server pool ID value, obtained during the creation of the server pool, and the cluster object itself. The code for the serverPoolCreateCluster method is presented below:

@Override
    public Job serverPoolCreateCluster(final Id<ServerPool> serverPoolId, ]
       final Cluster cluster) throws WsException
    {
        try
        {
            return api.serverPoolCreateCluster(serverPoolId, cluster);
        }
        catch (final WsException_Exception ex)
        {
            throw convertException(ex);
        }
    }

As expected, this method is a wrapper around the actual API call.

Create a Cluster Heartbeat Device

A cluster requires a heartbeat device that can be located on shared storage accessible to all servers that get added to the server pool. For this purpose, we need to create the heartbeat device as a child object of the cluster object. The WsDevClient class contains an example of this:

ClusterHeartbeatDevice hbDevice = new ClusterHeartbeatDevice();
hbDevice.setName(clusterHeartbeatDeviceName);
hbDevice.setStorageType(clusterHeartbeatStorageDeviceType);
switch (clusterHeartbeatStorageDeviceType)
{
   case NFS:
     hbDevice.setNetworkFileSystemId(clusterHeartbeatNetworkFileSystem.getId());
     break;
   case STORAGE_ELEMENT:
     hbDevice.setStorageElementId(clusterHeartbeatStorageElement.getId());
     break;
   default:
     throw new Exception(
     "Invalid cluster heartbeat storage device type: " + 
        clusterHeartbeatStorageDeviceType);
}

final Job hbDeviceCreateJob = api.clusterCreateHeartbeatDevice(testClusterId, hbDevice);
System.out.println("create cluster heartbeat device job id: " + 
       hbDeviceCreateJob.getId());
testHeartbeatDeviceId = waitForJobComplete(api, hbDeviceCreateJob, 
       ClusterHeartbeatDevice.class);

The cluster heartbeat device requires a number of parameters that need to be set before the object is created. In the example, the code sets a variety of parameters based on variables defined in the WsDevClient.properties file. This provides the user of the example client with the option to define whether to use an NFS storage repository or an alternative such as an ISCSI LUN. Depending on the storage device type selected, the appropriate heartbeat device parameter, indicating the storage ID within Oracle VM Manager must be set.

Once the heartbeat device object parameters are set, the clusterCreateHeartbeatDevice method is called from the OvmWsSoapClient class. As for most of the methods defined in the OvmWsSoapClient class, this method is a wrapper for the actual API call.