List of usage examples for java.lang.management RuntimeMXBean getVmVersion
public String getVmVersion();
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 ww .j a v a 2 s. c o m }
From source file:com.alibaba.wasp.util.ServerCommandLine.java
/** * Log information about the currently running JVM. *//* w w w . j a v a 2 s. c o m*/ 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()); }/* ww w.j av 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:de.unisb.cs.st.javalanche.mutation.runtime.jmx.MutationMxClient.java
public static boolean connect(int i) { JMXConnector jmxc = null;/*from www .j a v a 2 s . c om*/ JMXServiceURL url = null; try { url = new JMXServiceURL(MXBeanRegisterer.ADDRESS + i); jmxc = JMXConnectorFactory.connect(url, null); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { return false; // System.out.println("Could not connect to address: " + url); // e.printStackTrace(); } if (jmxc != null) { try { MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); ObjectName objectName = new ObjectName(MXBeanRegisterer.OBJECT_NAME); Object numberOfMutations = mbsc.getAttribute(objectName, "NumberOfMutations"); Object currentTest = mbsc.getAttribute(objectName, "CurrentTest"); Object currentMutation = mbsc.getAttribute(objectName, "CurrentMutation"); Object allMutations = mbsc.getAttribute(objectName, "Mutations"); Object mutationsDuration = mbsc.getAttribute(objectName, "MutationDuration"); Object testDuration = mbsc.getAttribute(objectName, "TestDuration"); // Object mutationSummary = mbsc.getAttribute(objectName, // "MutationSummary"); final RuntimeMXBean remoteRuntime = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); final MemoryMXBean remoteMemory = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class); System.out.print("Connection: " + i + " "); System.out.println("Target VM: " + remoteRuntime.getName() + " - " + remoteRuntime.getVmVendor() + " - " + remoteRuntime.getSpecVersion() + " - " + remoteRuntime.getVmVersion()); System.out.println( "Running for: " + DurationFormatUtils.formatDurationHMS(remoteRuntime.getUptime())); System.out .println("Memory usage: Heap - " + formatMemory(remoteMemory.getHeapMemoryUsage().getUsed()) + " Non Heap - " + formatMemory(remoteMemory.getNonHeapMemoryUsage().getUsed())); String mutationDurationFormatted = DurationFormatUtils .formatDurationHMS(Long.parseLong(mutationsDuration.toString())); String testDurationFormatted = DurationFormatUtils .formatDurationHMS(Long.parseLong(testDuration.toString())); if (DEBUG_ADD) { System.out.println("Classpath: " + remoteRuntime.getClassPath()); System.out.println("Args: " + remoteRuntime.getInputArguments()); System.out.println("All Mutations: " + allMutations); } // System.out.println(mutationSummary); System.out.println( "Current mutation (Running for: " + mutationDurationFormatted + "): " + currentMutation); System.out.println("Mutations tested: " + numberOfMutations); System.out.println("Current test: (Running for: " + testDurationFormatted + "): " + currentTest); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (MalformedObjectNameException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (AttributeNotFoundException e) { e.printStackTrace(); } catch (InstanceNotFoundException e) { e.printStackTrace(); } catch (MBeanException e) { e.printStackTrace(); } catch (ReflectionException e) { e.printStackTrace(); } finally { try { jmxc.close(); } catch (IOException e) { e.printStackTrace(); } } } return true; }
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. ja va 2 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));//from w w w . jav a 2 s . com 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. ja va 2 s .c om 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/*from www. j a v a 2s . 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 w w w . j a v a2s .c om*/ */ 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."); }