Java Code Examples for com.google.common.collect.EvictingQueue#create()
The following examples show how to use
com.google.common.collect.EvictingQueue#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KafkaIngestionHealthCheck.java From incubator-gobblin with Apache License 2.0 | 6 votes |
public KafkaIngestionHealthCheck(Config config, KafkaExtractorStatsTracker statsTracker) { this.config = config; this.slidingWindowSize = ConfigUtils.getInt(config, KAFKA_INGESTION_HEALTH_CHECK_SLIDING_WINDOW_SIZE_KEY, DEFAULT_KAFKA_INGESTION_HEALTH_CHECK_SLIDING_WINDOW_SIZE); this.ingestionLatencyThresholdMinutes = ConfigUtils.getLong(config, KAFKA_INGESTION_HEALTH_CHECK_LATENCY_THRESHOLD_MINUTES_KEY, DEFAULT_KAFKA_INGESTION_HEALTH_CHECK_LATENCY_THRESHOLD_MINUTES); this.consumptionRateDropOffFraction = ConfigUtils.getDouble(config, KAFKA_INGESTION_HEALTH_CHECK_CONSUMPTION_RATE_DROPOFF_FRACTION_KEY, DEFAULT_KAFKA_INGESTION_HEALTH_CHECK_CONSUMPTION_RATE_DROPOFF_FRACTION); this.expectedConsumptionRate = ConfigUtils.getDouble(config, KAFKA_INGESTION_HEALTH_CHECK_EXPECTED_CONSUMPTION_RATE_MBPS_KEY, DEFAULT_KAFKA_INGESTION_HEALTH_CHECK_EXPECTED_CONSUMPTION_RATE_MBPS); this.increasingLatencyCheckEnabled = ConfigUtils.getBoolean(config, KAFKA_INGESTION_HEALTH_CHECK_INCREASING_LATENCY_CHECK_ENABLED_KEY, DEFAULT_KAFKA_INGESTION_HEALTH_CHECK_INCREASING_LATENCY_CHECK_ENABLED); this.ingestionLatencies = EvictingQueue.create(this.slidingWindowSize); this.consumptionRateMBps = EvictingQueue.create(this.slidingWindowSize); EventBus eventBus; try { eventBus = EventBusFactory.get(ContainerHealthCheckFailureEvent.CONTAINER_HEALTH_CHECK_EVENT_BUS_NAME, SharedResourcesBrokerFactory.getImplicitBroker()); } catch (IOException e) { log.error("Could not find EventBus instance for container health check", e); eventBus = null; } this.eventBus = eventBus; this.statsTracker = statsTracker; }
Example 2
Source File: ArimaProcess.java From java-timeseries with MIT License | 6 votes |
private ArimaProcess(Builder builder) { this.coefficients = builder.coefficients; this.distribution = builder.distribution; this.period = builder.period; this.seasonalCycle = builder.seasonalCycle; this.startTime = builder.startTime; this.currentTime = startTime; int seasonalFrequency = (int) builder.period.frequencyPer(builder.seasonalCycle); double[] arSarCoeffs = ArimaCoefficients.expandArCoefficients(coefficients.arCoeffs(), coefficients.seasonalARCoeffs(), seasonalFrequency); double[] maSmaCoeffs = ArimaCoefficients.expandMaCoefficients(coefficients.maCoeffs(), coefficients.seasonalMACoeffs(), seasonalFrequency); this.errors = EvictingQueue.create(maSmaCoeffs.length); this.diffSeries = EvictingQueue.create(arSarCoeffs.length); this.series = EvictingQueue.create(coefficients.d() + coefficients.D() * seasonalFrequency); this.maPoly = LagPolynomial.movingAverage(maSmaCoeffs); this.arPoly = LagPolynomial.autoRegressive(arSarCoeffs); this.diffPoly = LagPolynomial.differences(coefficients.d()) .times(LagPolynomial.seasonalDifferences(seasonalFrequency, coefficients.D())); }
Example 3
Source File: ProducerBatch.java From aliyun-log-java-producer with Apache License 2.0 | 6 votes |
public ProducerBatch( GroupKey groupKey, String packageId, int batchSizeThresholdInBytes, int batchCountThreshold, int maxReservedAttempts, long nowMs) { this.groupKey = groupKey; this.packageId = packageId; this.createdMs = nowMs; this.batchSizeThresholdInBytes = batchSizeThresholdInBytes; this.batchCountThreshold = batchCountThreshold; this.curBatchCount = 0; this.curBatchSizeInBytes = 0; this.reservedAttempts = EvictingQueue.create(maxReservedAttempts); this.attemptCount = 0; }
Example 4
Source File: PendingTransactions.java From besu with Apache License 2.0 | 5 votes |
public PendingTransactions( final int maxTransactionRetentionHours, final int maxPendingTransactions, final int maxPooledTransactionHashes, final Clock clock, final MetricsSystem metricsSystem, final Supplier<BlockHeader> chainHeadHeaderSupplier, final Optional<EIP1559> eip1559, final Percentage priceBump) { this.maxTransactionRetentionHours = maxTransactionRetentionHours; this.maxPendingTransactions = maxPendingTransactions; this.clock = clock; this.newPooledHashes = EvictingQueue.create(maxPooledTransactionHashes); this.chainHeadHeaderSupplier = chainHeadHeaderSupplier; this.transactionReplacementHandler = new TransactionPoolReplacementHandler(eip1559, priceBump); final LabelledMetric<Counter> transactionAddedCounter = metricsSystem.createLabelledCounter( BesuMetricCategory.TRANSACTION_POOL, "transactions_added_total", "Count of transactions added to the transaction pool", "source"); localTransactionAddedCounter = transactionAddedCounter.labels("local"); remoteTransactionAddedCounter = transactionAddedCounter.labels("remote"); localTransactionHashesAddedCounter = transactionAddedCounter.labels("pool"); transactionRemovedCounter = metricsSystem.createLabelledCounter( BesuMetricCategory.TRANSACTION_POOL, "transactions_removed_total", "Count of transactions removed from the transaction pool", "source", "operation"); }
Example 5
Source File: OfferOutcomeTrackerV2.java From dcos-commons with Apache License 2.0 | 5 votes |
public OfferOutcomeSummary() { this.acceptedCount = 0; this.rejectedCount = 0; this.outcomes = EvictingQueue.create(DEFAULT_CAPACITY); this.failureReasons = new HashMap<>(); this.rejectedAgents = new HashMap<>(); }
Example 6
Source File: BoostVHTActiveLearningNode.java From incubator-samoa with Apache License 2.0 | 5 votes |
public BoostVHTActiveLearningNode(double[] classObservation, int parallelism_hint, SplittingOption splitOption, int maxBufferSize) { super(classObservation, parallelism_hint); weightSeenAtLastSplitEvaluation = this.getWeightSeen(); id = VerticalHoeffdingTree.LearningNodeIdGenerator.generate(); attributeContentEventKeys = new HashMap<>(); isSplitting = false; parallelismHint = parallelism_hint; this.splittingOption = splitOption; this.maxBufferSize = maxBufferSize; this.buffer = EvictingQueue.create(maxBufferSize); }
Example 7
Source File: SystemProcessImpl.java From datacollector with Apache License 2.0 | 5 votes |
public SimpleFileTailer(File file) { this.file = file; this.history = EvictingQueue.create(2500); this.inbuf = new byte[8192 * 8]; try { this.randomAccessFile = new RandomAccessFile(file, "r"); } catch (FileNotFoundException e) { throw new RuntimeException(Utils.format("Unexpected error reading output file '{}': {}", file, e), e); } }
Example 8
Source File: EdmxDetector.java From adaptive-alerting with Apache License 2.0 | 5 votes |
public EdmxDetector(UUID uuid, EdmxHyperparams hyperparams, boolean trusted) { notNull(uuid, "uuid can't be null"); notNull(hyperparams, "hyperparams can't be null"); hyperparams.validate(); log.info("Creating EdmxDetector: uuid={}, hyperparams={}", uuid, hyperparams); this.uuid = uuid; this.hyperparams = hyperparams; this.buffer = EvictingQueue.create(hyperparams.getBufferSize()); this.trusted = trusted; }
Example 9
Source File: SmaPointForecaster.java From adaptive-alerting with Apache License 2.0 | 5 votes |
public SmaPointForecaster(SmaPointForecasterParams params) { notNull(params, "params can't be null"); params.validate(); this.params = params; this.periodOfValues = EvictingQueue.create(params.getLookBackPeriod()); if (params.getInitialPeriodOfValues() != null) { params.getInitialPeriodOfValues().forEach(this::updateMeanEstimate); } }
Example 10
Source File: MessagesReSender.java From che with Eclipse Public License 2.0 | 5 votes |
public void resend(String endpointId) { Queue<DelayedMessage> delayedMessages = delayedMessageRegistry.remove(endpointId); if (delayedMessages == null || delayedMessages.isEmpty()) { return; } Optional<Session> sessionOptional = registry.get(endpointId); if (!sessionOptional.isPresent()) { return; } Queue<DelayedMessage> backingQueue = EvictingQueue.create(delayedMessages.size()); while (!delayedMessages.isEmpty()) { backingQueue.offer(delayedMessages.poll()); } Session session = sessionOptional.get(); for (DelayedMessage delayedMessage : backingQueue) { if (session.isOpen()) { session.getAsyncRemote().sendText(delayedMessage.message); } else { delayedMessages.add(delayedMessage); } } if (!delayedMessages.isEmpty()) { delayedMessageRegistry.put(endpointId, delayedMessages); } }
Example 11
Source File: TimeSeriesRepositoryImpl.java From attic-aurora with Apache License 2.0 | 4 votes |
TimeSeriesImpl(String name) { this.name = name; samples = EvictingQueue.create(retainedSampleLimit); }
Example 12
Source File: SerialDiffPipelineAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public InternalAggregation reduce(InternalAggregation aggregation, ReduceContext reduceContext) { InternalHistogram histo = (InternalHistogram) aggregation; List<? extends InternalHistogram.Bucket> buckets = histo.getBuckets(); InternalHistogram.Factory<? extends InternalHistogram.Bucket> factory = histo.getFactory(); List newBuckets = new ArrayList<>(); EvictingQueue<Double> lagWindow = EvictingQueue.create(lag); int counter = 0; for (InternalHistogram.Bucket bucket : buckets) { Double thisBucketValue = resolveBucketValue(histo, bucket, bucketsPaths()[0], gapPolicy); InternalHistogram.Bucket newBucket = bucket; counter += 1; // Still under the initial lag period, add nothing and move on Double lagValue; if (counter <= lag) { lagValue = Double.NaN; } else { lagValue = lagWindow.peek(); // Peek here, because we rely on add'ing to always move the window } // Normalize null's to NaN if (thisBucketValue == null) { thisBucketValue = Double.NaN; } // Both have values, calculate diff and replace the "empty" bucket if (!Double.isNaN(thisBucketValue) && !Double.isNaN(lagValue)) { double diff = thisBucketValue - lagValue; List<InternalAggregation> aggs = new ArrayList<>(eagerTransform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); aggs.add(new InternalSimpleValue(name(), diff, formatter, new ArrayList<PipelineAggregator>(), metaData())); newBucket = factory.createBucket(bucket.getKey(), bucket.getDocCount(), new InternalAggregations( aggs), bucket.getKeyed(), bucket.getFormatter()); } newBuckets.add(newBucket); lagWindow.add(thisBucketValue); } return factory.create(newBuckets, histo); }
Example 13
Source File: RecordEventsSpanImpl.java From opencensus-java with Apache License 2.0 | 4 votes |
TraceEvents(int maxNumEvents) { events = EvictingQueue.create(maxNumEvents); }
Example 14
Source File: InProcessSampledSpanStoreImpl.java From opencensus-java with Apache License 2.0 | 4 votes |
private Bucket(int numSamples) { sampledSpansQueue = EvictingQueue.create(numSamples); notSampledSpansQueue = EvictingQueue.create(numSamples); }
Example 15
Source File: QueueMetricProducer.java From opencensus-java with Apache License 2.0 | 4 votes |
private QueueMetricProducer(int bufferSize) { synchronized (monitor) { bufferedMetrics = EvictingQueue.<Metric>create(bufferSize); } }
Example 16
Source File: SourceStatsManager.java From pulsar with Apache License 2.0 | 4 votes |
@Override public EvictingQueue<InstanceCommunication.FunctionStatus.ExceptionInformation> getLatestSinkExceptions() { return EvictingQueue.create(0); }
Example 17
Source File: MoreQueues.java From vjtools with Apache License 2.0 | 2 votes |
/** * LRUQueue, 如果Queue已满,则删除最旧的元素. * * 内部实现是ArrayDeque */ public static <E> EvictingQueue<E> createLRUQueue(int maxSize) { return EvictingQueue.create(maxSize); }
Example 18
Source File: MessageTrace.java From synapse with Apache License 2.0 | 2 votes |
/** * Creates a new instance with specified capacity. * * @param capacity the size of the underlying ring buffer. */ public MessageTrace(final int capacity) { traceEntries = EvictingQueue.create(capacity); this.capacity = capacity; }
Example 19
Source File: OnHeapRingBufferMessageStore.java From synapse with Apache License 2.0 | 2 votes |
/** * Creates a new instance with specified capacity. * * @param capacity the size of the underlying ring buffer. */ public OnHeapRingBufferMessageStore(final int capacity) { this.entries = EvictingQueue.create(capacity); }
Example 20
Source File: QueueUtil.java From j360-dubbo-app-all with Apache License 2.0 | 2 votes |
/** * LRUQueue, 如果Queue已满,则删除最旧的元素. * * 内部实现是ArrayDeque */ public static <E> EvictingQueue<E> createLRUQueue(int maxSize) { return EvictingQueue.create(maxSize); }