Java Code Examples for jdk.jfr.internal.Utils#checkAccessFlightRecorder()
The following examples show how to use
jdk.jfr.internal.Utils#checkAccessFlightRecorder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlightRecorder.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the Flight Recorder for the platform. * * @return a Flight Recorder instance, not {@code null} * * @throws IllegalStateException if the platform Flight Recorder couldn't be * created (for example, if the file repository can't be created or * accessed) * * @throws SecurityException if a security manager exists and the caller does * not have {@code FlightRecorderPermission("accessFlightRecorder")} */ public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException { synchronized (PlatformRecorder.class) { Utils.checkAccessFlightRecorder(); JVMSupport.ensureWithIllegalStateException(); if (platformRecorder == null) { try { platformRecorder = new FlightRecorder(new PlatformRecorder()); } catch (IllegalStateException ise) { throw ise; } catch (Exception e) { throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e); } // Must be in synchronized block to prevent instance leaking out // before initialization is done initialized = true; Logger.log(JFR, INFO, "Flight Recorder initialized"); Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes"); Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes"); Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes"); Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount()); Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath()); Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads()); Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth()); Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize()); Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString()); PlatformRecorder.notifyRecorderInitialized(platformRecorder); } } return platformRecorder; }
Example 2
Source File: ManagementSupport.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static List<EventType> getEventTypes() { // would normally be checked when a Flight Recorder instance is created Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return new ArrayList<>(); } JDKEvents.initialize(); // make sure JDK events are available return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes()); }
Example 3
Source File: FlightRecorder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns the Flight Recorder for the platform. * * @return a Flight Recorder instance, not {@code null} * * @throws IllegalStateException if Flight Recorder can't be created (for * example, if the Java Virtual Machine (JVM) lacks Flight Recorder * support, or if the file repository can't be created or accessed) * * @throws SecurityException if a security manager exists and the caller does * not have {@code FlightRecorderPermission("accessFlightRecorder")} */ public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException { synchronized (PlatformRecorder.class) { Utils.checkAccessFlightRecorder(); JVMSupport.ensureWithIllegalStateException(); if (platformRecorder == null) { try { platformRecorder = new FlightRecorder(new PlatformRecorder()); } catch (IllegalStateException ise) { throw ise; } catch (Exception e) { throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e); } // Must be in synchronized block to prevent instance leaking out // before initialization is done initialized = true; Logger.log(JFR, INFO, "Flight Recorder initialized"); Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes"); Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes"); Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes"); Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount()); Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath()); Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads()); Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth()); Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize()); Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString()); PlatformRecorder.notifyRecorderInitialized(platformRecorder); } } return platformRecorder; }
Example 4
Source File: ManagementSupport.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static List<EventType> getEventTypes() { // would normally be checked when a Flight Recorder instance is created Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return new ArrayList<>(); } JDKEvents.initialize(); // make sure JDK events are available return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes()); }
Example 5
Source File: FlightRecorder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Returns the Flight Recorder for the platform. * * @return a Flight Recorder instance, not {@code null} * * @throws IllegalStateException if Flight Recorder can't be created (for * example, if the Java Virtual Machine (JVM) lacks Flight Recorder * support, or if the file repository can't be created or accessed) * * @throws SecurityException if a security manager exists and the caller does * not have {@code FlightRecorderPermission("accessFlightRecorder")} */ public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException { synchronized (PlatformRecorder.class) { Utils.checkAccessFlightRecorder(); JVMSupport.ensureWithIllegalStateException(); if (platformRecorder == null) { try { platformRecorder = new FlightRecorder(new PlatformRecorder()); } catch (IllegalStateException ise) { throw ise; } catch (Exception e) { throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e); } // Must be in synchronized block to prevent instance leaking out // before initialization is done initialized = true; Logger.log(JFR, INFO, "Flight Recorder initialized"); Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes"); Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes"); Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes"); Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount()); Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath()); Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads()); Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth()); Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize()); Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString()); PlatformRecorder.notifyRecorderInitialized(platformRecorder); } } return platformRecorder; }
Example 6
Source File: ManagementSupport.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static List<EventType> getEventTypes() { // would normally be checked when a Flight Recorder instance is created Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return new ArrayList<>(); } JDKEvents.initialize(); // make sure JDK events are available return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes()); }
Example 7
Source File: FlightRecorder.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Adds a recorder listener and captures the {@code AccessControlContext} to * use when invoking the listener. * <p> * If Flight Recorder is already initialized when the listener is added, the the method * {@link FlightRecorderListener#recorderInitialized(FlightRecorder)} method is * invoked before returning from this method. * * @param changeListener the listener to add, not {@code null} * * @throws SecurityException if a security manager exists and the caller * does not have * {@code FlightRecorderPermission("accessFlightRecorder")} */ public static void addListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener); Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return; } PlatformRecorder.addListener(changeListener); }
Example 8
Source File: FlightRecorder.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Removes a recorder listener. * <p> * If the same listener is added multiple times, only one instance is * removed. * * @param changeListener listener to remove, not {@code null} * * @throws SecurityException if a security manager exists and the caller * does not have * {@code FlightRecorderPermission("accessFlightRecorder")} * * @return {@code true}, if the listener could be removed, {@code false} * otherwise */ public static boolean removeListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener); Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return false; } return PlatformRecorder.removeListener(changeListener); }
Example 9
Source File: FlightRecorder.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
/** * Adds a recorder listener and captures the {@code AccessControlContext} to * use when invoking the listener. * <p> * If Flight Recorder is already initialized when the listener is added, then the method * {@link FlightRecorderListener#recorderInitialized(FlightRecorder)} method is * invoked before returning from this method. * * @param changeListener the listener to add, not {@code null} * * @throws SecurityException if a security manager exists and the caller * does not have * {@code FlightRecorderPermission("accessFlightRecorder")} */ public static void addListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener); Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return; } PlatformRecorder.addListener(changeListener); }
Example 10
Source File: FlightRecorder.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
/** * Removes a recorder listener. * <p> * If the same listener is added multiple times, only one instance is * removed. * * @param changeListener listener to remove, not {@code null} * * @throws SecurityException if a security manager exists and the caller * does not have * {@code FlightRecorderPermission("accessFlightRecorder")} * * @return {@code true}, if the listener could be removed, {@code false} * otherwise */ public static boolean removeListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener); Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return false; } return PlatformRecorder.removeListener(changeListener); }
Example 11
Source File: FlightRecorder.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Adds a recorder listener and captures the {@code AccessControlContext} to * use when invoking the listener. * <p> * If Flight Recorder is already initialized when the listener is added, then the method * {@link FlightRecorderListener#recorderInitialized(FlightRecorder)} method is * invoked before returning from this method. * * @param changeListener the listener to add, not {@code null} * * @throws SecurityException if a security manager exists and the caller * does not have * {@code FlightRecorderPermission("accessFlightRecorder")} */ public static void addListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener); Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return; } PlatformRecorder.addListener(changeListener); }
Example 12
Source File: FlightRecorder.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Removes a recorder listener. * <p> * If the same listener is added multiple times, only one instance is * removed. * * @param changeListener listener to remove, not {@code null} * * @throws SecurityException if a security manager exists and the caller * does not have * {@code FlightRecorderPermission("accessFlightRecorder")} * * @return {@code true}, if the listener could be removed, {@code false} * otherwise */ public static boolean removeListener(FlightRecorderListener changeListener) { Objects.requireNonNull(changeListener); Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return false; } return PlatformRecorder.removeListener(changeListener); }