Example usage for javax.management ObjectName ObjectName

List of usage examples for javax.management ObjectName ObjectName

Introduction

In this page you can find the example usage for javax.management ObjectName ObjectName.

Prototype

public ObjectName(String name) throws MalformedObjectNameException 

Source Link

Document

Construct an object name from the given string.

Usage

From source file:co.paralleluniverse.common.monitoring.PeriodicMonitor.java

public void unregisterMBean() {
    try {/* w  w w.j  av  a2  s . c om*/
        if (registered) {
            LOG.info("Unregistering MBean {}", name);
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name));
            timer.stop();
        }
        this.registered = false;
    } catch (Exception e) {
        LOG.warn("Exception:", e);
    }
}

From source file:com.neophob.sematrix.core.jmx.PixelControllerStatus.java

/**
 * Register the JMX Bean./*from  w  ww .j av a2 s  .  c  o  m*/
 *
 * @param configuredFps the configured fps
 */
public PixelControllerStatus(Collector col, int configuredFps) {
    LOG.log(Level.INFO, "Initialize the PixelControllerStatus JMX Bean");

    this.configuredFps = configuredFps;
    this.col = col;

    // initialize all buffers 
    this.timeMeasureMapGlobal = new ConcurrentHashMap<TimeMeasureItemGlobal, CircularFifoBuffer>();
    for (TimeMeasureItemGlobal timeMeasureItem : TimeMeasureItemGlobal.values()) {
        this.timeMeasureMapGlobal.put(timeMeasureItem, new CircularFifoBuffer(this.configuredFps * SECONDS));
    }
    this.timeMeasureMapOutput = new ConcurrentHashMap<IOutput, Map<TimeMeasureItemOutput, CircularFifoBuffer>>();
    this.outputList = new ArrayList<IOutput>();

    startTime = System.currentTimeMillis();

    // register MBean
    try {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName name = new ObjectName(JMX_BEAN_NAME);
        // check if the MBean is already registered
        if (!server.isRegistered(name)) {
            server.registerMBean(this, name);
        }
    } catch (JMException ex) {
        LOG.log(Level.WARNING, "Error while registering class as JMX Bean.", ex);
    }
}

From source file:com.ricston.connectors.dataanalysis.DataAnalysisConnector.java

/**
 * Stop the module by closing the Map DB and unregister from the Mbean server
 * //w ww . jav a2  s. c om
 * @throws MalformedObjectNameException
 * @throws MBeanRegistrationException
 * @throws InstanceNotFoundException
 */
@Stop
public void stopModule()
        throws MalformedObjectNameException, MBeanRegistrationException, InstanceNotFoundException {
    logger.info("**********************************");
    logger.info("*Stopping Data Analysis Connector*");
    logger.info("**********************************");

    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    ObjectName id = new ObjectName(String.format(MBEAN_NAME, application));
    server.unregisterMBean(id);

    logger.info("Unregistered mbean with name: " + String.format(MBEAN_NAME, application));

    stopMapDb();
}

From source file:c3.ops.priam.aws.S3FileSystem.java

@Inject
public S3FileSystem(Provider<AbstractBackupPath> pathProvider, ICompression compress,
        final IConfiguration config, ICredential cred) {
    this.pathProvider = pathProvider;
    this.compress = compress;
    this.config = config;
    int threads = config.getMaxBackupUploadThreads();
    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(threads);
    this.executor = new BlockingSubmitThreadPoolExecutor(threads, queue, UPLOAD_TIMEOUT);
    double throttleLimit = config.getUploadThrottle();
    rateLimiter = RateLimiter.create(throttleLimit < 1 ? Double.MAX_VALUE : throttleLimit);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    String mbeanName = MBEAN_NAME;
    try {/*from w w  w. jav a 2s .  c  o  m*/
        mbs.registerMBean(this, new ObjectName(mbeanName));
    } catch (Exception e) {
        logger.warn("Fail to register " + mbeanName);
        //throw new RuntimeException(e);
    }

    s3Client = new AmazonS3Client(cred.getAwsCredentialProvider());
    s3Client.setEndpoint(getS3Endpoint());
}

From source file:com.stumbleupon.hbaseadmin.JMXQuery.java

public String execute(String hostport) throws Exception {
    Iterator i;// w ww. j a va 2 s .  c o  m
    String result = "";
    final JMXServiceURL rmiurl = new JMXServiceURL(
            "service:jmx:rmi://" + hostport + "/jndi/rmi://" + hostport + "/jmxrmi");
    final JMXConnector jmxc = JMXConnectorFactory.connect(rmiurl, getCredentials(password_file));
    try {
        final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

        final ObjectName objName = new ObjectName(beanName);
        final Set beans = mbsc.queryMBeans(objName, null);

        if (beans.size() == 0) {
            logger.warn(objName.getCanonicalName() + " is not a registered bean");
        } else if (beans.size() == 1) {
            final ObjectInstance instance = (ObjectInstance) beans.iterator().next();
            result = doBean(mbsc, instance, command);
        } else {

            for (i = beans.iterator(); i.hasNext();) {
                final Object obj = i.next();

                if (obj instanceof ObjectName)
                    System.out.println(((ObjectName) obj).getCanonicalName());
                else if (obj instanceof ObjectInstance) {
                    System.out.println(((ObjectInstance) obj).getObjectName().getCanonicalName());
                } else
                    logger.error("Unexpected object type: " + obj);
            }
        }
    } finally {
        jmxc.close();
    }
    return result;
}

From source file:fr.xebia.monitoring.demo.payment.CreditCardServiceMonitoringImpl.java

@Override
public ObjectName getObjectName() throws MalformedObjectNameException {
    return new ObjectName(Monitoring.JMX_DOMAIN + ":type=CreditCardService,name=" + beanName);
}

From source file:com.netflix.priam.aws.S3FileSystem.java

@Inject
public S3FileSystem(Provider<AbstractBackupPath> pathProvider, ICompression compress,
        final IConfiguration config, ICredential cred) {
    this.pathProvider = pathProvider;
    this.compress = compress;
    this.config = config;
    int threads = config.getMaxBackupUploadThreads();
    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(threads);
    this.executor = new BlockingSubmitThreadPoolExecutor(threads, queue, UPLOAD_TIMEOUT);
    double throttleLimit = config.getUploadThrottle();
    rateLimiter = RateLimiter.create(throttleLimit < 1 ? Double.MAX_VALUE : throttleLimit);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    String mbeanName = MBEAN_NAME;
    try {//  w w  w . j  av a  2s  .  c om
        mbs.registerMBean(this, new ObjectName(mbeanName));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    s3Client = new AmazonS3Client(cred.getAwsCredentialProvider());
    s3Client.setEndpoint(getS3Endpoint());
}

From source file:net.sf.ehcache.management.ManagementServiceTest.java

/**
 * Integration test for the registration service using a contructed ManagementService as would be done
 * by an IoC container./*from w  ww .  j  ava 2  s . c  o  m*/
 */
public void testRegistrationServiceFourTrueUsing14MBeanServerWithConstructorInjection() throws Exception {
    mBeanServer = create14MBeanServer();
    ManagementService managementService = new ManagementService(manager, mBeanServer, true, true, true, true);
    managementService.init();
    assertEquals(OBJECTS_IN_TEST_EHCACHE,
            mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null).size());
}

From source file:hermes.ext.jbossmq.JBossMQAdmin.java

public Map getStatistics(DestinationConfig dConfig) throws JMSException {
    final Map stats = new LinkedHashMap();
    ObjectName objectName = null;

    try {//from ww w.  j  a  va2s.co m
        if (dConfig.getDomain() == Domain.QUEUE.getId()) {

            objectName = new ObjectName(
                    "jboss.mq.destination:name=" + getRealDestinationName(dConfig) + ",service=Queue");

            try {
                stats.put("QueueName", getRMIAdapter().getAttribute(objectName, "QueueName"));
            } catch (JMSException ex) {
                log.error("Unable to get QueueName property", ex);
            }

            try {
                stats.put("ScheduledMessageCount",
                        getRMIAdapter().getAttribute(objectName, "ScheduledMessageCount"));
            } catch (JMSException ex) {
                log.error("Unable to get ScheduledMessageCount property", ex);
            }

            try {
                stats.put("ReceiversCount", getRMIAdapter().getAttribute(objectName, "ReceiversCount"));
            } catch (JMSException ex) {
                log.error("Unable to get ReceiversCount property", ex);
            }
        } else {
            objectName = new ObjectName(
                    "jboss.mq.destination:name=" + getRealDestinationName(dConfig) + ",service=Topic");

            try {
                stats.put("TopicName", getRMIAdapter().getAttribute(objectName, "TopicName"));
            } catch (JMSException ex) {
                log.error("Unable to get TopicName property", ex);
            }
        }

        try {
            stats.put("StateString", getRMIAdapter().getAttribute(objectName, "StateString"));
        } catch (JMSException ex) {
            log.error("Unable to get StateString property", ex);
        }

        try {
            stats.put("State", getRMIAdapter().getAttribute(objectName, "State"));
        } catch (JMSException ex) {
            log.error("Unable to get State property", ex);
        }
    } catch (Exception e) {
        throw new HermesException(e);
    }

    return stats;
}

From source file:io.fabric8.insight.log.support.LogQuerySupport.java

public ObjectName getMbeanName() throws MalformedObjectNameException {
    if (mbeanName == null) {
        mbeanName = new ObjectName("io.fabric8.insight:type=LogQuery");
    }/*from www .j  a v  a2s  . co  m*/
    return mbeanName;
}