use of javax.management.ReflectionException in project geode by apache.
the class MBeanJMXAdapter method isAttributeAvailable.
public static boolean isAttributeAvailable(String attributeName, String objectName) {
try {
ObjectName objName = new ObjectName(objectName);
mbeanServer.getAttribute(objName, attributeName);
} catch (MalformedObjectNameException e) {
return false;
} catch (NullPointerException e) {
return false;
} catch (AttributeNotFoundException e) {
return false;
} catch (InstanceNotFoundException e) {
return false;
} catch (MBeanException e) {
return false;
} catch (ReflectionException e) {
return false;
}
return true;
}
use of javax.management.ReflectionException in project geode by apache.
the class ManagementFunction method execute.
/**
* Actual function execution. It delegates task at managed node according to the request received.
*
* If any exception is encountered it will set the result to UNDEFINED
*/
public void execute(FunctionContext fc) {
boolean executedSuccessfully = false;
InternalCache cache = GemFireCacheImpl.getInstance();
Object[] functionArguments = (Object[]) fc.getArguments();
ObjectName objectName = (ObjectName) functionArguments[0];
String methodName = (String) functionArguments[1];
String[] signature = (String[]) functionArguments[2];
Object[] args = (Object[]) functionArguments[3];
String memberName = (String) functionArguments[4];
Object returnObj = null;
try {
final int nargs = (args == null) ? 0 : args.length;
if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1) {
Attribute attr = new Attribute(methodName.substring(3), args[0]);
mbeanServer.setAttribute(objectName, attr);
fc.getResultSender().lastResult((Serializable) null);
} else if (methodName.equals("addNotificationListener")) {
notificationHub.addHubNotificationListener(memberName, objectName);
fc.getResultSender().lastResult((Serializable) ManagementConstants.UNDEFINED);
} else if (methodName.equals("removeNotificationListener")) {
notificationHub.removeHubNotificationListener(memberName, objectName);
fc.getResultSender().lastResult((Serializable) ManagementConstants.UNDEFINED);
} else if (methodName.equals("getNotificationInfo")) {
fc.getResultSender().lastResult(mbeanServer.getMBeanInfo(objectName));
} else {
returnObj = mbeanServer.invoke(objectName, methodName, args, signature);
fc.getResultSender().lastResult((Serializable) returnObj);
}
executedSuccessfully = true;
} catch (InstanceNotFoundException e) {
if (cache != null && !cache.isClosed()) {
sendException(e, fc);
}
} catch (ReflectionException e) {
sendException(e, fc);
} catch (MBeanException e) {
sendException(e, fc);
} catch (NullPointerException e) {
sendException(e, fc);
} catch (Exception e) {
sendException(e, fc);
} finally {
if (!executedSuccessfully) {
if (cache == null || (cache != null && cache.isClosed())) {
Exception e = new Exception(ManagementStrings.MEMBER_IS_SHUTTING_DOWN.toLocalizedString());
sendException(e, fc);
// member is closing or invalid member
return;
}
}
}
}
use of javax.management.ReflectionException in project geode by apache.
the class MBeanUtil method printBeanDetails.
public static void printBeanDetails(ObjectName objName) throws Exception {
MBeanAttributeInfo[] attributeInfos;
MBeanInfo info = null;
try {
info = mbeanServer.getMBeanInfo(objName);
} catch (IntrospectionException e1) {
fail("Could not obtain Sender Proxy Details");
} catch (InstanceNotFoundException e1) {
fail("Could not obtain Sender Proxy Details");
} catch (ReflectionException e1) {
fail("Could not obtain Sender Proxy Details");
}
attributeInfos = info.getAttributes();
for (MBeanAttributeInfo attributeInfo : attributeInfos) {
Object propertyValue = null;
String propertyName = null;
try {
propertyName = attributeInfo.getName();
propertyValue = mbeanServer.getAttribute(objName, propertyName);
LogWriterUtils.getLogWriter().info("<ExpectedString> " + propertyName + " = " + propertyValue + "</ExpectedString> ");
} catch (Exception e) {
}
}
}
use of javax.management.ReflectionException in project geode by apache.
the class JMXDataUpdater method updateMemberClient.
/**
* function used for getting member clients from mbean and update the clients information in
* member object's client arraylist
*/
private void updateMemberClient(ObjectName mbeanName) throws IOException {
try {
String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
if (cluster.getMembersHMap().containsKey(memberName)) {
Cluster.Member existingMember = cluster.getMembersHMap().get(memberName);
HashMap<String, Cluster.Client> memberClientsHM = new HashMap<String, Cluster.Client>();
existingMember.setMemberPort("" + this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_PORT));
this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS_ALT);
existingMember.setHostnameForClients((String) this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS_ALT));
existingMember.setBindAddress((String) this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_BINDADDRESS));
CompositeData[] compositeData = (CompositeData[]) (this.mbs.invoke(mbeanName, PulseConstants.MBEAN_OPERATION_SHOWALLCLIENTS, null, null));
for (CompositeData cmd : compositeData) {
Cluster.Client client = new Cluster.Client();
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CLIENTID)) {
client.setId((String) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CLIENTID));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NAME)) {
client.setName((String) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NAME));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME)) {
client.setHost((String) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE)) {
client.setQueueSize((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME)) {
client.setProcessCpuTime((Long) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_UPTIME)) {
client.setUptime((Long) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_UPTIME));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS)) {
client.setThreads((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS)) {
client.setGets((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS)) {
client.setPuts((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) {
client.setCpus((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CPUS));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) {
client.setCpuUsage(0);
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CONNECTED)) {
client.setConnected((Boolean) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTED));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CLIENTCQCOUNT)) {
client.setClientCQCount((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CLIENTCQCOUNT));
}
if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_SUBSCRIPTIONENABLED)) {
client.setSubscriptionEnabled((Boolean) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_SUBSCRIPTIONENABLED));
}
memberClientsHM.put(client.getId(), client);
}
existingMember.updateMemberClientsHMap(memberClientsHM);
}
} catch (InstanceNotFoundException | ReflectionException | AttributeNotFoundException | MBeanException infe) {
logger.warn(infe);
}
}
use of javax.management.ReflectionException in project geode by apache.
the class JMXDataUpdater method updateClusterStatement.
private void updateClusterStatement(ObjectName mbeanName) throws IOException {
try {
AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.STATEMENT_MBEAN_ATTRIBUTES);
// retrieve the full path of the region
String statementDefinition = mbeanName.getKeyProperty("name");
if (isQuoted(statementDefinition)) {
statementDefinition = ObjectName.unquote(statementDefinition);
}
Cluster.Statement statement = cluster.getClusterStatements().get(statementDefinition);
if (null == statement) {
statement = new Cluster.Statement();
statement.setQueryDefinition(statementDefinition);
}
for (int i = 0; i < attributeList.size(); i++) {
Attribute attribute = (Attribute) attributeList.get(i);
String name = attribute.getName();
switch(name) {
case PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED:
statement.setNumTimesCompiled(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION:
statement.setNumExecution(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS:
statement.setNumExecutionsInProgress(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP:
statement.setNumTimesGlobalIndexLookup(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED:
statement.setNumRowsModified(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_PARSETIME:
statement.setParseTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_BINDTIME:
statement.setBindTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME:
statement.setOptimizeTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME:
statement.setRoutingInfoTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME:
statement.setGenerateTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME:
statement.setTotalCompilationTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME:
statement.setExecutionTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME:
statement.setProjectionTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME:
statement.setTotalExecutionTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME:
statement.setRowsModificationTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN:
statement.setqNNumRowsSeen(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME:
statement.setqNMsgSendTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME:
statement.setqNMsgSerTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME:
statement.setqNRespDeSerTime(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
}
}
cluster.addClusterStatement(statementDefinition, statement);
// TODO : to store data for sparklines later
/*
* region.getPutsPerSecTrend().add(region.getPutsRate());
* region.getGetsPerSecTrend().add(region.getGetsRate());
*/
} catch (InstanceNotFoundException | ReflectionException infe) {
logger.warn(infe);
}
}
Aggregations