本文整理汇总了Java中com.google.common.cache.RemovalNotification.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java RemovalNotification.getValue方法的具体用法?Java RemovalNotification.getValue怎么用?Java RemovalNotification.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.cache.RemovalNotification
的用法示例。
在下文中一共展示了RemovalNotification.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Object, Cache<Query, Value>> notification) {
Object key = notification.getKey();
if (key == null) {
return;
}
Cache<Query, Value> valueCache = notification.getValue();
if (valueCache == null) {
return;
}
for (Value value : valueCache.asMap().values()) {
listener.onRemoval(value.shardId, value.bitset);
// if null then this means the shard has already been removed and the stats are 0 anyway for the shard this key belongs to
}
}
示例2: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
public void onRemoval(RemovalNotification<Integer, StatementInfo> notification) {
Integer stmtId = notification.getKey();
StatementInfo doomed = notification.getValue();
if (doomed == null) {
// log/throw?
return;
}
LOG.debug("Expiring statement {} because {}", stmtId, notification.getCause());
try {
if (doomed.getResultSet() != null) {
doomed.getResultSet().close();
}
if (doomed.statement != null) {
doomed.statement.close();
}
} catch (Throwable t) {
LOG.info("Exception thrown while expiring statement {}", stmtId, t);
}
}
示例3: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
public void onRemoval(RemovalNotification<Integer, StatementInfo> notification) {
Integer stmtId = notification.getKey();
StatementInfo doomed = notification.getValue();
if (doomed == null) {
// log/throw?
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Expiring statement " + stmtId + " because "
+ notification.getCause());
}
try {
if (doomed.resultSet != null) {
doomed.resultSet.close();
}
if (doomed.statement != null) {
doomed.statement.close();
}
} catch (Throwable t) {
LOG.info("Exception thrown while expiring statement " + stmtId);
}
}
示例4: clientRemovalListener
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
private RemovalListener<String, DFSClient> clientRemovalListener() {
return new RemovalListener<String, DFSClient>() {
@Override
public void onRemoval(
RemovalNotification<String, DFSClient> notification) {
DFSClient client = notification.getValue();
try {
client.close();
} catch (IOException e) {
LOG.warn(String
.format("IOException when closing the DFSClient(%s), cause: %s",
client, e));
}
}
};
}
示例5: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<CacheValue, NodeDocument> n) {
//If removed explicitly then we clear from L2
if (n.getCause() == RemovalCause.EXPLICIT
|| n.getCause() == RemovalCause.REPLACED) {
offHeapCache.invalidate(n.getKey());
}
//If removed because of size then we move it to
//L2
if (n.getCause() == RemovalCause.SIZE) {
NodeDocument doc = n.getValue();
if (doc != NodeDocument.NULL) {
offHeapCache.put(n.getKey(),
new NodeDocReference(n.getKey(), doc));
}
}
}
示例6: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
public void onRemoval(RemovalNotification<String, Object> notification) {
Class<?> handlerClass = null;
try {
handlerClass = Class.forName(notification.getKey());
} catch (ClassNotFoundException e) {
logger.error("Unexpected exception", e);
}
if (handlerClass != null) {
String[] beanNames = beanFactory.getBeanNamesForType(handlerClass);
if (beanNames != null && beanNames.length > 0) {
if (beanFactory.isPrototype(beanNames[0])) {
if (notification.getValue() instanceof WebSocketSessionAware) {
WebSocketSessionAware webSocketSessionAwareHandler = (WebSocketSessionAware)notification.getValue();
webSocketSessionAwareHandler.onWebSocketSessionRemoved(webSocketSession);
}
beanFactory.destroyBean(notification.getValue());
} // else this is a singleton and we don't do anything with singletons
} // this shouldn't happen
} // this shouldn't happen either
}
示例7: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<String, CachedOffer> notification) {
if (notification.getCause() == RemovalCause.EXPLICIT) {
return;
}
LOG.debug("Cache removal for {} due to {}", notification.getKey(), notification.getCause());
synchronized (offerCache) {
if (notification.getValue().offerState == OfferState.AVAILABLE) {
declineOffer(notification.getValue());
} else {
notification.getValue().expire();
}
}
}
示例8: 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);
}
}
示例9: createRemovalListener
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
private RemovalListener<String, DataContext> createRemovalListener() {
return new RemovalListener<String, DataContext>() {
@Override
public void onRemoval(final RemovalNotification<String, DataContext> notification) {
final DataContext dataContext = notification.getValue();
// some DataContexts are closeable - attempt closing it here
FileHelper.safeClose(dataContext);
}
};
}
示例10: createRemovalListener
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
private RemovalListener<String, TenantContext> createRemovalListener() {
return new RemovalListener<String, TenantContext>() {
@Override
public void onRemoval(final RemovalNotification<String, TenantContext> notification) {
final TenantContext tenantContext = notification.getValue();
// TenantContexts could be closeable - attempt closing it here
FileHelper.safeClose(tenantContext);
}
};
}
示例11: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<FileInfo, MuxedFile> notification) {
if (notification.getCause() != RemovalCause.EXPLICIT) {
MuxedFile muxedFile = notification.getValue();
// This is racy, at worst we will re-trigger muxing for unlucky files being re-opened
if (!openMuxFiles.containsValue(muxedFile)) {
muxFiles.remove(muxedFile.getInfo(), muxedFile.getMuxer());
logger.info("Expired {}: {} deleted = {}", notification.getCause(), muxedFile, safeDelete(muxedFile));
} else {
logger.warn("BUG: Expired {}: {}, but is still open!", notification.getCause(), muxedFile);
}
}
}
示例12: 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);
}
示例13: clientRemovalListener
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
private RemovalListener<String, DFSClient> clientRemovalListener() {
return new RemovalListener<String, DFSClient>() {
@Override
public void onRemoval(RemovalNotification<String, DFSClient> notification) {
DFSClient client = notification.getValue();
try {
client.close();
} catch (IOException e) {
LOG.warn(String.format(
"IOException when closing the DFSClient(%s), cause: %s", client,
e));
}
}
};
}
示例14: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<HBaseConnectionKey, Connection> notification) {
try {
Connection conn = notification.getValue();
if (isValid(conn)) {
conn.close();
}
logger.info("HBase connection '{}' closed.", conn);
} catch (Throwable t) {
logger.warn("Error while closing HBase connection.", t);
}
}
示例15: 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());
}
}