49
50 Test starts ten Java processes, each with a unique id.
51
52 Each process creates a file named after the id and then it waits for
53 the test to remove the file, at which the Java process exits.
54
55 The processes are monitored by the test to make sure notifications
56 are sent when they are started/terminated.
57
58 To avoid Java processes being left behind, in case of an unexpected
59 failure, shutdown hooks are installed that remove files when the test
60 exits. If files are not removed, i.e. due to a JVM crash, the Java
61 processes will exit themselves after 1000 s.
62
63 */
64
65 /*
66 * @test
67 * @bug 4990825
68 * @summary attach to external but local JVM processes
69 * @library /lib/testlibrary
70 * @modules java.management
71 * jdk.internal.jvmstat/sun.jvmstat.monitor
72 * jdk.internal.jvmstat/sun.jvmstat.monitor.event
73 * @build jdk.testlibrary.*
74 * @run main/othervm MonitorVmStartTerminate
75 */
76 public final class MonitorVmStartTerminate {
77
78 private static final int PROCESS_COUNT = 10;
79
80 public static void main(String... args) throws Exception {
81
82 MonitoredHost host = MonitoredHost.getMonitoredHost("localhost");
83 host.setInterval(1); // 1 ms
84
85 String id = UUID.randomUUID().toString();
86
87 List<JavaProcess> javaProcesses = new ArrayList<>();
88 for (int i = 0; i < PROCESS_COUNT; i++) {
89 javaProcesses.add(new JavaProcess(id + "_" + i));
90 }
91
92 Listener listener = new Listener(host, javaProcesses);
|
49
50 Test starts ten Java processes, each with a unique id.
51
52 Each process creates a file named after the id and then it waits for
53 the test to remove the file, at which the Java process exits.
54
55 The processes are monitored by the test to make sure notifications
56 are sent when they are started/terminated.
57
58 To avoid Java processes being left behind, in case of an unexpected
59 failure, shutdown hooks are installed that remove files when the test
60 exits. If files are not removed, i.e. due to a JVM crash, the Java
61 processes will exit themselves after 1000 s.
62
63 */
64
65 /*
66 * @test
67 * @bug 4990825
68 * @summary attach to external but local JVM processes
69 *
70 * @library /lib/testlibrary
71 * @modules java.management
72 * jdk.internal.jvmstat/sun.jvmstat.monitor
73 * jdk.internal.jvmstat/sun.jvmstat.monitor.event
74 *
75 * @build jdk.testlibrary.*
76 * @run main/othervm MonitorVmStartTerminate
77 */
78 public final class MonitorVmStartTerminate {
79
80 private static final int PROCESS_COUNT = 10;
81
82 public static void main(String... args) throws Exception {
83
84 MonitoredHost host = MonitoredHost.getMonitoredHost("localhost");
85 host.setInterval(1); // 1 ms
86
87 String id = UUID.randomUUID().toString();
88
89 List<JavaProcess> javaProcesses = new ArrayList<>();
90 for (int i = 0; i < PROCESS_COUNT; i++) {
91 javaProcesses.add(new JavaProcess(id + "_" + i));
92 }
93
94 Listener listener = new Listener(host, javaProcesses);
|