List of usage examples for java.lang Runtime getRuntime
public static Runtime getRuntime()
From source file:lunarion.cluster.quickstart.ExampleProcess.java
public static void main(String[] args) throws Exception { String zkConnectString = "localhost:2181"; String clusterName = "storage-integration-cluster"; String instanceName = "localhost_8905"; String file = null;/*from w ww.j ava 2s . com*/ String stateModelValue = "MasterSlave"; int delay = 0; boolean skipZeroArgs = true;// false is for dev testing if (!skipZeroArgs || args.length > 0) { CommandLine cmd = processCommandLineArgs(args); zkConnectString = cmd.getOptionValue(zkServer); clusterName = cmd.getOptionValue(cluster); String host = cmd.getOptionValue(hostAddress); String portString = cmd.getOptionValue(hostPort); int port = Integer.parseInt(portString); instanceName = host + "_" + port; file = cmd.getOptionValue(configFile); if (file != null) { File f = new File(file); if (!f.exists()) { System.err.println("static config file doesn't exist"); System.exit(1); } } stateModelValue = cmd.getOptionValue(stateModel); if (cmd.hasOption(transDelay)) { try { delay = Integer.parseInt(cmd.getOptionValue(transDelay)); if (delay < 0) { throw new Exception("delay must be positive"); } } catch (Exception e) { e.printStackTrace(); delay = 0; } } } // Espresso_driver.py will consume this System.out.println("Starting Process with ZK:" + zkConnectString); ExampleProcess process = new ExampleProcess(zkConnectString, clusterName, instanceName, file, stateModelValue, delay); process.start(); Runtime.getRuntime().addShutdownHook(new HelixManagerShutdownHook(process.getManager())); Thread.currentThread().join(); }
From source file:Main.java
public static int getNbCpus() { return Runtime.getRuntime().availableProcessors(); }
From source file:Main.java
public static long maxMemory() { return Runtime.getRuntime().maxMemory(); }
From source file:Main.java
public static long freeMemory() { return Runtime.getRuntime().freeMemory(); }
From source file:Main.java
public static long totalMemory() { return Runtime.getRuntime().totalMemory(); }
From source file:Main.java
public static void releaseMemGc() { if ((Runtime.getRuntime().freeMemory() / Runtime.getRuntime().totalMemory()) > 0.7) System.gc();/*from w w w . j av a 2 s. c om*/ }
From source file:Main.java
public static long getFreeMemory() { return Runtime.getRuntime().freeMemory(); }
From source file:Main.java
public static long getTotalMemory() { return Runtime.getRuntime().totalMemory(); }
From source file:Main.java
public static int getProcessorsCount() { return Runtime.getRuntime().availableProcessors(); }
From source file:Main.java
public static int getMaxMemory() { return (int) Runtime.getRuntime().maxMemory(); }