NIFI-2309 Correcting AmbariReportingTask so it reports total task duration as seconds and as nano-seconds

This closes #672

Signed-off-by: jpercivall <joepercivall@yahoo.com>
This commit is contained in:
Bryan Bende 2016-07-18 17:32:44 -04:00 committed by jpercivall
parent deb2819bfb
commit 8e2663c54d
3 changed files with 11 additions and 3 deletions

View File

@ -31,7 +31,8 @@ public interface MetricNames {
String BYTES_READ = "BytesReadLast5Minutes";
String BYTES_WRITTEN = "BytesWrittenLast5Minutes";
String ACTIVE_THREADS = "ActiveThreads";
String TOTAL_TASK_DURATION = "TotalTaskDurationSeconds";
String TOTAL_TASK_DURATION_SECONDS = "TotalTaskDurationSeconds";
String TOTAL_TASK_DURATION_NANOS = "TotalTaskDurationNanoSeconds";
// JVM Metrics
String JVM_UPTIME = "jvm.uptime";

View File

@ -46,7 +46,13 @@ public class MetricsService {
metrics.put(MetricNames.BYTES_READ, String.valueOf(status.getBytesRead()));
metrics.put(MetricNames.BYTES_WRITTEN, String.valueOf(status.getBytesWritten()));
metrics.put(MetricNames.ACTIVE_THREADS, String.valueOf(status.getActiveThreadCount()));
metrics.put(MetricNames.TOTAL_TASK_DURATION, String.valueOf(calculateProcessingNanos(status)));
final long durationNanos = calculateProcessingNanos(status);
metrics.put(MetricNames.TOTAL_TASK_DURATION_NANOS, String.valueOf(durationNanos));
final long durationSeconds = TimeUnit.SECONDS.convert(durationNanos, TimeUnit.NANOSECONDS);
metrics.put(MetricNames.TOTAL_TASK_DURATION_SECONDS, String.valueOf(durationSeconds));
return metrics;
}

View File

@ -71,7 +71,8 @@ public class TestMetricsService {
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION));
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
}
@Test