com.google.common.collect.EvictingQueue#create ( )源码实例Demo

下面列出了com.google.common.collect.EvictingQueue#create ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
}
 
源代码2 项目: aliyun-log-java-producer   文件: ProducerBatch.java
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;
}
 
源代码3 项目: java-timeseries   文件: ArimaProcess.java
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()));
}
 
源代码4 项目: che   文件: MessagesReSender.java
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);
  }
}
 
源代码5 项目: besu   文件: PendingTransactions.java
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");
}
 
源代码6 项目: adaptive-alerting   文件: SmaPointForecaster.java
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);
    }
}
 
源代码7 项目: adaptive-alerting   文件: EdmxDetector.java
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;
}
 
源代码8 项目: datacollector   文件: SystemProcessImpl.java
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);
  }
}
 
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);
}
 
源代码10 项目: dcos-commons   文件: OfferOutcomeTrackerV2.java
public OfferOutcomeSummary() {
  this.acceptedCount = 0;
  this.rejectedCount = 0;
  this.outcomes = EvictingQueue.create(DEFAULT_CAPACITY);
  this.failureReasons = new HashMap<>();
  this.rejectedAgents = new HashMap<>();
}
 
源代码11 项目: attic-aurora   文件: TimeSeriesRepositoryImpl.java
TimeSeriesImpl(String name) {
  this.name = name;
  samples = EvictingQueue.create(retainedSampleLimit);
}
 
@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);
}
 
源代码13 项目: opencensus-java   文件: RecordEventsSpanImpl.java
TraceEvents(int maxNumEvents) {
  events = EvictingQueue.create(maxNumEvents);
}
 
private Bucket(int numSamples) {
  sampledSpansQueue = EvictingQueue.create(numSamples);
  notSampledSpansQueue = EvictingQueue.create(numSamples);
}
 
源代码15 项目: opencensus-java   文件: QueueMetricProducer.java
private QueueMetricProducer(int bufferSize) {
  synchronized (monitor) {
    bufferedMetrics = EvictingQueue.<Metric>create(bufferSize);
  }
}
 
源代码16 项目: pulsar   文件: SourceStatsManager.java
@Override
public EvictingQueue<InstanceCommunication.FunctionStatus.ExceptionInformation> getLatestSinkExceptions() {
    return EvictingQueue.create(0);
}
 
源代码17 项目: vjtools   文件: MoreQueues.java
/**
 * LRUQueue, 如果Queue已满,则删除最旧的元素.
 * 
 * 内部实现是ArrayDeque
 */
public static <E> EvictingQueue<E> createLRUQueue(int maxSize) {
	return EvictingQueue.create(maxSize);
}
 
源代码18 项目: synapse   文件: MessageTrace.java
/**
 * 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;
}
 
源代码19 项目: synapse   文件: OnHeapRingBufferMessageStore.java
/**
 * 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);
}
 
源代码20 项目: j360-dubbo-app-all   文件: QueueUtil.java
/**
 * LRUQueue, 如果Queue已满,则删除最旧的元素.
 * 
 * 内部实现是ArrayDeque
 */
public static <E> EvictingQueue<E> createLRUQueue(int maxSize) {
	return EvictingQueue.create(maxSize);
}