List of usage examples for javax.management.openmbean CompositeData get
public Object get(String key);
From source file:org.sakaiproject.kernel.component.KernelLifecycle.java
/** * Execute the start phase of the lifecycle, creating the MBean and registering the newly started * Kernel with JMX./* w ww. ja va 2s. c o m*/ * * @see org.sakaiproject.kernel.loader.common.CommonLifecycle#start() */ public void start() { LOG.info("==========PHASE 1 STARTING ================="); try { long start = System.currentTimeMillis(); lifecycleEvent(CommonLifecycleEvent.BEFORE_START); lastLoadDate = new Date(); // Start the kernel MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); RequiredModelMBean model = new RequiredModelMBean(createMBeanInfo()); model.setManagedResource(this, "objectReference"); ObjectName kernelName = new ObjectName(Kernel.MBEAN_KERNEL); mbs.registerMBean(model, kernelName); kernel = new KernelImpl(); kernel.start(); // Start the service manager serviceManager = new ServiceManagerImpl(kernel); serviceManager.start(); // Start the component manager. componentManager = new ComponentManagerImpl(kernel); componentManager.start(); try { System.runFinalization(); Runtime.getRuntime().gc(); CompositeData permGen = null; try { permGen = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=Perm Gen"), "Usage"); } catch (Exception ex) { permGen = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=CMS Perm Gen"), "Usage"); } CompositeData tenuredGen; try { tenuredGen = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=Tenured Gen"), "Usage"); } catch (Exception ex) { tenuredGen = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=CMS Old Gen"), "Usage"); } CompositeData codeCache = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=Code Cache"), "Usage"); CompositeData edenSpace = null; try { edenSpace = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=Eden Space"), "Usage"); } catch (Exception ex) { edenSpace = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=Par Eden Space"), "Usage"); } CompositeData survivorSpace = null; try { survivorSpace = (CompositeData) mbs .getAttribute(new ObjectName("java.lang:type=MemoryPool,name=Survivor Space"), "Usage"); } catch (Exception ex) { survivorSpace = (CompositeData) mbs.getAttribute( new ObjectName("java.lang:type=MemoryPool,name=Par Survivor Space"), "Usage"); } long permGenUsed = Long.parseLong(String.valueOf(permGen.get("used"))); long codeCacheUsed = Long.parseLong(String.valueOf(codeCache.get("used"))); long edenSpaceUsed = Long.parseLong(String.valueOf(edenSpace.get("used"))); long tenuredGenUsed = Long.parseLong(String.valueOf(tenuredGen.get("used"))); long survivorSpaceUsed = Long.parseLong(String.valueOf(survivorSpace.get("used"))); LOG.info("Memory Stats after startup\n" + "\tPermgen Used " + permGenUsed / (ONEM) + " MB\n" + "\tCode Cache Used " + codeCacheUsed / (ONEM) + " MB\n" + "\tEden Used " + edenSpaceUsed / (ONEM) + " MB\n" + "\tTenured Used " + tenuredGenUsed / (ONEM) + " MB\n" + "\tSurvivour Used " + survivorSpaceUsed / (ONEM) + " MB"); } catch (RuntimeException ex2) { LOG.info("Startup Memory Stats Not available ", ex2); } catch (Exception ex2) { LOG.info("Startup Memory Stats Not available ", ex2); } lifecycleEvent(CommonLifecycleEvent.START); lifecycleEvent(CommonLifecycleEvent.AFTER_START); loadTime = System.currentTimeMillis() - start; } catch (Throwable ex) { LOG.error("Failed to start Component Lifecycle ", ex); throw new Error("Failed to start Component Lifecycle ", ex); } LOG.info("============END of LIFECYCLE STARTUP==============================="); }
From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used to iterate through all member attributes and return the * updated member//from ww w. jav a 2 s . c om */ 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; } } // SQLFire specific attributes if (PulseController.getPulseProductSupport().equalsIgnoreCase(PulseConstants.PRODUCT_NAME_SQLFIRE)) { try { // get sqlfire mbeans String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER); ObjectName sfMemberMbeansObjectName = new ObjectName( PulseConstants.OBJECT_NAME_SF_MEMBER_PATTERN + memberName); Set<ObjectName> sfMemberMBeans = this.mbs.queryNames(sfMemberMbeansObjectName, null); for (ObjectName sfMemberMBean : sfMemberMBeans) { AttributeList attrList = this.mbs.getAttributes(sfMemberMBean, PulseConstants.SF_MEMBER_MBEAN_ATTRIBUTES); for (int i = 0; i < attrList.size(); i++) { Attribute attribute = (Attribute) attrList.get(i); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_DATASTORE)) { member.setServer(getBooleanAttribute(attribute.getValue(), attribute.getName())); // Update Server count if (member.isServer()) { cluster.setServerCount(cluster.getServerCount() + 1); } } else if (attribute.getName() .equals(PulseConstants.MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS)) { CompositeData nscConnStats = (CompositeData) attribute.getValue(); // Update sqlfire client count member.setNumSqlfireClients(getLongAttribute( nscConnStats.get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE), PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE)); } } break; } } catch (MalformedObjectNameException e) { LOGGER.warning(e); } catch (NullPointerException e) { LOGGER.warning(e); } } return member; }