14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package jdk.jfr.api.recorder;
26
27 import java.util.concurrent.CountDownLatch;
28
29 import jdk.jfr.FlightRecorder;
30 import jdk.jfr.FlightRecorderListener;
31 import jdk.jfr.Recording;
32 import jdk.jfr.RecordingState;
33
34 /*
35 * @test TestRecorderListener
36 *
37 * @key jfr
38 * @run main/othervm jdk.jfr.api.recorder.TestRecorderListener
39 */
40 public class TestRecorderListener {
41
42 static class Listener implements FlightRecorderListener {
43
44 private final CountDownLatch latch = new CountDownLatch(1);
45 private final RecordingState waitFor;
46
47 public Listener(RecordingState state) {
48 waitFor = state;
49 }
50
51 @Override
52 public void recordingStateChanged(Recording recording) {
53 System.out.println("Listener: recording=" + recording.getName() + " state=" + recording.getState());
54 RecordingState rs = recording.getState();
55 if (rs == waitFor) {
56 latch.countDown();
57 }
|
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package jdk.jfr.api.recorder;
26
27 import java.util.concurrent.CountDownLatch;
28
29 import jdk.jfr.FlightRecorder;
30 import jdk.jfr.FlightRecorderListener;
31 import jdk.jfr.Recording;
32 import jdk.jfr.RecordingState;
33
34 /**
35 * @test TestRecorderListener
36 *
37 * @key jfr
38 * @requires vm.hasJFR
39 * @run main/othervm jdk.jfr.api.recorder.TestRecorderListener
40 */
41 public class TestRecorderListener {
42
43 static class Listener implements FlightRecorderListener {
44
45 private final CountDownLatch latch = new CountDownLatch(1);
46 private final RecordingState waitFor;
47
48 public Listener(RecordingState state) {
49 waitFor = state;
50 }
51
52 @Override
53 public void recordingStateChanged(Recording recording) {
54 System.out.println("Listener: recording=" + recording.getName() + " state=" + recording.getState());
55 RecordingState rs = recording.getState();
56 if (rs == waitFor) {
57 latch.countDown();
58 }
|