Example usage for javax.management StandardMBean StandardMBean

List of usage examples for javax.management StandardMBean StandardMBean

Introduction

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

Prototype

protected StandardMBean(Class<?> mbeanInterface, boolean isMXBean) 

Source Link

Document

Make a DynamicMBean out of this, using the specified mbeanInterface class, and choosing whether the resulting MBean is an MXBean.

Usage

From source file:org.codice.ddf.registry.federationadmin.impl.FederationAdmin.java

private void configureMBean() {
    mbeanServer = ManagementFactory.getPlatformMBeanServer();

    try {//from w w w.  jav a2 s.c o  m
        objectName = new ObjectName(FederationAdminMBean.OBJECT_NAME);
    } catch (MalformedObjectNameException e) {
        LOGGER.info("Exception while creating object name: {}", FederationAdminMBean.OBJECT_NAME, e);
    }

    try {
        try {
            mbeanServer.registerMBean(new StandardMBean(this, FederationAdminMBean.class), objectName);
        } catch (InstanceAlreadyExistsException e) {
            mbeanServer.unregisterMBean(objectName);
            mbeanServer.registerMBean(new StandardMBean(this, FederationAdminMBean.class), objectName);
        }
    } catch (Exception e) {
        LOGGER.info("Could not register mbean.", e);
    }
}

From source file:org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset.java

/**
 * Register the FSDataset MBean using the name
 * "hadoop:service=DataNode,name=FSDatasetState-<storageid>"
 * We use storage id for MBean name since a minicluster within a single
 * Java VM may have multiple Simulated Datanodes.
 *//*from www .j a  v a2 s .c  om*/
void registerMBean(final String storageId) {
    // We wrap to bypass standard mbean naming convetion.
    // This wraping can be removed in java 6 as it is more flexible in 
    // package naming for mbeans and their impl.
    StandardMBean bean;

    try {
        bean = new StandardMBean(this, FSDatasetMBean.class);
        mbeanName = MBeans.register("DataNode", "FSDatasetState-" + storageId, bean);
    } catch (NotCompliantMBeanException e) {
        DataNode.LOG.warn("Error registering FSDatasetState MBean", e);
    }

    DataNode.LOG.info("Registered FSDatasetState MBean");
}

From source file:org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetImpl.java

/**
 * Register the FSDataset MBean using the name
 * "hadoop:service=DataNode,name=FSDatasetState-<datanodeUuid>"
 *///from ww w. j a v  a 2  s  . c  o m
void registerMBean(final String datanodeUuid) {
    // We wrap to bypass standard mbean naming convetion.
    // This wraping can be removed in java 6 as it is more flexible in 
    // package naming for mbeans and their impl.
    try {
        StandardMBean bean = new StandardMBean(this, FSDatasetMBean.class);
        mbeanName = MBeans.register("DataNode", "FSDatasetState-" + datanodeUuid, bean);
    } catch (NotCompliantMBeanException e) {
        LOG.warn("Error registering FSDatasetState MBean", e);
    }
    LOG.info("Registered FSDatasetState MBean");
}

From source file:org.apache.hadoop.hdfs.server.datanode.FSDataset.java

/**
 * Register the FSDataset MBean using the name
 *        "hadoop:service=DataNode,name=FSDatasetState-<storageid>"
 *//* w w  w . java 2s  . c  o m*/
void registerMBean(final String storageId) {
    // We wrap to bypass standard mbean naming convetion.
    // This wraping can be removed in java 6 as it is more flexible in
    // package naming for mbeans and their impl.
    StandardMBean bean;
    String storageName;
    if (storageId == null || storageId.equals("")) {// Temp fix for the uninitialized storage
        storageName = "UndefinedStorageId" + rand.nextInt();
    } else {
        storageName = storageId;
    }
    try {
        bean = new StandardMBean(this, FSDatasetMBean.class);
        mbeanName = MBeanUtil.registerMBean("DataNode", "FSDatasetState-" + storageName, bean);
        versionBeanName = VersionInfo.registerJMX("DataNode");
    } catch (NotCompliantMBeanException e) {
        e.printStackTrace();
    }

    DataNode.LOG.info("Registered FSDatasetStatusMBean");
}

From source file:org.apache.hadoop.dfs.FSNamesystem.java

/**
 * Register the FSNamesystem MBean/* www .j a  v  a2 s.com*/
 */
void registerMBean(Configuration conf) {
    // We wrap to bypass standard mbean naming convetion.
    // This wraping can be removed in java 6 as it is more flexible in 
    // package naming for mbeans and their impl.
    StandardMBean bean;
    try {
        myFSMetrics = new FSNamesystemMetrics(conf);
        bean = new StandardMBean(this, FSNamesystemMBean.class);
        mbeanName = MBeanUtil.registerMBean("NameNode", "FSNamesystemStatus", bean);
    } catch (NotCompliantMBeanException e) {
        e.printStackTrace();
    }

    LOG.info("Registered FSNamesystemStatusMBean");
}

From source file:org.apache.jxtadoop.hdfs.server.namenode.FSNamesystem.java

/**
 * Register the FSNamesystem MBean using the name
 *        "hadoop:service=NameNode,name=FSNamesystemState"
 *//*from  ww  w .  j  a v  a  2  s.  c  o m*/
void registerMBean(Configuration conf) {
    // We wrap to bypass standard mbean naming convention.
    // This wraping can be removed in java 6 as it is more flexible in 
    // package naming for mbeans and their impl.
    StandardMBean bean;
    try {
        myFSMetrics = new FSNamesystemMetrics(conf);
        bean = new StandardMBean(this, FSNamesystemMBean.class);
        mbeanName = MBeanUtil.registerMBean("NameNode", "FSNamesystemState", bean);
    } catch (NotCompliantMBeanException e) {
        e.printStackTrace();
    }

    LOG.info("Registered FSNamesystemStatusMBean");
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSNamesystem.java

/**
 * Register the FSNamesystem MBean using the name
 *        "hadoop:service=NameNode,name=FSNamesystemState"
 * Register the FSNamesystem MXBean using the name
 *        "hadoop:service=NameNode,name=NameNodeInfo"
 *//*  w ww.  jav a2 s  .co  m*/
void registerMBean(Configuration conf) {
    // We wrap to bypass standard mbean naming convention.
    // This wraping can be removed in java 6 as it is more flexible in 
    // package naming for mbeans and their impl.
    StandardMBean bean;
    try {
        bean = new StandardMBean(this, FSNamesystemMBean.class);
        mbeanName = MBeans.register("NameNode", "FSNamesystemState", bean);
    } catch (NotCompliantMBeanException e) {
        e.printStackTrace();
    }
    mxBean = MBeans.register("NameNode", "NameNodeInfo", this);

    LOG.info("Registered FSNamesystemStateMBean and NameNodeMXBean");
}