|
34 | 34 | import java.util.Collections;
|
35 | 35 | import java.util.Comparator;
|
36 | 36 | import java.util.HashMap;
|
| 37 | +import java.util.HashSet; |
37 | 38 | import java.util.Iterator;
|
38 | 39 | import java.util.List;
|
39 | 40 | import java.util.Map;
|
| 41 | +import java.util.Set; |
40 | 42 | import java.util.TreeMap;
|
41 | 43 | import javax.swing.AbstractAction;
|
42 | 44 | import javax.swing.AbstractButton;
|
@@ -270,51 +272,74 @@ private static final class State {
|
270 | 272 | private long lastTimestamp = Long.MIN_VALUE;
|
271 | 273 | private Map<Long, List<State>> states;
|
272 | 274 | private Map<Long, Definition> definitions;
|
| 275 | + private Set<String> ignoredEvents; |
273 | 276 |
|
274 | 277 | private boolean[] activeTypes = new boolean[6];
|
275 | 278 |
|
276 | 279 | @Override
|
277 | 280 | public void init() {
|
278 | 281 | states = new HashMap();
|
279 | 282 | definitions = new TreeMap();
|
| 283 | + ignoredEvents = new HashSet(); |
280 | 284 | }
|
281 | 285 |
|
282 | 286 | @Override
|
283 | 287 | public boolean visit(String typeName, JFREvent event) {
|
284 |
| - if ("jdk.ThreadStart".equals(typeName)) { // NOI18N |
285 |
| - processEvent(event, "thread", CommonConstants.THREAD_STATUS_RUNNING, Byte.MIN_VALUE); // NOI18N |
286 |
| - activeTypes[0] = true; |
287 |
| - } else if ("jdk.ThreadEnd".equals(typeName)) { // NOI18N |
288 |
| - processEvent(event, "thread", CommonConstants.THREAD_STATUS_ZOMBIE, Byte.MIN_VALUE); // NOI18N |
289 |
| - activeTypes[1] = true; |
290 |
| - } else if ("jdk.JavaMonitorWait".equals(typeName)) { // NOI18N |
291 |
| - processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_WAIT, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
292 |
| - activeTypes[2] = true; |
293 |
| - } else if ("jdk.JavaMonitorEnter".equals(typeName)) { // NOI18N |
294 |
| - processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_MONITOR, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
295 |
| - activeTypes[3] = true; |
296 |
| - } else if ("jdk.ThreadPark".equals(typeName)) { // NOI18N |
297 |
| - processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_PARK, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
298 |
| - activeTypes[4] = true; |
299 |
| - } else if ("jdk.ThreadSleep".equals(typeName)) { // NOI18N |
300 |
| - processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_SLEEPING, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
301 |
| - activeTypes[5] = true; |
302 |
| - } else if ("jdk.Compilation".equals(typeName)) { // ?? // NOI18N |
303 |
| - processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_RUNNING, CommonConstants.THREAD_STATUS_PARK); // ?? // NOI18N |
304 |
| - } else if ("jdk.ThreadAllocationStatistics".equals(typeName)) { // NOI18N |
305 |
| - try { |
306 |
| - JFRThread thread = event.getThread("eventThread"); // NOI18N |
307 |
| - if (thread != null) { |
308 |
| - long allocated = event.getLong("allocated"); // NOI18N |
309 |
| - byte tstate = allocated > 0 ? CommonConstants.THREAD_STATUS_RUNNING : CommonConstants.THREAD_STATUS_WAIT; // ?? |
310 |
| - processDefinition(thread.getId(), thread.getName(), ValuesConverter.instantToRelativeNanos(event.getInstant("eventTime"), jfrModel), tstate); // NOI18N |
| 288 | + switch (typeName) { |
| 289 | + case "jdk.ThreadStart": // NOI18N |
| 290 | + processEvent(event, "thread", CommonConstants.THREAD_STATUS_RUNNING, Byte.MIN_VALUE); // NOI18N |
| 291 | + activeTypes[0] = true; |
| 292 | + break; |
| 293 | + |
| 294 | + case "jdk.ThreadEnd": // NOI18N |
| 295 | + processEvent(event, "thread", CommonConstants.THREAD_STATUS_ZOMBIE, Byte.MIN_VALUE); // NOI18N |
| 296 | + activeTypes[1] = true; |
| 297 | + break; |
| 298 | + |
| 299 | + case "jdk.JavaMonitorWait": // NOI18N |
| 300 | + processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_WAIT, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
| 301 | + activeTypes[2] = true; |
| 302 | + break; |
| 303 | + |
| 304 | + case "jdk.JavaMonitorEnter": // NOI18N |
| 305 | + processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_MONITOR, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
| 306 | + activeTypes[3] = true; |
| 307 | + break; |
| 308 | + |
| 309 | + case "jdk.ThreadPark": // NOI18N |
| 310 | + processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_PARK, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
| 311 | + activeTypes[4] = true; |
| 312 | + break; |
| 313 | + |
| 314 | + case "jdk.ThreadSleep": // NOI18N |
| 315 | + processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_SLEEPING, CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
| 316 | + activeTypes[5] = true; |
| 317 | + break; |
| 318 | + |
| 319 | + case "jdk.Compilation": // NOI18N |
| 320 | + processEvent(event, "eventThread", CommonConstants.THREAD_STATUS_RUNNING, CommonConstants.THREAD_STATUS_PARK); // ?? // NOI18N |
| 321 | + break; |
| 322 | + |
| 323 | + case "jdk.ThreadAllocationStatistics": // NOI18N |
| 324 | + try { |
| 325 | + JFRThread thread = event.getThread("eventThread"); // NOI18N |
| 326 | + if (thread != null) { |
| 327 | + long allocated = event.getLong("allocated"); // NOI18N |
| 328 | + byte tstate = allocated > 0 ? CommonConstants.THREAD_STATUS_RUNNING : CommonConstants.THREAD_STATUS_WAIT; // ?? |
| 329 | + processDefinition(thread.getId(), thread.getName(), ValuesConverter.instantToRelativeNanos(event.getInstant("eventTime"), jfrModel), tstate); // NOI18N |
| 330 | + } |
| 331 | + } catch (JFRPropertyNotAvailableException e) { System.err.println(">>> --- " + e); } |
| 332 | + break; |
| 333 | + |
| 334 | + default: |
| 335 | + try { |
| 336 | + if (!ignoredEvents.contains(typeName)) { |
| 337 | + JFRThread thread = event.getThread("eventThread"); // NOI18N |
| 338 | + if (thread != null) processDefinition(thread.getId(), thread.getName(), ValuesConverter.instantToRelativeNanos(event.getInstant("eventTime"), jfrModel), CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
| 339 | + } |
| 340 | + } catch (JFRPropertyNotAvailableException e) { |
| 341 | + ignoredEvents.add(typeName); |
311 | 342 | }
|
312 |
| - } catch (JFRPropertyNotAvailableException e) { System.err.println(">>> --- " + e); } |
313 |
| - } else { |
314 |
| - try { |
315 |
| - JFRThread thread = event.getThread("eventThread"); // NOI18N |
316 |
| - if (thread != null) processDefinition(thread.getId(), thread.getName(), ValuesConverter.instantToRelativeNanos(event.getInstant("eventTime"), jfrModel), CommonConstants.THREAD_STATUS_RUNNING); // NOI18N |
317 |
| - } catch (JFRPropertyNotAvailableException e) {} // valid state, no eventThread defined for the event |
318 | 343 | }
|
319 | 344 |
|
320 | 345 | return false;
|
@@ -369,11 +394,9 @@ public void run() {
|
369 | 394 | }
|
370 | 395 | });
|
371 | 396 |
|
372 |
| - states.clear(); |
373 | 397 | states = null;
|
374 |
| - |
375 |
| - definitions.clear(); |
376 | 398 | definitions = null;
|
| 399 | + ignoredEvents = null; |
377 | 400 | }
|
378 | 401 |
|
379 | 402 |
|
|
0 commit comments