super(executionContext, singleRollupReadContext, rollupBatchWriter);
}
public void run() {
singleRollupReadContext.getWaitHist().update(System.currentTimeMillis() - startWait);
Granularity dstGran = singleRollupReadContext.getRollupGranularity();
Granularity srcGran;
try {
singleRollupReadContext.getRollupGranularity().finer();
} catch (GranularityException ex) {
executionContext.decrementReadCounter();
return; // no work to be done.
}
if (dstGran.isCoarser(Granularity.MIN_5)) {
srcGran = Granularity.MIN_5;
} else {
srcGran = Granularity.FULL;
}
if (log.isDebugEnabled()) {
log.debug("Executing histogram rollup from {} for {} {}", new Object[] {
srcGran.shortName(),
singleRollupReadContext.getRange().toString(),
singleRollupReadContext.getLocator()});
}
Timer.Context timerContext = singleRollupReadContext.getExecuteTimer().time();
try {
// Read data and compute rollup
Points<HistogramRollup> input;
Rollup rollup = null;
ColumnFamily<Locator, Long> srcCF;
ColumnFamily<Locator, Long> dstCF = CassandraModel.getColumnFamily(HistogramRollup.class, dstGran);
RollupType rollupType = RollupType.fromString((String) rollupTypeCache.get(singleRollupReadContext.getLocator(),
MetricMetadata.ROLLUP_TYPE.name().toLowerCase()));
if (rollupType != RollupType.BF_BASIC) { // Do not compute histogram for statsd metrics.
executionContext.decrementReadCounter();
timerContext.stop();
return;
}
if (srcGran == Granularity.MIN_5) {
srcCF = CassandraModel.CF_METRICS_FULL;
} else {
// Coarser histograms are always computed from 5 MIN histograms for error minimization
srcCF = CassandraModel.CF_METRICS_HIST_5M;
}
Timer.Context calcrollupContext = calcTimer.time();
try {
input = AstyanaxReader.getInstance().getDataToRoll(
HistogramRollup.class,
singleRollupReadContext.getLocator(),
singleRollupReadContext.getRange(),
srcCF);
// next, compute the rollup.
rollup = RollupRunnable.getRollupComputer(RollupType.BF_HISTOGRAMS, srcGran).compute(input);
} finally {
calcrollupContext.stop();
}
if (rollup != null) {
rollupBatchWriter.enqueueRollupForWrite(new SingleRollupWriteContext(rollup, singleRollupReadContext, dstCF));
}
RollupService.lastRollupTime.set(System.currentTimeMillis());
} catch (Throwable th) {
log.error("Histogram rollup failed; Locator : ", singleRollupReadContext.getLocator()
+ ", Source Granularity: " + srcGran.name());
} finally {
executionContext.decrementReadCounter();
timerContext.stop();
}
}