List of usage examples for com.google.common.cache RemovalCause EXPIRED
RemovalCause EXPIRED
To view the source code for com.google.common.cache RemovalCause EXPIRED.
Click Source Link
From source file:com.kixeye.kixmpp.server.cluster.mapreduce.MapReduceTracker.java
@Override public void onRemoval(RemovalNotification<UUID, MapReduceTracker.RequestWrapper> notification) { if (notification.getCause() == RemovalCause.EXPIRED) { RequestWrapper wrapper = notification.getValue(); log.warn("Timing out MapReduce request <{}> with ref count <{}>", wrapper.getClass().toString(), wrapper.pendingResponseCount.get()); wrapper.request.onComplete(true); }//from w w w .ja va 2s . co m }
From source file:com.infinities.skyport.distributed.impl.hazelcast.hazeltask.executor.DistributedFutureTracker.java
public DistributedFutureTracker(final IExecutorTopologyService topologyService, long maxFutureWaitTime, TimeUnit unit) {/* w w w . ja v a 2 s . co m*/ this.topologyService = topologyService; futures = CacheBuilder.newBuilder() // no future will wait for more than this time .expireAfterAccess(maxFutureWaitTime, unit) .removalListener(new RemovalListener<String, DistributedFuture<Object>>() { @Override public void onRemoval(RemovalNotification<String, DistributedFuture<Object>> notification) { if (notification.getCause() == RemovalCause.EXPIRED) { DistributedFuture<Object> future = notification.getValue(); long waitTimeMillis = System.currentTimeMillis() - future.getCreatedTime(); notification.getValue() .setException(new TimeoutException("Future timed out waiting. Waited " + (TimeUnit.MILLISECONDS.toMinutes(waitTimeMillis)) + " minutes")); topologyService.cancelTask(future.getTaskId()); topologyService.removePendingTask(future.getTaskId()); } else if (notification.getCause() == RemovalCause.COLLECTED) { // future was GC'd because we didn't // want to track it logger.debug("Future {} was garabge collected and removed from the tracker", notification.getKey()); } } }).build(); }
From source file:org.onosproject.incubator.net.virtual.impl.provider.DefaultVirtualMeterProvider.java
@Activate public void activate() { providerRegistryService.registerProvider(this); internalMeterListener = new InternalMeterListener(); idGenerator = getIdGenerator();/*from ww w . j a v a 2 s. co m*/ pendingOperations = CacheBuilder.newBuilder().expireAfterWrite(TIMEOUT, TimeUnit.SECONDS) .removalListener((RemovalNotification<Long, VirtualMeterOperation> notification) -> { if (notification.getCause() == RemovalCause.EXPIRED) { NetworkId networkId = notification.getValue().networkId(); MeterOperation op = notification.getValue().operation(); VirtualMeterProviderService providerService = (VirtualMeterProviderService) providerRegistryService .getProviderService(networkId, VirtualMeterProvider.class); providerService.meterOperationFailed(op, MeterFailReason.TIMEOUT); } }).build(); meterService.addListener(internalMeterListener); log.info("Started"); }
From source file:org.onosproject.driver.pipeline.DefaultSingleTablePipeline.java
@Override public void init(DeviceId deviceId, PipelinerContext context) { this.serviceDirectory = context.directory(); this.deviceId = deviceId; flowRuleService = serviceDirectory.get(FlowRuleService.class); flowObjectiveStore = serviceDirectory.get(FlowObjectiveStore.class); pendingNext = CacheBuilder.newBuilder().expireAfterWrite(20, TimeUnit.SECONDS) .removalListener((RemovalNotification<Integer, NextObjective> notification) -> { if (notification.getCause() == RemovalCause.EXPIRED) { notification.getValue().context().ifPresent( c -> c.onError(notification.getValue(), ObjectiveError.FLOWINSTALLATIONFAILED)); }// w ww . jav a 2 s . c o m }).build(); }
From source file:ru.asmsoft.p2p.storage.MemoryNodesRepository.java
@Override public void onRemoval(RemovalNotification<String, Node> removalNotification) { if (removalNotification.getCause() == RemovalCause.EXPIRED) { logger.info("Nodes: {}, Expire node: {}", nodes.size(), removalNotification); }/*from w w w . j a v a 2 s .c o m*/ }
From source file:org.eclipse.rdf4j.http.server.repository.transaction.ActiveTransactionRegistry.java
/** * private constructor.//from w ww . java2 s. c om */ private ActiveTransactionRegistry() { int timeout = DEFAULT_TIMEOUT; final String configuredValue = System.getProperty(CACHE_TIMEOUT_PROPERTY); if (configuredValue != null) { try { timeout = Integer.parseInt(configuredValue); } catch (NumberFormatException e) { logger.warn("Expected integer value for property {}. Timeout will default to {} seconds. ", CACHE_TIMEOUT_PROPERTY, DEFAULT_TIMEOUT); } } primaryCache = CacheBuilder.newBuilder().removalListener(new RemovalListener<UUID, Transaction>() { @Override public void onRemoval(RemovalNotification<UUID, Transaction> notification) { Transaction entry = notification.getValue(); try { entry.close(); } catch (RepositoryException | InterruptedException | ExecutionException e) { // fall through } } }).build(); secondaryCache = CacheBuilder.newBuilder().removalListener(new RemovalListener<UUID, Transaction>() { @Override public void onRemoval(RemovalNotification<UUID, Transaction> notification) { if (RemovalCause.EXPIRED.equals(notification.getCause())) { final UUID transactionId = notification.getKey(); final Transaction entry = notification.getValue(); synchronized (primaryCache) { if (!entry.hasActiveOperations()) { // no operation active, we can decommission this entry primaryCache.invalidate(transactionId); logger.warn("deregistered expired transaction {}", transactionId); } else { // operation still active. Reinsert in secondary cache. secondaryCache.put(transactionId, entry); } } } } }).expireAfterAccess(timeout, TimeUnit.SECONDS).build(); }
From source file:org.codice.ddf.graphql.servlet.GraphQLTransformerServlet.java
/** * Refreshes the schema periodically once the cache invalidates if a REFRESH_SCHEMA event was * added to the cache. This allows multiple threads to ask for a schema refresh while only * refreshing the schema once.//from w w w . j a v a2 s .co m * * @param notification */ private void refreshSchemaOnExpire(RemovalNotification notification) { if (notification.getCause() == RemovalCause.EXPIRED) { refreshSchema(); } }
From source file:ru.justblender.secure.SecureCommands.java
private void notifyExpired(RemovalNotification notification) { CommandSender sender = (CommandSender) notification.getKey(); if (sender == null || notification.getCause() != RemovalCause.EXPIRED) return;// w w w . j a va 2 s.com sender.sendMessage( "cYou couldn't enter the secret code in time for command \"" + notification.getValue() + "\"."); getLogger().severe(sender.getName() + " failed 2FA (timed out) for command /" + notification.getValue()); }
From source file:io.pravega.segmentstore.server.host.stat.AutoScaleProcessor.java
AutoScaleProcessor(AutoScalerConfig configuration, Executor executor, ScheduledExecutorService maintenanceExecutor) { this.configuration = configuration; this.maintenanceExecutor = maintenanceExecutor; this.executor = executor; serializer = new JavaSerializer<>(); writerConfig = EventWriterConfig.builder().build(); writer = new AtomicReference<>(); cache = CacheBuilder.newBuilder().initialCapacity(INITIAL_CAPACITY).maximumSize(MAX_CACHE_SIZE) .expireAfterAccess(configuration.getCacheExpiry().getSeconds(), TimeUnit.SECONDS).removalListener( RemovalListeners.asynchronous((RemovalListener<String, Pair<Long, Long>>) notification -> { if (notification.getCause().equals(RemovalCause.EXPIRED)) { triggerScaleDown(notification.getKey(), true); }//ww w .jav a 2 s . co m }, maintenanceExecutor)) .build(); CompletableFuture.runAsync(this::bootstrapRequestWriters, maintenanceExecutor); }
From source file:org.onosproject.drivers.microsemi.EA1000Pipeliner.java
@Override public void init(DeviceId deviceId, PipelinerContext context) { this.serviceDirectory = context.directory(); this.deviceId = deviceId; flowRuleService = serviceDirectory.get(FlowRuleService.class); pendingNext = CacheBuilder.newBuilder().expireAfterWrite(20, TimeUnit.SECONDS) .removalListener((RemovalNotification<Integer, NextObjective> notification) -> { if (notification.getCause() == RemovalCause.EXPIRED) { notification.getValue().context().ifPresent( c -> c.onError(notification.getValue(), ObjectiveError.FLOWINSTALLATIONFAILED)); }/*from www . ja va2 s . c om*/ }).build(); log.debug("Loaded handler behaviour EA1000Pipeliner for " + handler().data().deviceId().uri()); }