![]() |
|||
![]() |
![]() ![]() |
![]() |
![]() ![]() |
![]() |
![]() ![]() |
![]() |
| |||||
Example 21-4 shows the use of other calls to the remote agent, such as getDefaultDomain and getMBeanCount that have the same purpose as in an agent application. 21.2.4.2 Accessing MBean Attributes and OperationsOnce you can access the object names for MBeans in the agent, you can know their management interface from their MBeanInfo object. The code in Example 21-5 is actually called in between the MBean creation and unregistration shown in Example 21-4. Example 21-5 Retrieving the MBeanInfo Object
It is then straightforward to perform management operations on MBeans through the legacy connector client. As in an agent, we call the generic getters, setters, and call methods with the object name of the MBean, the name of the attribute or operation, and any parameters. As in the methods of the MBean server, we need to use the Attribute and AttributeList classes to pass attributes as name-value pairs. Example 21-6 Accessing an MBean Through the Legacy Connector Client
All other MBean access methods are available in the same manner, such as bulk getters and setters, and the query methods. 21.2.4.3 Creating and Accessing Dynamic MBeansIn the first run of the example, the management application creates, manages, and unregisters a standard MBean in the remote agent. However, standard and dynamic MBeans are designed to be managed through the same methods, both in the MBeanServer and in the RemoteMBeanServer interfaces. As shown in Example 21-4, the subroutine of the example application takes only a single class name parameter. The first time this subroutine is called, the example passes the class name of a standard MBean, and the second time, that of a dynamic MBean. For the example to run, the two MBeans must have an identical management interface. By extension of this special case, we see that the connector client can manage dynamic MBeans through the same methods as it manages standard MBeans, without making any distinction between the two. 21.2.5 Running the SimpleClients ExampleThe examplesDir/legacy/SimpleClients directory contains all of the files for three sample managers, a base agent, and some MBeans to manage. In this chapter, we run the ClientWithoutProxy application that demonstrates simple operations on MBeans through a legacy RMI connector.
|
$ cd examplesDir/legacy/SimpleClients/ $ javac -classpath classpath *.java |
We do not need all the files for this chapter, but they are used in Chapter 24, Legacy Proxy Mechanism. In this demonstration, we only need the BaseAgent and ClientWithoutProxy applications, as well as the standard and dynamic MBeans.
Start the agent in another terminal window on the same host with the following command:
$ java -classpath classpath BaseAgent |
The agent creates an HTML protocol adaptor and a legacy RMI connector server to which the client application establishes a connection, and then it waits for management operations.
Wait for the agent to be completely initialized, then start the manager with the following command:
$ java -classpath classpath ClientWithoutProxy |
The client application creates the RMI connector client and establishes the connection to the base agent.
Press Enter in the manager window to step through the example.
The management application instantiates both types of MBeans, looks at their metadata, and performs management operations on them. The results of each step are displayed in the terminal window.
At any time, you can view the agent through its HTML adaptor and interact with the MBeans created by the management application.
For example, immediately after the manager creates an MBean, you could modify its attributes and see this change reflected when the connector client access the new values.
Press Enter in both windows to stop the agent and manager applications.
The legacy heartbeat mechanism monitors the connection between a manager and an agent and automates the cleanup procedure when the connection is lost. This enables both the manager and the agent to release resources that were allocated for maintaining the connection.
The mechanism is entirely contained in the connector client and connector server components, no additional objects are involved. In addition, connector clients send notifications that the manager application can receive to be aware of changes in the status of a connection.
All legacy connector clients of the Java DMK implement the HeartBeatClientHandler interface to provide a heartbeat mechanism. This means that agent-manager connections over the legacy RMI, HTTP, and HTTPS connectors can be monitored and controlled in the same way. A manager application could even use the same notification handler for all connector clients where the heartbeat mechanism is activated.
![]() ![]() |