|
23 | 23 |
|
24 | 24 | package jdk.jfr.api.consumer.streaming; |
25 | 25 |
|
| 26 | +import java.nio.file.Files; |
26 | 27 | import java.nio.file.Path; |
27 | 28 | import java.nio.file.Paths; |
| 29 | +import java.util.Comparator; |
| 30 | +import java.util.List; |
| 31 | +import java.util.ArrayList; |
28 | 32 | import java.util.concurrent.CountDownLatch; |
29 | 33 | import java.util.concurrent.TimeUnit; |
30 | 34 | import java.util.concurrent.atomic.AtomicBoolean; |
|
34 | 38 | import jdk.jfr.Name; |
35 | 39 | import jdk.jfr.Recording; |
36 | 40 | import jdk.jfr.consumer.EventStream; |
| 41 | +import jdk.jfr.consumer.RecordingFile; |
37 | 42 | import jdk.jfr.consumer.RecordingStream; |
38 | 43 |
|
39 | 44 | /** |
@@ -65,7 +70,8 @@ public static void main(String... args) throws Exception { |
65 | 70 | CountDownLatch beginChunks = new CountDownLatch(1); |
66 | 71 |
|
67 | 72 | try (RecordingStream r = new RecordingStream()) { |
68 | | - r.onEvent("MakeChunks", event-> { |
| 73 | + r.setMaxSize(1_000_000_000); |
| 74 | + r.onEvent("MakeChunks", event -> { |
69 | 75 | System.out.println(event); |
70 | 76 | beginChunks.countDown(); |
71 | 77 | }); |
@@ -100,13 +106,25 @@ public static void main(String... args) throws Exception { |
100 | 106 | // This latch ensures thatNotLatest has been |
101 | 107 | // flushed and a new valid position has been written |
102 | 108 | // to the chunk header |
103 | | - notLatestEvent.await(80, TimeUnit.SECONDS); |
| 109 | + boolean timeout = notLatestEvent.await(80, TimeUnit.SECONDS); |
104 | 110 | if (notLatestEvent.getCount() != 0) { |
| 111 | + System.out.println("timeout = " + timeout); |
| 112 | + Path repo = Path.of(System.getProperty("jdk.jfr.repository")); |
| 113 | + System.out.println("repo = " + repo); |
| 114 | + List<Path> files = new ArrayList<>(Files.list(repo).toList()); |
| 115 | + files.sort(Comparator.comparing(Path::toString)); |
| 116 | + for (Path f : files) { |
| 117 | + System.out.println("------------"); |
| 118 | + System.out.println("File: " + f); |
| 119 | + for (var event : RecordingFile.readAllEvents(f)) { |
| 120 | + System.out.println(event); |
| 121 | + } |
| 122 | + } |
105 | 123 | Recording rec = FlightRecorder.getFlightRecorder().takeSnapshot(); |
106 | 124 | Path p = Paths.get("error-not-latest.jfr").toAbsolutePath(); |
107 | 125 | rec.dump(p); |
108 | 126 | System.out.println("Dumping repository as a file for inspection at " + p); |
109 | | - throw new Exception("Timeout 80 s. Expected 6 event, but got " + notLatestEvent.getCount()); |
| 127 | + throw new Exception("Timeout 80 s. Expected 6 event, but got " + (6 - notLatestEvent.getCount())); |
110 | 128 | } |
111 | 129 |
|
112 | 130 | try (EventStream s = EventStream.openRepository()) { |
|
0 commit comments