Java Code Examples for org.apache.hadoop.metrics2.util.MBeans

The following examples show how to use org.apache.hadoop.metrics2.util.MBeans. These examples are extracted from open source projects. 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 Project: hadoop-ozone   Source File: SCMPipelineManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void close() throws IOException {
  if (scheduler != null) {
    scheduler.close();
    scheduler = null;
  }

  if(pmInfoBean != null) {
    MBeans.unregister(this.pmInfoBean);
    pmInfoBean = null;
  }

  SCMPipelineMetrics.unRegister();

  // shutdown pipeline provider.
  pipelineFactory.shutdown();
}
 
Example 2
Source Project: hadoop-ozone   Source File: HddsUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register the provided MBean with additional JMX ObjectName properties.
 * If additional properties are not supported then fallback to registering
 * without properties.
 *
 * @param serviceName - see {@link MBeans#register}
 * @param mBeanName - see {@link MBeans#register}
 * @param jmxProperties - additional JMX ObjectName properties.
 * @param mBean - the MBean to register.
 * @return the named used to register the MBean.
 */
public static ObjectName registerWithJmxProperties(
    String serviceName, String mBeanName, Map<String, String> jmxProperties,
    Object mBean) {
  try {

    // Check support for registering with additional properties.
    final Method registerMethod = MBeans.class.getMethod(
        "register", String.class, String.class,
        Map.class, Object.class);

    return (ObjectName) registerMethod.invoke(
        null, serviceName, mBeanName, jmxProperties, mBean);

  } catch (NoSuchMethodException | IllegalAccessException |
      InvocationTargetException e) {

    // Fallback
    if (LOG.isTraceEnabled()) {
      LOG.trace("Registering MBean {} without additional properties {}",
          mBeanName, jmxProperties);
    }
    return MBeans.register(serviceName, mBeanName, mBean);
  }
}
 
Example 3
Source Project: hadoop-ozone   Source File: RDBStore.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void close() throws IOException {

  for (final ColumnFamilyHandle handle : handleTable.values()) {
    handle.close();
  }

  if (statMBeanName != null) {
    MBeans.unregister(statMBeanName);
    statMBeanName = null;
  }

  RDBMetrics.unRegister();
  if (db != null) {
    db.close();
  }

  if (dbOptions != null) {
    dbOptions.close();
  }

  if (writeOptions != null) {
    writeOptions.close();
  }
}
 
Example 4
Source Project: hadoop   Source File: JournalNode.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Stop the daemon with the given status code
 * @param rc the status code with which to exit (non-zero
 * should indicate an error)
 */
public void stop(int rc) {
  this.resultCode = rc;
  
  if (rpcServer != null) { 
    rpcServer.stop();
  }

  if (httpServer != null) {
    try {
      httpServer.stop();
    } catch (IOException ioe) {
      LOG.warn("Unable to stop HTTP server for " + this, ioe);
    }
  }
  
  for (Journal j : journalsById.values()) {
    IOUtils.cleanup(LOG, j);
  }

  if (journalNodeInfoBeanName != null) {
    MBeans.unregister(journalNodeInfoBeanName);
    journalNodeInfoBeanName = null;
  }
}
 
Example 5
Source Project: hadoop   Source File: MetricsSystemImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public synchronized boolean shutdown() {
  LOG.debug("refCount="+ refCount);
  if (refCount <= 0) {
    LOG.debug("Redundant shutdown", new Throwable());
    return true; // already shutdown
  }
  if (--refCount > 0) return false;
  if (monitoring) {
    try { stop(); }
    catch (Exception e) {
      LOG.warn("Error stopping the metrics system", e);
    }
  }
  allSources.clear();
  allSinks.clear();
  callbacks.clear();
  namedCallbacks.clear();
  if (mbeanName != null) {
    MBeans.unregister(mbeanName);
    mbeanName = null;
  }
  LOG.info(prefix +" metrics system shutdown complete.");
  return true;
}
 
Example 6
Source Project: big-c   Source File: JournalNode.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Stop the daemon with the given status code
 * @param rc the status code with which to exit (non-zero
 * should indicate an error)
 */
public void stop(int rc) {
  this.resultCode = rc;
  
  if (rpcServer != null) { 
    rpcServer.stop();
  }

  if (httpServer != null) {
    try {
      httpServer.stop();
    } catch (IOException ioe) {
      LOG.warn("Unable to stop HTTP server for " + this, ioe);
    }
  }
  
  for (Journal j : journalsById.values()) {
    IOUtils.cleanup(LOG, j);
  }

  if (journalNodeInfoBeanName != null) {
    MBeans.unregister(journalNodeInfoBeanName);
    journalNodeInfoBeanName = null;
  }
}
 
Example 7
Source Project: big-c   Source File: MetricsSystemImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public synchronized boolean shutdown() {
  LOG.debug("refCount="+ refCount);
  if (refCount <= 0) {
    LOG.debug("Redundant shutdown", new Throwable());
    return true; // already shutdown
  }
  if (--refCount > 0) return false;
  if (monitoring) {
    try { stop(); }
    catch (Exception e) {
      LOG.warn("Error stopping the metrics system", e);
    }
  }
  allSources.clear();
  allSinks.clear();
  callbacks.clear();
  namedCallbacks.clear();
  if (mbeanName != null) {
    MBeans.unregister(mbeanName);
    mbeanName = null;
  }
  LOG.info(prefix +" metrics system shutdown complete.");
  return true;
}
 
Example 8
Source Project: hadoop-ozone   Source File: SCMConnectionManager.java    License: Apache License 2.0 5 votes vote down vote up
public SCMConnectionManager(ConfigurationSource conf) {
  this.mapLock = new ReentrantReadWriteLock();
  Long timeOut = getScmRpcTimeOutInMilliseconds(conf);
  this.rpcTimeout = timeOut.intValue();
  this.scmMachines = new HashMap<>();
  this.conf = conf;
  jmxBean = MBeans.register("HddsDatanode",
      "SCMConnectionManager",
      this);
}
 
Example 9
Source Project: hadoop-ozone   Source File: SCMConnectionManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void close() throws IOException {
  getValues().forEach(endpointStateMachine
      -> IOUtils.cleanupWithLogger(LOG, endpointStateMachine));
  if (jmxBean != null) {
    MBeans.unregister(jmxBean);
    jmxBean = null;
  }
}
 
Example 10
Source Project: hadoop-ozone   Source File: SCMPipelineManager.java    License: Apache License 2.0 5 votes vote down vote up
protected SCMPipelineManager(ConfigurationSource conf,
    NodeManager nodeManager,
    Table<PipelineID, Pipeline> pipelineStore,
    EventPublisher eventPublisher,
    PipelineStateManager pipelineStateManager,
    PipelineFactory pipelineFactory)
    throws IOException {
  this.lock = new ReentrantReadWriteLock();
  this.pipelineStore = pipelineStore;
  this.conf = conf;
  this.pipelineFactory = pipelineFactory;
  this.stateManager = pipelineStateManager;
  // TODO: See if thread priority needs to be set for these threads
  scheduler = new Scheduler("RatisPipelineUtilsThread", false, 1);
  this.backgroundPipelineCreator =
      new BackgroundPipelineCreator(this, scheduler, conf);
  this.eventPublisher = eventPublisher;
  this.nodeManager = nodeManager;
  this.metrics = SCMPipelineMetrics.create();
  this.pmInfoBean = MBeans.register("SCMPipelineManager",
      "SCMPipelineManagerInfo", this);
  this.pipelineWaitDefaultTimeout = conf.getTimeDuration(
      HddsConfigKeys.HDDS_PIPELINE_REPORT_INTERVAL,
      HddsConfigKeys.HDDS_PIPELINE_REPORT_INTERVAL_DEFAULT,
      TimeUnit.MILLISECONDS);
  this.isInSafeMode = new AtomicBoolean(conf.getBoolean(
      HddsConfigKeys.HDDS_SCM_SAFEMODE_ENABLED,
      HddsConfigKeys.HDDS_SCM_SAFEMODE_ENABLED_DEFAULT));
  // Pipeline creation is only allowed after the safemode prechecks have
  // passed, eg sufficient nodes have registered.
  this.pipelineCreationAllowed = new AtomicBoolean(!this.isInSafeMode.get());
}
 
Example 11
Source Project: hadoop-ozone   Source File: BlockManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param conf - configuration.
 * @param scm
 * @throws IOException
 */
public BlockManagerImpl(final ConfigurationSource conf,
                        final StorageContainerManager scm) {
  Objects.requireNonNull(scm, "SCM cannot be null");
  this.pipelineManager = scm.getPipelineManager();
  this.containerManager = scm.getContainerManager();

  this.containerSize = (long)conf.getStorageSize(
      ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE,
      ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT,
      StorageUnit.BYTES);

  mxBean = MBeans.register("BlockManager", "BlockManagerImpl", this);

  // SCM block deleting transaction log and deleting service.
  deletedBlockLog = new DeletedBlockLogImpl(conf, scm.getContainerManager(),
      scm.getScmMetadataStore());
  long svcInterval =
      conf.getTimeDuration(OZONE_BLOCK_DELETING_SERVICE_INTERVAL,
          OZONE_BLOCK_DELETING_SERVICE_INTERVAL_DEFAULT,
          TimeUnit.MILLISECONDS);
  long serviceTimeout =
      conf.getTimeDuration(
          OZONE_BLOCK_DELETING_SERVICE_TIMEOUT,
          OZONE_BLOCK_DELETING_SERVICE_TIMEOUT_DEFAULT,
          TimeUnit.MILLISECONDS);
  blockDeletingService =
      new SCMBlockDeletingService(deletedBlockLog, containerManager,
          scm.getScmNodeManager(), scm.getEventQueue(), svcInterval,
          serviceTimeout, conf);
  safeModePrecheck = new SafeModePrecheck(conf);
}
 
Example 12
Source Project: hadoop-ozone   Source File: BlockManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Close the resources for BlockManager.
 *
 * @throws IOException
 */
@Override
public void close() throws IOException {
  if (deletedBlockLog != null) {
    deletedBlockLog.close();
  }
  blockDeletingService.shutdown();
  if (mxBean != null) {
    MBeans.unregister(mxBean);
    mxBean = null;
  }
}
 
Example 13
Source Project: hadoop-ozone   Source File: ReplicationActivityStatus.java    License: Apache License 2.0 5 votes vote down vote up
public void start() {
  try {
    this.jmxObjectName =
        MBeans.register(
            "StorageContainerManager", "ReplicationActivityStatus", this);
  } catch (Exception ex) {
    LOG.error("JMX bean for ReplicationActivityStatus can't be registered",
        ex);
  }
}
 
Example 14
Source Project: hadoop-ozone   Source File: RocksDBStore.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void close() throws IOException {
  if (statMBeanName != null) {
    MBeans.unregister(statMBeanName);
    statMBeanName = null;
  }
  if (db != null) {
    db.close();
    db = null;
  }

}
 
Example 15
Source Project: hadoop   Source File: NameNode.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Stop all NameNode threads and wait for all to finish.
 */
public void stop() {
  synchronized(this) {
    if (stopRequested)
      return;
    stopRequested = true;
  }
  try {
    if (state != null) {
      state.exitState(haContext);
    }
  } catch (ServiceFailedException e) {
    LOG.warn("Encountered exception while exiting state ", e);
  } finally {
    stopCommonServices();
    if (metrics != null) {
      metrics.shutdown();
    }
    if (namesystem != null) {
      namesystem.shutdown();
    }
    if (nameNodeStatusBeanName != null) {
      MBeans.unregister(nameNodeStatusBeanName);
      nameNodeStatusBeanName = null;
    }
    if (this.spanReceiverHost != null) {
      this.spanReceiverHost.closeReceivers();
    }
  }
}
 
Example 16
Source Project: hadoop   Source File: FsDatasetImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Register the FSDataset MBean using the name
 *        "hadoop:service=DataNode,name=FSDatasetState-<datanodeUuid>"
 */
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");
}
 
Example 17
Source Project: hadoop   Source File: FsDatasetImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override // FsDatasetSpi
public void shutdown() {
  fsRunning = false;

  ((LazyWriter) lazyWriter.getRunnable()).stop();
  lazyWriter.interrupt();

  if (mbeanName != null) {
    MBeans.unregister(mbeanName);
  }
  
  if (asyncDiskService != null) {
    asyncDiskService.shutdown();
  }

  if (asyncLazyPersistService != null) {
    asyncLazyPersistService.shutdown();
  }
  
  if(volumes != null) {
    volumes.shutdown();
  }

  try {
    lazyWriter.join();
  } catch (InterruptedException ie) {
    LOG.warn("FsDatasetImpl.shutdown ignoring InterruptedException " +
             "from LazyWriter.join");
  }
}
 
Example 18
Source Project: hadoop   Source File: MetricsSourceAdapter.java    License: Apache License 2.0 5 votes vote down vote up
synchronized void startMBeans() {
  if (mbeanName != null) {
    LOG.warn("MBean "+ name +" already initialized!");
    LOG.debug("Stacktrace: ", new Throwable());
    return;
  }
  mbeanName = MBeans.register(prefix, name, this);
  LOG.debug("MBean for source "+ name +" registered.");
}
 
Example 19
Source Project: big-c   Source File: NameNode.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Stop all NameNode threads and wait for all to finish.
 */
public void stop() {
  synchronized(this) {
    if (stopRequested)
      return;
    stopRequested = true;
  }
  try {
    if (state != null) {
      state.exitState(haContext);
    }
  } catch (ServiceFailedException e) {
    LOG.warn("Encountered exception while exiting state ", e);
  } finally {
    stopCommonServices();
    if (metrics != null) {
      metrics.shutdown();
    }
    if (namesystem != null) {
      namesystem.shutdown();
    }
    if (nameNodeStatusBeanName != null) {
      MBeans.unregister(nameNodeStatusBeanName);
      nameNodeStatusBeanName = null;
    }
    if (this.spanReceiverHost != null) {
      this.spanReceiverHost.closeReceivers();
    }
  }
}
 
Example 20
Source Project: big-c   Source File: FsDatasetImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Register the FSDataset MBean using the name
 *        "hadoop:service=DataNode,name=FSDatasetState-<datanodeUuid>"
 */
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");
}
 
Example 21
Source Project: big-c   Source File: FsDatasetImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override // FsDatasetSpi
public void shutdown() {
  fsRunning = false;

  ((LazyWriter) lazyWriter.getRunnable()).stop();
  lazyWriter.interrupt();

  if (mbeanName != null) {
    MBeans.unregister(mbeanName);
  }
  
  if (asyncDiskService != null) {
    asyncDiskService.shutdown();
  }

  if (asyncLazyPersistService != null) {
    asyncLazyPersistService.shutdown();
  }
  
  if(volumes != null) {
    volumes.shutdown();
  }

  try {
    lazyWriter.join();
  } catch (InterruptedException ie) {
    LOG.warn("FsDatasetImpl.shutdown ignoring InterruptedException " +
             "from LazyWriter.join");
  }
}
 
Example 22
Source Project: big-c   Source File: MetricsSourceAdapter.java    License: Apache License 2.0 5 votes vote down vote up
synchronized void startMBeans() {
  if (mbeanName != null) {
    LOG.warn("MBean "+ name +" already initialized!");
    LOG.debug("Stacktrace: ", new Throwable());
    return;
  }
  mbeanName = MBeans.register(prefix, name, this);
  LOG.debug("MBean for source "+ name +" registered.");
}
 
Example 23
Source Project: hbase   Source File: IncrementCoalescer.java    License: Apache License 2.0 5 votes vote down vote up
public IncrementCoalescer(ThriftHBaseServiceHandler hand) {
  this.handler = hand;
  LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
  pool = new ThreadPoolExecutor(CORE_POOL_SIZE, CORE_POOL_SIZE, 50,
      TimeUnit.MILLISECONDS, queue,
      Threads.newDaemonThreadFactory("IncrementCoalescer"));
  MBeans.register("thrift", "Thrift", this);
}
 
Example 24
Source Project: hadoop-ozone   Source File: StorageContainerManager.java    License: Apache License 2.0 4 votes vote down vote up
private void unregisterMXBean() {
  if (this.scmInfoBeanName != null) {
    MBeans.unregister(this.scmInfoBeanName);
    this.scmInfoBeanName = null;
  }
}
 
Example 25
Source Project: hadoop-ozone   Source File: ReplicationActivityStatus.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void close() throws IOException {
  if (this.jmxObjectName != null) {
    MBeans.unregister(jmxObjectName);
  }
}
 
Example 26
Source Project: hadoop-ozone   Source File: SCMNodeManager.java    License: Apache License 2.0 4 votes vote down vote up
private void registerMXBean() {
  this.nmInfoBean = MBeans.register("SCMNodeManager",
      "SCMNodeManagerInfo", this);
}
 
Example 27
Source Project: hadoop-ozone   Source File: SCMNodeManager.java    License: Apache License 2.0 4 votes vote down vote up
private void unregisterMXBean() {
  if (this.nmInfoBean != null) {
    MBeans.unregister(this.nmInfoBean);
    this.nmInfoBean = null;
  }
}
 
Example 28
Source Project: hadoop-ozone   Source File: SCMNodeStorageStatMap.java    License: Apache License 2.0 4 votes vote down vote up
private void registerMXBean() {
  this.scmNodeStorageInfoBean = MBeans.register("StorageContainerManager",
      "scmNodeStorageInfo", this);
}
 
Example 29
Source Project: hadoop-ozone   Source File: SCMNodeStorageStatMap.java    License: Apache License 2.0 4 votes vote down vote up
private void unregisterMXBean() {
  if(this.scmNodeStorageInfoBean != null) {
    MBeans.unregister(this.scmNodeStorageInfoBean);
    this.scmNodeStorageInfoBean = null;
  }
}
 
Example 30
Source Project: hadoop-ozone   Source File: OzoneManager.java    License: Apache License 2.0 4 votes vote down vote up
private void unregisterMXBean() {
  if (this.omInfoBeanName != null) {
    MBeans.unregister(this.omInfoBeanName);
    this.omInfoBeanName = null;
  }
}