List of usage examples for java.lang Thread currentThread
@HotSpotIntrinsicCandidate public static native Thread currentThread();
From source file:com.linkedin.helix.mock.relay.DummyRelayProcess.java
public static void main(String[] args) throws Exception { String zkConnectString = "pganti-md:2181"; String clusterName = "SDR_RELAY"; String instanceName = "ela4-rly02.prod.linkedin.com_10015"; String file = null;/*from www . j av a 2 s . c om*/ if (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); } } } // Espresso_driver.py will consume this System.out.println("Dummy process started"); DummyRelayProcess process = new DummyRelayProcess(zkConnectString, clusterName, instanceName, file); process.start(); Thread.currentThread().join(); }
From source file:fr.tpt.s3.mcdag.bench.MainBench.java
public static void main(String[] args) throws IOException, InterruptedException { // Command line options Options options = new Options(); Option input = new Option("i", "input", true, "MC-DAG XML models"); input.setRequired(true);/* w ww .j a v a 2 s. c om*/ input.setArgs(Option.UNLIMITED_VALUES); options.addOption(input); Option output = new Option("o", "output", true, "Folder where results have to be written."); output.setRequired(true); options.addOption(output); Option uUti = new Option("u", "utilization", true, "Utilization."); uUti.setRequired(true); options.addOption(uUti); Option output2 = new Option("ot", "output-total", true, "File where total results are being written"); output2.setRequired(true); options.addOption(output2); Option oCores = new Option("c", "cores", true, "Cores given to the test"); oCores.setRequired(true); options.addOption(oCores); Option oLvls = new Option("l", "levels", true, "Levels tested for the system"); oLvls.setRequired(true); options.addOption(oLvls); Option jobs = new Option("j", "jobs", true, "Number of threads to be launched."); jobs.setRequired(false); options.addOption(jobs); Option debug = new Option("d", "debug", false, "Debug logs."); debug.setRequired(false); options.addOption(debug); /* * Parsing of the command line */ CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println(e.getMessage()); formatter.printHelp("Benchmarks MultiDAG", options); System.exit(1); return; } String inputFilePath[] = cmd.getOptionValues("input"); String outputFilePath = cmd.getOptionValue("output"); String outputFilePathTotal = cmd.getOptionValue("output-total"); double utilization = Double.parseDouble(cmd.getOptionValue("utilization")); boolean boolDebug = cmd.hasOption("debug"); int nbLvls = Integer.parseInt(cmd.getOptionValue("levels")); int nbJobs = 1; int nbFiles = inputFilePath.length; if (cmd.hasOption("jobs")) nbJobs = Integer.parseInt(cmd.getOptionValue("jobs")); int nbCores = Integer.parseInt(cmd.getOptionValue("cores")); /* * While files need to be allocated * run the tests in the pool of threads */ // For dual-criticality systems we call a specific thread if (nbLvls == 2) { System.out.println(">>>>>>>>>>>>>>>>>>>>> NB levels " + nbLvls); int i_files2 = 0; String outFile = outputFilePath.substring(0, outputFilePath.lastIndexOf('.')) .concat("-schedulability.csv"); PrintWriter writer = new PrintWriter(outFile, "UTF-8"); writer.println( "Thread; File; FSched (%); FPreempts; FAct; LSched (%); LPreempts; LAct; ESched (%); EPreempts; EAct; HSched(%); HPreempts; HAct; Utilization"); writer.close(); ExecutorService executor2 = Executors.newFixedThreadPool(nbJobs); while (i_files2 != nbFiles) { BenchThreadDualCriticality bt2 = new BenchThreadDualCriticality(inputFilePath[i_files2], outFile, nbCores, boolDebug); executor2.execute(bt2); i_files2++; } executor2.shutdown(); executor2.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); int fedTotal = 0; int laxTotal = 0; int edfTotal = 0; int hybridTotal = 0; int fedPreempts = 0; int laxPreempts = 0; int edfPreempts = 0; int hybridPreempts = 0; int fedActiv = 0; int laxActiv = 0; int edfActiv = 0; int hybridActiv = 0; // Read lines in file and do average int i = 0; File f = new File(outFile); @SuppressWarnings("resource") Scanner line = new Scanner(f); while (line.hasNextLine()) { String s = line.nextLine(); if (i > 0) { // To skip the first line try (Scanner inLine = new Scanner(s).useDelimiter("; ")) { int j = 0; while (inLine.hasNext()) { String val = inLine.next(); if (j == 2) { fedTotal += Integer.parseInt(val); } else if (j == 3) { fedPreempts += Integer.parseInt(val); } else if (j == 4) { fedActiv += Integer.parseInt(val); } else if (j == 5) { laxTotal += Integer.parseInt(val); } else if (j == 6) { laxPreempts += Integer.parseInt(val); } else if (j == 7) { laxActiv += Integer.parseInt(val); } else if (j == 8) { edfTotal += Integer.parseInt(val); } else if (j == 9) { edfPreempts += Integer.parseInt(val); } else if (j == 10) { edfActiv += Integer.parseInt(val); } else if (j == 11) { hybridTotal += Integer.parseInt(val); } else if (j == 12) { hybridPreempts += Integer.parseInt(val); } else if (j == 13) { hybridActiv += Integer.parseInt(val); } j++; } } } i++; } // Write percentage double fedPerc = (double) fedTotal / nbFiles; double laxPerc = (double) laxTotal / nbFiles; double edfPerc = (double) edfTotal / nbFiles; double hybridPerc = (double) hybridTotal / nbFiles; double fedPercPreempts = (double) fedPreempts / fedActiv; double laxPercPreempts = (double) laxPreempts / laxActiv; double edfPercPreempts = (double) edfPreempts / edfActiv; double hybridPercPreempts = (double) hybridPreempts / hybridActiv; Writer wOutput = new BufferedWriter(new FileWriter(outputFilePathTotal, true)); wOutput.write(Thread.currentThread().getName() + "; " + utilization + "; " + fedPerc + "; " + fedPreempts + "; " + fedActiv + "; " + fedPercPreempts + "; " + laxPerc + "; " + laxPreempts + "; " + laxActiv + "; " + laxPercPreempts + "; " + edfPerc + "; " + edfPreempts + "; " + edfActiv + "; " + edfPercPreempts + "; " + hybridPerc + "; " + hybridPreempts + "; " + hybridActiv + "; " + hybridPercPreempts + "\n"); wOutput.close(); } else if (nbLvls > 2) { int i_files2 = 0; String outFile = outputFilePath.substring(0, outputFilePath.lastIndexOf('.')) .concat("-schedulability.csv"); PrintWriter writer = new PrintWriter(outFile, "UTF-8"); writer.println( "Thread; File; LSched (%); LPreempts; LAct; ESched (%); EPreempts; EAct; HSched(%); HPreempts; HAct; Utilization"); writer.close(); ExecutorService executor2 = Executors.newFixedThreadPool(nbJobs); while (i_files2 != nbFiles) { BenchThreadNLevels bt2 = new BenchThreadNLevels(inputFilePath[i_files2], outFile, nbCores, boolDebug); executor2.execute(bt2); i_files2++; } executor2.shutdown(); executor2.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); int laxTotal = 0; int edfTotal = 0; int hybridTotal = 0; int laxPreempts = 0; int edfPreempts = 0; int hybridPreempts = 0; int laxActiv = 0; int edfActiv = 0; int hybridActiv = 0; // Read lines in file and do average int i = 0; File f = new File(outFile); @SuppressWarnings("resource") Scanner line = new Scanner(f); while (line.hasNextLine()) { String s = line.nextLine(); if (i > 0) { // To skip the first line try (Scanner inLine = new Scanner(s).useDelimiter("; ")) { int j = 0; while (inLine.hasNext()) { String val = inLine.next(); if (j == 2) { laxTotal += Integer.parseInt(val); } else if (j == 3) { laxPreempts += Integer.parseInt(val); } else if (j == 4) { laxActiv += Integer.parseInt(val); } else if (j == 5) { edfTotal += Integer.parseInt(val); } else if (j == 6) { edfPreempts += Integer.parseInt(val); } else if (j == 7) { edfActiv += Integer.parseInt(val); } else if (j == 8) { hybridTotal += Integer.parseInt(val); } else if (j == 9) { hybridPreempts += Integer.parseInt(val); } else if (j == 10) { hybridActiv += Integer.parseInt(val); } j++; } } } i++; } // Write percentage double laxPerc = (double) laxTotal / nbFiles; double edfPerc = (double) edfTotal / nbFiles; double hybridPerc = (double) hybridTotal / nbFiles; double laxPercPreempts = (double) laxPreempts / laxActiv; double edfPercPreempts = (double) edfPreempts / edfActiv; double hybridPercPreempts = (double) hybridPreempts / hybridActiv; Writer wOutput = new BufferedWriter(new FileWriter(outputFilePathTotal, true)); wOutput.write(Thread.currentThread().getName() + "; " + utilization + "; " + laxPerc + "; " + laxPreempts + "; " + laxActiv + "; " + laxPercPreempts + "; " + edfPerc + "; " + edfPreempts + "; " + edfActiv + "; " + edfPercPreempts + "; " + hybridPerc + "; " + hybridPreempts + "; " + hybridActiv + "; " + hybridPercPreempts + "\n"); wOutput.close(); } else { System.err.println("Wrong number of levels"); System.exit(-1); } System.out.println("[BENCH Main] Done benchmarking U = " + utilization + " Levels " + nbLvls); }
From source file:com.linkedin.helix.examples.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 w w . jav a 2s . co m*/ 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(); Thread.currentThread().join(); }
From source file:Wait.java
public static void bySeconds(long s) { try {// w w w. j av a 2s.c o m Thread.currentThread().sleep(s * 1000); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Wait.java
public static void oneSec() { try {//from w ww. jav a 2 s .c om Thread.currentThread().sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } }
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;//w w w. ja v a 2 s.c o m 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 void interrupt() { Thread.currentThread().interrupt(); }
From source file:Main.java
private static String gm() { return Thread.currentThread().getStackTrace()[1].getMethodName() + ":: "; }
From source file:Main.java
public static String getName() { return Thread.currentThread().getName(); }
From source file:Main.java
public static String getMethodName() { return Thread.currentThread().getStackTrace()[3].getMethodName(); }