Skip to content

Commit

Permalink
[HWKMETRICS-200] add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
John Sanda committed Aug 13, 2015
1 parent a4ed252 commit 807e094
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@
*/
package org.hawkular.metrics.core.impl;

import static java.util.Collections.singletonList;

import static org.hawkular.metrics.core.api.MetricType.COUNTER;
import static org.hawkular.metrics.core.api.MetricType.COUNTER_RATE;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.hawkular.metrics.core.api.DataPoint;
import org.hawkular.metrics.core.api.Metric;
import org.hawkular.metrics.core.api.MetricId;
import org.hawkular.metrics.core.api.MetricsService;
import org.hawkular.metrics.tasks.api.Task2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import rx.Observable;
import rx.functions.Action1;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static java.util.Collections.singletonList;
import static org.hawkular.metrics.core.api.MetricType.COUNTER;
import static org.hawkular.metrics.core.api.MetricType.COUNTER_RATE;

/**
* @author jsanda
* Calculates and persists rates for all counter metrics of a single tenant.
*/
public class GenerateRate implements Action1<Task2> {

Expand All @@ -48,6 +50,7 @@ public GenerateRate(MetricsService metricsService) {

@Override
public void call(Task2 task) {
// TODO We need to make this fault tolerant. See HWKMETRICS-213 for details.
logger.info("Generating rate for {}", task);
String tenant = task.getParameters().get("tenant");
long start = task.getTrigger().getTriggerTime();
Expand All @@ -64,19 +67,21 @@ public void call(Task2 task) {
CountDownLatch latch = new CountDownLatch(1);

updates.subscribe(
aVoid -> {},
aVoid -> {
},
t -> {
logger.warn("There was an error persisting rates for {tenant= " + tenant + ", start= " +
start + ", end= " + end + "}", t);
start + ", end= " + end + "}", t);
latch.countDown();
},
() -> {
logger.debug("Successfully persisted rate data for {tenant= " + tenant + ", start= " +
start + ", end= " + end + "}");
start + ", end= " + end + "}");
latch.countDown();
}
);

// TODO We do not want to block but have to for now. See HWKMETRICS-214 for details.
try {
latch.await();
} catch (InterruptedException e) {
Expand Down

0 comments on commit 807e094

Please sign in to comment.