List of usage examples for java.lang.management ManagementFactory getRuntimeMXBean
public static RuntimeMXBean getRuntimeMXBean()
From source file:com.gemstone.gemfire.test.dunit.standalone.ProcessManager.java
/** * Get the java agent passed to this process and pass it to the child VMs. * This was added to support jacoco code coverage reports *//* w w w . jav a2 s. co m*/ private String getAgentString() { RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); if (runtimeBean != null) { for (String arg : runtimeBean.getInputArguments()) { if (arg.contains("-javaagent:")) { //HACK for gradle bug GRADLE-2859. Jacoco is passing a relative path //That won't work when we pass this to dunit VMs in a different //directory arg = arg.replace("-javaagent:..", "-javaagent:" + System.getProperty("user.dir") + File.separator + ".."); arg = arg.replace("destfile=..", "destfile=" + System.getProperty("user.dir") + File.separator + ".."); return arg; } } } return "-DdummyArg=true"; }
From source file:edu.uci.ics.hyracks.control.nc.NodeControllerService.java
public NodeControllerService(NCConfig ncConfig) throws Exception { this.ncConfig = ncConfig; id = ncConfig.nodeId;// w w w . j a v a 2 s . co m NodeControllerIPCI ipci = new NodeControllerIPCI(); ipc = new IPCSystem(new InetSocketAddress(ncConfig.clusterNetIPAddress, ncConfig.clusterNetPort), ipci, new CCNCFunctions.SerializerDeserializer()); this.ctx = new RootHyracksContext(this, new IOManager(getDevices(ncConfig.ioDevices))); if (id == null) { throw new Exception("id not set"); } partitionManager = new PartitionManager(this); netManager = new NetworkManager(ncConfig.dataIPAddress, ncConfig.dataPort, partitionManager, ncConfig.nNetThreads, ncConfig.nNetBuffers, ncConfig.dataPublicIPAddress, ncConfig.dataPublicPort); lccm = new LifeCycleComponentManager(); queue = new WorkQueue(); jobletMap = new Hashtable<JobId, Joblet>(); timer = new Timer(true); serverCtx = new ServerContext(ServerContext.ServerType.NODE_CONTROLLER, new File(new File(NodeControllerService.class.getName()), id)); memoryMXBean = ManagementFactory.getMemoryMXBean(); gcMXBeans = ManagementFactory.getGarbageCollectorMXBeans(); threadMXBean = ManagementFactory.getThreadMXBean(); runtimeMXBean = ManagementFactory.getRuntimeMXBean(); osMXBean = ManagementFactory.getOperatingSystemMXBean(); registrationPending = true; getNodeControllerInfosAcceptor = new MutableObject<FutureValue<Map<String, NodeControllerInfo>>>(); memoryManager = new MemoryManager( (long) (memoryMXBean.getHeapMemoryUsage().getMax() * MEMORY_FUDGE_FACTOR)); ioCounter = new IOCounterFactory().getIOCounter(); }
From source file:com.arpnetworking.test.junitbenchmarks.JsonBenchmarkConsumer.java
/** * Retrieve the process id./* w w w . jav a 2 s .c o m*/ * * @return The process id. */ protected long getProcessId() { final String processName = ManagementFactory.getRuntimeMXBean().getName(); return Long.parseLong(processName.split("@")[0]); }
From source file:edu.umd.cs.marmoset.utilities.MarmosetUtilities.java
/** returns the PID of the JVM */ public static int getPid() { String s = ManagementFactory.getRuntimeMXBean().getName(); int i = s.indexOf("@"); if (i < 0) throw new UnsupportedOperationException("Could not extract pid from " + s); String n = s.substring(0, i); try {//ww w . ja va 2s. com return Integer.parseInt(n); } catch (Exception e) { throw new UnsupportedOperationException("Could not extract pid from " + s); } }
From source file:org.pgptool.gui.tools.singleinstance.SingleInstanceFileBasedImpl.java
private static String getProcessId() { String jvmName = ManagementFactory.getRuntimeMXBean().getName(); return jvmName.split("@")[0]; }
From source file:org.callimachusproject.management.CalliServer.java
public synchronized void start() throws IOException, OpenRDFException { running = true;//from w ww . j a v a2 s. c om notifyAll(); if (server != null) { try { logger.info("Callimachus is binding to {}", toString()); for (SetupRealm origin : getRealms()) { HttpHost host = URIUtils.extractHost(java.net.URI.create(origin.getRealm())); HttpClientFactory.getInstance().setProxy(host, server); } for (CalliRepository repository : repositories.values()) { repository.setCompileRepository(true); } server.start(); System.gc(); Thread.yield(); long uptime = ManagementFactory.getRuntimeMXBean().getUptime(); logger.info("Callimachus started after {} seconds", uptime / 1000.0); if (listener != null) { listener.webServiceStarted(server); } } catch (IOException e) { logger.error(e.toString(), e); } catch (OpenRDFException e) { logger.error(e.toString(), e); } } }
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); }//from ww w .jav a 2s.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:org.kepler.ddp.Utilities.java
/** Load the model for a stub from a Nephele Configuration. The * top-level ports and connected relations are removed. *//*w w w . ja va 2 s. co m*/ public static synchronized CompositeActor getModel(String modelName, String modelString, String modelFile, boolean sameJVM, String redirectDir) { CompositeActor model = null; if (modelName == null) { throw new RuntimeException("Subworkflow name was not set in configuration."); } if (sameJVM) { CompositeActor originalModel = DDPEngine.getModel(modelName); try { model = (CompositeActor) originalModel.clone(new Workspace()); } catch (CloneNotSupportedException e) { throw new RuntimeException("Error cloning subworkflow: " + e.getMessage()); } Utilities.removeModelPorts(model); // create an effigy for the model so that gui actors can open windows. DDPEngine.createEffigy(model); } else { List<?> filters = MoMLParser.getMoMLFilters(); Workspace workspace = new Workspace(); final MoMLParser parser = new MoMLParser(workspace); //parser.resetAll(); MoMLParser.setMoMLFilters(null); MoMLParser.setMoMLFilters(BackwardCompatibility.allFilters(), workspace); if (redirectDir.isEmpty()) { MoMLParser.addMoMLFilter(new RemoveGraphicalClasses(), workspace); } else { //redirect display-related actors final String pid = ManagementFactory.getRuntimeMXBean().getName(); final String threadId = String.valueOf(Thread.currentThread().getId()); final String displayPath = redirectDir + File.separator + pid + "_" + threadId; MoMLParser.addMoMLFilter(new DisplayRedirectFilter(displayPath), workspace); final ArrayList<PtolemyModule> actorModules = new ArrayList<PtolemyModule>(); actorModules.add(new PtolemyModule(ResourceBundle.getBundle("org/kepler/ActorModuleBatch"))); Initializer _defaultInitializer = new Initializer() { @Override public void initialize() { PtolemyInjector.createInjector(actorModules); } }; ActorModuleInitializer.setInitializer(_defaultInitializer); } // get the model from the configuration // see if model is in the configuration. if (modelString != null) { try { model = (CompositeActor) parser.parse(modelString); } catch (Exception e) { throw new RuntimeException("Error parsing model " + modelName + ": " + e.getMessage()); } //LOG.info("parsed model from " + modelString); } else { // the model was saved as a file. if (modelFile == null) { throw new RuntimeException("No model for " + modelName + " in configuration."); } // load the model try { model = (CompositeActor) parser.parseFile(modelFile); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException( "Error parsing model " + modelName + " in file " + modelFile + ": " + e.getMessage()); } LOG.info("parsed model from " + modelFile); } // restore the moml filters MoMLParser.setMoMLFilters(null); MoMLParser.setMoMLFilters(filters); // remove provenance recorder and reporting listener final List<Attribute> toRemove = new LinkedList<Attribute>( model.attributeList(ProvenanceRecorder.class)); toRemove.addAll(model.attributeList(ReportingListener.class)); for (Attribute attribute : toRemove) { try { attribute.setContainer(null); } catch (Exception e) { throw new RuntimeException("Error removing " + attribute.getName() + ": " + e.getMessage()); } } } return model; }
From source file:org.onosproject.ospf.controller.impl.Controller.java
/** * get the up time. * * @return rb.getUptime */ public Long getUptime() { RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean(); return rb.getUptime(); }
From source file:com.evolveum.midpoint.web.page.admin.configuration.PageAbout.java
private void initLayout() { Label revision = new Label(ID_REVISION, createStringResource("PageAbout.midPointRevision")); revision.setRenderBodyOnly(true);//from w ww . j a va2s . c o m add(revision); ListView<SystemItem> listSystemItems = new ListView<SystemItem>(ID_LIST_SYSTEM_ITEMS, getItems()) { @Override protected void populateItem(ListItem<SystemItem> item) { SystemItem systemItem = item.getModelObject(); Label property = new Label(ID_PROPERTY, systemItem.getProperty()); property.setRenderBodyOnly(true); item.add(property); Label value = new Label(ID_VALUE, systemItem.getValue()); value.setRenderBodyOnly(true); item.add(value); } }; add(listSystemItems); addLabel(ID_IMPLEMENTATION_SHORT_NAME, "implementationShortName"); addLabel(ID_IMPLEMENTATION_DESCRIPTION, "implementationDescription"); addLabel(ID_IS_EMBEDDED, "isEmbedded"); addLabel(ID_DRIVER_SHORT_NAME, "driverShortName"); addLabel(ID_DRIVER_VERSION, "driverVersion"); addLabel(ID_REPOSITORY_URL, "repositoryUrl"); ListView<LabeledString> additionalDetails = new ListView<LabeledString>(ID_ADDITIONAL_DETAILS, new PropertyModel<List<? extends LabeledString>>(repoDiagModel, "additionalDetails")) { @Override protected void populateItem(ListItem<LabeledString> item) { LabeledString labeledString = item.getModelObject(); Label property = new Label(ID_DETAIL_NAME, labeledString.getLabel()); property.setRenderBodyOnly(true); item.add(property); Label value = new Label(ID_DETAIL_VALUE, labeledString.getData()); value.setRenderBodyOnly(true); item.add(value); } }; add(additionalDetails); ListView<LabeledString> provisioningAdditionalDetails = new ListView<LabeledString>( ID_PROVISIONING_ADDITIONAL_DETAILS, new PropertyModel<List<? extends LabeledString>>(provisioningDiagModel, "additionalDetails")) { @Override protected void populateItem(ListItem<LabeledString> item) { LabeledString labeledString = item.getModelObject(); Label property = new Label(ID_PROVISIONING_DETAIL_NAME, labeledString.getLabel()); property.setRenderBodyOnly(true); item.add(property); Label value = new Label(ID_PROVISIONING_DETAIL_VALUE, labeledString.getData()); value.setRenderBodyOnly(true); item.add(value); } }; add(provisioningAdditionalDetails); Label jvmProperties = new Label(ID_JVM_PROPERTIES, new LoadableModel<String>(false) { @Override protected String load() { try { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimeMxBean.getInputArguments(); return StringUtils.join(arguments, "<br/>"); } catch (Exception ex) { return PageAbout.this.getString("PageAbout.message.couldntObtainJvmParams"); } } }); jvmProperties.setEscapeModelStrings(false); add(jvmProperties); initButtons(); }