List of usage examples for javax.management ObjectName getKeyProperty
public String getKeyProperty(String property)
From source file:org.hyperic.hq.plugin.weblogic.jmx.WeblogicRuntimeDiscoverer.java
private void discoverDynamicServices(WeblogicDiscover discover, MBeanServerConnection mServer, ServerQuery parent, ArrayList services, Set serviceTypes) throws PluginException, WeblogicDiscoverException { try {/*w w w . ja v a 2 s . c o m*/ final Set objectNames = mServer.queryNames(new ObjectName(MBeanUtil.DYNAMIC_SERVICE_DOMAIN + ":*"), null); //Only WebLogic Admin servers have auto-inventory plugins - have to construct a ServerInfo for the WebLogic server String[] platformTypes = ((ServerTypeInfo) plugin.getTypeInfo()).getPlatformTypes(); ServerTypeInfo server = new ServerTypeInfo(parent.getResourceType(), parent.getDescription(), parent.getVersion()); server.setValidPlatformTypes(platformTypes); for (Iterator iterator = objectNames.iterator(); iterator.hasNext();) { final ObjectName objectName = (ObjectName) iterator.next(); final MBeanInfo serviceInfo = mServer.getMBeanInfo(objectName); if (serviceInfo instanceof ModelMBeanInfo) { ServiceType identityType = serviceTypeFactory.getServiceType( plugin.getProductPlugin().getName(), server, (ModelMBeanInfo) serviceInfo, objectName); //identityType could be null if MBean is not to be exported if (identityType != null) { ServiceType serviceType; if (!serviceTypes.contains(identityType)) { serviceType = serviceTypeFactory.create(plugin.getProductPlugin(), server, (ModelMBeanInfo) serviceInfo, objectName); if (serviceType != null) { serviceTypes.add(serviceType); } } else { serviceType = findServiceType(identityType.getInfo().getName(), serviceTypes); } final String shortServiceType = identityType.getServiceName(); DynamicServiceQuery dynamicServiceQuery = new DynamicServiceQuery(); dynamicServiceQuery.setParent(parent); dynamicServiceQuery.setType(shortServiceType); dynamicServiceQuery.setAttributeNames(serviceType.getCustomProperties().getOptionNames()); dynamicServiceQuery.setName(objectName.getKeyProperty("name")); dynamicServiceQuery.getDynamicAttributes(mServer, objectName); services.add(dynamicServiceQuery); } } } } catch (Exception e) { throw new PluginException(e.getMessage(), e); } }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
private void updateClusterStatement(ObjectName mbeanName) throws IOException { try {/* w w w . j a v a 2s. c om*/ 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:io.fabric8.api.registry.rules.CamelEndpointFinder.java
protected void addToApiDescription(ApiDeclaration apiDeclaration, CamelRestService restService, ObjectName objectName) { String basePath = restService.getBaseUrl(); String resourcePath = restService.getBasePath(); if (apiDeclaration.getBasePath() == null) { String uriText = basePath; if (basePath.endsWith(resourcePath)) { uriText = basePath.substring(0, basePath.length() - resourcePath.length()); }//w w w . j a v a2s.com if (replaceWithProxyLink) { uriText = switchToUseProxyLink(uriText); } try { URI uri = new URI(uriText); apiDeclaration.setBasePath(uri); } catch (URISyntaxException e) { LOG.warn("Could not parse basePath: " + uriText + ". " + e, e); } } if (Strings.isNullOrBlank(apiDeclaration.getResourcePath())) { apiDeclaration.setResourcePath(resourcePath); } List<Api> apis = SwaggerHelpers.getOrCreateApis(apiDeclaration); String path = urlPathJoin(resourcePath, restService.getUriTemplate()); Api api = SwaggerHelpers.findOrCreateApiForPath(apis, path); List<Operation> operations = SwaggerHelpers.getOrCreateOperations(api); Operation operation = new Operation(); String method = restService.getMethod(); String inType = restService.getInType(); if (Strings.isNotBlank(method)) { method = method.toUpperCase(Locale.US); operation.setMethod(Operation.Method.fromValue(method)); } String description = restService.getDescription(); if (Strings.isNotBlank(description)) { operation.setSummary(description); } // TODO have way to expose the nickname? Might be nice to expose the route id? String nickname = objectName.getKeyProperty("context"); if (Strings.isNullOrBlank(nickname)) { nickname = (Strings.isNotBlank(method) ? method + " " : "") + Strings.defaultIfEmpty(inType, "") + " " + restService.getUriTemplate(); } else { String route = restService.getRouteId(); if (Strings.isNotBlank(route)) { nickname += "." + route; } } operation.setNickname(nickname); operation.setConsumes(splitStringToSet(restService.getConsumes(), ",")); operation.setProduces(splitStringToSet(restService.getProduces(), ",")); List<Parameter> parameters = SwaggerHelpers.getOrCreateParameters(operation); addUrlParameters(parameters, restService.getUrl()); if (Strings.isNotBlank(inType)) { Parameter parameter = new Parameter(); parameter.setParamType(Parameter.ParamType.BODY); parameter.setRequired(true); parameter.setAllowMultiple(false); parameter.setName("body"); parameter.setType(inType); parameters.add(parameter); } String outType = restService.getOutType(); if (Strings.isNotBlank(outType)) { List<ResponseMessage> responseMessages = SwaggerHelpers.getOrCreateResponseMessages(operation); ResponseMessage responseMessage = new ResponseMessage(); responseMessage.setMessage(outType); responseMessages.add(responseMessage); } operations.add(operation); }
From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used for getting a Gateway Receiver from mBean for giving member * and update the gateway receiver for respective member object *//*w ww. ja v a 2 s . c o m*/ private void updateGatewayReceiver(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.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName); existingMember.setGatewayReceiver(gatewayReceiver); } else { Cluster.Member member = new Cluster.Member(); member.setName(memberName); member.setId(memberName); Cluster.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName); member.setGatewayReceiver(gatewayReceiver); 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:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used to get attribute values of Cluster Member and map them to * cluster member vo/*from www . j av a 2 s . c om*/ * * @param mbeanName * Cluster Member MBean */ private void updateClusterMember(ObjectName mbeanName) throws IOException { try { String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER); Cluster.Member clusterMember = cluster.getMembersHMap().get(memberName); if (clusterMember != null) // checking if member exists or not { cluster.getDeletedMembers().remove(memberName); } else { clusterMember = new Cluster.Member(); cluster.getMembersHMap().put(memberName, clusterMember); } // initialize member and add to cluster's member list clusterMember = initializeMember(mbeanName, clusterMember); ArrayList<Cluster.Member> memberArrList = (ArrayList<Cluster.Member>) cluster.getPhysicalToMember() .get(clusterMember.getHost()); if (memberArrList != null) { if (!memberArrList.contains(clusterMember)) { memberArrList.add(clusterMember); } } else { ArrayList<Cluster.Member> memberList = new ArrayList<Cluster.Member>(); memberList.add(clusterMember); cluster.getPhysicalToMember().put(clusterMember.getHost(), memberList); } } catch (InstanceNotFoundException infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } }
From source file:edu.nwpu.gemfire.monitor.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 www. j a v a 2 s. co m private void updateAsyncEventQueue(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.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName); for (Iterator<Cluster.AsyncEventQueue> it = existingMember.getAsyncEventQueueList().iterator(); it .hasNext();) { Cluster.AsyncEventQueue exisAsyncEventQueue = it.next(); if ((exisAsyncEventQueue.getId()).equals(asyncQ.getId())) { it.remove(); break; } } // Add async event queue existingMember.getAsyncEventQueueList().add(asyncQ); } else { Cluster.Member member = new Cluster.Member(); member.setName(memberName); member.setId(memberName); Cluster.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName); member.getAsyncEventQueueList().add(asyncQ); 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:edu.nwpu.gemfire.monitor.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 *///w w w . j ava 2 s . c o m 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 (Iterator<Cluster.GatewaySender> it = existingMember.getGatewaySenderList().iterator(); it .hasNext();) { Cluster.GatewaySender exisGatewaySender = it.next(); if ((exisGatewaySender.getId()).equals(gatewaySender.getId())) { it.remove(); 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: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 www. j a v a 2s . 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 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:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used to get attribute values of Member Region and map them to * Member vo/*w ww. j a va 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); 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.warning(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 infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } }
From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used for updating Cluster Data. *///from w w w . ja v 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_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) { // For SQLfire 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) { 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: if (PulseConstants.PRODUCT_NAME_SQLFIRE .equalsIgnoreCase(PulseController.getPulseProductSupport())) { // For SQLfire 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); } 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); //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; }