List of usage examples for javax.management Attribute getName
public String getName()
From source file:com.cyberway.issue.crawler.settings.ComplexType.java
/** Set the value of a specific attribute of the ComplexType. * * This method is an extension to the Dynamic MBean specification so that * it is possible to set the value for a CrawlerSettings object other than * the settings object representing the order. * * @param settings the settings object for which this attributes value is valid * @param attribute The identification of the attribute to be set and the * value it is to be set to. * @throws AttributeNotFoundException is thrown if there is no attribute * with this name./* w w w. j ava2 s . c om*/ * @throws InvalidAttributeValueException is thrown if the attribute is of * wrong type and cannot be converted to the right type. * @see javax.management.DynamicMBean#setAttribute(javax.management.Attribute) */ public synchronized final void setAttribute(CrawlerSettings settings, Attribute attribute) throws InvalidAttributeValueException, AttributeNotFoundException { if (settings == null) { settings = globalSettings(); } DataContainer data = getOrCreateDataContainer(settings); Object value = attribute.getValue(); ModuleAttributeInfo attrInfo = (ModuleAttributeInfo) getAttributeInfo(settings.getParent(), attribute.getName()); ModuleAttributeInfo localAttrInfo = (ModuleAttributeInfo) data.getAttributeInfo(attribute.getName()); // Check if attribute exists if (attrInfo == null && localAttrInfo == null) { throw new AttributeNotFoundException(attribute.getName()); } // Check if we are overriding and if that is allowed for this attribute if (localAttrInfo == null) { if (!attrInfo.isOverrideable()) { throw new InvalidAttributeValueException("Attribute not overrideable: " + attribute.getName()); } localAttrInfo = new ModuleAttributeInfo(attrInfo); } // Check if value is of correct type. If not, see if it is // a string and try to turn it into right type Class typeClass = getDefinition(attribute.getName()).getLegalValueType(); if (!(typeClass.isInstance(value)) && value instanceof String) { try { value = SettingsHandler.StringToType((String) value, SettingsHandler.getTypeName(typeClass.getName())); } catch (ClassCastException e) { throw new InvalidAttributeValueException( "Unable to decode string '" + value + "' into type '" + typeClass.getName() + "'"); } } // Check if the attribute value is legal FailedCheck error = checkValue(settings, attribute.getName(), value); if (error != null) { if (error.getLevel() == Level.SEVERE) { throw new InvalidAttributeValueException(error.getMessage()); } else if (error.getLevel() == Level.WARNING) { if (!getSettingsHandler().fireValueErrorHandlers(error)) { throw new InvalidAttributeValueException(error.getMessage()); } } else { getSettingsHandler().fireValueErrorHandlers(error); } } // Everything ok, set it localAttrInfo.setType(value); Object oldValue = data.put(attribute.getName(), localAttrInfo, value); // If the attribute is a complex type other than the old value, // make sure that all sub attributes are correctly set if (value instanceof ComplexType && value != oldValue) { ComplexType complex = (ComplexType) value; replaceComplexType(settings, complex); } }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to get attribute values of Gateway Receiver and map them to * GatewayReceiver inner class object//from www .j a va 2 s. c om * * @param mbeanName * @return GatewayReceiver object * @throws InstanceNotFoundException * @throws IntrospectionException * @throws ReflectionException * @throws IOException * @throws AttributeNotFoundException * @throws MBeanException * * */ private Cluster.GatewayReceiver initGatewayReceiver(ObjectName mbeanName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, AttributeNotFoundException, MBeanException { Cluster.GatewayReceiver gatewayReceiver = new Cluster.GatewayReceiver(); AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.GATEWAY_MBEAN_ATTRIBUTES); for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PORT)) { gatewayReceiver.setListeningPort(getIntegerAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE)) { gatewayReceiver.setLinkThroughput(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_AVEARGEBATCHPROCESSINGTIME)) { gatewayReceiver .setAvgBatchProcessingTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_RUNNING)) { gatewayReceiver.setStatus(getBooleanAttribute(attribute.getValue(), attribute.getName())); } } return gatewayReceiver; }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to get attribute values of Gateway Sender and map them to * GatewaySender inner class object/*from w w w .ja v a2 s . c o m*/ * * @param mbeanName * @return * @throws InstanceNotFoundException * @throws IntrospectionException * @throws ReflectionException * @throws IOException * @throws AttributeNotFoundException * @throws MBeanException */ private Cluster.GatewaySender initGatewaySender(ObjectName mbeanName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, AttributeNotFoundException, MBeanException { Cluster.GatewaySender gatewaySender = new Cluster.GatewaySender(); AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.GATEWAYSENDER_MBEAN_ATTRIBUTES); for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE)) { gatewaySender.setLinkThroughput(getFloatAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_BATCHSIZE)) { gatewaySender.setBatchSize(getIntegerAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_SENDERID)) { gatewaySender.setId(getStringAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_EVENTQUEUESIZE)) { gatewaySender.setQueueSize(getIntegerAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_RUNNING)) { gatewaySender.setStatus(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PRIMARY)) { gatewaySender.setPrimary(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PERSISTENCEENABLED)) { gatewaySender.setPersistenceEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PARALLEL)) { gatewaySender.setSenderType(getBooleanAttribute(attribute.getValue(), attribute.getName())); } } return gatewaySender; }
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 * //from w w w .jav a2 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 {/* ww w . j a v a 2 s. co 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); } }
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 w w . j a v a 2s.co 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); // 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
private void updateClusterStatement(ObjectName mbeanName) throws IOException { try {/* www.jav a 2 s. co 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); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED)) { statement.setNumTimesCompiled(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION)) { statement.setNumExecution(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS)) { statement.setNumExecutionsInProgress( getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP)) { statement.setNumTimesGlobalIndexLookup( getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED)) { statement.setNumRowsModified(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PARSETIME)) { statement.setParseTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_BINDTIME)) { statement.setBindTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME)) { statement.setOptimizeTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME)) { statement.setRoutingInfoTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME)) { statement.setGenerateTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME)) { statement.setTotalCompilationTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME)) { statement.setExecutionTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME)) { statement.setProjectionTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME)) { statement.setTotalExecutionTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME)) { statement.setRowsModificationTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN)) { statement.setqNNumRowsSeen(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME)) { statement.setqNMsgSendTime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME)) { statement.setqNMsgSerTime(getLongAttribute(attribute.getValue(), attribute.getName())); } if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME)) { statement.setqNRespDeSerTime(getLongAttribute(attribute.getValue(), attribute.getName())); } } cluster.addClusterStatement(statementDefinition, statement); // TODO : to store data for sparklines later /* * region.getPutsPerSecTrend().add(region.getPutsRate()); * region.getGetsPerSecTrend().add(region.getGetsRate()); */ } catch (InstanceNotFoundException infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } }
From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to iterate through all member attributes and return the updated member *///from w w w . jav a 2 s . c o m private Cluster.Member initializeMember(ObjectName mbeanName, Cluster.Member member) throws InstanceNotFoundException, ReflectionException, IOException { AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.MEMBER_MBEAN_ATTRIBUTES); for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); String name = attribute.getName(); switch (name) { case PulseConstants.MBEAN_ATTRIBUTE_GEMFIREVERSION: if (member.getGemfireVersion() == null) { // Set Member's GemFire Version if not set already String gemfireVersion = obtainGemfireVersion( getStringAttribute(attribute.getValue(), attribute.getName())); member.setGemfireVersion(gemfireVersion); } break; case PulseConstants.MBEAN_ATTRIBUTE_MANAGER: member.setManager(getBooleanAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT: member.setTotalRegionCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_LOCATOR: member.setLocator(getBooleanAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE: member.setTotalDiskUsage(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_SERVER: member.setServer(getBooleanAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALFILEDESCRIPTOROPEN: member.setTotalFileDescriptorOpen(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_LOADAVERAGE: member.setLoadAverage(getDoubleAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE: member.setThroughputWrites(getDoubleAttribute(attribute.getValue(), attribute.getName())); member.getThroughputWritesTrend().add(member.getThroughputWrites()); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE: member.setThroughputReads(getDoubleAttribute(attribute.getValue(), attribute.getName())); member.getThroughputReadsTrend().add(member.getThroughputReads()); break; case PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES: long trendVal = determineCurrentJVMPauses(PulseConstants.JVM_PAUSES_TYPE_MEMBER, member.getName(), getLongAttribute(attribute.getValue(), attribute.getName())); member.setGarbageCollectionCount(trendVal); member.getGarbageCollectionSamples().add(member.getGarbageCollectionCount()); break; case PulseConstants.MBEAN_ATTRIBUTE_USEDMEMORY: member.setCurrentHeapSize(getLongAttribute(attribute.getValue(), attribute.getName())); member.getHeapUsageSamples().add(member.getCurrentHeapSize()); break; case PulseConstants.MBEAN_ATTRIBUTE_MAXMEMORY: member.setMaxHeapSize(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NUMTHREADS: member.setNumThreads(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_MEMBERUPTIME: member.setUptime(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_HOST: member.setHost(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS: member.setHostnameForClients(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_BINDADDRESS: member.setBindAddress(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALBYTESONDISK: member.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(), attribute.getName())); member.getTotalBytesOnDiskSamples().add(member.getTotalBytesOnDisk()); break; case PulseConstants.MBEAN_ATTRIBUTE_CPUUSAGE: member.setCpuUsage(getDoubleAttribute(attribute.getValue(), attribute.getName())); member.getCpuUsageSamples().add(member.getCpuUsage()); break; case PulseConstants.MBEAN_ATTRIBUTE_HOSTCPUUSAGE: // Float value is expected for host cpu usage. // TODO Remove Float.valueOf() when float value is provided in mbean member.setHostCpuUsage( Double.valueOf(getIntegerAttribute(attribute.getValue(), attribute.getName()))); break; case PulseConstants.MBEAN_ATTRIBUTE_MEMBER: member.setName(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_ID: member.setId(getStringAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS: member.setGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); member.getGetsPerSecond().add(member.getGetsRate()); break; case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES: member.setPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); member.getPutsPerSecond().add(member.getPutsRate()); break; case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPFREESIZE: member.setOffHeapFreeSize(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPUSEDSIZE: member.setOffHeapUsedSize(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_SERVERGROUPS: String sgValues[] = (String[]) attribute.getValue(); member.getServerGroups().clear(); for (int k = 0; k < sgValues.length; k++) { member.getServerGroups().add(sgValues[k]); } break; case PulseConstants.MBEAN_ATTRIBUTE_REDUNDANCYZONES: String rzValue = ""; if (null != attribute.getValue()) { rzValue = getStringAttribute(attribute.getValue(), attribute.getName()); } member.getRedundancyZones().clear(); if (!rzValue.isEmpty()) { member.getRedundancyZones().add(rzValue); } break; } } return member; }
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 www . j av a2s . co 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:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to get attribute values of Cluster System and map them to cluster vo * // w w w. ja va2 s . c om * @param mbeanName Cluster System MBean */ private void updateClusterSystem(ObjectName mbeanName) throws IOException { try { if (!this.isAddedNotiListner) { this.mbs.addNotificationListener(mbeanName, this, null, new Object()); this.isAddedNotiListner = true; } String[] serverCnt = (String[]) (this.mbs.invoke(mbeanName, PulseConstants.MBEAN_OPERATION_LISTSERVERS, null, null)); cluster.setServerCount(serverCnt.length); TabularData table = (TabularData) (this.mbs.invoke(mbeanName, PulseConstants.MBEAN_OPERATION_VIEWREMOTECLUSTERSTATUS, null, null)); Collection<CompositeData> rows = (Collection<CompositeData>) table.values(); cluster.getWanInformationObject().clear(); for (CompositeData row : rows) { final Object key = row.get("key"); final Object value = row.get("value"); cluster.getWanInformationObject().put((String) key, (Boolean) value); } AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.CLUSTER_MBEAN_ATTRIBUTES); for (int i = 0; i < attributeList.size(); i++) { Attribute attribute = (Attribute) attributeList.get(i); String name = attribute.getName(); switch (name) { case PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT: cluster.setMemberCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NUMCLIENTS: cluster.setClientConnectionCount( getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_DISTRIBUTEDSYSTEMID: cluster.setClusterId(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_LOCATORCOUNT: cluster.setLocatorCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NUMRUNNIGFUNCTION: try { cluster.setRunningFunctionCount( getIntegerAttribute(attribute.getValue(), attribute.getName())); } catch (Exception e) { cluster.setRunningFunctionCount(0); continue; } break; case PulseConstants.MBEAN_ATTRIBUTE_REGISTEREDCQCOUNT: cluster.setRegisteredCQCount(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NUMSUBSCRIPTIONS: cluster.setSubscriptionCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NUMTXNCOMMITTED: cluster.setTxnCommittedCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_NUMTXNROLLBACK: cluster.setTxnRollbackCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALHEAPSIZE: cluster.setTotalHeapSize(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_USEDHEAPSIZE: try { cluster.setUsedHeapSize(getLongAttribute(attribute.getValue(), attribute.getName())); } catch (Exception e) { cluster.setUsedHeapSize((long) 0); continue; } cluster.getMemoryUsageTrend().add(cluster.getUsedHeapSize()); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONENTRYCOUNT: cluster.setTotalRegionEntryCount(getLongAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_CURRENTENTRYCOUNT: cluster.setCurrentQueryCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE: try { cluster.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(), attribute.getName())); } catch (Exception e) { cluster.setTotalBytesOnDisk((long) 0); continue; } cluster.getTotalBytesOnDiskTrend().add(cluster.getTotalBytesOnDisk()); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE: cluster.setDiskWritesRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); cluster.getThroughoutWritesTrend().add(cluster.getDiskWritesRate()); break; case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES: try { cluster.setWritePerSec(getDoubleAttribute(attribute.getValue(), attribute.getName())); } catch (Exception e) { cluster.setWritePerSec(0); continue; } cluster.getWritePerSecTrend().add(cluster.getWritePerSec()); break; case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS: try { cluster.setReadPerSec(getDoubleAttribute(attribute.getValue(), attribute.getName())); } catch (Exception e) { cluster.setReadPerSec(0); continue; } cluster.getReadPerSecTrend().add(cluster.getReadPerSec()); break; case PulseConstants.MBEAN_ATTRIBUTE_QUERYREQUESTRATE: cluster.setQueriesPerSec(getDoubleAttribute(attribute.getValue(), attribute.getName())); cluster.getQueriesPerSecTrend().add(cluster.getQueriesPerSec()); break; case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE: cluster.setDiskReadsRate(getDoubleAttribute(attribute.getValue(), attribute.getName())); cluster.getThroughoutReadsTrend().add(cluster.getDiskReadsRate()); break; case PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES: long trendVal = determineCurrentJVMPauses(PulseConstants.JVM_PAUSES_TYPE_CLUSTER, "", getLongAttribute(attribute.getValue(), attribute.getName())); cluster.setGarbageCollectionCount(trendVal); cluster.getGarbageCollectionTrend().add(cluster.getGarbageCollectionCount()); break; case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT: cluster.setTotalRegionCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); break; } } } catch (InstanceNotFoundException | ReflectionException | MBeanException infe) { logger.warn(infe); } }