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

The following examples show how to use org.apache.hadoop.metrics2.util.MBeans. 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 File: MetricsSystemImpl.java    From hadoop with 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 #2
Source File: SCMPipelineManager.java    From hadoop-ozone with 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 #3
Source File: JournalNode.java    From hadoop with 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 #4
Source File: MetricsSystemImpl.java    From big-c with 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 #5
Source File: JournalNode.java    From big-c with 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 #6
Source File: HddsUtils.java    From hadoop-ozone with 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 #7
Source File: RDBStore.java    From hadoop-ozone with 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 #8
Source File: NameNode.java    From hadoop with 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 #9
Source File: NameNode.java    From big-c with 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 #10
Source File: MetricsSourceAdapter.java    From hadoop with 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 #11
Source File: FsDatasetImpl.java    From big-c with 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 #12
Source File: SCMConnectionManager.java    From hadoop-ozone with 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 #13
Source File: FsDatasetImpl.java    From big-c with 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 #14
Source File: FsDatasetImpl.java    From hadoop with 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 #15
Source File: FsDatasetImpl.java    From hadoop with 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 #16
Source File: MetricsSourceAdapter.java    From big-c with 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 #17
Source File: ReplicationActivityStatus.java    From hadoop-ozone with 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 #18
Source File: SCMConnectionManager.java    From hadoop-ozone with 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 #19
Source File: SCMPipelineManager.java    From hadoop-ozone with 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 #20
Source File: BlockManagerImpl.java    From hadoop-ozone with 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 #21
Source File: BlockManagerImpl.java    From hadoop-ozone with 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 #22
Source File: IncrementCoalescer.java    From hbase with 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 #23
Source File: RocksDBStore.java    From hadoop-ozone with 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 #24
Source File: FairCallQueue.java    From big-c with Apache License 2.0 4 votes vote down vote up
private MetricsProxy(String namespace) {
  MBeans.register(namespace, "FairCallQueue", this);
}
 
Example #25
Source File: DecayRpcScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
private MetricsProxy(String namespace) {
  MBeans.register(namespace, "DecayRpcScheduler", this);
}
 
Example #26
Source File: MetricsSystemImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void initSystemMBean() {
  checkNotNull(prefix, "prefix should not be null here!");
  if (mbeanName == null) {
    mbeanName = MBeans.register(prefix, MS_CONTROL_NAME, this);
  }
}
 
Example #27
Source File: DataNode.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void registerMXBean() {
  dataNodeInfoBeanName = MBeans.register("DataNode", "DataNodeInfo", this);
}
 
Example #28
Source File: MetricsSourceAdapter.java    From big-c with Apache License 2.0 4 votes vote down vote up
synchronized void stopMBeans() {
  if (mbeanName != null) {
    MBeans.unregister(mbeanName);
    mbeanName = null;
  }
}
 
Example #29
Source File: JournalNode.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * Register JournalNodeMXBean
 */
private void registerJNMXBean() {
  journalNodeInfoBeanName = MBeans.register("JournalNode", "JournalNodeInfo", this);
}
 
Example #30
Source File: SnapshotManager.java    From big-c with Apache License 2.0 4 votes vote down vote up
public void shutdown() {
  MBeans.unregister(mxBeanName);
  mxBeanName = null;
}