本文整理汇总了Java中com.google.common.cache.RemovalNotification.wasEvicted方法的典型用法代码示例。如果您正苦于以下问题:Java RemovalNotification.wasEvicted方法的具体用法?Java RemovalNotification.wasEvicted怎么用?Java RemovalNotification.wasEvicted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.cache.RemovalNotification
的用法示例。
在下文中一共展示了RemovalNotification.wasEvicted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Writable, T> note) {
// System.err.println("S0 Cache: " + activeKey + " " + note.getKey() + " " + note.getCause() + " " + cache.size());
if (!(note.wasEvicted() || note.getCause() == RemovalCause.EXPLICIT)) {
return;
}
if (activeKey != null && activeKey.equals(note.getKey())) {
return;
}
try {
// System.err.println(" s0emit: " + note.getCause() + " " + note.getKey() + " " + note.getValue());
// Emit the record.
collector.emit(new FValues(note.getKey(), note.getValue()));
} catch (Throwable e) {
lastThrown = e;
}
}
示例2: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
public void onRemoval(RemovalNotification<String, List<Tuple>> removal) {
if (!removal.wasEvicted())
return;
LOG.error("Purged from waitAck {} with {} values", removal.getKey(),
removal.getValue().size());
for (Tuple t : removal.getValue()) {
_collector.fail(t);
}
}
示例3: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<IndicesRequestCache.Key, IndicesRequestCache.Value> removalNotification) {
if (removalNotification.wasEvicted()) {
evictionsMetric.inc();
}
long dec = 0;
if (removalNotification.getKey() != null) {
dec += removalNotification.getKey().ramBytesUsed();
}
if (removalNotification.getValue() != null) {
dec += removalNotification.getValue().ramBytesUsed();
}
totalMetric.dec(dec);
}
示例4: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Integer, SettableFuture<CompletedBatchOperation>> notification) {
// wrapping in ExecutionException to support Future.get
if (notification.wasEvicted()) {
notification.getValue()
.setException(new ExecutionException("Timed out",
new TimeoutException()));
}
}
示例5: stateRemoved
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
private void stateRemoved(final RemovalNotification<Identifier, AssembledMessageState> notification) {
if (notification.wasEvicted()) {
LOG.warn("{}: AssembledMessageState for {} was expired from the cache", logContext, notification.getKey());
} else {
LOG.debug("{}: AssembledMessageState for {} was removed from the cache due to {}", logContext,
notification.getKey(), notification.getCause());
}
notification.getValue().close();
}
示例6: stateRemoved
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
private void stateRemoved(final RemovalNotification<Identifier, SlicedMessageState<ActorRef>> notification) {
final SlicedMessageState<ActorRef> state = notification.getValue();
state.close();
if (notification.wasEvicted()) {
LOG.warn("{}: SlicedMessageState for {} was expired from the cache", logContext, notification.getKey());
state.getOnFailureCallback().accept(new RuntimeException(String.format(
"The slicing state for message identifier %s was expired due to inactivity from the assembling "
+ "component on the other end", state.getIdentifier())));
} else {
LOG.debug("{}: SlicedMessageState for {} was removed from the cache due to {}", logContext,
notification.getKey(), notification.getCause());
}
}
示例7: SingleSizeCache
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
/**
* Default constructor. Specify the size of the blocks, number of blocks, and
* the SlabCache this cache will be assigned to.
*
*
* @param blockSize the size of each block, in bytes
*
* @param numBlocks the number of blocks of blockSize this cache will hold.
*
* @param master the SlabCache this SingleSlabCache is assigned to.
*/
public SingleSizeCache(int blockSize, int numBlocks,
SlabItemActionWatcher master) {
this.blockSize = blockSize;
this.numBlocks = numBlocks;
backingStore = new Slab(blockSize, numBlocks);
this.stats = new CacheStats();
this.actionWatcher = master;
this.size = new AtomicLong(CACHE_FIXED_OVERHEAD + backingStore.heapSize());
this.timeSinceLastAccess = new AtomicLong();
// This evictionListener is called whenever the cache automatically
// evicts
// something.
RemovalListener<BlockCacheKey, CacheablePair> listener =
new RemovalListener<BlockCacheKey, CacheablePair>() {
@Override
public void onRemoval(
RemovalNotification<BlockCacheKey, CacheablePair> notification) {
if (!notification.wasEvicted()) {
// Only process removals by eviction, not by replacement or
// explicit removal
return;
}
CacheablePair value = notification.getValue();
timeSinceLastAccess.set(System.nanoTime()
- value.recentlyAccessed.get());
stats.evict();
doEviction(notification.getKey(), value);
}
};
backingMap = CacheBuilder.newBuilder()
.maximumSize(numBlocks - 1)
.removalListener(listener)
.<BlockCacheKey, CacheablePair>build()
.asMap();
}
示例8: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Integer, SettableFuture<CompletedBatchOperation>> notification) {
// wrapping in ExecutionException to support Future.get
if (notification.wasEvicted()) {
notification.getValue()
.setException(new ExecutionException("Timed out",
new TimeoutException()));
}
}
示例9: SingleSizeCache
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
/**
* Default constructor. Specify the size of the blocks, number of blocks, and
* the SlabCache this cache will be assigned to.
*
*
* @param blockSize the size of each block, in bytes
*
* @param numBlocks the number of blocks of blockSize this cache will hold.
*
* @param master the SlabCache this SingleSlabCache is assigned to.
*/
public SingleSizeCache(int blockSize, int numBlocks,
SlabItemActionWatcher master) {
this.blockSize = blockSize;
this.numBlocks = numBlocks;
backingStore = new Slab(blockSize, numBlocks);
this.stats = new CacheStats();
this.actionWatcher = master;
this.size = new AtomicLong(CACHE_FIXED_OVERHEAD + backingStore.heapSize());
this.timeSinceLastAccess = new AtomicLong();
// This evictionListener is called whenever the cache automatically
// evicts something.
RemovalListener<BlockCacheKey, CacheablePair> listener =
new RemovalListener<BlockCacheKey, CacheablePair>() {
@Override
public void onRemoval(
RemovalNotification<BlockCacheKey, CacheablePair> notification) {
if (!notification.wasEvicted()) {
// Only process removals by eviction, not by replacement or
// explicit removal
return;
}
CacheablePair value = notification.getValue();
timeSinceLastAccess.set(System.nanoTime()
- value.recentlyAccessed.get());
stats.evict();
doEviction(notification.getKey(), value);
}
};
backingMap = CacheBuilder.newBuilder()
.maximumSize(numBlocks - 1)
.removalListener(listener)
.<BlockCacheKey, CacheablePair>build()
.asMap();
}
示例10: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(
RemovalNotification<Integer, SettableFuture<Response>> arg0) {
if (arg0.wasEvicted()) {
SettableFuture<Response> response = arg0.getValue();
logger.warn("request id {} timeout", arg0.getKey());
response.setException(new RequestTimeoutException("request timeout"));
}
}
示例11: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Writable, T> note) {
// System.err.println("S1 Cache: " + activeKey + " " + note.getKey() + " " + note.getCause() + " " + cache.size());
if (!(note.wasEvicted() || note.getCause() == RemovalCause.EXPLICIT)) {
return;
}
if (activeKey != null && activeKey.equals(note.getKey())) {
return;
}
try {
// Determine if the current value is in the backlog or the prefetch.
T cur;
if (!stateBacklog.containsKey(note.getKey())) {
// Pull the values in from the prefetch.
runPrefetch();
}
cur = stateBacklog.remove(note.getKey());
// System.err.println("stateBacklogged: k=<" + note.getKey() + "> v=" + cur);
// Apply the update.
cur = storeAgg.combine(cur, note.getValue());
// Move things to the writeAhead.
writeAhead.put(note.getKey(), cur);
// Emit the result.
collector.emit(new FValues(note.getKey(), cur));
} catch (Throwable e) {
lastThrown = e;
}
}
示例12: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<IpmiReceiverKey, IpmiReceiver> notification) {
IpmiReceiverKey key = notification.getKey();
IpmiReceiver receiver = notification.getValue();
if (key != null && receiver != null && notification.wasEvicted())
receiver.timeout(key);
}
示例13: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Integer,
SettableFuture<CompletedBatchOperation>> notification) {
// wrapping in ExecutionException to support Future.get
if (notification.wasEvicted()) {
notification.getValue()
.setException(new ExecutionException("Timed out",
new TimeoutException()));
}
}
示例14: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Long, Callback> entry) {
if (entry.wasEvicted()) {
entry.getValue().completeExceptionally(new TimeoutException("Timedout waiting for reply"));
}
}
示例15: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Long, SettableFuture<byte[]>> entry) {
if (entry.wasEvicted()) {
entry.getValue().setException(new TimeoutException("Timedout waiting for reply"));
}
}