Search in sources :

Example 31 with MBeanServer

use of javax.management.MBeanServer in project neo4j by neo4j.

the class JmxService method listDomains.

@GET
@Path(DOMAINS_PATH)
public Response listDomains() throws NullPointerException {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    ListRepresentation domains = ListRepresentation.strings(server.getDomains());
    return output.ok(domains);
}
Also used : ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) MBeanServer(javax.management.MBeanServer) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 32 with MBeanServer

use of javax.management.MBeanServer in project tdi-studio-se by Talend.

the class Agent method registerMXBeans.

/**
     * Registers the MXBeans.
     * 
     * @param inst
     *            The instrumentation
     * @return <tt>true</tt> if registered, and <tt>false</tt> if nothing was
     *         done since MBeans had already been registered.
     * @throws Throwable
     */
private static boolean registerMXBeans(Instrumentation inst) throws Throwable {
    boolean agentLoaded = false;
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    ObjectName profilerObjectName = new ObjectName(CpuBciProfilerMXBean.PROFILER_MXBEAN_NAME);
    ObjectName dataTransferObjectName = new ObjectName(DataTransferMXBean.DATA_TRANSFER_MXBEAN_NAME);
    ObjectName swtResourceMonitorObjectName = new ObjectName(SWTResourceMonitorMXBean.SWT_RESOURCE_MONITOR_MXBEAN_NAME);
    if (!server.isRegistered(profilerObjectName)) {
        CpuBciProfilerMXBeanImpl profiler = new CpuBciProfilerMXBeanImpl(inst);
        server.registerMBean(profiler, profilerObjectName);
        agentLoaded = true;
    }
    if (!server.isRegistered(dataTransferObjectName)) {
        DataTransferMXBeanImpl dataTransfer = new DataTransferMXBeanImpl();
        server.registerMBean(dataTransfer, dataTransferObjectName);
        agentLoaded = true;
    }
    if (!server.isRegistered(swtResourceMonitorObjectName)) {
        SWTResourceMonitorMXBeanImpl swtResourceMonitor = new SWTResourceMonitorMXBeanImpl(inst);
        if (swtResourceMonitor.isSuppoted()) {
            server.registerMBean(swtResourceMonitor, swtResourceMonitorObjectName);
        }
        agentLoaded = true;
    }
    return agentLoaded;
}
Also used : MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 33 with MBeanServer

use of javax.management.MBeanServer in project voltdb by VoltDB.

the class ManagedUtil method registerLog4jMBeans.

/**
     * Register the log4j JMX mbeans. Set environment variable
     * "zookeeper.jmx.log4j.disable" to true to disable registration.
     * @see http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/jmx/package-summary.html
     * @throws JMException if registration fails
     */
public static void registerLog4jMBeans() throws JMException {
    if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
        return;
    }
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    // Create and Register the top level Log4J MBean
    HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
    ObjectName mbo = new ObjectName("log4j:hiearchy=default");
    mbs.registerMBean(hdm, mbo);
    // Add the root logger to the Hierarchy MBean
    Logger rootLogger = Logger.getRootLogger();
    hdm.addLoggerMBean(rootLogger.getName());
    // Get each logger from the Log4J Repository and add it to
    // the Hierarchy MBean created above.
    LoggerRepository r = LogManager.getLoggerRepository();
    Enumeration enumer = r.getCurrentLoggers();
    Logger logger = null;
    while (enumer.hasMoreElements()) {
        logger = (Logger) enumer.nextElement();
        hdm.addLoggerMBean(logger.getName());
    }
}
Also used : LoggerRepository(org.apache.log4j.spi.LoggerRepository) Enumeration(java.util.Enumeration) HierarchyDynamicMBean(org.apache.log4j.jmx.HierarchyDynamicMBean) Logger(org.apache.log4j.Logger) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 34 with MBeanServer

use of javax.management.MBeanServer in project nhin-d by DirectProject.

the class DNSServer method registerMBean.

/**
	 * Register the MBean
	 */
private void registerMBean(DNSServerSettings settings) {
    String[] itemNames = { "Port", "Bind Address", "Max Request Size", "Max Outstanding Accepts", "Max Active Accepts", "Max Connection Backlog", "Read Buffer Size", "Send Timeout", "Receive Timeout", "Socket Close Timeout" };
    String[] itemDesc = { "Port", "Bind Address", "Max Request Size", "Max Outstanding Accepts", "Max Active Accepts", "Max Connection Backlog", "Read Buffer Size", "Send Timeout", "Receive Timeout", "Socket Close Timeout" };
    OpenType<?>[] types = { SimpleType.INTEGER, SimpleType.STRING, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER };
    Object[] settingsValues = { settings.getPort(), settings.getBindAddress(), settings.getMaxRequestSize(), settings.getMaxOutstandingAccepts(), settings.getMaxActiveRequests(), settings.getMaxConnectionBacklog(), settings.getReadBufferSize(), settings.getSendTimeout(), settings.getReceiveTimeout(), settings.getSocketCloseTimeout() };
    try {
        CompositeType settingsType = new CompositeType(DNSServerSettings.class.getSimpleName(), "DNS server settings.", itemNames, itemDesc, types);
        settingsData = new CompositeDataSupport(settingsType, itemNames, settingsValues);
    } catch (OpenDataException e) {
        LOGGER.error("Failed to create settings composite type: " + e.getLocalizedMessage(), e);
        return;
    }
    Class<?> clazz = this.getClass();
    final StringBuilder objectNameBuilder = new StringBuilder(clazz.getPackage().getName());
    objectNameBuilder.append(":type=").append(clazz.getSimpleName());
    objectNameBuilder.append(",name=").append(UUID.randomUUID());
    try {
        final StandardMBean mbean = new StandardMBean(this, DNSServerMBean.class);
        final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        mbeanServer.registerMBean(mbean, new ObjectName(objectNameBuilder.toString()));
    } catch (JMException e) {
        LOGGER.error("Unable to register the DNSServer MBean", e);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) StandardMBean(javax.management.StandardMBean) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ObjectName(javax.management.ObjectName) OpenDataException(javax.management.openmbean.OpenDataException) JMException(javax.management.JMException) CompositeType(javax.management.openmbean.CompositeType) MBeanServer(javax.management.MBeanServer)

Example 35 with MBeanServer

use of javax.management.MBeanServer in project nhin-d by DirectProject.

the class DNSSocketServer method registerMBean.

protected void registerMBean(Class<?> clazz) {
    final StringBuilder objectNameBuilder = new StringBuilder(clazz.getPackage().getName());
    objectNameBuilder.append(":type=").append(clazz.getSimpleName());
    objectNameBuilder.append(",name=").append(UUID.randomUUID());
    try {
        final StandardMBean mbean = new StandardMBean(this, DNSSocketServerMBean.class);
        final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        mbeanServer.registerMBean(mbean, new ObjectName(objectNameBuilder.toString()));
    } catch (JMException e) {
        LOGGER.error("Unable to register the DNSSocketServer MBean", e);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) JMException(javax.management.JMException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

MBeanServer (javax.management.MBeanServer)1218 ObjectName (javax.management.ObjectName)939 Test (org.junit.Test)214 MalformedObjectNameException (javax.management.MalformedObjectNameException)123 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)94 InstanceNotFoundException (javax.management.InstanceNotFoundException)87 IOException (java.io.IOException)82 JMXServiceURL (javax.management.remote.JMXServiceURL)70 Attribute (javax.management.Attribute)66 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)65 HashMap (java.util.HashMap)63 MBeanRegistrationException (javax.management.MBeanRegistrationException)56 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)54 TabularData (javax.management.openmbean.TabularData)51 ArrayList (java.util.ArrayList)47 JMXConnectorServer (javax.management.remote.JMXConnectorServer)47 JMXConnector (javax.management.remote.JMXConnector)40 Map (java.util.Map)38 JMException (javax.management.JMException)38 Test (org.junit.jupiter.api.Test)36