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"); } } } }); } }
HeapDumpCreator(final Configuration configuration, final String hostName, final PlatformManagedObject heapDumpBean, final CommandExecutor commandExecutor, final Logger logger) throws Exception { this.configuration = configuration; this.nameFormatter = new HeapDumpNameFormatter(configuration.getHeapDumpName(), hostName); this.heapDumpBean = heapDumpBean; this.heapDumpMethod = heapDumpBean.getClass().getMethod("dumpHeap", String.class, boolean.class); this.commandExecutor = commandExecutor; this.logger = logger; }
@SuppressWarnings("unchecked") protected HotSpotDiagnosticMXBeanHeapDumper() { try { Class<?> diagnosticMXBeanClass = ClassUtils.resolveClassName( "com.sun.management.HotSpotDiagnosticMXBean", null); this.diagnosticMXBean = ManagementFactory.getPlatformMXBean( (Class<PlatformManagedObject>) diagnosticMXBeanClass); this.dumpHeapMethod = ReflectionUtils.findMethod(diagnosticMXBeanClass, "dumpHeap", String.class, Boolean.TYPE); } catch (Throwable ex) { throw new HeapDumperUnavailableException( "Unable to locate HotSpotDiagnosticMXBean", ex); } }
@Nullable private static <T extends PlatformManagedObject> T getBean(final Class<T> iface) { final String name = iface.getCanonicalName(); T ret; try { ret = ManagementFactory.getPlatformMXBean(iface); } catch (IllegalArgumentException e) { LOG.warn("error getting bean {}", name, e); return null; } if (ret == null) { LOG.warn("bean {} did not exist", name); } return ret; }
@SuppressWarnings("unchecked") protected HotSpotDiagnosticMXBeanHeapDumper() { try { Class<?> diagnosticMXBeanClass = ClassUtils.resolveClassName("com.sun.management.HotSpotDiagnosticMXBean", null); this.diagnosticMXBean = ManagementFactory.getPlatformMXBean((Class<PlatformManagedObject>) diagnosticMXBeanClass); this.dumpHeapMethod = ReflectionUtils.findMethod(diagnosticMXBeanClass, "dumpHeap", String.class, Boolean.TYPE); } catch (Throwable ex) { throw new HeapDumperUnavailableException("Unable to locate HotSpotDiagnosticMXBean", ex); } }
/** * 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; }
/** * 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() { return Collections.emptyList(); }