当前位置: 首页>>代码示例>>Java>>正文


Java EvictingQueue类代码示例

本文整理汇总了Java中com.google.common.collect.EvictingQueue的典型用法代码示例。如果您正苦于以下问题:Java EvictingQueue类的具体用法?Java EvictingQueue怎么用?Java EvictingQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EvictingQueue类属于com.google.common.collect包,在下文中一共展示了EvictingQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fail

import com.google.common.collect.EvictingQueue; //导入依赖的package包/类
public void fail(T object) {
	logger.info("Server {}:{} failed.", ((ThriftServer)object).getHost(),((ThriftServer)object).getPort());
	boolean addToFail = false;
	try {
		EvictingQueue<Long> evictingQueue = failCountMap.get(object);
		synchronized (evictingQueue) {
			evictingQueue.add(System.currentTimeMillis());
			if (evictingQueue.remainingCapacity() == 0 && evictingQueue.element() >= (System.currentTimeMillis() - failDuration)) {
				addToFail = true;
			}
		}
	} catch (ExecutionException e) {
		logger.error("Ops.", e);
	}
	if (addToFail) {
		failedList.put(object, Boolean.TRUE);
		logger.info("Server {}:{} failed. Add to fail list.", ((ThriftServer)object).getHost(), ((ThriftServer)object).getPort());
	}
}
 
开发者ID:cyfonly,项目名称:ThriftJ,代码行数:20,代码来源:FailoverStrategy.java

示例2: fail

import com.google.common.collect.EvictingQueue; //导入依赖的package包/类
/**
 * <p>
 * fail.
 * </p>
 *
 * @param object a T object.
 */
public void fail(T object) {
    logger.trace("server {} failed.", object);
    boolean addToFail = false;
    try {
        EvictingQueue<Long> evictingQueue = failCountMap.get(object);
        synchronized (evictingQueue) {
            evictingQueue.add(System.currentTimeMillis());
            if (evictingQueue.remainingCapacity() == 0
                    && evictingQueue.element() >= System.currentTimeMillis() - failDuration) {
                addToFail = true;
            }
        }
    } catch (ExecutionException e) {
        logger.error("Ops.", e);
    }
    if (addToFail) {
        failedList.put(object, TRUE);
        logger.trace("server {} failed. add to fail list.", object);
    }
}
 
开发者ID:ngayngo9x,项目名称:q-thrift,代码行数:28,代码来源:FailoverCheckingStrategy.java

示例3: restore

import com.google.common.collect.EvictingQueue; //导入依赖的package包/类
private EvictingQueue<String> restore(EvictingQueue<String> queue, String queueName){
    String storedStr= callbacks.loadExtensionSetting(queueName);        
    if (storedStr == null)  return queue;
    
    EvictingQueue<String> newQueue=null;
    try (
        ByteArrayInputStream byteArrIn = new ByteArrayInputStream(storedStr.getBytes());
        ObjectInputStream objectIn = new ObjectInputStream(byteArrIn);
    ){  
        newQueue = (EvictingQueue<String>) objectIn.readObject();            
    } 
    catch (IOException | ClassNotFoundException ex) {
        PrintWriter stderr = new PrintWriter(callbacks.getStderr());
        ex.printStackTrace(stderr);
    }
    finally{
        if (newQueue==null) return queue; 
        else return newQueue;
    }     
}
 
开发者ID:DanNegrea,项目名称:TokenJar,代码行数:21,代码来源:PersistSettings.java

示例4: 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

示例5: getSamplesFilteredByLatency

import com.google.common.collect.EvictingQueue; //导入依赖的package包/类
private static void getSamplesFilteredByLatency(
    long latencyLowerNs,
    long latencyUpperNs,
    int maxSpansToReturn,
    List<SpanImpl> output,
    EvictingQueue<SpanImpl> queue) {
  for (SpanImpl span : queue) {
    if (output.size() >= maxSpansToReturn) {
      break;
    }
    long spanLatencyNs = span.getLatencyNs();
    if (spanLatencyNs >= latencyLowerNs && spanLatencyNs < latencyUpperNs) {
      output.add(span);
    }
  }
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:17,代码来源:SampledSpanStoreImpl.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: fail

import com.google.common.collect.EvictingQueue; //导入依赖的package包/类
@Override
public void fail(T object) {
    if (!getAll().contains(object)) {
        logger.warn("invalid fail obj:{}, it's not in original list.", object);
        return;
    }
    logger.warn("server {} failed.", object);
    boolean addToFail = false;
    EvictingQueue<Long> evictingQueue = failCountMap.getUnchecked(object);
    synchronized (evictingQueue) {
        evictingQueue.add(currentTimeMillis());
        if (evictingQueue.remainingCapacity() == 0
                && evictingQueue.element() >= currentTimeMillis() - failDuration) {
            addToFail = true;
        }
    }
    if (addToFail) {
        failedList.add(object);
    }
    recoveryFuture.get();
}
 
开发者ID:PhantomThief,项目名称:simple-failover-java,代码行数:22,代码来源:RecoverableCheckFailover.java

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


注:本文中的com.google.common.collect.EvictingQueue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。