當前位置: 首頁>>代碼示例>>Java>>正文


Java EvictingQueue.create方法代碼示例

本文整理匯總了Java中com.google.common.collect.EvictingQueue.create方法的典型用法代碼示例。如果您正苦於以下問題:Java EvictingQueue.create方法的具體用法?Java EvictingQueue.create怎麽用?Java EvictingQueue.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.EvictingQueue的用法示例。


在下文中一共展示了EvictingQueue.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: start

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
@Override
public void start() {
    if (this.encoder == null) {
        addError("No encoder set for the appender named ["+ name +"].");
        return;
    }

    try {
        encoder.init(stream);
    } catch (IOException ignored) {
    }

    EvictingQueue<String> q = EvictingQueue.create(limit);
    logList = Queues.synchronizedQueue(q);

    isLoggingOn = true;

    super.start();
}
 
開發者ID:Quiq,項目名稱:dropwizard-wiretap,代碼行數:20,代碼來源:WiretapAppender.java

示例2: ArimaProcess

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
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()));
}
 
開發者ID:signaflo,項目名稱:java-timeseries,代碼行數:24,代碼來源:ArimaProcess.java

示例3: ExtensibleOpMode

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
/**
 * Bootstraps the Extensible OpMode to the Xtensible library
 */
public ExtensibleOpMode() {
    super();

    loopCount = 0;
    skipNextLoop = 0;

    loopManager = new ExtensibleLoopManager();
    loopTimes = EvictingQueue.create(50);

    Log.i(TAG, "Starting OpMode: " + this.getClass().getSimpleName());
}
 
開發者ID:MHS-FIRSTrobotics,項目名稱:RadicalRobotics2017,代碼行數:15,代碼來源:ExtensibleOpMode.java

示例4: UsageStatsNodePeriodical

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
@Inject
public UsageStatsNodePeriodical(UsageStatsNodeService usageStatsNodeService,
                                NodeId nodeId,
                                ServerStatus serverStatus,
                                UsageStatsConfiguration config,
                                ClusterConfigService clusterConfigService,
                                @CompressingHttpClient OkHttpClient httpClient,
                                @SmileObjectMapper ObjectMapper objectMapper) {
    this(
            usageStatsNodeService,
            nodeId,
            serverStatus,
            config,
            clusterConfigService,
            EvictingQueue.<UsageStatsRequest>create(config.getMaxQueueSize()),
            httpClient,
            objectMapper);
}
 
開發者ID:Graylog2,項目名稱:graylog-plugin-anonymous-usage-statistics,代碼行數:19,代碼來源:UsageStatsNodePeriodical.java

示例5: UsageStatsClusterPeriodical

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
@Inject
public UsageStatsClusterPeriodical(UsageStatsClusterService usageStatsClusterService,
                                   ServerStatus serverStatus,
                                   UsageStatsConfiguration config,
                                   ClusterConfigService clusterConfigService,
                                   @CompressingHttpClient OkHttpClient httpClient,
                                   @SmileObjectMapper ObjectMapper objectMapper) {
    this(
            usageStatsClusterService,
            serverStatus,
            config,
            clusterConfigService,
            EvictingQueue.<UsageStatsRequest>create(config.getMaxQueueSize()),
            httpClient,
            objectMapper);
}
 
開發者ID:Graylog2,項目名稱:graylog-plugin-anonymous-usage-statistics,代碼行數:17,代碼來源:UsageStatsClusterPeriodical.java

示例6: updatePassword

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
@Override
public void updatePassword(User user, String password, User author) throws ServiceException, SecurityServiceException {
	if (user == null || !StringUtils.hasText(password)) {
		return;
	}
	
	userService.setPasswords(user, password);
	user.getPasswordInformation().setLastUpdateDate(new Date());
	
	if (getOptions(user).isPasswordHistoryEnabled()) {
		EvictingQueue<String> historyQueue = EvictingQueue.create(propertyService.get(PASSWORD_HISTORY_COUNT));
		
		for (String oldPassword : user.getPasswordInformation().getHistory()) {
			historyQueue.offer(oldPassword);
		}
		historyQueue.offer(user.getPasswordHash());
		
		user.getPasswordInformation().setHistory(Lists.newArrayList(historyQueue));
	}
	
	user.getPasswordRecoveryRequest().reset();
	userService.update(user);
	
	historyLogService.log(HistoryEventType.PASSWORD_UPDATE, user, HistoryLogAdditionalInformationBean.empty());
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:26,代碼來源:SecurityManagementServiceImpl.java

示例7: createDefaultTrackLogger

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
/**
 * Creates a TrackLogger which can be recorded against the current session id, for later retrieval from the dev toolbar.
 * @param pRequestContext
 * @return
 */
public static TrackLogger createDefaultTrackLogger(RequestContext pRequestContext) {
  TrackLogger lNewTrackLogger = createDefaultTrackLogger(pRequestContext.getFoxRequest());

  //Get or create the recent track list for the given origin ID, then record this new track in it
  if(FoxGlobals.getInstance().isDevelopment() || InternalAuthentication.instance().getSessionAuthLevel(pRequestContext.getFoxRequest()).intValue() >= InternalAuthLevel.INTERNAL_SUPPORT.intValue()) {
    FoxCache<String, Queue<String>> lFoxCache = CacheManager.getCache(BuiltInCacheDefinition.RECENT_TRACK_IDS_FOR_SESSION_ID);
    Queue<String> lRecentTrackQueue = lFoxCache.get(pRequestContext.getFoxRequest().getHttpRequest().getSession().getId());
    if(lRecentTrackQueue == null) {
      lRecentTrackQueue = EvictingQueue.create(MAX_RECENT_TRACKS);
      lFoxCache.put(pRequestContext.getFoxRequest().getHttpRequest().getSession().getId(), lRecentTrackQueue);
    }
    lRecentTrackQueue.add(lNewTrackLogger.getTrackId());
  }

  return lNewTrackLogger;
}
 
開發者ID:Fivium,項目名稱:FOXopen,代碼行數:22,代碼來源:TrackUtils.java

示例8: ExtensibleTelemetry

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
public ExtensibleTelemetry(int dataPointsToSend, @NotNull Telemetry telemetry) {
    checkArgument(dataPointsToSend < MAX_DATA_MAX);

    this.parent = telemetry;

    this.dataPointsToSend = dataPointsToSend;
    cache = CacheBuilder.newBuilder().
            concurrencyLevel(4).
            expireAfterAccess(250, TimeUnit.MILLISECONDS).
            maximumSize(dataPointsToSend).build();

    dataCache = EvictingQueue.create((int) (dataPointsToSend * .75));
    data = LinkedHashMultimap.create();
    log = new LinkedList<>();

    try {
        logcat = Runtime.getRuntime().exec(new String[] {"logcat", "*:I"});
        reader = new BufferedReader(new InputStreamReader(logcat.getInputStream()));
    } catch (IOException e) {
        Log.e(TAG, "Cannot start logcat monitor", e);
    }

    executorService = Executors.newSingleThreadScheduledExecutor();
    executorService.scheduleAtFixedRate(new SendDataRunnable(), 250, 250, TimeUnit.MILLISECONDS);
}
 
開發者ID:MHS-FIRSTrobotics,項目名稱:TeamClutch2016,代碼行數:26,代碼來源:ExtensibleTelemetry.java

示例9: ExtensibleOpMode

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
/**
     * Bootstraps the Extensible OpMode to the Xtensible library
     */
    protected ExtensibleOpMode() {
        this.gamepad1 = super.gamepad1;
        this.gamepad2 = super.gamepad2;
        this.hardwareMap = super.hardwareMap;

//        if (super.hardwareMap.appContext == null) {
//            RobotLog.w("App Context is null during construction.");
//        }

        this.telemetry = super.telemetry;
        loopCount = 0;
        skipNextLoop = 0;

        if (parent == null) {
            robotContext = new RobotContext(hardwareMap, telemetry);
            parent = this;
        } else {
            robotContext = parent.robotContext;
        }

        loopManager = new ExtensibleLoopManager();
        loopTimes = EvictingQueue.create(50);

        Log.i(TAG, "OpMode: " + this.getClass().getSimpleName());
    }
 
開發者ID:MHS-FIRSTrobotics,項目名稱:TeamClutch2016,代碼行數:29,代碼來源:ExtensibleOpMode.java

示例10: SingleSpecieLogisticDelayGrowthBiology

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
public SingleSpecieLogisticDelayGrowthBiology(
        Species species, double currentBiomass, double maxBiomass, int yearDelays, double aParameter,
        double bParameter) {
    Preconditions.checkArgument(yearDelays > 0, "Use undelayed biology rather than feeding 0 to a delayed one");
    Preconditions.checkArgument(maxBiomass > 0);
    Preconditions.checkArgument(currentBiomass <= maxBiomass);
    Preconditions.checkArgument(currentBiomass >= 0);
    this.species = species;
    this.yearDelays = yearDelays;
    pastBiomass = EvictingQueue.create(yearDelays);
    while(pastBiomass.remainingCapacity()>0)
        pastBiomass.add(currentBiomass);
    this.aParameter = aParameter;
    this.bParameter = bParameter;
    this.currentBiomass = currentBiomass;
    this.maxBiomass = maxBiomass;
}
 
開發者ID:CarrKnight,項目名稱:POSEIDON,代碼行數:18,代碼來源:SingleSpecieLogisticDelayGrowthBiology.java

示例11: retainErrorMessagesInMemory

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
private void retainErrorMessagesInMemory(Map<String, List<ErrorMessage>> errorMessages) {
  // Shortcut to avoid synchronization
  if(errorMessages.isEmpty()) {
    return;
  }

  synchronized (stageToErrorMessagesMap) {
    for (Map.Entry<String, List<ErrorMessage>> e : errorMessages.entrySet()) {
      EvictingQueue<ErrorMessage> errorMessageList = stageToErrorMessagesMap.get(e.getKey());
      if (errorMessageList == null) {
        errorMessageList = EvictingQueue.create(
          configuration.get(Constants.MAX_PIPELINE_ERRORS_KEY, Constants.MAX_PIPELINE_ERRORS_DEFAULT)
        );
        stageToErrorMessagesMap.put(e.getKey(), errorMessageList);
      }
      errorMessageList.addAll(errorMessages.get(e.getKey()));
    }
  }
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:20,代碼來源:ProductionPipelineRunner.java

示例12: retainErrorRecordsInMemory

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
private void retainErrorRecordsInMemory(Map<String, List<Record>> errorRecords) {
  // Shortcut to avoid synchronization
  if(errorRecords.isEmpty()) {
    return;
  }

  synchronized (stageToErrorRecordsMap) {
    for (Map.Entry<String, List<Record>> e : errorRecords.entrySet()) {
      EvictingQueue<Record> errorRecordList = stageToErrorRecordsMap.get(e.getKey());
      if (errorRecordList == null) {
        //replace with a data structure with an upper cap
        errorRecordList = EvictingQueue.create(
          configuration.get(Constants.MAX_ERROR_RECORDS_PER_STAGE_KEY, Constants.MAX_ERROR_RECORDS_PER_STAGE_DEFAULT)
        );
        stageToErrorRecordsMap.put(e.getKey(), errorRecordList);
      }
      errorRecordList.addAll(errorRecords.get(e.getKey()));
    }
  }
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:21,代碼來源:ProductionPipelineRunner.java

示例13: getAllData

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
public Collection<String> getAllData() {
  EvictingQueue<String> result = EvictingQueue.create(2500);
  BufferedReader reader = null;
  try {
    reader = new BufferedReader(new FileReader(file));
    String line;
    while ((line = reader.readLine()) != null) {
      result.add(line);
    }
  } catch (IOException e) {
    String msg = Utils.format("Error reading from command output file '{}': {}", file, e);
    throw new RuntimeException(msg, e);
  } finally {
    if (reader != null) {
      try {
        reader.close();
      } catch (IOException ex) {
        // ignored
      }
    }
  }
  return result;
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:24,代碼來源:SystemProcessImpl.java

示例14: Announcer

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
public Announcer(final MockedTorrent torrent, final ConnectionHandler connectionHandler, final BitTorrentClient bitTorrentClient, final ApplicationEventPublisher publisher) {
    this.announceHistory = EvictingQueue.create(3);
    this.torrent = new TorrentWithStats(torrent);
    this.publisher = publisher;
    this.eventListeners = new ArrayList<>();
    this.trackerClientProvider = new TrackerClientProvider(this.torrent, connectionHandler, bitTorrentClient);
    this.moveToNextTrackerClient();

    this.thread = null;

    if (logger.isDebugEnabled()) {
        logger.debug("Initialized announce sub-system with {} trackers on {}.", new Object[]{this.torrent.getTorrent().getTrackerCount(), torrent});
    }
}
 
開發者ID:anthonyraymond,項目名稱:joal,代碼行數:15,代碼來源:Announcer.java

示例15: VertxSink

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
/**
 * Protected constructor.
 *
 * @param builder Instance of <code>Builder</code>.
 */
protected VertxSink(final Builder<?, ?> builder) {
    super(builder);
    _serverAddress = builder._serverAddress;
    _hostnameResolver = builder._hostnameResolver;
    _serverPort = builder._serverPort;
    _vertx = VertxFactory.newVertx();
    //Calling this just so the context gets created
    if (_vertx instanceof DefaultVertx) {
        final DefaultVertx vertx = (DefaultVertx) _vertx;
        final DefaultContext context = vertx.getOrCreateContext();
        vertx.setContext(context);
        _context = context;
    } else {
        _context = null;
        LOGGER.warn()
                .setMessage("Vertx instance not a DefaultVertx as expected. Threading may be incorrect.")
                .addData("sink", getName())
                .log();
    }

    _client = _vertx.createNetClient()
            .setReconnectAttempts(0)
            .setConnectTimeout(5000)
            .setTCPNoDelay(true)
            .setTCPKeepAlive(true);
    _socket = new AtomicReference<>();
    _pendingData = EvictingQueue.create(builder._maxQueueSize);
    _exponentialBackoffBase = builder._exponentialBackoffBase;

    connectToServer();
    consumeLoop();
}
 
開發者ID:ArpNetworking,項目名稱:metrics-aggregator-daemon,代碼行數:38,代碼來源:VertxSink.java


注:本文中的com.google.common.collect.EvictingQueue.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。