当前位置: 首页>>代码示例>>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;未经允许,请勿转载。