Example usage for java.lang.management RuntimeMXBean getVmName

List of usage examples for java.lang.management RuntimeMXBean getVmName

Introduction

In this page you can find the example usage for java.lang.management RuntimeMXBean getVmName.

Prototype

public String getVmName();

Source Link

Document

Returns the Java virtual machine implementation name.

Usage

From source file:Test.java

public static void main(String[] args) {
    RuntimeMXBean mxBean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class);

    System.out.println("JVM Name: " + mxBean.getName());
    System.out.println("JVM Specification Name: " + mxBean.getSpecName());
    System.out.println("JVM Specification Version: " + mxBean.getSpecVersion());
    System.out.println("JVM Implemenation Name: " + mxBean.getVmName());
    System.out.println("JVM Implemenation Vendor: " + mxBean.getVmVendor());
    System.out.println("JVM Implemenation Version: " + mxBean.getVmVersion());

    // Using the getPlatformMXBeans method
    List<OperatingSystemMXBean> list = ManagementFactory.getPlatformMXBeans(OperatingSystemMXBean.class);
    System.out.println("size: " + list.size());
    for (OperatingSystemMXBean bean : list) {
        System.out.println("Operating System Name: " + bean.getName());
        System.out.println("Operating System Architecture: " + bean.getArch());
        System.out.println("Operating System Version: " + bean.getVersion());
    }// w w w  .j a v  a  2s.  com

}

From source file:com.alibaba.wasp.util.ServerCommandLine.java

/**
 * Log information about the currently running JVM.
 *//*  w w  w .j a  v a  2s. c  om*/
public static void logJVMInfo() {
    // Print out vm stats before starting up.
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    if (runtime != null) {
        LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + runtime.getVmVendor() + ", vmVersion="
                + runtime.getVmVersion());
        LOG.info("vmInputArguments=" + runtime.getInputArguments());
    }
}

From source file:edu.washington.cs.cupid.usage.CupidDataCollector.java

private static SystemData fetchSystemData() {
    RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();

    Map<String, String> bundles = Maps.newHashMap();
    for (Bundle bundle : Activator.getDefault().getBundle().getBundleContext().getBundles()) {
        bundles.put(bundle.getSymbolicName(), bundle.getVersion().toString());
    }//from   ww w  .j  a v  a2 s . c  o  m

    return new SystemData(Platform.getNL(), Platform.getOS(), Platform.getOSArch(), Platform.getWS(),
            RuntimemxBean.getVmName(), RuntimemxBean.getVmVendor(), RuntimemxBean.getVmVersion(), bundles);
}

From source file:com.android.tools.idea.diagnostics.crash.GoogleCrash.java

@NotNull
private static Map<String, String> getDefaultParameters() {
    Map<String, String> map = new HashMap<>();
    ApplicationInfo applicationInfo = getApplicationInfo();

    if (ANONYMIZED_UID != null) {
        map.put("guid", ANONYMIZED_UID);
    }/* w  w w.  j  av  a2 s. c o m*/
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    map.put("ptime", Long.toString(runtimeMXBean.getUptime()));

    // product specific key value pairs
    map.put(KEY_VERSION, applicationInfo == null ? "0.0.0.0" : applicationInfo.getStrictVersion());
    map.put(KEY_PRODUCT_ID, CrashReport.PRODUCT_ANDROID_STUDIO); // must match registration with Crash
    map.put("fullVersion", applicationInfo == null ? "0.0.0.0" : applicationInfo.getFullVersion());

    map.put("osName", StringUtil.notNullize(SystemInfo.OS_NAME));
    map.put("osVersion", StringUtil.notNullize(SystemInfo.OS_VERSION));
    map.put("osArch", StringUtil.notNullize(SystemInfo.OS_ARCH));
    map.put("locale", StringUtil.notNullize(LOCALE));

    map.put("vmName", StringUtil.notNullize(runtimeMXBean.getVmName()));
    map.put("vmVendor", StringUtil.notNullize(runtimeMXBean.getVmVendor()));
    map.put("vmVersion", StringUtil.notNullize(runtimeMXBean.getVmVersion()));

    MemoryUsage usage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    map.put("heapUsed", Long.toString(usage.getUsed()));
    map.put("heapCommitted", Long.toString(usage.getCommitted()));
    map.put("heapMax", Long.toString(usage.getMax()));

    return map;
}

From source file:net.risesoft.soa.asf.web.controller.SystemController.java

private List<SysInfo> getVMInfo() {
    List list = new ArrayList();
    String group = "3. VM ?";
    RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
    list.add(new SysInfo("BootClassPath", rt.getBootClassPath(), group));
    list.add(new SysInfo("ClassPath", rt.getClassPath(), group));
    list.add(new SysInfo("LibraryPath", rt.getLibraryPath(), group));
    list.add(new SysInfo("ManagementSpecVersion", rt.getManagementSpecVersion(), group));
    list.add(new SysInfo("Name", rt.getName(), group));
    list.add(new SysInfo("SpecName", rt.getSpecName(), group));
    list.add(new SysInfo("SpecVendor", rt.getSpecVendor(), group));
    list.add(new SysInfo("SpecVersion", rt.getSpecVersion(), group));
    list.add(new SysInfo("VmName", rt.getVmName(), group));
    list.add(new SysInfo("VmVendor", rt.getVmVendor(), group));
    list.add(new SysInfo("VmVersion", rt.getVmVersion(), group));
    list.add(new SysInfo("StartTime", DateFormat.getDateTimeInstance().format(new Date(rt.getStartTime())),
            group));/*w ww  .  j  a  v  a2  s  .c o  m*/

    list.add(new SysInfo("UpTime", this.helper.getUpTimeStr(rt.getUptime()), group));
    list.add(new SysInfo("InputArguments", rt.getInputArguments(), group));

    group = "6. ?";
    Map<String, String> sysProps = rt.getSystemProperties();
    for (Map.Entry entry : sysProps.entrySet()) {
        list.add(new SysInfo((String) entry.getKey(), entry.getValue(), group));
    }
    Collections.sort(list, new Comparator() {
        public int compare(SystemController.SysInfo o1, SystemController.SysInfo o2) {
            String key1 = o1.getKey();
            String key2 = o2.getKey();
            return key1.compareToIgnoreCase(key2);
        }
    });
    return list;
}

From source file:org.apache.flink.runtime.util.EnvironmentInformation.java

public static String getJvmVersion() {
    try {//from www .  j a va 2 s  .co  m
        final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
        return bean.getVmName() + " - " + bean.getVmVendor() + " - " + bean.getSpecVersion() + '/'
                + bean.getVmVersion();
    } catch (Throwable t) {
        return UNKNOWN;
    }
}

From source file:org.apache.hadoop.hbase.io.BatchUpdate.java

/**
 * Code to test sizes of BatchUpdate arrays.
 * @param args// w  w  w . j a  v  a2  s  .  c  om
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException {
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + runtime.getVmVendor() + ", vmVersion="
            + runtime.getVmVersion());
    LOG.info("vmInputArguments=" + runtime.getInputArguments());
    final int count = 10000;
    BatchUpdate[] batch1 = new BatchUpdate[count];
    // TODO: x32 vs x64
    long size = 0;
    for (int i = 0; i < count; i++) {
        BatchUpdate bu = new BatchUpdate(HConstants.EMPTY_BYTE_ARRAY);
        bu.put(HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY);
        batch1[i] = bu;
        size += bu.heapSize();
    }
    LOG.info("batch1 estimated size=" + size);
    // Make a variably sized memcache.
    size = 0;
    BatchUpdate[] batch2 = new BatchUpdate[count];
    for (int i = 0; i < count; i++) {
        BatchUpdate bu = new BatchUpdate(Bytes.toBytes(i));
        bu.put(Bytes.toBytes(i), new byte[i]);
        batch2[i] = bu;
        size += bu.heapSize();
    }
    LOG.info("batch2 estimated size=" + size);
    final int seconds = 30;
    LOG.info("Waiting " + seconds + " seconds while heap dump is taken");
    for (int i = 0; i < seconds; i++) {
        Thread.sleep(1000);
    }
    LOG.info("Exiting.");
}

From source file:org.apache.hadoop.hbase.io.TestHeapSize.java

@BeforeClass
public static void beforeClass() throws Exception {
    // Print detail on jvm so we know what is different should below test fail.
    RuntimeMXBean b = ManagementFactory.getRuntimeMXBean();
    LOG.info("name=" + b.getName());
    LOG.info("specname=" + b.getSpecName());
    LOG.info("specvendor=" + b.getSpecVendor());
    LOG.info("vmname=" + b.getVmName());
    LOG.info("vmversion=" + b.getVmVersion());
    LOG.info("vmvendor=" + b.getVmVendor());
    Map<String, String> p = b.getSystemProperties();
    LOG.info("properties=" + p);
}

From source file:org.apache.hadoop.hbase.regionserver.DefaultMemStore.java

/**
 * Code to help figure if our approximation of object heap sizes is close
 * enough.  See hbase-900.  Fills memstores then waits so user can heap
 * dump and bring up resultant hprof in something like jprofiler which
 * allows you get 'deep size' on objects.
 * @param args main args//from  ww  w .  ja v a  2  s.  c o m
 */
public static void main(String[] args) {
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + runtime.getVmVendor() + ", vmVersion="
            + runtime.getVmVersion());
    LOG.info("vmInputArguments=" + runtime.getInputArguments());
    DefaultMemStore memstore1 = new DefaultMemStore();
    // TODO: x32 vs x64
    long size = 0;
    final int count = 10000;
    byte[] fam = Bytes.toBytes("col");
    byte[] qf = Bytes.toBytes("umn");
    byte[] empty = new byte[0];
    for (int i = 0; i < count; i++) {
        // Give each its own ts
        size += memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty));
    }
    LOG.info("memstore1 estimated size=" + size);
    for (int i = 0; i < count; i++) {
        size += memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty));
    }
    LOG.info("memstore1 estimated size (2nd loading of same data)=" + size);
    // Make a variably sized memstore.
    DefaultMemStore memstore2 = new DefaultMemStore();
    for (int i = 0; i < count; i++) {
        size += memstore2.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, new byte[i]));
    }
    LOG.info("memstore2 estimated size=" + size);
    final int seconds = 30;
    LOG.info("Waiting " + seconds + " seconds while heap dump is taken");
    for (int i = 0; i < seconds; i++) {
        // Thread.sleep(1000);
    }
    LOG.info("Exiting.");
}

From source file:org.apache.hadoop.hbase.regionserver.Memcache.java

/**
 * Code to help figure if our approximation of object heap sizes is close
 * enough.  See hbase-900.  Fills memcaches then waits so user can heap
 * dump and bring up resultant hprof in something like jprofiler which
 * allows you get 'deep size' on objects.
 * @param args/*  w w  w  .j  a  va  2 s  .c  o  m*/
 * @throws InterruptedException
 * @throws IOException 
 */
public static void main(String[] args) throws InterruptedException, IOException {
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + runtime.getVmVendor() + ", vmVersion="
            + runtime.getVmVersion());
    LOG.info("vmInputArguments=" + runtime.getInputArguments());
    Memcache memcache1 = new Memcache();
    // TODO: x32 vs x64
    long size = 0;
    final int count = 10000;
    byte[] column = Bytes.toBytes("col:umn");
    for (int i = 0; i < count; i++) {
        // Give each its own ts
        size += memcache1.put(new KeyValue(Bytes.toBytes(i), column, i), false);
    }
    LOG.info("memcache1 estimated size=" + size);
    for (int i = 0; i < count; i++) {
        size += memcache1.put(new KeyValue(Bytes.toBytes(i), column, i), false);
    }
    LOG.info("memcache1 estimated size (2nd loading of same data)=" + size);
    // Make a variably sized memcache.
    Memcache memcache2 = new Memcache();
    for (int i = 0; i < count; i++) {
        size += memcache2.put(new KeyValue(Bytes.toBytes(i), column, i, new byte[i]), false);
    }
    LOG.info("memcache2 estimated size=" + size);
    final int seconds = 30;
    LOG.info("Waiting " + seconds + " seconds while heap dump is taken");
    for (int i = 0; i < seconds; i++) {
        // Thread.sleep(1000);
    }
    LOG.info("Exiting.");
}