< prev index next >

src/share/classes/java/lang/management/PlatformComponent.java

Print this page
rev 13428 : jfr backport

*** 1,7 **** /* ! * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 35,48 **** --- 35,51 ---- import javax.management.MBeanServerConnection; import javax.management.ObjectName; import com.sun.management.HotSpotDiagnosticMXBean; import com.sun.management.UnixOperatingSystemMXBean; + import com.sun.management.VMOption; import sun.management.ManagementFactoryHelper; import sun.management.Util; + import jdk.management.jfr.FlightRecorderMXBean; + /** * This enum class defines the list of platform components * that provides monitoring and management support. * Each enum represents one MXBean interface. A MXBean * instance could implement one or more MXBean interfaces.
*** 268,279 **** true, // singleton new MXBeanFetcher<HotSpotDiagnosticMXBean>() { public List<HotSpotDiagnosticMXBean> getMXBeans() { return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean()); } ! }); /** * A task that returns the MXBeans for a component. */ interface MXBeanFetcher<T extends PlatformManagedObject> { --- 271,302 ---- true, // singleton new MXBeanFetcher<HotSpotDiagnosticMXBean>() { public List<HotSpotDiagnosticMXBean> getMXBeans() { return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean()); } ! }), + /** + * Flight Recorder. + */ + FLIGHT_RECORDER( + "jdk.management.jfr.FlightRecorderMXBean", + "jdk.management.jfr", "FlightRecorder", defaultKeyProperties(), + true, + new MXBeanFetcher<FlightRecorderMXBean>() { + public List<FlightRecorderMXBean> getMXBeans() { + HotSpotDiagnosticMXBean hsDiagMBean = ManagementFactoryHelper.getDiagnosticMXBean(); + VMOption opt = hsDiagMBean.getVMOption("EnableJFR"); + if (Boolean.valueOf(opt.getValue())) { + FlightRecorderMXBean m = ManagementFactoryHelper.getFlightRecorderMXBean(); + if (m != null) { + return Collections.singletonList(m); + } + } + return Collections.emptyList(); + } + }); /** * A task that returns the MXBeans for a component. */ interface MXBeanFetcher<T extends PlatformManagedObject> {
*** 377,402 **** return (List<T>) fetcher.getMXBeans(); } <T extends PlatformManagedObject> T getSingletonMXBean(Class<T> mxbeanInterface) { ! if (!singleton) throw new IllegalArgumentException(mxbeanInterfaceName + " can have zero or more than one instances"); List<T> list = getMXBeans(mxbeanInterface); assert list.size() == 1; return list.isEmpty() ? null : list.get(0); } <T extends PlatformManagedObject> T getSingletonMXBean(MBeanServerConnection mbs, Class<T> mxbeanInterface) throws java.io.IOException { ! if (!singleton) throw new IllegalArgumentException(mxbeanInterfaceName + " can have zero or more than one instances"); // ObjectName of a singleton MXBean contains only domain and type assert keyProperties.size() == 1; String on = domain + ":type=" + type; return ManagementFactory.newPlatformMXBeanProxy(mbs, --- 400,427 ---- return (List<T>) fetcher.getMXBeans(); } <T extends PlatformManagedObject> T getSingletonMXBean(Class<T> mxbeanInterface) { ! if (!singleton) { throw new IllegalArgumentException(mxbeanInterfaceName + " can have zero or more than one instances"); + } List<T> list = getMXBeans(mxbeanInterface); assert list.size() == 1; return list.isEmpty() ? null : list.get(0); } <T extends PlatformManagedObject> T getSingletonMXBean(MBeanServerConnection mbs, Class<T> mxbeanInterface) throws java.io.IOException { ! if (!singleton) { throw new IllegalArgumentException(mxbeanInterfaceName + " can have zero or more than one instances"); + } // ObjectName of a singleton MXBean contains only domain and type assert keyProperties.size() == 1; String on = domain + ":type=" + type; return ManagementFactory.newPlatformMXBeanProxy(mbs,
*** 457,468 **** PlatformComponent getPlatformComponent(Class<T> mxbeanInterface) { ensureInitialized(); String cn = mxbeanInterface.getName(); PlatformComponent pc = enumMap.get(cn); ! if (pc != null && pc.getMXBeanInterface() == mxbeanInterface) return pc; return null; } private static final long serialVersionUID = 6992337162326171013L; } --- 482,494 ---- PlatformComponent getPlatformComponent(Class<T> mxbeanInterface) { ensureInitialized(); String cn = mxbeanInterface.getName(); PlatformComponent pc = enumMap.get(cn); ! if (pc != null && pc.getMXBeanInterface() == mxbeanInterface) { return pc; + } return null; } private static final long serialVersionUID = 6992337162326171013L; }
< prev index next >