 |
package org.glassfish.extended.management.sample.impl.performance;
import com.sun.esb.management.api.performance.PerformanceMeasurementService;
import com.sun.esb.management.client.ManagementClient;
import com.sun.esb.management.client.ManagementClientFactory;
import com.sun.esb.management.common.ManagementRemoteException;
import com.sun.esb.management.common.data.ComponentStatisticsData;
import com.sun.esb.management.common.data.helper.ComponentStatisticsDataReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.glassfish.openesb.management.ServerConnectionFactory;
import org.xml.sax.SAXException;
/**
*
* @author gopalan
*/
public class TestComponentStatistics {
/** * @param args */
public static void main(String[] args) {
String host = ServerConnectionFactory.LOCALHOST,
user = ServerConnectionFactory.ADMIN_USERNAME,
password = ServerConnectionFactory.ADMINADMIN_PASSWORD;
int port = ServerConnectionFactory.RMI_ADMIN_PORT;
String targetName = ServerConnectionFactory.SERVER_TARGET;
String componentName = "sun-http-binding";
String rawXMLData = null;
// Get an instance of Management Client
ManagementClient client = null;
PerformanceMeasurementService measurementService = null;
try {
client = ManagementClientFactory.getInstance(host, port, user, password);
// Get an instance of the Performance Measurement Service
measurementService = client.getPerformanceMeasurementService();
rawXMLData = measurementService.getComponentStatistics(componentName, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestComponentStatistics.class.getName()).log(Level.SEVERE, null, ex);
}
Map<String /* instanceName */, ComponentStatisticsData> targetToDataMap = null;
if (rawXMLData != null) {
try {
targetToDataMap = ComponentStatisticsDataReader.parseFromXMLData(rawXMLData);
if (targetToDataMap != null) {
for (String instanceName : targetToDataMap.keySet()) {
System.out.println(targetToDataMap.get(instanceName).getDisplayString());
}
}
} catch (MalformedURLException ex) {
Logger.getLogger(TestComponentStatistics.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParserConfigurationException ex) {
Logger.getLogger(TestComponentStatistics.class.getName()).log(Level.SEVERE, null, ex);
} catch (SAXException ex) {
Logger.getLogger(TestComponentStatistics.class.getName()).log(Level.SEVERE, null, ex);
} catch (URISyntaxException ex) {
Logger.getLogger(TestComponentStatistics.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(TestComponentStatistics.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
Quick Navigation Links
Number of visits: 5