use of co.paralleluniverse.common.monitoring.CpuUsageGaugeSet in project spaceships-demo by puniverse.
the class Spaceships method main.
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
System.out.println("COMPILER: " + System.getProperty("java.vm.name"));
System.out.println("VERSION: " + System.getProperty("java.version"));
System.out.println("OS: " + System.getProperty("os.name"));
System.out.println("PROCESSORS: " + Runtime.getRuntime().availableProcessors());
System.out.println();
Properties props = new Properties();
props.load(new InputStreamReader(ClassLoader.getSystemResourceAsStream("spaceships.properties")));
Metrics.register("cpu", new CpuUsageGaugeSet());
Metrics.register("memory", new MemoryUsageGaugeSet());
int glxNode = args.length > 0 ? Integer.parseInt(args[0]) : -1;
if (glxNode < 0)
glxNode = Integer.parseInt(props.getProperty("galaxy.nodeId", "-1"));
if (glxNode >= 0) {
if (glxNode == 0)
throw new IllegalArgumentException("Node cannot be 0. Reserved for Galaxy server.");
System.out.println("Connecting to Galaxy cluster...");
System.setProperty("co.paralleluniverse.flightRecorderDumpFile", "spaceships-" + glxNode + ".log");
System.setProperty("galaxy.nodeId", Integer.toString(glxNode));
System.setProperty("galaxy.port", props.getProperty("galaxy.port", Integer.toString(7050 + glxNode)));
System.setProperty("galaxy.slave_port", props.getProperty("galaxy.port", Integer.toString(8050 + glxNode)));
Grid.getInstance();
}
System.out.println("Initializing...");
spaceships = new Spaceships(glxNode, props);
System.out.println("Running...");
spaceships.run();
Thread.sleep(100000);
}
Aggregations