Tabnine Logo
TimelineAggregator
Code IndexAdd Tabnine to your IDE (free)

How to use
TimelineAggregator
in
com.ning.billing.meter.timeline.aggregator

Best Java code snippets using com.ning.billing.meter.timeline.aggregator.TimelineAggregator (Showing top 9 results out of 315)

origin: com.ning.billing/killbill-meter

  @Override
  public void run() {
    getAndProcessTimelineAggregationCandidates();
  }
},
origin: com.ning.billing/killbill-meter

for (int aggregationLevel = 0; aggregationLevel < config.getMaxAggregationLevel(); aggregationLevel++) {
  final long startingAggregatesCreated = aggregatesCreated.get();
  final Map<String, Long> initialCounters = captureAggregatorCounters();
  final int chunkCountIndex = aggregationLevel >= chunkCountsToAggregate.length ? chunkCountsToAggregate.length - 1 : aggregationLevel;
  final int chunksToAggregate = Integer.parseInt(chunkCountsToAggregate[chunkCountIndex]);
  streamingAggregateLevel(aggregationLevel, chunksToAggregate);
  final Map<String, Long> counterDeltas = subtractFromAggregatorCounters(initialCounters);
  final long netAggregatesCreated = aggregatesCreated.get() - startingAggregatesCreated;
  if (netAggregatesCreated == 0) {
origin: com.ning.billing/killbill-meter

aggregatesCreated.addAndGet(aggregateTimelineCandidates(sourceTimelineCandidates, aggregationLevel, chunksToAggregate));
performWrites();
origin: com.ning.billing/killbill-meter

private int aggregateTimelineCandidates(final List<TimelineChunk> timelineChunkCandidates, final int aggregationLevel, final int chunksToAggregate) {
  final TimelineChunk firstCandidate = timelineChunkCandidates.get(0);
  final int sourceId = firstCandidate.getSourceId();
  final int metricId = firstCandidate.getMetricId();
  log.debug("For sourceId {}, metricId {}, looking to aggregate {} candidates in {} chunks",
       new Object[]{sourceId, metricId, timelineChunkCandidates.size(), chunksToAggregate});
  int aggregatesCreated = 0;
  int chunkIndex = 0;
  while (timelineChunkCandidates.size() >= chunkIndex + chunksToAggregate) {
    final List<TimelineChunk> chunkCandidates = timelineChunkCandidates.subList(chunkIndex, chunkIndex + chunksToAggregate);
    chunkIndex += chunksToAggregate;
    timelineChunksCombined.addAndGet(chunksToAggregate);
    try {
      aggregateHostSampleChunks(chunkCandidates, aggregationLevel);
    } catch (IOException e) {
      log.error(String.format("IOException aggregating {} chunks, sourceId %s, metricId %s, looking to aggregate %s candidates in %s chunks",
                  new Object[]{firstCandidate.getSourceId(), firstCandidate.getMetricId(), timelineChunkCandidates.size(), chunksToAggregate}), e);
    }
    aggregatesCreated++;
  }
  return aggregatesCreated;
}
origin: com.ning.billing/killbill-meter

private void performWrites() {
  final InternalCallContext context = createCallContext();
  // This is the atomic operation: bulk insert the new aggregated TimelineChunk objects, and delete
  // or invalidate the ones that were aggregated.  This should be very fast.
  final long startWriteTime = System.currentTimeMillis();
  aggregatorSqlDao.begin();
  timelineDao.bulkInsertTimelineChunks(chunksToWrite, context);
  if (config.getDeleteAggregatedChunks()) {
    aggregatorSqlDao.deleteTimelineChunks(chunkIdsToInvalidateOrDelete, context);
  } else {
    aggregatorSqlDao.makeTimelineChunksInvalid(chunkIdsToInvalidateOrDelete, context);
  }
  aggregatorSqlDao.commit();
  msWritingDb.addAndGet(System.currentTimeMillis() - startWriteTime);
  timelineChunksWritten.addAndGet(chunksToWrite.size());
  timelineChunksInvalidatedOrDeleted.addAndGet(chunkIdsToInvalidateOrDelete.size());
  chunksToWrite.clear();
  chunkIdsToInvalidateOrDelete.clear();
  final long sleepMs = config.getAggregationSleepBetweenBatches().getMillis();
  if (sleepMs > 0) {
    final long timeBeforeSleep = System.currentTimeMillis();
    try {
      Thread.sleep(sleepMs);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
    msSpentSleeping.addAndGet(System.currentTimeMillis() - timeBeforeSleep);
  }
  timelineChunkBatchesProcessed.incrementAndGet();
}
origin: com.ning.billing/killbill-meter

performWrites();
origin: com.ning.billing/killbill-meter

@BeforeMethod(groups = "mysql")
public void setUp() throws Exception {
  timelineDao = new DefaultTimelineDao(getDBI());
  final Properties properties = System.getProperties();
  properties.put("killbill.usage.timelines.chunksToAggregate", "2,2");
  final MeterConfig config = new ConfigurationObjectFactory(properties).build(MeterConfig.class);
  aggregator = new TimelineAggregator(getDBI(), timelineDao, timelineCoder, sampleCoder, config, internalCallContextFactory);
}
origin: com.ning.billing/killbill-meter

  @Override
  public void run() {
    getAndProcessTimelineAggregationCandidates();
  }
});
origin: com.ning.billing/killbill-meter

checkSamplesForATimeline(124, 66, 2);
aggregator.getAndProcessTimelineAggregationCandidates();
com.ning.billing.meter.timeline.aggregatorTimelineAggregator

Javadoc

This class runs a thread that periodically looks for unaggregated timelines. When it finds them, it combines them intelligently as if they were originally a single sequence of times.

Most used methods

  • getAndProcessTimelineAggregationCandidates
    This method aggregates candidate timelines
  • <init>
  • aggregateHostSampleChunks
    The sequence of events is: * Build the aggregated TimelineChunk object, and save it, setting not_
  • aggregateTimelineCandidates
  • captureAggregatorCounters
  • createCallContext
  • performWrites
  • streamingAggregateLevel
  • subtractFromAggregatorCounters

Popular in Java

  • Reactive rest calls using spring rest template
  • getSupportFragmentManager (FragmentActivity)
  • setContentView (Activity)
  • onRequestPermissionsResult (Fragment)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • BoxLayout (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now