congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
OperationalStatsService
Code IndexAdd Tabnine to your IDE (free)

How to use
OperationalStatsService
in
co.cask.cdap.operations

Best Java code snippets using co.cask.cdap.operations.OperationalStatsService (Showing top 12 results out of 315)

origin: cdapio/cdap

@Override
protected void run() {
 while (isRunning()) {
  try {
   collectOperationalStats();
   if (!isRunning()) {
    // Need to check here before sleep as the collectOperationStats may swallow interrupted exception
    break;
   }
   TimeUnit.SECONDS.sleep(statsRefreshInterval);
  } catch (InterruptedException e) {
   // Expected on stopping. So just break the loop
   break;
  }
 }
}
origin: cdapio/cdap

@Override
protected void shutDown() throws Exception {
 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
 for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
  OperationalStats operationalStats = entry.getValue();
  ObjectName objectName = getObjectName(operationalStats);
  if (objectName == null) {
   LOG.warn("Found an operational extension with null service name and stat type while unregistering - {}. " +
         "Ignoring this extension.", operationalStats.getClass().getName());
   continue;
  }
  try {
   mbs.unregisterMBean(objectName);
  } catch (InstanceNotFoundException e) {
   LOG.warn("MBean {} not found while un-registering. Ignoring.", objectName);
  } catch (MBeanRegistrationException e) {
   LOG.warn("Error while un-registering MBean {}.", e);
  }
  operationalStats.destroy();
 }
 LOG.info("Successfully shutdown operational stats service.");
}
origin: co.cask.cdap/cdap-app-fabric

/**
 * Collects stats from all {@link OperationalStats}.
 */
private void collectOperationalStats() throws InterruptedException {
 LOG.trace("Running operational stats extension service iteration");
 for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
  if (!isRunning()) {
   return;
  }
  OperationalStats stats = entry.getValue();
  LOG.trace("Collecting stats for service {} of type {}", stats.getServiceName(), stats.getStatType());
  try {
   stats.collect();
  } catch (Throwable t) {
   Throwables.propagateIfInstanceOf(t, InterruptedException.class);
   Throwable rootCause = Throwables.getRootCause(t);
   if (rootCause instanceof ServiceUnavailableException || rootCause instanceof TException) {
    // Required service (for example DatasetService in case of ServiceUnavailableException
    // or Transaction Service in case of TException) is not running yet.
    // Return without logging.
    return;
   }
   if (rootCause instanceof InterruptedException) {
    throw (InterruptedException) rootCause;
   }
   READ_FAILURE_LOG.warn("Failed to collect stats for service {} of type {} due to {}",
              stats.getServiceName(), stats.getStatType(), rootCause.getMessage());
  }
 }
}
origin: cdapio/cdap

operationalStatsService.startAndWait();
origin: co.cask.cdap/cdap-standalone

operationalStatsService.stopAndWait();
origin: cdapio/cdap

/**
 * Collects stats from all {@link OperationalStats}.
 */
private void collectOperationalStats() throws InterruptedException {
 LOG.trace("Running operational stats extension service iteration");
 for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
  if (!isRunning()) {
   return;
  }
  OperationalStats stats = entry.getValue();
  LOG.trace("Collecting stats for service {} of type {}", stats.getServiceName(), stats.getStatType());
  try {
   stats.collect();
  } catch (Throwable t) {
   Throwables.propagateIfInstanceOf(t, InterruptedException.class);
   Throwable rootCause = Throwables.getRootCause(t);
   if (rootCause instanceof ServiceUnavailableException || rootCause instanceof TException) {
    // Required service (for example DatasetService in case of ServiceUnavailableException
    // or Transaction Service in case of TException) is not running yet.
    // Return without logging.
    return;
   }
   if (rootCause instanceof InterruptedException) {
    throw (InterruptedException) rootCause;
   }
   READ_FAILURE_LOG.warn("Failed to collect stats for service {} of type {} due to {}",
              stats.getServiceName(), stats.getStatType(), rootCause.getMessage());
  }
 }
}
origin: co.cask.cdap/cdap-standalone

operationalStatsService.startAndWait();
origin: cdapio/cdap

operationalStatsService.stopAndWait();
origin: co.cask.cdap/cdap-app-fabric

@Override
protected void run() {
 while (isRunning()) {
  try {
   collectOperationalStats();
   if (!isRunning()) {
    // Need to check here before sleep as the collectOperationStats may swallow interrupted exception
    break;
   }
   TimeUnit.SECONDS.sleep(statsRefreshInterval);
  } catch (InterruptedException e) {
   // Expected on stopping. So just break the loop
   break;
  }
 }
}
origin: co.cask.cdap/cdap-app-fabric

@Override
protected void shutDown() throws Exception {
 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
 for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
  OperationalStats operationalStats = entry.getValue();
  ObjectName objectName = getObjectName(operationalStats);
  if (objectName == null) {
   LOG.warn("Found an operational extension with null service name and stat type while unregistering - {}. " +
         "Ignoring this extension.", operationalStats.getClass().getName());
   continue;
  }
  try {
   mbs.unregisterMBean(objectName);
  } catch (InstanceNotFoundException e) {
   LOG.warn("MBean {} not found while un-registering. Ignoring.", objectName);
  } catch (MBeanRegistrationException e) {
   LOG.warn("Error while un-registering MBean {}.", e);
  }
  operationalStats.destroy();
 }
 LOG.info("Successfully shutdown operational stats service.");
}
origin: cdapio/cdap

/**
 * Registers all JMX {@link MXBean MXBeans} from {@link OperationalStats} extensions in the extensions directory.
 */
@Override
protected void startUp() throws Exception {
 runThread = Thread.currentThread();
 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
 for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
  OperationalStats operationalStats = entry.getValue();
  ObjectName objectName = getObjectName(operationalStats);
  if (objectName == null) {
   LOG.warn("Found an operational extension with null service name and stat type - {}. Ignoring this extension.",
        OperationalStats.class.getName());
   continue;
  }
  LOG.debug("Registering operational extension: {}; extension id: {}", operationalStats, entry.getKey());
  // initialize operational stats
  operationalStats.initialize(injector);
  // register MBean
  mbs.registerMBean(operationalStats, objectName);
 }
 LOG.info("Successfully started Operational Stats Service...");
}
origin: co.cask.cdap/cdap-app-fabric

/**
 * Registers all JMX {@link MXBean MXBeans} from {@link OperationalStats} extensions in the extensions directory.
 */
@Override
protected void startUp() throws Exception {
 runThread = Thread.currentThread();
 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
 for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
  OperationalStats operationalStats = entry.getValue();
  ObjectName objectName = getObjectName(operationalStats);
  if (objectName == null) {
   LOG.warn("Found an operational extension with null service name and stat type - {}. Ignoring this extension.",
        OperationalStats.class.getName());
   continue;
  }
  LOG.debug("Registering operational extension: {}; extension id: {}", operationalStats, entry.getKey());
  // initialize operational stats
  operationalStats.initialize(injector);
  // register MBean
  mbs.registerMBean(operationalStats, objectName);
 }
 LOG.info("Successfully started Operational Stats Service...");
}
co.cask.cdap.operationsOperationalStatsService

Javadoc

A service that registers OperationalStats extensions as JMX Beans. The Beans are registered with the JMX domain OperationalStatsUtils#JMX_DOMAIN with the following properties:
  1. OperationalStatsUtils#SERVICE_NAME_KEY = name of the service, as defined by OperationalStats#getServiceName();
  2. OperationalStatsUtils#STAT_TYPE_KEY = type of the stat; as defined by OperationalStats#getStatType()
It also updates the Beans periodically by calling their OperationalStats#collect() method.

Most used methods

  • collectOperationalStats
    Collects stats from all OperationalStats.
  • getObjectName
  • isRunning
  • startAndWait
  • stopAndWait

Popular in Java

  • Reading from database using SQL prepared statement
  • findViewById (Activity)
  • onCreateOptionsMenu (Activity)
  • onRequestPermissionsResult (Fragment)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now