use of com.codahale.metrics.Snapshot in project incubator-gobblin by apache.
the class OutputStreamReporter method printHistogram.
private void printHistogram(Histogram histogram) {
this.outputBufferPrintStream.printf(locale, " count = %d%n", histogram.getCount());
Snapshot snapshot = histogram.getSnapshot();
this.outputBufferPrintStream.printf(locale, " min = %d%n", snapshot.getMin());
this.outputBufferPrintStream.printf(locale, " max = %d%n", snapshot.getMax());
this.outputBufferPrintStream.printf(locale, " mean = %2.2f%n", snapshot.getMean());
this.outputBufferPrintStream.printf(locale, " stddev = %2.2f%n", snapshot.getStdDev());
this.outputBufferPrintStream.printf(locale, " median = %2.2f%n", snapshot.getMedian());
this.outputBufferPrintStream.printf(locale, " 75%% <= %2.2f%n", snapshot.get75thPercentile());
this.outputBufferPrintStream.printf(locale, " 95%% <= %2.2f%n", snapshot.get95thPercentile());
this.outputBufferPrintStream.printf(locale, " 98%% <= %2.2f%n", snapshot.get98thPercentile());
this.outputBufferPrintStream.printf(locale, " 99%% <= %2.2f%n", snapshot.get99thPercentile());
this.outputBufferPrintStream.printf(locale, " 99.9%% <= %2.2f%n", snapshot.get999thPercentile());
}
use of com.codahale.metrics.Snapshot in project Singularity by HubSpot.
the class SingularityTaskReconciliation method checkReconciliation.
private void checkReconciliation(final long reconciliationStart, final Collection<SingularityTaskId> remainingTaskIds, final int numTimes, final Histogram histogram) {
final List<SingularityTaskStatusHolder> taskStatusHolders = taskManager.getLastActiveTaskStatusesFor(remainingTaskIds);
final List<MesosTaskStatusObject> taskStatuses = Lists.newArrayListWithCapacity(taskStatusHolders.size());
for (SingularityTaskStatusHolder taskStatusHolder : taskStatusHolders) {
if (taskStatusHolder.getServerId().equals(serverId) && taskStatusHolder.getServerTimestamp() > reconciliationStart) {
histogram.update(taskStatusHolder.getServerTimestamp() - reconciliationStart);
continue;
}
if (taskStatusHolder.getTaskStatus().isPresent()) {
LOG.debug("Re-requesting task status for {}", taskStatusHolder.getTaskId());
taskStatuses.add(taskStatusHolder.getTaskStatus().get());
} else {
TaskStatus.Builder fakeTaskStatusBuilder = TaskStatus.newBuilder().setTaskId(TaskID.newBuilder().setValue(taskStatusHolder.getTaskId().getId())).setState(TaskState.TASK_STARTING);
if (taskStatusHolder.getAgentId().isPresent()) {
fakeTaskStatusBuilder.setAgentId(AgentID.newBuilder().setValue(taskStatusHolder.getAgentId().get()));
}
LOG.info("Task {} didn't have a TaskStatus yet, submitting fake status", taskStatusHolder.getTaskId());
taskStatuses.add(mesosProtosUtils.taskStatusFromProtos(fakeTaskStatusBuilder.build()));
}
}
if (taskStatuses.isEmpty()) {
LOG.info("Task reconciliation ended after {} checks and {}", numTimes, JavaUtils.duration(reconciliationStart));
final Snapshot snapshot = histogram.getSnapshot();
stateManager.saveTaskReconciliationStatistics(new SingularityTaskReconciliationStatistics(reconciliationStart, System.currentTimeMillis() - reconciliationStart, numTimes, histogram.getCount(), snapshot.getMax(), snapshot.getMean(), snapshot.getMin(), snapshot.getMedian(), snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(), snapshot.get99thPercentile(), snapshot.get999thPercentile(), snapshot.getStdDev()));
isRunningReconciliation.set(false);
return;
}
LOG.info("Requesting reconciliation of {} taskStatuses, task reconciliation has been running for {}", taskStatuses.size(), JavaUtils.duration(reconciliationStart));
schedulerClient.reconcile(taskStatuses.stream().map(t -> Task.newBuilder().setTaskId(MesosProtosUtils.toTaskId(t.getTaskId())).setAgentId(MesosProtosUtils.toAgentId(t.getAgentId())).build()).collect(Collectors.toList()));
scheduleReconciliationCheck(reconciliationStart, remainingTaskIds, numTimes, histogram);
}
Aggregations