List of usage examples for javax.management ObjectName getKeyProperty
public String getKeyProperty(String property)
From source file:org.apache.geode.management.internal.beans.DistributedSystemBridge.java
public ObjectName[] fetchRegionObjectNames(ObjectName memberMBeanName) throws Exception { List<ObjectName> list = new ArrayList<>(); if (mapOfMembers.get(memberMBeanName) != null) { MemberMXBean bean = mapOfMembers.get(memberMBeanName); String member = memberMBeanName.getKeyProperty(ManagementConstants.OBJECTNAME_MEMBER_APPENDER); String[] regions = bean.listRegions(); for (String region : regions) { ObjectName regionMBeanName = MBeanJMXAdapter.getRegionMBeanName(member, region); list.add(regionMBeanName);/*from ww w. j a va2 s. c om*/ } ObjectName[] objNames = new ObjectName[list.size()]; return list.toArray(objNames); } else { throw new Exception(ManagementStrings.MEMBER_MBEAN_NOT_FOUND_IN_DS.toString()); } }
From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used for getting member clients from mbean and update the clients information in * member object's client arraylist/*ww w . j a va 2 s .c om*/ */ 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); } }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used for getting list of Gateway Senders from mBean for giving * member and update the list of gateway senders for respective member object * /*from ww w . j ava2 s . c om*/ * @param mbeanName * @param memberName * @throws InstanceNotFoundException * @throws IntrospectionException * @throws ReflectionException * @throws IOException * @throws AttributeNotFoundException * @throws MBeanException * */ private void updateGatewaySender(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); Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName); for (Cluster.GatewaySender exisGatewaySender : existingMember.getGatewaySenderList()) { if ((exisGatewaySender.getId()).equals(gatewaySender.getId())) { existingMember.getGatewaySenderList().remove(exisGatewaySender); break; } } // Add gateway sender existingMember.getGatewaySenderList().add(gatewaySender); } else { Cluster.Member member = new Cluster.Member(); member.setName(memberName); member.setId(memberName); Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName); member.getGatewaySenderList().add(gatewaySender); cluster.getMembersHMap().put(memberName, member); } } catch (InstanceNotFoundException infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } catch (MBeanException me) { LOGGER.warning(me); } catch (AttributeNotFoundException anfe) { LOGGER.warning(anfe); } catch (IntrospectionException ire) { LOGGER.warning(ire); } }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used for getting member clients from mbean and update the clients * information in member object's client arraylist * /* w w w .j a v a 2s . c o m*/ * @param mbeanName * @param memberName * @throws InstanceNotFoundException * @throws IntrospectionException * @throws ReflectionException * @throws IOException * @throws MBeanException * @throws AttributeNotFoundException * */ 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)); 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)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NAME)) { client.setName((String) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NAME)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME)) { client.setHost((String) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE)) { client.setQueueSize((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME)) { client.setProcessCpuTime((Long) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_UPTIME)) { client.setUptime((Long) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_UPTIME)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS)) { client.setThreads((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS)) { client.setGets((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS)) { client.setPuts((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) { client.setCpus((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CPUS)); } else if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) { client.setCpuUsage(0); } 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); } }
From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used for updating Cluster Data. *//*from w ww .j ava 2 s . c om*/ @Override public boolean updateData() { try { if (this.conn == null) { return false; } // deleted Members cluster.getDeletedMembers().clear(); for (Entry<String, Cluster.Member> memberSet : cluster.getMembersHMap().entrySet()) { cluster.getDeletedMembers().add(memberSet.getKey()); } // Deleted Regions cluster.getDeletedRegions().clear(); for (Cluster.Region region : cluster.getClusterRegions().values()) { cluster.getDeletedRegions().add(region.getFullPath()); } this.systemMBeans = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED, null); for (ObjectName sysMBean : this.systemMBeans) { updateClusterSystem(sysMBean); } // Cluster Regions/Tables Set<ObjectName> regionMBeans = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_REGION_DISTRIBUTED, null); // For Gemfire for (ObjectName regMBean : regionMBeans) { updateClusterRegion(regMBean); } // Remove deleted regions from cluster's regions list for (Iterator<String> it = cluster.getDeletedRegions().iterator(); it.hasNext();) { cluster.removeClusterRegion(it.next()); } // Cluster Members Set<ObjectName> memberMBeans = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_MEMBER, null); for (ObjectName memMBean : memberMBeans) { String service = memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE); if (service == null) { // Cluster Member updateClusterMember(memMBean); } else { switch (service) { case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_REGION: updateMemberRegion(memMBean); break; case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_CACHESERVER: updateMemberClient(memMBean); break; case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYRECEIVER: updateGatewayReceiver(memMBean); break; case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYSENDER: updateGatewaySender(memMBean); break; case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_ASYNCEVENTQUEUE: updateAsyncEventQueue(memMBean); break; case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_LOCATOR: updateClusterMember(memMBean); break; } } } // Cluster Query Statistics Set<ObjectName> statementObjectNames = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED, null); for (ObjectName stmtObjectName : statementObjectNames) { updateClusterStatement(stmtObjectName); } } catch (IOException ioe) { logger.fatal(ioe.getMessage(), ioe); this.mbs = null; if (this.conn != null) { try { this.conn.close(); } catch (IOException e1) { logger.fatal(e1.getMessage(), e1); } this.conn = null; } return false; } // If there were members deleted, remove them from the membersList & // physicalToMember. Iterator<String> iterator = cluster.getDeletedMembers().iterator(); while (iterator.hasNext()) { String memberKey = iterator.next(); if (cluster.getMembersHMap().containsKey(memberKey)) { Cluster.Member member = cluster.getMembersHMap().get(memberKey); List<Cluster.Member> memberArrList = cluster.getPhysicalToMember().get(member.getHost()); if (memberArrList != null) { if (memberArrList.contains(member)) { String host = member.getHost(); cluster.getPhysicalToMember().get(member.getHost()).remove(member); if (cluster.getPhysicalToMember().get(member.getHost()).size() == 0) { cluster.getPhysicalToMember().remove(host); } } } cluster.getMembersHMap().remove(memberKey); } } return true; }
From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to get attribute values of Member Region and map them to Member vo * //from w ww . j av a2s .c om * @param mbeanName Member Region MBean */ private void updateMemberRegion(ObjectName mbeanName) throws IOException { try { String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER); Cluster.Member member = cluster.getMembersHMap().get(memberName); // Following attributes are not present in 9.0 // "Members" // "EmptyNodes" // "SystemRegionEntryCount" // "MemberCount" AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.REGION_MBEAN_ATTRIBUTES); // retrieve the full path of the region String regionFullPathKey = null; for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) { regionFullPathKey = getStringAttribute(attribute.getValue(), attribute.getName()); break; } } // if member does not exists defined for this region then create a member if (null == member) { member = new Cluster.Member(); member.setName(memberName); cluster.getMembersHMap().put(memberName, member); } // if region with given path exists then update same else add new region Cluster.Region region = member.getMemberRegions().get(regionFullPathKey); if (null == region) { region = new Cluster.Region(); member.getMemberRegions().put(regionFullPathKey, region); member.setTotalRegionCount(member.getTotalRegionCount() + 1); } region.setFullPath(regionFullPathKey); // use already retrieved values // update the existing or new region for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); String name = attribute.getName(); switch (name) { case PulseConstants.MBEAN_ATTRIBUTE_FULLPATH: region.setFullPath(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE: region.setDiskReadsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE: region.setDiskWritesRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE: region.setGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_LRUEVICTIONRATE: region.setLruEvictionRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE: region.setPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_REGIONTYPE: region.setRegionType(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT: region.setMemberCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE: region.setEntrySize(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_ENTRYCOUNT: region.setSystemRegionEntryCount(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NAME: region.setName(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_PERSISTENTENABLED: region.setPersistentEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_GATEWAYENABLED: region.setWanEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); break; } } /* * GemfireXD related code try{// Added for Rolling upgrade changes. Needs to removed once * Rolling upgrade handled gracefully CompositeData compositeData = (CompositeData) * (this.mbs.invoke(mbeanName, PulseConstants.MBEAN_OPERATION_LISTREGIONATTRIBUTES, null, * null)); * * if (compositeData != null) { if * (compositeData.containsKey(PulseConstants.COMPOSITE_DATA_KEY_SCOPE)) { * region.setScope((String) compositeData .get(PulseConstants.COMPOSITE_DATA_KEY_SCOPE)); } * else if (compositeData .containsKey(PulseConstants.COMPOSITE_DATA_KEY_DISKSTORENAME)) { * region.setDiskStoreName((String) compositeData * .get(PulseConstants.COMPOSITE_DATA_KEY_DISKSTORENAME)); } else if (compositeData * .containsKey(PulseConstants.COMPOSITE_DATA_KEY_DISKSYNCHRONOUS)) { * region.setDiskSynchronous((Boolean) compositeData * .get(PulseConstants.COMPOSITE_DATA_KEY_DISKSYNCHRONOUS)); } } }catch (MBeanException anfe) * { logger.warn(anfe); }catch (javax.management.RuntimeMBeanException anfe) { * region.setScope(""); region.setDiskStoreName(""); region.setDiskSynchronous(false); * //logger. * warning("Some of the Pulse elements are not available currently. There might be a GemFire upgrade going on." * ); } * * * // Remove deleted regions from member's regions list for (Iterator<String> it = * cluster.getDeletedRegions().iterator(); it .hasNext();) { String deletedRegion = it.next(); * if (member.getMemberRegions().get(deletedRegion) != null) { * member.getMemberRegions().remove(deletedRegion); } * member.setTotalRegionCount(member.getMemberRegions().size()); } */ } catch (InstanceNotFoundException | ReflectionException infe) { logger.warn(infe); } }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to get attribute values of Member Region and map them to * Member vo//from w w w . j a v a 2 s.c o m * * @param mbeanName * Member Region MBean */ private void updateMemberRegion(ObjectName mbeanName) throws IOException { try { String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER); Cluster.Member member = cluster.getMembersHMap().get(memberName); AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.REGION_MBEAN_ATTRIBUTES); // retrieve the full path of the region String regionFullPathKey = null; for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) { regionFullPathKey = getStringAttribute(attribute.getValue(), attribute.getName()); break; } } // if member does not exists defined for this region then create a member if (null == member) { member = new Cluster.Member(); member.setName(memberName); cluster.getMembersHMap().put(memberName, member); } // if region with given path exists then update same else add new region Cluster.Region region = member.getMemberRegions().get(regionFullPathKey); if (null == region) { region = new Cluster.Region(); member.getMemberRegions().put(regionFullPathKey, region); member.setTotalRegionCount(member.getTotalRegionCount() + 1); // Initialize region attributes CompositeData compositeData = (CompositeData) (mbs.invoke(mbeanName, PulseConstants.MBEAN_OPERATION_LISTREGIONATTRIBUTES, null, null)); if (compositeData.containsKey(PulseConstants.COMPOSITE_DATA_KEY_SCOPE)) { region.setScope((String) compositeData.get(PulseConstants.COMPOSITE_DATA_KEY_SCOPE)); } if (compositeData.containsKey(PulseConstants.COMPOSITE_DATA_KEY_DISKSTORENAME)) { region.setDiskStoreName( (String) compositeData.get(PulseConstants.COMPOSITE_DATA_KEY_DISKSTORENAME)); } if (compositeData.containsKey(PulseConstants.COMPOSITE_DATA_KEY_DISKSYNCHRONOUS)) { region.setDiskSynchronous( (Boolean) compositeData.get(PulseConstants.COMPOSITE_DATA_KEY_DISKSYNCHRONOUS)); } } region.setFullPath(regionFullPathKey); // use already retrieved values // update the existing or new region for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); 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_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_MEMBERCOUNT)) { region.setMemberCount(getIntegerAttribute(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_ENTRYCOUNT)) { region.setSystemRegionEntryCount(getLongAttribute(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_PERSISTENTENABLED)) { region.setPersistentEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_GATEWAYENABLED)) { region.setWanEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); } } // Remove deleted regions from member's regions list for (Iterator<String> it = cluster.getDeletedRegions().iterator(); it.hasNext();) { String deletedRegion = it.next(); if (member.getMemberRegions().get(deletedRegion) != null) { member.getMemberRegions().remove(deletedRegion); } member.setTotalRegionCount(member.getMemberRegions().size()); } } catch (InstanceNotFoundException infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } catch (MBeanException anfe) { LOGGER.warning(anfe); } }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used for updating Cluster Data. *//* w w w .j av a 2 s . c o m*/ @Override public boolean updateData() { try { if (!this.isConnected()) { return false; } // deleted Members cluster.getDeletedMembers().clear(); for (Entry<String, Cluster.Member> memberSet : cluster.getMembersHMap().entrySet()) { cluster.getDeletedMembers().add(memberSet.getKey()); } // Deleted Regions cluster.getDeletedRegions().clear(); for (Cluster.Region region : cluster.getClusterRegions().values()) { cluster.getDeletedRegions().add(region.getFullPath()); } // try { // Cluster this.systemMBeans = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED, null); for (ObjectName sysMBean : this.systemMBeans) { updateClusterSystem(sysMBean); } // Cluster Regions/Tables Set<ObjectName> regionMBeans = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_REGION_DISTRIBUTED, null); Set<ObjectName> tableMBeans = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_TABLE_AGGREGATE, null); if (PulseConstants.PRODUCT_NAME_GEMFIREXD.equalsIgnoreCase(PulseController.getPulseProductSupport())) { // For GemFireXD for (ObjectName tableMBean : tableMBeans) { String regNameFromTable = StringUtils .getRegionNameFromTableName(tableMBean.getKeyProperty("table")); for (ObjectName regionMBean : regionMBeans) { String regionName = regionMBean.getKeyProperty("name"); if (regNameFromTable.equals(regionName)) { updateClusterRegion(regionMBean); // Increment cluster region count cluster.setTotalRegionCount(cluster.getTotalRegionCount() + 1); break; } } } } else { // For GemFire for (ObjectName regMBean : regionMBeans) { updateClusterRegion(regMBean); } } // Remove deleted regions from cluster's regions list for (Iterator<String> it = cluster.getDeletedRegions().iterator(); it.hasNext();) { cluster.removeClusterRegion(it.next()); } // Cluster Members Set<ObjectName> memberMBeans = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_MEMBER, null); for (ObjectName memMBean : memberMBeans) { // member regions if (memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE) != null) { if (memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE) .equals(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_REGION)) { if (PulseConstants.PRODUCT_NAME_GEMFIREXD .equalsIgnoreCase(PulseController.getPulseProductSupport())) { // For GemFireXD for (ObjectName tableMBean : tableMBeans) { String regNameFromTable = StringUtils .getRegionNameFromTableName(tableMBean.getKeyProperty("table")); String regionName = memMBean.getKeyProperty("name"); if (regNameFromTable.equals(regionName)) { updateMemberRegion(memMBean); break; } } } else { // For GemFire updateMemberRegion(memMBean); } } else if (memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE) .equals(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_CACHESERVER)) { updateMemberClient(memMBean); } // Gateway Receiver Attributes else if (memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE) .equals(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYRECEIVER)) { updateGatewayReceiver(memMBean); } else if (memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE) .equals(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYSENDER)) { updateGatewaySender(memMBean); } } else { // Cluster Member updateClusterMember(memMBean); } } // Cluster Query Statistics Set<ObjectName> statementObjectNames = this.mbs.queryNames(this.MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED, null); LOGGER.info("statementObjectNames = " + statementObjectNames); for (ObjectName stmtObjectName : statementObjectNames) { LOGGER.info("stmtObjectName = " + stmtObjectName); updateClusterStatement(stmtObjectName); } } catch (IOException ioe) { // write errors StringWriter swBuffer = new StringWriter(); PrintWriter prtWriter = new PrintWriter(swBuffer); ioe.printStackTrace(prtWriter); LOGGER.severe("IOException Details : " + swBuffer.toString() + "\n"); this.mbs = null; if (this.conn != null) { try { this.conn.close(); } catch (IOException e1) { LOGGER.severe("Error closing JMX connection " + swBuffer.toString() + "\n"); } } return false; } // If there were members deleted, remove them from the membersList & // physicalToMember. Iterator<String> iterator = cluster.getDeletedMembers().iterator(); while (iterator.hasNext()) { String memberKey = iterator.next(); if (cluster.getMembersHMap().containsKey(memberKey)) { Cluster.Member member = cluster.getMembersHMap().get(memberKey); List<Cluster.Member> memberArrList = cluster.getPhysicalToMember().get(member.getHost()); if (memberArrList != null) { if (memberArrList.contains(member)) { String host = member.getHost(); cluster.getPhysicalToMember().get(member.getHost()).remove(member); if (cluster.getPhysicalToMember().get(member.getHost()).size() == 0) { cluster.getPhysicalToMember().remove(host); } } } cluster.getMembersHMap().remove(memberKey); } } return true; }
From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to get attribute values of Cluster Region and map them to cluster region vo * // ww w.ja va 2 s .c o m * @param mbeanName Cluster Region MBean */ 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 regionObjectName = mbeanName.getKeyProperty("name"); 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); String name = attribute.getName(); switch (name) { case 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]); } break; case PulseConstants.MBEAN_ATTRIBUTE_FULLPATH: region.setFullPath(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE: region.setDiskReadsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE: region.setDiskWritesRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_EMPTYNODES: region.setEmptyNode(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE: region.setGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_LRUEVICTIONRATE: region.setLruEvictionRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE: region.setPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_REGIONTYPE: region.setRegionType(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE: region.setEntrySize(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_SYSTEMREGIONENTRYCOUNT: region.setSystemRegionEntryCount(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT: region.setMemberCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_PERSISTENTENABLED: region.setPersistentEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NAME: region.setName(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_GATEWAYENABLED: region.setWanEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKUSAGE: region.setDiskUsage(getLongAttribute(attribute.getValue(), attribute.getName())); break; } } // add for each member updateRegionOnMembers(regionObjectName, regionFullPath, region); 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()); } catch (InstanceNotFoundException | ReflectionException infe) { logger.warn(infe); } }
From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java
private void updateClusterStatement(ObjectName mbeanName) throws IOException { try {/* w w w . jav a 2 s . c o m*/ 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); } }