List of usage examples for javax.management ObjectName getKeyProperty
public String getKeyProperty(String property)
From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used to get attribute values of Cluster Region and map them to * cluster region vo/* w ww. j a v a 2s. 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 infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } }
From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
private void updateClusterStatement(ObjectName mbeanName) throws IOException { try {/*from w w w .ja 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 infe) { LOGGER.warning(infe); } catch (ReflectionException re) { LOGGER.warning(re); } }
From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java
/** * function used to iterate through all member attributes and return the * updated member/* ww w . j av a2 s. co m*/ * * @param attrs * @param mbeanName * @param member * @return * @throws IOException * @throws ReflectionException * @throws InstanceNotFoundException */ 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); if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_MANAGER)) { member.setManager(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT)) { member.setTotalRegionCount(getIntegerAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_LOCATOR)) { member.setLocator(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE)) { member.setTotalDiskUsage(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_SERVER)) { member.setServer(getBooleanAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_TOTALFILEDESCRIPTOROPEN)) { member.setTotalFileDescriptorOpen(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_LOADAVERAGE)) { member.setLoadAverage(getDoubleAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE)) { member.setThroughputWrites(getFloatAttribute(attribute.getValue(), attribute.getName())); member.getThroughputWritesTrend().add(member.getThroughputWrites()); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE)) { member.setThroughputReads(getFloatAttribute(attribute.getValue(), attribute.getName())); member.getThroughputReadsTrend().add(member.getThroughputReads()); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES)) { member.setGarbageCollectionCount(getLongAttribute(attribute.getValue(), attribute.getName())); member.getGarbageCollectionSamples().add(member.getGarbageCollectionCount()); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_CURRENTHEAPSIZE)) { member.setCurrentHeapSize(getLongAttribute(attribute.getValue(), attribute.getName())); member.getHeapUsageSamples().add(member.getCurrentHeapSize()); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_MAXIMUMHEAPSIZE)) { member.setMaxHeapSize(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_NUMTHREADS)) { member.setNumThreads(getIntegerAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_MEMBERUPTIME)) { member.setUptime(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_HOST)) { member.setHost(getStringAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_TOTALBYTESONDISK)) { member.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(), attribute.getName())); member.getTotalBytesOnDiskSamples().add(member.getTotalBytesOnDisk()); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_CPUUSAGE)) { member.setCpuUsage(getFloatAttribute(attribute.getValue(), attribute.getName())); member.getCpuUsageSamples().add(member.getCpuUsage()); } else if (attribute.getName().equals(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( Float.valueOf(getIntegerAttribute(attribute.getValue(), attribute.getName()))); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_MEMBER)) { member.setName(getStringAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_ID)) { member.setId(getStringAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS)) { member.setGetsRate(getFloatAttribute(attribute.getValue(), attribute.getName())); member.getGetsPerSecond().add(member.getGetsRate()); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES)) { member.setPutsRate(getFloatAttribute(attribute.getValue(), attribute.getName())); member.getPutsPerSecond().add(member.getPutsRate()); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPFREESIZE)) { member.setOffHeapFreeSize(getLongAttribute(attribute.getValue(), attribute.getName())); } else if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPUSEDSIZE)) { member.setOffHeapUsedSize(getLongAttribute(attribute.getValue(), attribute.getName())); } } // GemFireXD specific attributes if (PulseController.getPulseProductSupport().equalsIgnoreCase(PulseConstants.PRODUCT_NAME_GEMFIREXD)) { try { // get GemFireXD 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 GemFireXD client count member.setNumGemFireXDClients(getLongAttribute( nscConnStats.get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSOPEN), PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSOPEN)); } } break; } } catch (MalformedObjectNameException e) { LOGGER.warning(e); } catch (NullPointerException e) { LOGGER.warning(e); } } return member; }
From source file:org.jboss.web.tomcat.tc5.TomcatDeployer.java
protected void performDeployInternal(String hostName, WebApplication appInfo, String warUrl, AbstractWebContainer.WebDescriptorParser webAppParser) throws Exception { WebMetaData metaData = appInfo.getMetaData(); String ctxPath = metaData.getContextRoot(); if (ctxPath.equals("/") || ctxPath.equals("/ROOT") || ctxPath.equals("")) { log.debug("deploy root context=" + ctxPath); ctxPath = "/"; metaData.setContextRoot(ctxPath); }/*from ww w.j a v a 2 s.c o m*/ log.info("deploy, ctxPath=" + ctxPath + ", warUrl=" + shortWarUrlFromServerHome(warUrl)); URL url = new URL(warUrl); ClassLoader loader = Thread.currentThread().getContextClassLoader(); /* If we are using the jboss class loader we need to augment its path to include the WEB-INF/{lib,classes} dirs or else scoped class loading does not see the war level overrides. The call to setWarURL adds these paths to the deployment UCL. */ Loader webLoader = null; if (config.isUseJBossWebLoader()) { WebCtxLoader jbossLoader = new WebCtxLoader(loader); jbossLoader.setWarURL(url); webLoader = jbossLoader; } else { String[] pkgs = config.getFilteredPackages(); WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs); jbossLoader.setDelegate(getJava2ClassLoadingCompliance()); webLoader = jbossLoader; } // We need to establish the JNDI ENC prior to the start // of the web container so that init on startup servlets are able // to interact with their ENC. We hook into the context lifecycle // events to be notified of the start of the // context as this occurs before the servlets are started. if (appInfo.getAppData() == null) webAppParser.parseWebAppDescriptors(loader, appInfo.getMetaData()); appInfo.setName(url.getPath()); appInfo.setClassLoader(loader); appInfo.setURL(url); String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath + ",J2EEApplication=none,J2EEServer=none"; ObjectName objectName = new ObjectName(objectNameS); if (server.isRegistered(objectName)) { log.debug("Already exists, destroying " + objectName); server.invoke(objectName, "destroy", new Object[] {}, new String[] {}); } server.createMBean("org.apache.commons.modeler.BaseModelMBean", objectName, new Object[] { config.getContextClassName() }, new String[] { "java.lang.String" }); // Find and set config file on the context // If WAR is packed, expand config file to temp folder String ctxConfig = null; try { ctxConfig = findConfig(url); } catch (IOException e) { log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e); } server.setAttribute(objectName, new Attribute("docBase", url.getFile())); server.setAttribute(objectName, new Attribute("configFile", ctxConfig)); server.setAttribute(objectName, new Attribute("defaultContextXml", "context.xml")); server.setAttribute(objectName, new Attribute("defaultWebXml", "conf/web.xml")); server.setAttribute(objectName, new Attribute("javaVMs", javaVMs)); server.setAttribute(objectName, new Attribute("server", serverName)); server.setAttribute(objectName, new Attribute("saveConfig", Boolean.FALSE)); if (webLoader != null) { server.setAttribute(objectName, new Attribute("loader", webLoader)); } else { server.setAttribute(objectName, new Attribute("parentClassLoader", loader)); } server.setAttribute(objectName, new Attribute("delegate", new Boolean(getJava2ClassLoadingCompliance()))); String[] jspCP = getCompileClasspath(loader); StringBuffer classpath = new StringBuffer(); for (int u = 0; u < jspCP.length; u++) { String repository = jspCP[u]; if (repository == null) continue; if (repository.startsWith("file://")) repository = repository.substring(7); else if (repository.startsWith("file:")) repository = repository.substring(5); else continue; if (repository == null) continue; // ok it is a file. Make sure that is is a directory or jar file File fp = new File(repository); if (!fp.isDirectory()) { // if it is not a directory, try to open it as a zipfile. try { // avoid opening .xml files if (fp.getName().toLowerCase().endsWith(".xml")) continue; ZipFile zip = new ZipFile(fp); zip.close(); } catch (IOException e) { continue; } } if (u > 0) classpath.append(File.pathSeparator); classpath.append(repository); } server.setAttribute(objectName, new Attribute("compilerClasspath", classpath.toString())); // Set the session cookies flag according to metadata switch (metaData.getSessionCookies()) { case WebMetaData.SESSION_COOKIES_ENABLED: server.setAttribute(objectName, new Attribute("cookies", new Boolean(true))); log.debug("Enabling session cookies"); break; case WebMetaData.SESSION_COOKIES_DISABLED: server.setAttribute(objectName, new Attribute("cookies", new Boolean(false))); log.debug("Disabling session cookies"); break; default: log.debug("Using session cookies default setting"); } // Add a valve to estalish the JACC context before authorization valves Certificate[] certs = null; CodeSource cs = new CodeSource(url, certs); JaccContextValve jaccValve = new JaccContextValve(metaData.getJaccContextID(), cs); server.invoke(objectName, "addValve", new Object[] { jaccValve }, new String[] { "org.apache.catalina.Valve" }); // Pass the metadata to the RunAsListener via a thread local RunAsListener.metaDataLocal.set(metaData); try { // Init the container; this will also start it server.invoke(objectName, "init", new Object[] {}, new String[] {}); } finally { RunAsListener.metaDataLocal.set(null); } // make the context class loader known to the WebMetaData, ws4ee needs it // to instanciate service endpoint pojos that live in this webapp Loader ctxLoader = (Loader) server.getAttribute(objectName, "loader"); metaData.setContextLoader(ctxLoader.getClassLoader()); // Clustering if (metaData.getDistributable()) { // Try to initate clustering, fallback to standard if no clustering is available try { AbstractJBossManager manager = null; String managerClassName = config.getManagerClass(); Class managerClass = Thread.currentThread().getContextClassLoader().loadClass(managerClassName); manager = (AbstractJBossManager) managerClass.newInstance(); if (manager instanceof JBossCacheManager) { // TODO either deprecate snapshot mode or move its config // into jboss-web.xml. String snapshotMode = config.getSnapshotMode(); int snapshotInterval = config.getSnapshotInterval(); JBossCacheManager jbcm = (JBossCacheManager) manager; jbcm.setSnapshotMode(snapshotMode); jbcm.setSnapshotInterval(snapshotInterval); } String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath; manager.init(name, metaData, config.isUseJK(), config.isUseLocalCache()); // Don't assign the manager to the context until all config // is done, or else the manager will be started without the config server.setAttribute(objectName, new Attribute("manager", manager)); log.debug("Enabled clustering support for ctxPath=" + ctxPath); } catch (ClusteringNotSupportedException e) { // JBAS-3513 Just log a WARN, not an ERROR log.warn("Failed to setup clustering, clustering disabled. ClusteringNotSupportedException: " + e.getMessage()); } catch (NoClassDefFoundError ncdf) { // JBAS-3513 Just log a WARN, not an ERROR log.debug("Classes needed for clustered webapp unavailable", ncdf); log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: " + ncdf.getMessage()); } catch (Throwable t) { // TODO consider letting this through and fail the deployment log.error("Failed to setup clustering, clustering disabled. Exception: ", t); } } /* Add security association valve after the authorization valves so that the authenticated user may be associated with the request thread/session. */ SecurityAssociationValve valve = new SecurityAssociationValve(metaData, config.getSecurityManagerService()); valve.setSubjectAttributeName(config.getSubjectAttributeName()); server.invoke(objectName, "addValve", new Object[] { valve }, new String[] { "org.apache.catalina.Valve" }); // Retrieve the state, and throw an exception in case of a failure Integer state = (Integer) server.getAttribute(objectName, "state"); if (state.intValue() != 1) { throw new DeploymentException("URL " + warUrl + " deployment failed"); } appInfo.setAppData(objectName); // Create mbeans for the servlets DeploymentInfo di = webAppParser.getDeploymentInfo(); di.deployedObject = objectName; ObjectName servletQuery = new ObjectName(config.getCatalinaDomain() + ":j2eeType=Servlet,WebModule=" + objectName.getKeyProperty("name") + ",*"); Iterator iterator = server.queryMBeans(servletQuery, null).iterator(); while (iterator.hasNext()) { di.mbeans.add(((ObjectInstance) iterator.next()).getObjectName()); } log.debug("Initialized: " + appInfo + " " + objectName); }
From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java
/** * function used to iterate through all member attributes and return the * updated member/*from w w w.j av a 2 s. co 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; } } // 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; }