< prev index next >

test/hotspot/jtreg/containers/docker/EventGeneratorLoop.java

Print this page

        

*** 18,35 **** * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import jdk.jfr.Event; import jdk.jfr.Description; import jdk.jfr.Label; ! // This class generates simple event in a loop ! // for a specified time. ! // Pass the time in seconds as a parameter. public class EventGeneratorLoop { @Label("SimpleEvent") @Description("Simple custom event") static class SimpleEvent extends Event { --- 18,37 ---- * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ + + import java.nio.file.Files; + import java.nio.file.Path; + import java.nio.file.Paths; import jdk.jfr.Event; import jdk.jfr.Description; import jdk.jfr.Label; ! // This class generates simple event in a loop for a specified time. public class EventGeneratorLoop { @Label("SimpleEvent") @Description("Simple custom event") static class SimpleEvent extends Event {
*** 39,60 **** --- 41,75 ---- @Label("Count") int count; } + // Arguments: + // - time to run (in seconds) - mandatory + // - full file path to signal the start of main - optional public static void main(String[] args) throws Exception { if ((args.length < 1) || (args[0] == null)) { throw new IllegalArgumentException("Expecting one argument: time to run (seconds)"); } int howLong = Integer.parseInt(args[0]); + if ((args.length > 1) && (args[1] != null)) { + signalStartOfMain(args[1]); + } + for (int i=0; i < howLong; i++) { SimpleEvent ev = new SimpleEvent(); ev.msg = "Hello"; ev.count = i; ev.commit(); try { Thread.sleep(1000); } catch (InterruptedException e) {} System.out.print("."); } } + + private static void signalStartOfMain(String fileName) throws Exception { + Path p = Paths.get(fileName); + Files.createFile(p); + p.toFile().deleteOnExit(); + } }
< prev index next >