List of usage examples for javax.management.openmbean CompositeData containsKey
public boolean containsKey(String key);
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to get attribute values of Cluster Region and map them to * cluster region vo//from ww w .java2s . c o m * * @param mbeanName * Cluster Region MBean * @throws IOException * @throws ReflectionException * @throws IntrospectionException * @throws InstanceNotFoundException * @throws MBeanException * @throws AttributeNotFoundException */ private void updateClusterRegion(ObjectName mbeanName) throws IOException { try { AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.REGION_MBEAN_ATTRIBUTES); // retrieve the full path of the region String regionFullPath = null; for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) { regionFullPath = getStringAttribute(attribute.getValue(), attribute.getName()); break; } } Cluster.Region region = cluster.getClusterRegions().get(regionFullPath); if (null == region) { region = new Cluster.Region(); } for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_MEMBERS)) { String memName[] = (String[]) attribute.getValue(); region.getMemberName().clear(); for (int k = 0; k < memName.length; k++) { region.getMemberName().add(memName[k]); } } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) { region.setFullPath(getStringAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE)) { region.setDiskReadsRate(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE)) { region.setDiskWritesRate(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_EMPTYNODES)) { region.setEmptyNode(getIntegerAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_GETSRATE)) { region.setGetsRate(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_LRUEVICTIONRATE)) { region.setLruEvictionRate(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE)) { region.setPutsRate(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS)) { region.setAverageReads(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES)) { region.setAverageWrites(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_REGIONTYPE)) { region.setRegionType(getStringAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE)) { region.setEntrySize(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_SYSTEMREGIONENTRYCOUNT)) { region.setSystemRegionEntryCount(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT)) { region.setMemberCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PERSISTENTENABLED)) { region.setPersistentEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_NAME)) { region.setName(getStringAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_GATEWAYENABLED)) { region.setWanEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_DISKUSAGE)) { region.setDiskUsage(getLongAttribute(attribute.getValue(), attribute.getName())); } } CompositeData compositeData = (CompositeData) (this.mbs.invoke(mbeanName, PulseConstants.MBEAN_OPERATION_LISTREGIONATTRIBUTES, null, null)); if (compositeData != null) { if (compositeData.containsKey(PulseConstants.COMPOSITE_DATA_KEY_COMPRESSIONCODEC)) { String regCompCodec = (String) compositeData .get(PulseConstants.COMPOSITE_DATA_KEY_COMPRESSIONCODEC); if (null != regCompCodec) { region.setCompressionCodec(regCompCodec); } } if (compositeData.containsKey(PulseConstants.COMPOSITE_DATA_KEY_ENABLEOFFHEAPMEMORY)) { region.setEnableOffHeapMemory( (Boolean) compositeData.get(PulseConstants.COMPOSITE_DATA_KEY_ENABLEOFFHEAPMEMORY)); } if (compositeData.containsKey(PulseConstants.COMPOSITE_DATA_KEY_HDFSWRITEONLY)) { region.setHdfsWriteOnly( (Boolean) compositeData.get(PulseConstants.COMPOSITE_DATA_KEY_HDFSWRITEONLY)); } } // TODO : Uncomment below code when sql fire mbean attributes are // available /* * // IF GEMFIREXD if * (PulseConstants.PRODUCT_NAME_GEMFIREXD.equalsIgnoreCase(PulseController * .getPulseProductSupport())) { * * try { String tableName = this.getTableNameFromRegionName(region * .getFullPath()); * * ObjectName tableObjName = new ObjectName( * PulseConstants.OBJECT_NAME_TABLE_AGGREGATE_PATTERN + tableName); * * AttributeList tableAttributeList = this.mbs.getAttributes( * tableObjName, PulseConstants.SF_TABLE_MBEAN_ATTRIBUTES); * * for (int i = 0; i < tableAttributeList.size(); i++) { * * Attribute attribute = (Attribute) tableAttributeList.get(i); * * if (attribute.getName().equals( * PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE)) { * System.out.println("[GemFireXD] setting entry size"); * region.setEntrySize(getLongAttribute(attribute.getValue(), * attribute.getName())); } else if (attribute.getName().equals( * PulseConstants.MBEAN_ATTRIBUTE_NUMBEROFROWS)) { * System.out.println("[GemFireXD] setting num of rows"); * region.setSystemRegionEntryCount(getLongAttribute( * attribute.getValue(), attribute.getName())); } } } catch * (MalformedObjectNameException e) { LOGGER.warning(e); } catch * (NullPointerException e) { LOGGER.warning(e); } } */ // Add to map even if region is present. If region is already there it // will be a no-op. cluster.addClusterRegion(regionFullPath, region); cluster.getDeletedRegions().remove(region.getFullPath()); // Memory Reads and writes region.getPutsPerSecTrend().add(region.getPutsRate()); region.getGetsPerSecTrend().add(region.getGetsRate()); // Disk Reads and Writes region.getDiskReadsPerSecTrend().add(region.getDiskReadsRate()); region.getDiskWritesPerSecTrend().add(region.getDiskWritesRate()); // Average Reads and Writes region.getAverageReadsTrend().add(region.getAverageReads()); region.getAverageWritesTrend().add(region.getAverageWrites()); } catch (InstanceNotFoundException infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } catch (MBeanException anfe) { LOGGER.warning(anfe); } }
From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used for getting member clients from mbean and update the clients * information in member object's client arraylist *//*from w w w . j a v a 2 s . c o m*/ 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 infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } catch (MBeanException me) { LOGGER.warning(me); } catch (AttributeNotFoundException anfe) { LOGGER.warning(anfe); } }