63 import jdk.jfr.internal.settings.StackTraceSetting; |
63 import jdk.jfr.internal.settings.StackTraceSetting; |
64 import jdk.jfr.internal.settings.ThresholdSetting; |
64 import jdk.jfr.internal.settings.ThresholdSetting; |
65 |
65 |
66 public final class Utils { |
66 public final class Utils { |
67 |
67 |
|
68 private static final Object flushObject = new Object(); |
68 private static final String INFINITY = "infinity"; |
69 private static final String INFINITY = "infinity"; |
69 |
|
70 private static Boolean SAVE_GENERATED; |
|
71 |
|
72 public static final String EVENTS_PACKAGE_NAME = "jdk.jfr.events"; |
70 public static final String EVENTS_PACKAGE_NAME = "jdk.jfr.events"; |
73 public static final String INSTRUMENT_PACKAGE_NAME = "jdk.jfr.internal.instrument"; |
71 public static final String INSTRUMENT_PACKAGE_NAME = "jdk.jfr.internal.instrument"; |
74 public static final String HANDLERS_PACKAGE_NAME = "jdk.jfr.internal.handlers"; |
72 public static final String HANDLERS_PACKAGE_NAME = "jdk.jfr.internal.handlers"; |
75 public static final String REGISTER_EVENT = "registerEvent"; |
73 public static final String REGISTER_EVENT = "registerEvent"; |
76 public static final String ACCESS_FLIGHT_RECORDER = "accessFlightRecorder"; |
74 public static final String ACCESS_FLIGHT_RECORDER = "accessFlightRecorder"; |
77 |
|
78 private final static String LEGACY_EVENT_NAME_PREFIX = "com.oracle.jdk."; |
75 private final static String LEGACY_EVENT_NAME_PREFIX = "com.oracle.jdk."; |
|
76 |
|
77 private static Boolean SAVE_GENERATED; |
|
78 |
79 |
79 |
80 public static void checkAccessFlightRecorder() throws SecurityException { |
80 public static void checkAccessFlightRecorder() throws SecurityException { |
81 SecurityManager sm = System.getSecurityManager(); |
81 SecurityManager sm = System.getSecurityManager(); |
82 if (sm != null) { |
82 if (sm != null) { |
83 sm.checkPermission(new FlightRecorderPermission(ACCESS_FLIGHT_RECORDER)); |
83 sm.checkPermission(new FlightRecorderPermission(ACCESS_FLIGHT_RECORDER)); |
593 String pid = JVM.getJVM().getPid(); |
593 String pid = JVM.getJVM().getPid(); |
594 String date = Repository.REPO_DATE_FORMAT.format(LocalDateTime.now()); |
594 String date = Repository.REPO_DATE_FORMAT.format(LocalDateTime.now()); |
595 String idText = recording == null ? "" : "-id-" + Long.toString(recording.getId()); |
595 String idText = recording == null ? "" : "-id-" + Long.toString(recording.getId()); |
596 return "hotspot-" + "pid-" + pid + idText + "-" + date + ".jfr"; |
596 return "hotspot-" + "pid-" + pid + idText + "-" + date + ".jfr"; |
597 } |
597 } |
|
598 |
598 public static void takeNap(long millis) { |
599 public static void takeNap(long millis) { |
599 try { |
600 try { |
600 Thread.sleep(millis); |
601 Thread.sleep(millis); |
601 } catch (InterruptedException e) { |
602 } catch (InterruptedException e) { |
602 } |
603 } |
603 } |
604 } |
|
605 |
|
606 public static void notifyFlush() { |
|
607 synchronized (flushObject) { |
|
608 flushObject.notifyAll(); |
|
609 } |
|
610 } |
|
611 |
|
612 public static void waitFlush(long timeOut) { |
|
613 synchronized (flushObject) { |
|
614 try { |
|
615 flushObject.wait(timeOut); |
|
616 } catch (InterruptedException e) { |
|
617 // OK |
|
618 } |
|
619 } |
|
620 |
|
621 } |
604 } |
622 } |