private RollupsQueryParams(long from, long to, Set<BasicRollupsOutputSerializer.MetricStat> stats) { if (from >= to) { throw new IllegalArgumentException("'from' timestamp has to be strictly less than 'to'."); } this.stats = stats; this.range = new Range(from, to); this.points = 0; this.resolution = Resolution.FULL; }
Iterable<Range> ranges = Range.rangesForInterval(gran, range.getStart(), range.getStop()); ArrayList<SingleRollupWriteContext> writeContexts = new ArrayList<SingleRollupWriteContext>();
@Override public void run() { Timer.Context rollupTimerContext = rollupTimer.time(); try { Rollup.Type rollupComputer = RollupRunnable.getRollupComputer(RollupType.BF_BASIC, Granularity.FULL); Rollup rollup = rollupComputer.compute(points); writer.enqueueRollupForWrite(new SingleRollupWriteContext(rollup, loc, Granularity.MIN_5, CassandraModel.CF_METRICS_5M, range.getStart())); log.info("Calculated and queued rollup for "+loc+" within range "+range); } catch (Exception e) { // I want to be very harsh with exceptions encountered while validating and computing rollups. Just stop everything. log.error("Error encountered while validating and calculating rollups", e); rollupValidationAndComputeFailed.inc(); RollupGenerator.rollupExecutors.shutdownNow(); OutOFBandRollup.getRollupGeneratorThread().interrupt(); // Stop the monitoring thread OutOFBandRollup.getMonitoringThread().interrupt(); // Stop the file handler thread pool from sending data to buildstore FileHandler.handlerThreadPool.shutdownNow(); throw new RuntimeException(e); } finally { rollupTimerContext.stop(); } } }
metricData = GetDataByPoints(tenantId, metricName, params.getRange().getStart(), params.getRange().getStop(), params.getPoints(), params.getStats()); } else if (params.isGetByResolution()) { metricData = GetDataByResolution(tenantId, metricName, params.getRange().getStart(), params.getRange().getStop(), params.getResolution(), params.getStats()); } else { throw new InvalidRequestException("Invalid rollups query. Neither points nor resolution specified.");
work.add(new ReRollWork(locator, gran, new Range(START_MILLIS, STOP_MILLIS)));
try { RollupsQueryParams params = PlotRequestParser.parseParams(requestWithParams.getQueryParams()); Map<Locator, MetricData> results = getRollupByGranularity(tenantId, locators, params.getRange().getStart(), params.getRange().getStop(), params.getGranularity(tenantId)); JSONObject metrics = serializer.transformRollupData(results, params.getStats()); final JsonElement element = parser.parse(metrics.toString());
public synchronized boolean hasNewFiles() { // see if there are any files since lastMarker. BlobStoreContext ctx = ContextBuilder.newBuilder(provider) .credentials(user, key) .overrides(new Properties() {{ setProperty(LocationConstants.PROPERTY_ZONE, zone); }}) .buildView(BlobStoreContext.class); BlobStore store = ctx.getBlobStore(); ListContainerOptions options = new ListContainerOptions().maxResults(batchSize).afterMarker(lastMarker); PageSet<? extends StorageMetadata> pages = store.list(container, options); log.debug("Saw {} new files since {}", pages.size() == batchSize ? "many" : Integer.toString(pages.size()), lastMarker); boolean emptiness = getBlobsWithinRange(pages).isEmpty(); if(emptiness) { log.warn("No file found within range {}", new Range(START_TIME, STOP_TIME)); } else { log.debug("New files found within range {}", new Range(START_TIME, STOP_TIME)); } return !emptiness; }
long snappedMillis = Granularity.MIN_5.snapMillis(timestamp); Range rangeOfThisTimestamp = new Range(snappedMillis, snappedMillis + Granularity.MIN_5.milliseconds() - 1);