java.lang.management.PlatformManagedObject Java Examples

The following examples show how to use java.lang.management.PlatformManagedObject. 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: GetObjectName.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #2
Source File: GetObjectName.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #3
Source File: GetObjectName.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #4
Source File: GetObjectName.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #5
Source File: GetObjectName.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #6
Source File: GetObjectName.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #7
Source File: GetObjectName.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #8
Source File: GetObjectName.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #9
Source File: GetObjectName.java    From native-obfuscator with GNU General Public License v3.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #10
Source File: GetObjectName.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #11
Source File: GetObjectName.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #12
Source File: GetObjectName.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #13
Source File: GetObjectName.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #14
Source File: GetObjectName.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
 
Example #15
Source File: MetricUtils.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a set of metrics (gauges) that correspond to available bean properties for the provided MXBean.
 * @param obj an instance of MXBean
 * @param interfaces interfaces that it may implement. Each interface will be tried in turn, and only
 *                   if it exists and if it contains unique properties then they will be added as metrics.
 * @param prefix optional prefix for metric names
 * @param consumer consumer for created names and metrics
 * @param <T> formal type
 */
public static <T extends PlatformManagedObject> void addMXBeanMetrics(T obj, String[] interfaces,
    String prefix, BiConsumer<String, Metric> consumer) {
  for (String clazz : interfaces) {
    try {
      final Class<? extends PlatformManagedObject> intf = Class.forName(clazz)
          .asSubclass(PlatformManagedObject.class);
      MetricUtils.addMXBeanMetrics(obj, intf, null, consumer);
    } catch (ClassNotFoundException e) {
      // ignore
    }
  }
}
 
Example #16
Source File: HeapDumper.java    From buck with Apache License 2.0 5 votes vote down vote up
private static PlatformManagedObject getDiagnosticBean() {
  try {
    Class<? extends PlatformManagedObject> clazz =
        Class.forName("com.sun.management.HotSpotDiagnosticMXBean")
            .asSubclass(PlatformManagedObject.class);
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    PlatformManagedObject bean =
        ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME, clazz);
    return bean;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
Example #17
Source File: BrokerAttributeInjector.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
private ConfiguredObjectInjectedOperation<?> injectSetJVMOptions() throws NoSuchMethodException
{

        Method setVMOptionMethod =
                _hotSpotDiagnosticMXBeanClass.getDeclaredMethod("setVMOption", String.class, String.class);

        Method method = BrokerAttributeInjector.class.getDeclaredMethod("setJVMOptions",
                                                                        Broker.class,
                                                                        PlatformManagedObject.class,
                                                                        Method.class,
                                                                        Map.class);

        final OperationParameter[] params =
                new OperationParameter[]{new OperationParameterFromInjection("options",
                                                                             Map.class,
                                                                             ParameterizedTypes.MAP_OF_STRING_STRING,
                                                                             "",
                                                                             "JVM options map",
                                                                             new String[0], true)};
        ConfiguredObjectInjectedOperation<?> setVMOptionOperation = new ConfiguredObjectInjectedOperation(
                "setJVMOptions",
                "Sets given JVM options",
                true,
                false,
                "",
                params,
                method,
                new Object[]{_hotSpotDiagnosticMXBean, setVMOptionMethod},
                _typeValidator);
        return setVMOptionOperation;
}
 
Example #18
Source File: BrokerAttributeInjector.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
private ConfiguredObjectInjectedOperation<?> injectDumpHeap() throws NoSuchMethodException
{
        Method heapDumpMethod =
                _hotSpotDiagnosticMXBeanClass.getDeclaredMethod("dumpHeap", String.class, boolean.class);

        Method method = BrokerAttributeInjector.class.getDeclaredMethod("dumpHeap",
                                                                        Broker.class,
                                                                        PlatformManagedObject.class,
                                                                        Method.class,
                                                                        String.class,
                                                                        boolean.class);

        final OperationParameter[] params = new OperationParameter[2];

        params[0] = new OperationParameterFromInjection("outputFile",
                                                        String.class,
                                                        String.class,
                                                        "",
                                                        "the system-dependent filename",
                                                        new String[0], true);
        params[1] = new OperationParameterFromInjection("live",
                                                        boolean.class,
                                                        boolean.class,
                                                        "true",
                                                        "if true dump only live objects i.e. objects that are reachable from others",
                                                        new String[]{Boolean.TRUE.toString(), Boolean.FALSE.toString()},
                                                        false);
        ConfiguredObjectInjectedOperation<?> setVMOptionOperation = new ConfiguredObjectInjectedOperation(
                "dumpHeap",
                "Dumps the heap to the outputFile file in the same format as the hprof heap dump.",
                true,
                false,
                "",
                params,
                method,
                new Object[]{_hotSpotDiagnosticMXBean, heapDumpMethod},
                _typeValidator);
        return setVMOptionOperation;
}
 
Example #19
Source File: ExtendedPlatformComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {

    if ("jdk.management.jfr.FlightRecorderMXBean".equals(mxbeanInterface.getName())) {
        return (T)getFlightRecorderBean();
    }
    return null;
}
 
Example #20
Source File: ExtendedPlatformComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the extended set of platform MXBeans that should be registered in the
 * platform MBeanServer, or an empty list if there are no such MXBeans.
 */
public static List<? extends PlatformManagedObject> getMXBeans() {
    PlatformManagedObject o = getFlightRecorderBean();
    if (o != null) {
        return Collections.singletonList(o);
    } else {
        return Collections.emptyList();
    }
}
 
Example #21
Source File: ExtendedPlatformComponent.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {

    if ("jdk.management.jfr.FlightRecorderMXBean".equals(mxbeanInterface.getName())) {
        return (T)getFlightRecorderBean();
    }
    return null;
}
 
Example #22
Source File: ExtendedPlatformComponent.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the extended set of platform MXBeans that should be registered in the
 * platform MBeanServer, or an empty list if there are no such MXBeans.
 */
public static List<? extends PlatformManagedObject> getMXBeans() {
    PlatformManagedObject o = getFlightRecorderBean();
    if (o != null) {
        return Collections.singletonList(o);
    } else {
        return Collections.emptyList();
    }
}
 
Example #23
Source File: ExtendedPlatformComponent.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}
 
Example #24
Source File: ExtendedPlatformComponent.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}
 
Example #25
Source File: ExtendedPlatformComponent.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}
 
Example #26
Source File: ExtendedPlatformComponent.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}
 
Example #27
Source File: ExtendedPlatformComponent.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}
 
Example #28
Source File: ExtendedPlatformComponent.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}
 
Example #29
Source File: ExtendedPlatformComponent.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}
 
Example #30
Source File: ExtendedPlatformComponent.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the extended platform MXBean implementing the given
 * mxbeanInterface, or null if there is no such MXBean.
 */
public static <T extends PlatformManagedObject>
        T getMXBean(Class<T> mxbeanInterface) {
    return null;
}