Java Code Examples for org.apache.hadoop.metrics.util.MetricsBase#pushMetric()

The following examples show how to use org.apache.hadoop.metrics.util.MetricsBase#pushMetric() . 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: ClusterManagerMetrics.java    From RDFS with Apache License 2.0 6 votes vote down vote up
@Override
public void doUpdates(MetricsContext context) {
  // Get the fair scheduler metrics
  if (scheduler != null) {
    scheduler.submitMetrics(metricsRecord);
  }

  // Get the number of pending calls.
  setNumPendingCalls(sessionNotifier.getNumPendingCalls());

  // Not synchronized on the ClusterManagerMetrics object.
  // The list of metrics in the registry is modified only in the constructor.
  // And pushMetrics() is thread-safe.
  for (MetricsBase m : registry.getMetricsList()) {
    m.pushMetric(metricsRecord);
  }

  metricsRecord.update();
}
 
Example 2
Source File: TaskTrackerMetricsInst.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 */
@Override
public void doUpdates(MetricsContext unused) {
  synchronized (this) {
    for (MetricsBase metricsBase : registry.getMetricsList()) {
      metricsBase.pushMetric(metricsRecord);
    }

    metricsRecord.setMetric("aveMapSlotRefillMsecs",
      tt.getAveMapSlotRefillMsecs());
    metricsRecord.setMetric("aveReduceSlotRefillMsecs",
      tt.getAveReduceSlotRefillMsecs());

    metricsRecord.setMetric("maps_running", tt.getRunningMaps());
    metricsRecord.setMetric("reduces_running", tt.getRunningReduces());
    metricsRecord.setMetric("mapTaskSlots", (short)tt.getMaxActualMapTasks());
    metricsRecord.setMetric("reduceTaskSlots",
                                 (short)tt.getMaxActualReduceTasks());
    metricsRecord.incrMetric("map_tasks_completed",
        numCompletedMapTasks);
    metricsRecord.incrMetric("reduce_tasks_completed",
        numCompletedReduceTasks);
    metricsRecord.incrMetric("tasks_completed", numCompletedTasks);
    metricsRecord.incrMetric("tasks_failed_timeout", timedoutTasks);
    metricsRecord.incrMetric("tasks_failed_ping", tasksFailedPing);
    metricsRecord.setMetric("unaccounted_memory", unaccountedMemory);

    numCompletedMapTasks = 0;
    numCompletedReduceTasks = 0;
    numCompletedTasks = 0;
    timedoutTasks = 0;
    tasksFailedPing = 0;
  }
    metricsRecord.update();
}
 
Example 3
Source File: TaskErrorCollector.java    From RDFS with Apache License 2.0 5 votes vote down vote up
@Override
public void doUpdates(MetricsContext context) {
  synchronized (this) {
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 4
Source File: RaidNodeMetrics.java    From RDFS with Apache License 2.0 5 votes vote down vote up
@Override
public void doUpdates(MetricsContext context) {
  synchronized (this) {
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 5
Source File: RpcMetrics.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Push the metrics to the monitoring subsystem on doUpdate() call.
 */
public void doUpdates(MetricsContext context) {
  
  synchronized (this) {
    // ToFix - fix server to use the following two metrics directly so
    // the metrics do not have be copied here.
    numOpenConnections.set(myServer.getNumOpenConnections());
    callQueueLen.set(myServer.getCallQueueLen());
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 6
Source File: DFSClientMetrics.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 */
public void doUpdates(MetricsContext unused) {
	synchronized (this) {
		for (MetricsBase m : registry.getMetricsList()) {
			m.pushMetric(metricsRecord);
		}
	}
	metricsRecord.setMetric("client.ls.calls", getAndResetLsCalls());
	metricsRecord.update();
}
 
Example 7
Source File: FSNamesystemMetrics.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 * We set the metrics value within  this function before pushing it out. 
 * FSNamesystem updates its own local variables which are
 * light weight compared to Metrics counters. 
 *
 * Some of the metrics are explicity casted to int. Few metrics collectors
 * do not handle long values. It is safe to cast to int for now as all these
 * values fit in int value.
 * Metrics related to DFS capacity are stored in bytes which do not fit in 
 * int, so they are rounded to GB
 */
public void doUpdates(MetricsContext unused) {
  /** 
   * ToFix
   * If the metrics counter were instead stored in the metrics objects themselves
   * we could avoid copying the values on each update.
   */
  synchronized (this) {
    filesTotal.set((int) fsNameSystem.getFilesAndDirectoriesTotal());
    blocksTotal.set((int)fsNameSystem.getBlocksTotal());
    diskSpaceTotalGB.set(roundBytesToGBytes(fsNameSystem.getDiskSpaceTotal()));
    capacityTotalGB.set(roundBytesToGBytes(fsNameSystem.getCapacityTotal()));
    capacityUsedGB.set(roundBytesToGBytes(fsNameSystem.getCapacityUsed()));
    capacityRemainingGB.set(roundBytesToGBytes(fsNameSystem.
                                             getCapacityRemaining()));
    totalLoad.set(fsNameSystem.getTotalLoad());
    corruptBlocks.set((int)fsNameSystem.getCorruptReplicaBlocks());
    excessBlocks.set((int)fsNameSystem.getExcessBlocks());
    pendingDeletionBlocks.set((int)fsNameSystem.getPendingDeletionBlocks());
    pendingReplicationBlocks.set((int)fsNameSystem.
                                 getPendingReplicationBlocks());
    underReplicatedBlocks.set((int)fsNameSystem.getUnderReplicatedBlocks());
    scheduledReplicationBlocks.set((int)fsNameSystem.
                                    getScheduledReplicationBlocks());
    missingBlocks.set((int)fsNameSystem.getMissingBlocksCount());
    blockCapacity.set(fsNameSystem.getBlockCapacity());
    numLeases.set(fsNameSystem.leaseManager.countLease());
    numUnderConstructionFiles.set(fsNameSystem.leaseManager.countPath());
    upgradeTime.set(fsNameSystem.getUpgradeTime());
    
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 8
Source File: NameNodeMetrics.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 */
public void doUpdates(MetricsContext unused) {
  synchronized (this) {
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 9
Source File: HighTideNodeMetrics.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 */
public void doUpdates(MetricsContext unused) {
  synchronized (this) {
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 10
Source File: DataNodeMetrics.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 */
public void doUpdates(MetricsContext unused) {
  synchronized (this) {
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 11
Source File: SepMetrics.java    From hbase-indexer with Apache License 2.0 5 votes vote down vote up
@Override
public void doUpdates(MetricsContext unused) {
    synchronized (this) {
        for (MetricsBase m : metricsRegistry.getMetricsList()) {
            m.pushMetric(metricsRecord);
        }
    }
    metricsRecord.update();
}
 
Example 12
Source File: RpcMetrics.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Push the metrics to the monitoring subsystem on doUpdate() call.
 */
public void doUpdates(MetricsContext context) {
  
  synchronized (this) {
    // ToFix - fix server to use the following two metrics directly so
    // the metrics do not have be copied here.
    numOpenConnections.set(myServer.getNumOpenConnections());
    callQueueLen.set(myServer.getCallQueueLen());
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 13
Source File: FSNamesystemMetrics.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 * We set the metrics value within  this function before pushing it out. 
 * FSNamesystem updates its own local variables which are
 * light weight compared to Metrics counters. 
 *
 * Some of the metrics are explicity casted to int. Few metrics collectors
 * do not handle long values. It is safe to cast to int for now as all these
 * values fit in int value.
 * Metrics related to DFS capacity are stored in bytes which do not fit in 
 * int, so they are rounded to GB
 */
public void doUpdates(MetricsContext unused) {
  /** 
   * ToFix
   * If the metrics counter were instead stored in the metrics objects themselves
   * we could avoid copying the values on each update.
   */
  synchronized (this) {
    FSNamesystem fsNameSystem = FSNamesystem.getFSNamesystem();
    filesTotal.set((int)fsNameSystem.getFilesTotal());
    blocksTotal.set((int)fsNameSystem.getBlocksTotal());
    capacityTotalGB.set(roundBytesToGBytes(fsNameSystem.getCapacityTotal()));
    capacityUsedGB.set(roundBytesToGBytes(fsNameSystem.getCapacityUsed()));
    capacityRemainingGB.set(roundBytesToGBytes(fsNameSystem.
                                             getCapacityRemaining()));
    totalLoad.set(fsNameSystem.getTotalLoad());
    corruptBlocks.set((int)fsNameSystem.getCorruptReplicaBlocks());
    excessBlocks.set((int)fsNameSystem.getExcessBlocks());
    pendingDeletionBlocks.set((int)fsNameSystem.getPendingDeletionBlocks());
    pendingReplicationBlocks.set((int)fsNameSystem.
                                 getPendingReplicationBlocks());
    underReplicatedBlocks.set((int)fsNameSystem.getUnderReplicatedBlocks());
    scheduledReplicationBlocks.set((int)fsNameSystem.
                                    getScheduledReplicationBlocks());
    missingBlocks.set((int)fsNameSystem.getMissingBlocksCount());
    blockCapacity.set(fsNameSystem.getBlockCapacity());

    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 14
Source File: NameNodeMetrics.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 */
public void doUpdates(MetricsContext unused) {
  synchronized (this) {
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 15
Source File: DataNodeMetrics.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Since this object is a registered updater, this method will be called
 * periodically, e.g. every 5 seconds.
 */
public void doUpdates(MetricsContext unused) {
  synchronized (this) {
    for (MetricsBase m : registry.getMetricsList()) {
      m.pushMetric(metricsRecord);
    }
  }
  metricsRecord.update();
}
 
Example 16
Source File: MultiTaskTracker.java    From RDFS with Apache License 2.0 4 votes vote down vote up
@Override
public void doUpdates(MetricsContext context) {
  LOG.info("Updating metrics");
  int numTrackers = trackerList.size();
  long totalMapRefill = 0;
  long totalReduceRefill = 0;
  int totalRunningMaps = 0;
  int totalRunningReduces = 0;
  int totalMapSlots = 0;
  int totalReduceSlots = 0;
  for (TaskTracker tracker : trackerList) {
    totalMapRefill += tracker.getAveMapSlotRefillMsecs();
    totalReduceRefill += tracker.getAveReduceSlotRefillMsecs();
    totalRunningMaps += tracker.getRunningMaps();
    totalRunningReduces += tracker.getRunningReduces();
    totalMapSlots += tracker.getMaxActualMapTasks();
    totalReduceSlots += tracker.getMaxActualReduceTasks();

    // If the metrics exists, aggregate the task launch msecs for all
    // trackers
    TaskTrackerInstrumentation instrumentation =
        tracker.getTaskTrackerInstrumentation();
    if (instrumentation != null) {
      MetricsTimeVaryingRate taskLaunchMsecs =
          instrumentation.getTaskLaunchMsecs();
      if (taskLaunchMsecs != null) {
        taskLaunchMsecs.pushMetric(null);
        aggTaskLaunchMsecs.inc(
            taskLaunchMsecs.getPreviousIntervalAverageTime());
      }
    }
  }
  long avgMapRefill = totalMapRefill / numTrackers;
  long avgReduceRefill = totalReduceRefill / numTrackers;
  metricsRecord.setMetric("aveMapSlotRefillMsecs", avgMapRefill);
  metricsRecord.setMetric("aveReduceSlotRefillMsecs", avgReduceRefill);
  metricsRecord.setMetric("maps_running", totalRunningMaps);
  metricsRecord.setMetric("reduces_running", totalRunningReduces);
  metricsRecord.setMetric("mapTaskSlots", totalMapSlots);
  metricsRecord.setMetric("reduceTaskSlots", totalReduceSlots);

  for (MetricsBase metricsBase : registry.getMetricsList()) {
    metricsBase.pushMetric(metricsRecord);
  }

  metricsRecord.update();
}