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


Java RemovalNotification.wasEvicted方法代码示例

本文整理汇总了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;
		}
	}
 
开发者ID:JamesLampton,项目名称:piggybank-squeal,代码行数:19,代码来源:Stage0Executor.java

示例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);
    }
}
 
开发者ID:eorliac,项目名称:patent-crawler,代码行数:10,代码来源:StatusUpdaterBolt.java

示例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);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:ShardRequestCache.java

示例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()));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:SimpleFlowRuleStore.java

示例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();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:MessageAssembler.java

示例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());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:MessageSlicer.java

示例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();


}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:51,代码来源:SingleSizeCache.java

示例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()));
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:10,代码来源:SimpleFlowRuleStore.java

示例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();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:48,代码来源:SingleSizeCache.java

示例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"));
    }
}
 
开发者ID:lyogavin,项目名称:Pistachio,代码行数:10,代码来源:NettyPistachioClientHandler.java

示例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;
		}
	}
 
开发者ID:JamesLampton,项目名称:piggybank-squeal,代码行数:34,代码来源:Stage1Executor.java

示例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);
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:8,代码来源:IpmiPayloadReceiveDispatcher.java

示例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()));
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:11,代码来源:SimpleVirtualFlowRuleStore.java

示例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"));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:NettyMessagingManager.java

示例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"));
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:7,代码来源:NettyMessagingService.java


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