Package com.opencloud.slee.remote

<p>Create remote management connections to Rhino and proxies for MBeans on the server.

See: Description

Package com.opencloud.slee.remote Description

<p>Create remote management connections to Rhino and proxies for MBeans on the server.</p> <h2>Connecting to Rhino</h2> <h3>Rhino Connection Factory</h3> <p>The <a href="RhinoConnectionFactory.html" title="class in com.opencloud.slee.remote"><code>RhinoConnectionFactory</code></a> class is used to create connections to Rhino. The class has connect methods that allow connection parameters to be specified in several different ways (see the class documentation for more details). </p> <h3>Rhino Connections</h3> <p>The objects returned by the connection factory implement <a href="RhinoConnection.html"><code>RhinoConnection</code></a>, which is a subinterface of MBeanServerConnection. The connection objects can therefore be used directly in other JMX Remote API calls. Also, MBeanServerConnection objects obtained via other means (e.g., from a local MBeanServer) can be used by the rest of the Rhino Remote library classes (but will obviously not have the extra features described below). </p> <p>If multiple servers are provided when creating a connection, they will be tried in the order given. Exceptions indicating a connection failure are only thrown when all servers are unreachable. If a previously active connection is found to have failed when attempting to execute a command, the other servers provided will be tried. The pending command will be executed if a connection can be made.</p> <h3>Execution Contexts</h3> <p>In some cases, it may be desirable to control whether or not a particular operation or set of operations is allowed to failover to another node. This control is available via the Execution Context mechanism. See <a href="RhinoConnection.html#setAllowedExecutionContext(com.opencloud.slee.remote.ExecutionContext)"><code>RhinoConnection.setAllowedExecutionContext(ExecutionContext)</code></a> and <a href="ExecutionContext.html"><code>ExecutionContext</code></a>. </p> <h3>SSL Configuration</h3> <p>If Rhino is configured to require SSL connections to the JMX-Remote interface (the default setting) then the SSL connection factory used by the JMX client must be provided with a keystore and a trust store, and a password for each. There are two ways of providing these settings. One is by setting system properties when starting the JVM that is running the JMX client: <pre> -Djavax.net.ssl.keyStore=$RHINO_CLIENT_HOME/rhino-public.keystore -Djavax.net.ssl.keyStorePassword=xxxxxxxx \ -Djavax.net.ssl.trustStore=$RHINO_CLIENT_HOME/rhino-public.keystore -Djavax.net.ssl.trustStorePassword=xxxxxxxx </pre> The other is to put these settings into a properties file or properties object, and use one of the connection factory methods that takes such a parameter. For example, in a properties file you could have the following lines: <pre> javax.net.ssl.trustStore=rhino-public.keystore javax.net.ssl.trustStorePassword=xxxxxxxx javax.net.ssl.keyStore=rhino-public.keystore javax.net.ssl.keyStorePassword=xxxxxxxx </pre> and then create a connection as follows: <pre> File propertiesFile = new File("remote.properties"); MBeanServerConnection connection = RhinoConnectionFactory.connect(propertiesFile); </pre> </p> <h3>Connection Logging</h3> <p>Exceptions thrown by the connection factory methods generally will contain sufficient detail to determine the cause of any connection problems. If more fine-grained tracing is needed, then a PrintWriter can be provided to the connection factory, and all connection objects will write trace messages to it while trying to connect. </p> <p>For examples of how to write connection trace messages to stdout or a Log4J logger, see <a href="RhinoConnectionFactory.html#setLogWriter(java.io.PrintWriter)"><code>RhinoConnectionFactory.setLogWriter(PrintWriter)</code></a>. </p> <h2>Retrieving JSLEE MBean Proxies</h2> <p>The <a href="SleeManagement.html" title="class in com.opencloud.slee.remote"><code>SleeManagement</code></a> class is used to create proxy instances for SLEE-standard MBeans with well-known Object Names. An <code>MBeanServerConnection</code> must be obtained first, then one of the methods on this class can be called. <pre> MBeanServerConnection connection = RhinoConnectionFactory.connect( …​ ); SleeManagementMBean sleeManagement = SleeManagement.getSleeManagementMBean(connection); </pre> </p> <h2>Retrieving Rhino MBean Proxies</h2> <p>The <a href="RhinoManagement.html" title="class in com.opencloud.slee.remote"><code>RhinoManagement</code></a> class is used to create proxy instances for Rhino-specific MBeans. An <code>MBeanServerConnection</code> must be obtained first, then one of the methods on this class can be called. <pre> MBeanServerConnection connection = RhinoConnectionFactory.connect( …​ ); RhinoHousekeepingMBean rhinoHousekeeping = RhinoManagement.getRhinoHousekeepingMBean(connection); </pre> </p> <h2>Working with Profiles</h2> <p>The <a href="RemoteProfiles.html"><code>RemoteProfiles</code></a> class contains a number of utility methods to greatly ease working with SLEE profile management operations. There are methods to: get proxies to ProfileMBeans; create and commit a new profile; create an uncommitted profile that can have its attributes set before it is committed; get attribute names, values and types. These methods are in addition to the standard management operations available on <a href="../../../../com/opencloud/rhino/management/profile/ProfileProvisioningMBean.html"><code>ProfileProvisioningMBean</code></a>. </p> <h3>Creating a Profile Table</h3> <p>This can be done using the <code>ProfileProvisioningMBean</code>, but <code>RemoteProfiles</code> has a utility method to check if a profile table exists: <pre> ProfileSpecificationID profileSpecificationID = new ProfileSpecificationID("AddressProfileSpec", "javax.slee", "1.0"); if(RemoteProfiles.profileTableExists(connection, "TestProfileTable")) { profileProvisioning.removeProfileTable("TestProfileTable"); } profileProvisioning.createProfileTable(profileSpecificationID, "TestProfileTable"); </pre></p> <h3>Creating a Profile</h3> <p>Option 1: Supply the attributes when creating the profile and have it committed. <pre> AttributeList list = new AttributeList(); list.add(new Attribute("Addresses", new Address[] { new Address(AddressPlan.IP, "127.0.0.1") })); RemoteProfiles.createCommittedProfile(connection, "TestProfileTable", "TestProfile1", list); </pre> </p> <p>Option 2: Create the profile in the uncommitted state, and use a proxy to the Profile Management interface to set the attributes, then call commitProfile. <pre> RemoteProfiles.UncommittedProfile<AddressProfileManagement> uncommittedProfile1;

uncommittedProfile1 = RemoteProfiles.createUncommittedProfile(connection, "TestProfileTable", "TestProfile2",
                                                                       AddressProfileManagement.class);
AddressProfileManagement addressProfile = uncommittedProfile1.getProfileProxy();
addressProfile.setAddresses(new Address[] { new Address(AddressPlan.IP, "127.0.0.2") });
uncommittedProfile1.getProfileMBean().commitProfile();
    </pre>
</p>
<p>Option 3: Create the profile in the uncommitted state, and use the setAttribute method on the connection, then
    call commitProfile.
    <pre>
RemoteProfiles.UncommittedProfile uncommittedProfile2;
uncommittedProfile2 = RemoteProfiles.createUncommittedProfile(connection, "TestProfileTable", "TestProfile3");
connection.setAttribute(uncommittedProfile2.getObjectName(), new Attribute("Addresses", new Address[] { new Address(AddressPlan.IP, "127.0.0.3") }));
uncommittedProfile2.getProfileMBean().commitProfile();
    </pre>
</p>
<h3>Editing a Profile</h3>
<p>Using the profile management interface as a proxy to the profile object allows set methods to be invoked directly:
    <pre>
ProfileMBean profileMBean = RemoteProfiles.getProfileMBean(connection, "TestProfileTable", profileName);
profileMBean.editProfile();
AddressProfileManagement addressProfileManagement = RemoteProfiles.getProfile(connection, "TestProfileTable", profileName, AddressProfileManagement.class);
addressProfileManagement.setAddresses(new Address[] { new Address(AddressPlan.IP, "127.0.1.1") });
profileMBean.commitProfile();
    </pre>
</p>
<h3>Inspecting Profile Tables</h3>
<p>Using <code>RemoteProfiles</code> methods to get the attribute names and types for a given profile table:
    <pre>
String[] names = RemoteProfiles.getAttributeNames(connection, "TestProfileTable");
System.out.println("Profile attributes:");
for (String name : names) {
    String type = RemoteProfiles.getAttributeType(connection, "TestProfileTable", name);
    System.out.println("    " + name + " (" + type + ")");
}
    </pre>
</p>
<p></p>
<h2>Working with Usage</h2>
<p> The <a href="RemoteUsage.html"><code>RemoteUsage</code></a> class contains a number of utility methods to assist
    working with MBeans related to SLEE Usage.</p>
<h2>Rhino Housekeeping</h2>
<p> The <a href="RemoteHousekeeping.html"><code>RemoteHousekeeping</code></a> class methods to get a Rhino housekeeping
    MBean for a cluster or for a particular node.</p>