List of usage examples for java.lang.management RuntimeMXBean getInputArguments
public java.util.List<String> getInputArguments();
From source file:org.apache.gobblin.util.JvmUtils.java
/** * Gets the input arguments passed to the JVM. * @return The input arguments.//from w w w . j a v a2 s . co m */ public static String getJvmInputArguments() { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimeMxBean.getInputArguments(); return String.format("JVM Input Arguments: %s", JOINER.join(arguments)); }
From source file:org.apache.hadoop.hbase.io.BatchUpdate.java
/** * Code to test sizes of BatchUpdate arrays. * @param args//ww w .j a v a 2s . c o m * @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.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//ww w.ja va 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/*from ww w . j a v a 2 s . co 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."); }
From source file:org.apache.hadoop.hbase.regionserver.MemStore.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 va 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()); MemStore memstore1 = new MemStore(); // 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. MemStore memstore2 = new MemStore(); 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.util.DirectMemoryUtils.java
/** * @return the setting of -XX:MaxDirectMemorySize as a long. Returns 0 if * -XX:MaxDirectMemorySize is not set. */// w ww . jav a 2 s .c o m public static long getDirectMemorySize() { RuntimeMXBean runtimemxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimemxBean.getInputArguments(); long multiplier = 1; //for the byte case. for (String s : arguments) { if (s.contains("-XX:MaxDirectMemorySize=")) { String memSize = s.toLowerCase().replace("-xx:maxdirectmemorysize=", "").trim(); if (memSize.contains("k")) { multiplier = 1024; } else if (memSize.contains("m")) { multiplier = 1048576; } else if (memSize.contains("g")) { multiplier = 1073741824; } memSize = memSize.replaceAll("[^\\d]", ""); long retValue = Long.parseLong(memSize); return retValue * multiplier; } } return 0; }
From source file:org.apache.pulsar.common.stats.JvmMetrics.java
private static String detectGCType() { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); Set<String> arguments = Sets.newHashSet(runtimeMxBean.getInputArguments()); for (Entry<String, Class<? extends JvmGCMetricsLogger>> gc : gcLoggerMap.entrySet()) { if (arguments.contains(gc.getKey())) { return gc.getValue().getName(); }/* w ww. j ava 2 s.co m*/ } return null; }
From source file:org.apache.solr.handler.admin.SystemInfoHandler.java
/** * Get JVM Info - including memory info//from w ww . j a va 2 s .c o m */ public static SimpleOrderedMap<Object> getJvmInfo() { SimpleOrderedMap<Object> jvm = new SimpleOrderedMap<Object>(); jvm.add("version", System.getProperty("java.vm.version")); jvm.add("name", System.getProperty("java.vm.name")); Runtime runtime = Runtime.getRuntime(); jvm.add("processors", runtime.availableProcessors()); long used = runtime.totalMemory() - runtime.freeMemory(); // not thread safe, but could be thread local DecimalFormat df = new DecimalFormat("#.#"); double percentUsed = ((double) (used) / (double) runtime.maxMemory()) * 100; SimpleOrderedMap<Object> mem = new SimpleOrderedMap<Object>(); mem.add("free", humanReadableUnits(runtime.freeMemory(), df)); mem.add("total", humanReadableUnits(runtime.totalMemory(), df)); mem.add("max", humanReadableUnits(runtime.maxMemory(), df)); mem.add("used", humanReadableUnits(used, df) + " (%" + df.format(percentUsed) + ")"); jvm.add("memory", mem); // JMX properties -- probably should be moved to a different handler SimpleOrderedMap<Object> jmx = new SimpleOrderedMap<Object>(); try { RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean(); jmx.add("bootclasspath", mx.getBootClassPath()); jmx.add("classpath", mx.getClassPath()); // the input arguments passed to the Java virtual machine // which does not include the arguments to the main method. jmx.add("commandLineArgs", mx.getInputArguments()); // a map of names and values of all system properties. //jmx.add( "SYSTEM PROPERTIES", mx.getSystemProperties()); jmx.add("startTime", new Date(mx.getStartTime())); jmx.add("upTimeMS", mx.getUptime()); } catch (Exception e) { log.warn("Error getting JMX properties", e); } jvm.add("jmx", jmx); return jvm; }
From source file:org.artifactory.webapp.wicket.page.config.advanced.SystemInfoPage.java
/** * Return a formatted string of the system info to display * * @return//from www.j ava 2s . c om */ private String collectSystemInfo() { StringBuilder infoBuilder = new StringBuilder(); StorageProperties storageProperties = ContextHelper.get().beanForType(StorageProperties.class); infoBuilder.append("Storage Info:").append("\n"); addInfo(infoBuilder, "Database Type", storageProperties.getDbType().toString()); BinaryProviderType binariesStorageType = storageProperties.getBinariesStorageType(); addInfo(infoBuilder, "Storage Type", binariesStorageType.toString()); if (BinaryProviderType.S3 == binariesStorageType) { // S3 properties addInfo(infoBuilder, "s3.bucket.name", storageProperties.getS3BucketName()); addInfo(infoBuilder, "s3.bucket.path", storageProperties.getS3BucketPath()); addInfo(infoBuilder, "s3.endpoint", storageProperties.getS3Entpoint()); // Retry properties addInfo(infoBuilder, "retry.max.retries.number", Integer.toString(storageProperties.getMaxRetriesNumber())); addInfo(infoBuilder, "retry.delay.between.retries", Integer.toString(storageProperties.getDelayBetweenRetries())); // Eventually persisted properties addInfo(infoBuilder, "eventually.persisted.max.number.of.threads", Integer.toString(storageProperties.getEventuallyPersistedMaxNumberOfThread())); addInfo(infoBuilder, "eventually.persisted.timeout", Integer.toString(storageProperties.getEventuallyPersistedTimeOut())); addInfo(infoBuilder, "eventually.dispatcher.sleep.time", Long.toString(storageProperties.getEventuallyPersistedDispatcherSleepTime())); } infoBuilder.append("\n").append("System Properties:").append("\n"); Properties properties = System.getProperties(); //// add Artifactory version to the properties, will be alphabetically sorted later. properties.setProperty(ConstantValues.artifactoryVersion.getPropertyName(), ConstantValues.artifactoryVersion.getString()); AddonsManager addonsManager = ContextHelper.get().beanForType(AddonsManager.class); addInfo(infoBuilder, "artifactory.running.mode", addonsManager.getArtifactoryRunningMode().name()); addInfo(infoBuilder, "artifactory.running.state", ContextHelper.get().isOffline() ? "Offline" : "Online"); addFromProperties(infoBuilder, properties); addHaProperties(infoBuilder); infoBuilder.append("\n").append("General JVM Info:").append("\n"); OperatingSystemMXBean systemBean = ManagementFactory.getOperatingSystemMXBean(); addInfo(infoBuilder, "Available Processors", Integer.toString(systemBean.getAvailableProcessors())); MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); MemoryUsage heapMemoryUsage = memoryBean.getHeapMemoryUsage(); addInfo(infoBuilder, "Heap Memory Usage-Committed", Long.toString(heapMemoryUsage.getCommitted())); addInfo(infoBuilder, "Heap Memory Usage-Init", Long.toString(heapMemoryUsage.getInit())); addInfo(infoBuilder, "Heap Memory Usage-Max", Long.toString(heapMemoryUsage.getMax())); addInfo(infoBuilder, "Heap Memory Usage-Used", Long.toString(heapMemoryUsage.getUsed())); MemoryUsage nonHeapMemoryUsage = memoryBean.getNonHeapMemoryUsage(); addInfo(infoBuilder, "Non-Heap Memory Usage-Committed", Long.toString(nonHeapMemoryUsage.getCommitted())); addInfo(infoBuilder, "Non-Heap Memory Usage-Init", Long.toString(nonHeapMemoryUsage.getInit())); addInfo(infoBuilder, "Non-Heap Memory Usage-Max", Long.toString(nonHeapMemoryUsage.getMax())); addInfo(infoBuilder, "Non-Heap Memory Usage-Used", Long.toString(nonHeapMemoryUsage.getUsed())); RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean(); StringBuilder vmArgumentBuilder = new StringBuilder(); List<String> vmArguments = RuntimemxBean.getInputArguments(); if (vmArguments != null) { for (String vmArgument : vmArguments) { if (InfoWriter.shouldMaskValue(vmArgument)) { vmArgument = Strings.maskKeyValue(vmArgument); } vmArgumentBuilder.append(vmArgument); if (vmArguments.indexOf(vmArgument) != (vmArguments.size() - 1)) { vmArgumentBuilder.append("\n"); } } } infoBuilder.append("\nJVM Arguments:\n").append(vmArgumentBuilder.toString()); return StringUtils.removeEnd(infoBuilder.toString(), "\n"); }
From source file:org.craftercms.commons.monitoring.VersionMonitor.java
@SuppressWarnings("unchecked") private void initRuntime() { RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); java_version = runtime.getSpecVersion(); java_vendor = runtime.getSpecVendor(); java_runtime = runtime.getSpecName(); java_vm = runtime.getVmName();/*from w w w . ja v a 2s. c om*/ jvm_input_arguments = StringUtils.join(runtime.getInputArguments()); jvm_implementation_version = runtime.getVmVersion(); jvm_vendor = runtime.getVmVendor(); jvm_version = runtime.getSpecVersion(); }