當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassLoadingMXBean類代碼示例

本文整理匯總了Java中java.lang.management.ClassLoadingMXBean的典型用法代碼示例。如果您正苦於以下問題:Java ClassLoadingMXBean類的具體用法?Java ClassLoadingMXBean怎麽用?Java ClassLoadingMXBean使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClassLoadingMXBean類屬於java.lang.management包,在下文中一共展示了ClassLoadingMXBean類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: instantiateClassLoaderMetrics

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
private static void instantiateClassLoaderMetrics(MetricGroup metrics) {
	final ClassLoadingMXBean mxBean = ManagementFactory.getClassLoadingMXBean();

	metrics.<Long, Gauge<Long>>gauge("ClassesLoaded", new Gauge<Long> () {
		@Override
		public Long getValue() {
			return mxBean.getTotalLoadedClassCount();
		}
	});

	metrics.<Long, Gauge<Long>>gauge("ClassesUnloaded", new Gauge<Long> () {
		@Override
		public Long getValue() {
			return mxBean.getUnloadedClassCount();
		}
	});
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:18,代碼來源:MetricUtils.java

示例2: doExecute

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
protected Object doExecute() throws Exception {
    if (numThreads != null) {
         numberOfDisplayedThreads = Integer.parseInt(numThreads);
    }
    if (updates != null) {
         DEFAULT_REFRESH_INTERVAL = Integer.parseInt(updates);
    } 
    try {
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
        ThreadMXBean threads = ManagementFactory.getThreadMXBean();
        MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
        ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
        KTop(runtime, os, threads, mem, cl);
    } catch (IOException e) {
        //Ignore
    }
    return null;
}
 
開發者ID:savoirtech,項目名稱:ktop,代碼行數:20,代碼來源:KTop.java

示例3: main

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    ClassLoadingMXBean classMXBean = ManagementFactory
            .getClassLoadingMXBean();
    if (!classMXBean.isVerbose()) {
        fail();
    }
    Class.forName(args[0]);
    classMXBean.setVerbose(false);
    if (classMXBean.isVerbose()) {
        fail();
    }
    System.out.println(args[1]);
    Class.forName(args[2]);
    classMXBean.setVerbose(true);
    if (!classMXBean.isVerbose()) {
        fail();
    }
    System.out.println(args[3]);
    System.exit(77);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:Test.java

示例4: addClassLoadingInfo

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
/**
 * Creates the metadata for the {@link ClassLoadingMXBean}bean. For this
 * type of platform bean the metadata covers :
 * <ul>
 * <li>4 attributes
 * <li>0 constructors
 * <li>0 operations
 * <li>0 notifications
 * </ul>
 * 
 * @param result
 */
private static void addClassLoadingInfo(HashMap<String, MBeanInfo> result) {
    // Attributes
    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[4];
    attributes[0] = new MBeanAttributeInfo("LoadedClassCount", Integer.TYPE
            .getName(), "LoadedClassCount", true, false, false);
    attributes[1] = new MBeanAttributeInfo("TotalLoadedClassCount",
            Long.TYPE.getName(), "TotalLoadedClassCount", true, false,
            false);
    attributes[2] = new MBeanAttributeInfo("UnloadedClassCount", Long.TYPE
            .getName(), "UnloadedClassCount", true, false, false);
    attributes[3] = new MBeanAttributeInfo("Verbose", Boolean.TYPE
            .getName(), "Verbose", true, true, true);
    result.put(ClassLoadingMXBean.class.getName(), new MBeanInfo(
            ClassLoadingMXBeanImpl.class.getName(),
            ClassLoadingMXBeanImpl.class.getName(), attributes, null, null,
            null));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:30,代碼來源:ManagementUtils.java

示例5: testNewPlatformMXBeanProxy_ClassLoadingMXBean

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
public void testNewPlatformMXBeanProxy_ClassLoadingMXBean()
        throws Exception {
    ClassLoadingMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
            ManagementFactory.getPlatformMBeanServer(),
            "java.lang:type=ClassLoading", ClassLoadingMXBean.class);
    assertNotNull(proxy);
    ClassLoadingMXBean classLoadingMXBean = ManagementFactory
            .getClassLoadingMXBean();
    assertEquals(proxy.getLoadedClassCount(), classLoadingMXBean
            .getLoadedClassCount());
    assertEquals(proxy.getTotalLoadedClassCount(), classLoadingMXBean
            .getTotalLoadedClassCount());
    assertEquals(proxy.getUnloadedClassCount(), classLoadingMXBean
            .getUnloadedClassCount());
    assertEquals(proxy.isVerbose(), classLoadingMXBean.isVerbose());

    boolean initialVal = proxy.isVerbose();
    proxy.setVerbose(!initialVal);
    assertTrue(proxy.isVerbose() != initialVal);
    proxy.setVerbose(initialVal);
    assertEquals(initialVal, proxy.isVerbose());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:ManagementFactoryTest.java

示例6: testClassLoadingMXBean

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
@Test
public void testClassLoadingMXBean() throws IOException {
    DescribedResource describedResource = basicResourceTest("class-loading", null);

    ClassLoadingMXBean mbean = ManagementFactory.getClassLoadingMXBean();
    boolean verbose = describedResource.resource.get("verbose").asBoolean();
    Assert.assertEquals(mbean.isVerbose(), verbose);

    ModelNode op = getOperation("write-attribute", "class-loading", null);
    op.get("name").set("verbose");
    op.get("value").set(!verbose);
    executeOp(op, false);
    Assert.assertEquals(mbean.isVerbose(), !verbose);

    // Restore
    mbean.setVerbose(verbose);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:18,代碼來源:PlatformMBeanResourceUnitTestCase.java

示例7: sense

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
@Override
public void sense(final MetricRecorder.Context metricContext)
{
    ClassLoadingMXBean mxBean = ManagementFactory.getClassLoadingMXBean();

    metricContext.record(CURRENT_COUNT, mxBean.getLoadedClassCount(), Unit.NONE);
    metricContext.record(TOTAL_COUNT, mxBean.getTotalLoadedClassCount(), Unit.NONE);
    metricContext.record(UNLOADED_COUNT, mxBean.getUnloadedClassCount(), Unit.NONE);
}
 
開發者ID:awslabs,項目名稱:swage,代碼行數:10,代碼來源:ClassLoadingSensor.java

示例8: bindTo

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
@Override
public void bindTo(MeterRegistry registry) {
    ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean();

    Gauge.builder("jvm.classes.loaded", classLoadingBean, ClassLoadingMXBean::getLoadedClassCount)
        .tags(tags)
        .description("The number of classes that are currently loaded in the Java virtual machine")
        .register(registry);

    FunctionCounter.builder("jvm.classes.unloaded", classLoadingBean, ClassLoadingMXBean::getUnloadedClassCount)
        .tags(tags)
        .description("The total number of classes unloaded since the Java virtual machine has started execution")
        .register(registry);
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:15,代碼來源:ClassLoaderMetrics.java

示例9: doClassLoadingMXBeanTest

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- ClassLoadingMXBean") ;

    try {
        ObjectName classLoadingName =
                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        ClassLoadingMXBean classLoading = null;

        classLoading = JMX.newMXBeanProxy(mbsc,
                classLoadingName,
                ClassLoadingMXBean.class) ;
        System.out.println("getLoadedClassCount\t\t"
                + classLoading.getLoadedClassCount());
        System.out.println("getTotalLoadedClassCount\t\t"
                + classLoading.getTotalLoadedClassCount());
        System.out.println("getUnloadedClassCount\t\t"
                + classLoading.getUnloadedClassCount());
        System.out.println("isVerbose\t\t"
                + classLoading.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:36,代碼來源:MXBeanInteropTest1.java

示例10: readClassLoadUsage

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
private void readClassLoadUsage(MonitorElementInstance instance) {

        ClassLoadingMXBean clmb = ManagementFactory.getClassLoadingMXBean();

        instance.setValue("class_total", clmb.getTotalLoadedClassCount());
        instance.setValue("class_load", clmb.getLoadedClassCount());
        instance.setValue("class_unload", clmb.getUnloadedClassCount());
    }
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:9,代碼來源:JVMStateCapHandler.java

示例11: addClassLoadingMetrics

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
/**
 * Add class loading metrics.
 * @param result the result
 */
protected void addClassLoadingMetrics(Collection<Metric<?>> result) {
	ClassLoadingMXBean classLoadingMxBean = ManagementFactory.getClassLoadingMXBean();
	result.add(new Metric<Long>("classes",
			(long) classLoadingMxBean.getLoadedClassCount()));
	result.add(new Metric<Long>("classes.loaded",
			classLoadingMxBean.getTotalLoadedClassCount()));
	result.add(new Metric<Long>("classes.unloaded",
			classLoadingMxBean.getUnloadedClassCount()));
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:14,代碼來源:SystemPublicMetrics.java

示例12: displayManagementBean

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
private String displayManagementBean(ClassLoadingMXBean mxBean) {
    StringBuilder sb = new StringBuilder();
    if (mxBean != null) {
        sb.append(mxBean.toString()).append('\n');
        sb.append(mxBean.getObjectName().toString()).append('\n');
        sb.append("Loaded Class Count:\t").append(mxBean.getLoadedClassCount()).append('\n');
        sb.append("Total Loaded Class Count:\t").append(mxBean.getTotalLoadedClassCount()).append('\n');
        sb.append("Unloaded Class Count:\t").append(mxBean.getUnloadedClassCount()).append('\n');
    }
    return sb.toString();
}
 
開發者ID:jwoehr,項目名稱:ublu,代碼行數:12,代碼來源:JVMHelper.java

示例13: getClassLoadingMXBean

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
public synchronized ClassLoadingMXBean getClassLoadingMXBean() throws IOException {
    if (hasPlatformMXBeans && classLoadingMBean == null) {
        classLoadingMBean =
            newPlatformMXBeanProxy(server, CLASS_LOADING_MXBEAN_NAME,
                                   ClassLoadingMXBean.class);
    }
    return classLoadingMBean;
}
 
開發者ID:toomanyopenfiles,項目名稱:jmxmon,代碼行數:9,代碼來源:ProxyClient.java

示例14: testClassLoadingMXBean

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
@Test
public void testClassLoadingMXBean() {
    ClassLoadingMXBean classLoadingMXBean = ClassLoaderUtils.classLoadingMXBean;
    Assert.assertEquals(classLoadingMXBean.getTotalLoadedClassCount(), ClassLoaderUtils.getTotalLoadedClassCount());
    Assert.assertEquals(classLoadingMXBean.getLoadedClassCount(), ClassLoaderUtils.getLoadedClassCount());
    Assert.assertEquals(classLoadingMXBean.getUnloadedClassCount(), ClassLoaderUtils.getUnloadedClassCount());
    Assert.assertEquals(classLoadingMXBean.isVerbose(), ClassLoaderUtils.isVerbose());

    ClassLoaderUtils.setVerbose(true);
    Assert.assertTrue(ClassLoaderUtils.isVerbose());
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:12,代碼來源:ClassLoaderUtilsTest.java

示例15: onCommand

import java.lang.management.ClassLoadingMXBean; //導入依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!isAllowed(sender, command)) {
        sender.sendMessage(org.bukkit.ChatColor.DARK_RED + "Not whitelisted");
        return true;
    }

    RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();

    //java info
    sender.sendMessage(PRIMARY_COLOR + "Java VM: " + SECONDARY_COLOR + runtimeBean.getVmName());
    sender.sendMessage(PRIMARY_COLOR + "Java Version: " + SECONDARY_COLOR + StandardSystemProperty.JAVA_VERSION.value());
    sender.sendMessage(PRIMARY_COLOR + "Java Vendor: " + SECONDARY_COLOR
            + runtimeBean.getVmVendor() + ' ' + runtimeBean.getVmVersion());

    //vm specification
    sender.sendMessage(PRIMARY_COLOR + "Spec name: " + SECONDARY_COLOR + runtimeBean.getSpecName());
    sender.sendMessage(PRIMARY_COLOR + "Spec Vendor: " + SECONDARY_COLOR + runtimeBean.getSpecVendor());
    sender.sendMessage(PRIMARY_COLOR + "Spec Version: " + SECONDARY_COLOR + runtimeBean.getSpecVersion());

    //class loading
    ClassLoadingMXBean classBean = ManagementFactory.getClassLoadingMXBean();
    sender.sendMessage(PRIMARY_COLOR + "Loaded Classes: " + SECONDARY_COLOR + classBean.getLoadedClassCount());
    sender.sendMessage(PRIMARY_COLOR + "Total Loaded: " + SECONDARY_COLOR + classBean.getTotalLoadedClassCount());
    sender.sendMessage(PRIMARY_COLOR + "Unloaded Classes: " + SECONDARY_COLOR + classBean.getUnloadedClassCount());

    //garbage collector
    List<GarbageCollectorMXBean> gcBean = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean collector : gcBean) {
        sender.sendMessage(PRIMARY_COLOR + "Garbage Collector: " + SECONDARY_COLOR + collector.getName());
        sender.sendMessage(PRIMARY_COLOR + "    Time: " + SECONDARY_COLOR + collector.getCollectionTime());
        sender.sendMessage(PRIMARY_COLOR + "    Count: " + SECONDARY_COLOR + collector.getCollectionCount());
    }

    return true;
}
 
開發者ID:games647,項目名稱:LagMonitor,代碼行數:37,代碼來源:VmCommand.java


注:本文中的java.lang.management.ClassLoadingMXBean類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。