当前位置: 首页>>代码示例>>Java>>正文


Java ObjectInstance.getObjectName方法代码示例

本文整理汇总了Java中javax.management.ObjectInstance.getObjectName方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectInstance.getObjectName方法的具体用法?Java ObjectInstance.getObjectName怎么用?Java ObjectInstance.getObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.ObjectInstance的用法示例。


在下文中一共展示了ObjectInstance.getObjectName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readCPUUsage

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static Map<String, Object> readCPUUsage(ObjectInstance oi, MBeanServerConnection mbsc) {

        Map<String, Object> m = new LinkedHashMap<String, Object>();

        ObjectName on = oi.getObjectName();

        Object procCPU = getMBeanAttrValue(mbsc, on, "ProcessCpuLoad");
        Object systemCPU = getMBeanAttrValue(mbsc, on, "SystemCpuLoad");

        if (procCPU == null) {
            procCPU = new Long(-1);
            systemCPU = new Long(-1);
        }
        else {
            DecimalFormat formatter = new DecimalFormat("00.0");

            procCPU = Double.valueOf(formatter.format((Double) procCPU * 100));
            systemCPU = Double.valueOf(formatter.format((Double) systemCPU * 100));
        }

        m.put("cpu_p", procCPU);
        m.put("cpu_s", systemCPU);

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:26,代码来源:JVMToolHelper.java

示例2: init

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public void init(String host, int port) throws Exception {
    int iport = 0;
    String shost = null;
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
    String onStr = "*:type=ThreadPool,*";
    ObjectName objectName = new ObjectName(onStr);
    Set<ObjectInstance> set = mBeanServer.queryMBeans(objectName, null);
    Iterator<ObjectInstance> iterator = set.iterator();
    while (iterator.hasNext()) {
        ObjectInstance oi = iterator.next();
        objName = oi.getObjectName();
        String name = objName.getKeyProperty("name");
          
        /* Name are:
         * http-8080
         * jk-10.33.144.3-8009
         * jk-jfcpc%2F10.33.144.3-8009
         */
        String [] elenames = name.split("-");
        String sport = elenames[elenames.length-1];
        iport = Integer.parseInt(sport);
        String [] shosts = elenames[1].split("%2F");
        shost = shosts[0];

        if (port==0 && host==null)
              break; /* Take the first one */
        if (host==null && iport==port)
            break; /* Only port done */
        if (shost.compareTo(host) == 0)
            break; /* Done port and host are the expected ones */
    }
    if (objName == null)
        throw(new Exception("Can't find connector for " + host + ":" + port));
    this.port = iport;
    this.host = shost;
    
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:CollectedInfo.java

示例3: main

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    for (Class<?> c : new Class<?>[] {
            Spume.class, Thing.class, XSpume.class, XThing.class
         }) {
        for (ObjectName n : new ObjectName[] {null, new ObjectName("a:b=c")}) {
            System.out.println("Class " + c.getName() + " with name " + n +
                    "...");
            ObjectName realName = new ObjectName("a:type=" + c.getName());
            Constructor<?> constr = c.getConstructor(ObjectName.class);
            Object mbean = constr.newInstance(realName);
            ObjectInstance oi;
            String what =
                "Registering MBean of type " + c.getName() + " under name " +
                "<" + n + ">: ";
            try {
                oi = mbs.registerMBean(mbean, n);
            } catch (Exception e) {
                e.printStackTrace();
                fail(what + " got " + e);
                continue;
            }
            ObjectName registeredName = oi.getObjectName();
            if (!registeredName.equals(realName))
                fail(what + " registered as " + registeredName);
            if (!mbs.isRegistered(realName)) {
                fail(what + " not registered as expected");
            }
            mbs.unregisterMBean(registeredName);
        }
    }
    System.err.flush();
    if (failures == 0)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: " + failure);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:PreRegisterNameTest.java

示例4: init

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public void init(String host, int port) throws Exception {
	int iport = 0;
	String shost = null;
	mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
	String onStr = "*:type=ThreadPool,*";
	ObjectName objectName = new ObjectName(onStr);
	Set<ObjectInstance> set = mBeanServer.queryMBeans(objectName, null);
	Iterator<ObjectInstance> iterator = set.iterator();
	while (iterator.hasNext()) {
		ObjectInstance oi = iterator.next();
		objName = oi.getObjectName();
		String name = objName.getKeyProperty("name");

		/*
		 * Name are: http-8080 jk-10.33.144.3-8009
		 * jk-jfcpc%2F10.33.144.3-8009
		 */
		String[] elenames = name.split("-");
		String sport = elenames[elenames.length - 1];
		iport = Integer.parseInt(sport);
		String[] shosts = elenames[1].split("%2F");
		shost = shosts[0];

		if (port == 0 && host == null)
			break; /* Take the first one */
		if (host == null && iport == port)
			break; /* Only port done */
		if (shost.compareTo(host) == 0)
			break; /* Done port and host are the expected ones */
	}
	if (objName == null)
		throw (new Exception("Can't find connector for " + host + ":" + port));
	this.port = iport;
	this.host = shost;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:37,代码来源:CollectedInfo.java

示例5: doRegister

import javax.management.ObjectInstance; //导入方法依赖的package包/类
/**
 * Actually register the MBean with the server. The behavior when encountering
 * an existing MBean can be configured using the {@link #setRegistrationBehavior(int)}
 * and {@link #setRegistrationBehaviorName(String)} methods.
 * @param mbean the MBean instance
 * @param objectName the suggested ObjectName for the MBean
 * @throws JMException if the registration failed
 */
protected void doRegister(Object mbean, ObjectName objectName) throws JMException {
	ObjectName actualObjectName;

	synchronized (this.registeredBeans) {
		ObjectInstance registeredBean = null;
		try {
			registeredBean = this.server.registerMBean(mbean, objectName);
		}
		catch (InstanceAlreadyExistsException ex) {
			if (this.registrationPolicy == RegistrationPolicy.IGNORE_EXISTING) {
				if (logger.isDebugEnabled()) {
					logger.debug("Ignoring existing MBean at [" + objectName + "]");
				}
			}
			else if (this.registrationPolicy == RegistrationPolicy.REPLACE_EXISTING) {
				try {
					if (logger.isDebugEnabled()) {
						logger.debug("Replacing existing MBean at [" + objectName + "]");
					}
					this.server.unregisterMBean(objectName);
					registeredBean = this.server.registerMBean(mbean, objectName);
				}
				catch (InstanceNotFoundException ex2) {
					logger.error("Unable to replace existing MBean at [" + objectName + "]", ex2);
					throw ex;
				}
			}
			else {
				throw ex;
			}
		}

		// Track registration and notify listeners.
		actualObjectName = (registeredBean != null ? registeredBean.getObjectName() : null);
		if (actualObjectName == null) {
			actualObjectName = objectName;
		}
		this.registeredBeans.add(actualObjectName);
	}

	onRegister(actualObjectName, mbean);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:MBeanRegistrationSupport.java

示例6: registerEngine

import javax.management.ObjectInstance; //导入方法依赖的package包/类
private void registerEngine()
    throws Exception
{
    ObjectName engineName = new ObjectName
        (domain + ":type=Engine");
    if ( ! mBeanServer.isRegistered(engineName)) return;
    String defaultHost = 
        (String) mBeanServer.getAttribute(engineName, "defaultHost");
    ObjectName hostName = new ObjectName
        (domain + ":type=Host," + "host=" + defaultHost);
    if (!mBeanServer.isRegistered(hostName)) {

        // Get the hosts' list
        String onStr = domain + ":type=Host,*";
        ObjectName objectName = new ObjectName(onStr);
        Set set = mBeanServer.queryMBeans(objectName, null);
        Iterator iterator = set.iterator();
        String[] aliases;
        boolean isRegisteredWithAlias = false;
        
        while (iterator.hasNext()) {

            if (isRegisteredWithAlias) break;
        
            ObjectInstance oi = (ObjectInstance) iterator.next();
            hostName = oi.getObjectName();
            aliases = (String[])
                mBeanServer.invoke(hostName, "findAliases", null, null);

            for (int i=0; i < aliases.length; i++){
                if (aliases[i].equalsIgnoreCase(defaultHost)){
                    isRegisteredWithAlias = true;
                    break;
                }
            }
        }
        
        if (!isRegisteredWithAlias)
            log.warn(sm.getString("mapperListener.unknownDefaultHost", defaultHost));
    }
    // This should probably be called later 
    if( defaultHost != null ) {
        mapper.setDefaultHostName(defaultHost);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:MapperListener.java

示例7: readGCUsage

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static Map<String, Object> readGCUsage(ObjectInstance oi, MBeanServerConnection mbsc) {

        Map<String, Object> m = new LinkedHashMap<String, Object>();

        ObjectName on = oi.getObjectName();

        String name = on.getKeyProperty("name");

        String gcName = null;

        if (minorGC.contains(name)) {
            gcName = "mgc";

        }
        else if (fullGC.contains(name)) {
            gcName = "fgc";
        }

        m.put(gcName + "_count", getMBeanAttrValue(mbsc, on, "CollectionCount"));
        m.put(gcName + "_time", getMBeanAttrValue(mbsc, on, "CollectionTime"));

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:24,代码来源:JVMToolHelper.java

示例8: doCaptureMonitorData

import javax.management.ObjectInstance; //导入方法依赖的package包/类
/**
 * doCaptureMonitorData
 * 
 * @param mbsc
 * @param timeFlag
 * @return
 * @throws IOException
 */
protected boolean doCaptureMonitorData(MBeanServerConnection mbsc, long timeFlag, MonitorDataFrame mdf)
        throws IOException {

    boolean needProcessCheck = true;
    // get all monitors' MBean
    Set<ObjectInstance> monitorMBeans = scanMonitorMBeans(mbsc);

    // the monitorMBeans should not be null if connection is all right, still check that in case abnormal issues
    if (doNoMBeanAction(monitorMBeans, "Monitor")) {
        /**
         * if the connection is not available, then the IOException will trigger process checking so if the
         * connection is OK but there is no any MBean, we notify that but still return false that means we will not
         * run process checking
         */
        return false;
    }

    Iterator<ObjectInstance> iterator = monitorMBeans.iterator();
    while (iterator.hasNext()) {
        ObjectInstance oi = iterator.next();
        try {
            // catch monitor data
            ObjectName monitorON = oi.getObjectName();
            Object oData = mbsc.getAttribute(monitorON, "Data");

            if (oData != null) {
                needProcessCheck = false;
                // add data to MonitorDataFrame
                mdf.addData(monitorON.getKeyProperty("id"), oData.toString());
            }

        }
        catch (Exception e) {
            log.err(this, "MonitorMBean[" + oi.getObjectName().toString() + "] catch data FAILs", e);
        }
    }

    // add appgroup
    mdf.addExt("appgroup", this.getAppGroup());

    return needProcessCheck;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:51,代码来源:JMXAppServerMonitorDataCatchWorker.java

示例9: readHeapPoolUsage

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static Map<String, Object> readHeapPoolUsage(ObjectInstance oi, MBeanServerConnection mbsc) {

        Map<String, Object> m = new LinkedHashMap<String, Object>();

        ObjectName on = oi.getObjectName();

        String jvmMemPoolName = getHeapPoolName(on.getKeyProperty("name"));

        m.put(jvmMemPoolName + "_use", getMBeanAttrValue(mbsc, on, "Usage", "used"));
        m.put(jvmMemPoolName + "_commit", getMBeanAttrValue(mbsc, on, "Usage", "committed"));
        m.put(jvmMemPoolName + "_max", getMBeanAttrValue(mbsc, on, "Usage", "max"));
        m.put(jvmMemPoolName + "_init", getMBeanAttrValue(mbsc, on, "Usage", "init"));

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:16,代码来源:JVMToolHelper.java

示例10: readClassLoadUsage

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static Map<String, Object> readClassLoadUsage(ObjectInstance oi, MBeanServerConnection mbsc) {

        Map<String, Object> m = new LinkedHashMap<String, Object>();

        ObjectName on = oi.getObjectName();

        m.put("class_total", getMBeanAttrValue(mbsc, on, "TotalLoadedClassCount"));
        m.put("class_load", getMBeanAttrValue(mbsc, on, "LoadedClassCount"));
        m.put("class_unload", getMBeanAttrValue(mbsc, on, "UnloadedClassCount"));

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:13,代码来源:JVMToolHelper.java

示例11: readHeapUsage

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static Map<String, Object> readHeapUsage(ObjectInstance oi, MBeanServerConnection mbsc) {

        Map<String, Object> m = new LinkedHashMap<String, Object>();

        ObjectName on = oi.getObjectName();

        m.put("heap_use", getMBeanAttrValue(mbsc, on, "HeapMemoryUsage", "used"));
        m.put("heap_commit", getMBeanAttrValue(mbsc, on, "HeapMemoryUsage", "committed"));
        m.put("heap_max", getMBeanAttrValue(mbsc, on, "HeapMemoryUsage", "max"));
        m.put("heap_init", getMBeanAttrValue(mbsc, on, "HeapMemoryUsage", "init"));

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:14,代码来源:JVMToolHelper.java

示例12: readNonHeapUsage

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static Map<String, Object> readNonHeapUsage(ObjectInstance oi, MBeanServerConnection mbsc) {

        Map<String, Object> m = new LinkedHashMap<String, Object>();

        ObjectName on = oi.getObjectName();

        m.put("noheap_use", getMBeanAttrValue(mbsc, on, "NonHeapMemoryUsage", "used"));
        m.put("noheap_commit", getMBeanAttrValue(mbsc, on, "NonHeapMemoryUsage", "committed"));
        m.put("noheap_max", getMBeanAttrValue(mbsc, on, "NonHeapMemoryUsage", "max"));
        m.put("noheap_init", getMBeanAttrValue(mbsc, on, "NonHeapMemoryUsage", "init"));

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:14,代码来源:JVMToolHelper.java

示例13: readThreadUsage

import javax.management.ObjectInstance; //导入方法依赖的package包/类
public static Map<String, Object> readThreadUsage(ObjectInstance oi, MBeanServerConnection mbsc) {

        Map<String, Object> m = new LinkedHashMap<String, Object>();

        ObjectName on = oi.getObjectName();

        m.put("thread_live", getMBeanAttrValue(mbsc, on, "ThreadCount"));
        m.put("thread_daemon", getMBeanAttrValue(mbsc, on, "DaemonThreadCount"));
        m.put("thread_peak", getMBeanAttrValue(mbsc, on, "PeakThreadCount"));
        m.put("thread_started", getMBeanAttrValue(mbsc, on, "TotalStartedThreadCount"));

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:14,代码来源:JVMToolHelper.java


注:本文中的javax.management.ObjectInstance.getObjectName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。