List of usage examples for java.lang.management ManagementFactory getRuntimeMXBean
public static RuntimeMXBean getRuntimeMXBean()
From source file:org.apache.geode.distributed.LauncherIntegrationTestCase.java
protected List<String> getJvmArguments() { return ManagementFactory.getRuntimeMXBean().getInputArguments(); }
From source file:org.apache.geode.management.internal.cli.commands.ConfigCommandsDUnitTest.java
@Test public void testDescribeConfig() throws Exception { setUpJmxManagerOnVm0ThenConnect(null); final String controllerName = "Member2"; /*//from ww w . ja va 2 s . c om * Create properties for the controller VM */ final Properties localProps = new Properties(); localProps.setProperty(MCAST_PORT, "0"); localProps.setProperty(LOG_LEVEL, "info"); localProps.setProperty(STATISTIC_SAMPLING_ENABLED, "true"); localProps.setProperty(ENABLE_TIME_STATISTICS, "true"); localProps.setProperty(NAME, controllerName); localProps.setProperty(GROUPS, "G1"); getSystem(localProps); Cache cache = getCache(); int ports[] = getRandomAvailableTCPPorts(1); CacheServer cs = getCache().addCacheServer(); cs.setPort(ports[0]); cs.setMaxThreads(10); cs.setMaxConnections(9); cs.start(); try { RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); List<String> jvmArgs = runtimeBean.getInputArguments(); getLogWriter().info("#SB Actual JVM Args : "); for (String jvmArg : jvmArgs) { getLogWriter().info("#SB JVM " + jvmArg); } InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem(); DistributionConfig config = system.getConfig(); config.setArchiveFileSizeLimit(1000); String command = CliStrings.DESCRIBE_CONFIG + " --member=" + controllerName; CommandProcessor cmdProcessor = new CommandProcessor(); cmdProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process(); CommandResult cmdResult = executeCommand(command); String resultStr = commandResultToString(cmdResult); getLogWriter().info("#SB Hiding the defaults\n" + resultStr); assertEquals(true, cmdResult.getStatus().equals(Status.OK)); assertEquals(true, resultStr.contains("G1")); assertEquals(true, resultStr.contains(controllerName)); assertEquals(true, resultStr.contains(ARCHIVE_FILE_SIZE_LIMIT)); assertEquals(true, !resultStr.contains("copy-on-read")); cmdResult = executeCommand(command + " --" + CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS + "=false"); resultStr = commandResultToString(cmdResult); getLogWriter().info("#SB No hiding of defaults\n" + resultStr); assertEquals(true, cmdResult.getStatus().equals(Status.OK)); assertEquals(true, resultStr.contains("is-server")); assertEquals(true, resultStr.contains(controllerName)); assertEquals(true, resultStr.contains("copy-on-read")); } finally { cs.stop(); } }
From source file:org.apache.hyracks.control.nc.NodeControllerService.java
public NodeControllerService(NCConfig ncConfig) throws Exception { this.ncConfig = ncConfig; id = ncConfig.nodeId;/* w w w .j ava 2 s. c o m*/ ipc = new IPCSystem(new InetSocketAddress(ncConfig.clusterNetIPAddress, ncConfig.clusterNetPort), new NodeControllerIPCI(this), new CCNCFunctions.SerializerDeserializer()); ioManager = 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, FullFrameChannelInterfaceFactory.INSTANCE); lccm = new LifeCycleComponentManager(); workQueue = new WorkQueue(id, Thread.NORM_PRIORITY); // Reserves MAX_PRIORITY of the heartbeat thread. jobletMap = new Hashtable<>(); 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<>(); memoryManager = new MemoryManager( (long) (memoryMXBean.getHeapMemoryUsage().getMax() * MEMORY_FUDGE_FACTOR)); ioCounter = new IOCounterFactory().getIOCounter(); }
From source file:org.pepstock.jem.node.StartUpSystem.java
/** * Main method which calls JEM configuration loading and then Hazelcast * initialization.// www . j a va 2 s. com * * @throws ConfigurationException if a configuration error, exception occurs */ public static void run() throws ConfigurationException { // load jem-node.xml configuration from node folder loadConfiguration(); // load jem-env.xml configuration from gfs loadEnvConfiguration(); // initialize Hazelcast startHazelcast(); // gets the network interface to use try { Main.NETWORK_INTERFACE = InterfacesUtils.getInterface(Main.getHazelcast().getConfig()); LogAppl.getInstance().emit(NodeMessage.JEMC273I, Main.NETWORK_INTERFACE); } catch (MessageException e) { throw new ConfigurationException(e); } LogAppl.getInstance().emit(NodeMessage.JEMC012I, ManagementFactory.getRuntimeMXBean().getName()); // recovery data loss handler PartitionService partitionService = Main.getHazelcast().getPartitionService(); partitionService.addMigrationListener(new NodeMigrationListener()); // start swarm try { Main.SWARM.start(); } catch (Exception e) { throw new ConfigurationException(e); } // start multicast service startMulticastService(); }
From source file:org.broadleafcommerce.common.extensibility.InstrumentationRuntimeFactory.java
private static void loadAgent(String agentJar, Class<?> vmClass) { try {//from www . j av a 2 s. c o m // first obtain the PID of the currently-running process // ### this relies on the undocumented convention of the // RuntimeMXBean's // ### name starting with the PID, but there appears to be no other // ### way to obtain the current process' id, which we need for // ### the attach process RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); String pid = runtime.getName(); if (pid.contains("@")) pid = pid.substring(0, pid.indexOf("@")); // JDK1.6: now attach to the current VM so we can deploy a new agent // ### this is a Sun JVM specific feature; other JVMs may offer // ### this feature, but in an implementation-dependent way Object vm = vmClass.getMethod("attach", new Class<?>[] { String.class }).invoke(null, pid); vmClass.getMethod("loadAgent", new Class[] { String.class }).invoke(vm, agentJar); vmClass.getMethod("detach", new Class[] {}).invoke(vm); } catch (Throwable t) { if (LOG.isTraceEnabled()) { LOG.trace("Problem loading the agent", t); } } }
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 w ww.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:org.ut.biolab.medsavant.MedSavantClient.java
public static void setRestartCommand(String[] args) { List<String> restartCommandList = new ArrayList<String>(); String launcher = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; restartCommandList.add(launcher);/*from ww w.ja v a 2s . com*/ for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) { restartCommandList.add(jvmArg); } restartCommandList.add("-cp"); restartCommandList.add(ManagementFactory.getRuntimeMXBean().getClassPath()); restartCommandList.add(MedSavantClient.class.getName()); for (String arg : args) { restartCommandList.add(arg); } restartCommand = restartCommandList.toArray(new String[restartCommandList.size()]); }
From source file:org.icgc.dcc.submission.Main.java
private String formatArguments(String[] args) { val runtime = ManagementFactory.getRuntimeMXBean(); val inputArguments = runtime.getInputArguments(); return "java " + join(inputArguments, ' ') + " -jar " + getJarName() + " " + join(args, ' '); }
From source file:it.isislab.dmason.util.SystemManagement.Worker.thrower.DMasonWorkerWithGui.java
public static DMasonWorkerWithGui newInstance(String args[]) { RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); ////from www .jav a 2 s .c o m // Get name representing the running Java virtual machine. // It returns something like 6460@AURORA. Where the value // before the @ symbol is the PID. // String jvmName = bean.getName(); //Used for log4j properties System.setProperty("logfile.name", "worker" + jvmName); //Used for log4j properties System.setProperty("steplog.name", "workerStep" + jvmName); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss_SS"); Date date = new Date(); dateFormat.format(date); System.setProperty("timestamp", date.toLocaleString()); System.setProperty("paramsfile.name", "params"); try { File logPath = new File("Logs/workers"); if (logPath.exists()) FileUtils.cleanDirectory(logPath); } catch (IOException e) { //not a problem } logger = Logger.getLogger(DMasonWorker.class.getCanonicalName()); logger.debug("StartWorker " + VERSION); autoStart = false; String ip = null; String port = null; String topic = ""; updated = false; isBatch = false; topicPrefix = ""; // ip, post, autoconnect if (args.length == 3) { ip = args[0]; port = args[1]; if (args[2].equals("autoconnect")) { autoStart = true; } } // ip, post, topic, event if (args.length == 4) { autoStart = true; if (args[3].equals("update")) { updated = true; } if (args[3].equals("reset")) { updated = false; isBatch = false; } if (args[3].contains("Batch")) { updated = false; isBatch = true; topicPrefix = args[3]; } ip = args[0]; port = args[1]; topic = args[2]; } /*if(args.length == 2 && args[0].equals("auto")) { autoStart = true; updated = true; topic = args[1]; } if(args.length == 1 && args[0].equals("auto")) { autoStart = true; }*/ return new DMasonWorkerWithGui(autoStart, updated, isBatch, topic, ip, port); }
From source file:in.bbat.license.LicenseManager.java
public static String getInstanceId() { String str = getUserId(); return str + "/" + ManagementFactory.getRuntimeMXBean().getName(); }