Search in sources :

Example 1 with MetricsLoggerTask

use of org.apache.hadoop.hdfs.server.common.MetricsLoggerTask in project hadoop by apache.

the class DataNode method startMetricsLogger.

/**
   * Start a timer to periodically write DataNode metrics to the log file. This
   * behavior can be disabled by configuration.
   *
   */
protected void startMetricsLogger() {
    long metricsLoggerPeriodSec = getConf().getInt(DFS_DATANODE_METRICS_LOGGER_PERIOD_SECONDS_KEY, DFS_DATANODE_METRICS_LOGGER_PERIOD_SECONDS_DEFAULT);
    if (metricsLoggerPeriodSec <= 0) {
        return;
    }
    MetricsLoggerTask.makeMetricsLoggerAsync(METRICS_LOG);
    // Schedule the periodic logging.
    metricsLoggerTimer = new ScheduledThreadPoolExecutor(1);
    metricsLoggerTimer.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    metricsLoggerTimer.scheduleWithFixedDelay(new MetricsLoggerTask(METRICS_LOG, "DataNode", (short) 0), metricsLoggerPeriodSec, metricsLoggerPeriodSec, TimeUnit.SECONDS);
}
Also used : MetricsLoggerTask(org.apache.hadoop.hdfs.server.common.MetricsLoggerTask) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Example 2 with MetricsLoggerTask

use of org.apache.hadoop.hdfs.server.common.MetricsLoggerTask in project hadoop by apache.

the class NameNode method startMetricsLogger.

/**
   * Start a timer to periodically write NameNode metrics to the log
   * file. This behavior can be disabled by configuration.
   * @param conf
   */
protected void startMetricsLogger(Configuration conf) {
    long metricsLoggerPeriodSec = conf.getInt(DFS_NAMENODE_METRICS_LOGGER_PERIOD_SECONDS_KEY, DFS_NAMENODE_METRICS_LOGGER_PERIOD_SECONDS_DEFAULT);
    if (metricsLoggerPeriodSec <= 0) {
        return;
    }
    MetricsLoggerTask.makeMetricsLoggerAsync(MetricsLog);
    // Schedule the periodic logging.
    metricsLoggerTimer = new ScheduledThreadPoolExecutor(1);
    metricsLoggerTimer.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    metricsLoggerTimer.scheduleWithFixedDelay(new MetricsLoggerTask(MetricsLog, "NameNode", (short) 128), metricsLoggerPeriodSec, metricsLoggerPeriodSec, TimeUnit.SECONDS);
}
Also used : MetricsLoggerTask(org.apache.hadoop.hdfs.server.common.MetricsLoggerTask) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Aggregations

ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)2 MetricsLoggerTask (org.apache.hadoop.hdfs.server.common.MetricsLoggerTask)2