本文整理汇总了Java中com.google.common.cache.RemovalNotification.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java RemovalNotification.getKey方法的具体用法?Java RemovalNotification.getKey怎么用?Java RemovalNotification.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.cache.RemovalNotification
的用法示例。
在下文中一共展示了RemovalNotification.getKey方法的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: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Key, Value> notification) {
if (notification.getKey() == null) {
return;
}
notification.getKey().shard.requestCache().onRemoval(notification);
}
示例5: 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);
}
示例6: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(final RemovalNotification<String, List<MemberDescriptor>> notification) {
final RemovalCause cause = notification.getCause();
if (cause.equals(RemovalCause.EXPLICIT)) {
final String key = notification.getKey();
ProjectDatabaseHelper.deleteMemberDescriptors(key);
}
}
示例7: createCacheRemoveListener
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
/**
* Creates the removal listener which is attached to the cache.
*
* @return cache entry removal listener.
*/
private RemovalListener<String, FSFilterStreamContext> createCacheRemoveListener()
{
//When an entry is removed from the cache, removal listener is notified and it closes the output stream.
return new RemovalListener<String, FSFilterStreamContext>()
{
@Override
public void onRemoval(@Nonnull RemovalNotification<String, FSFilterStreamContext> notification)
{
FSFilterStreamContext streamContext = notification.getValue();
if (streamContext != null) {
try {
String filename = notification.getKey();
String partFileName = getPartFileNamePri(filename);
LOG.info("closing {}", partFileName);
long start = System.currentTimeMillis();
closeStream(streamContext);
filesWithOpenStreams.remove(filename);
totalWritingTime += System.currentTimeMillis() - start;
} catch (IOException e) {
LOG.error("removing {}", notification.getValue(), e);
throw new RuntimeException(e);
}
}
}
};
}
示例8: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<ArtifactIdentifier, File> notification) {
ArtifactIdentifier artifactIdentifier = notification.getKey();
File file = notification.getValue();
if (file.exists()) {
if (file.delete()) {
LOG.debug("Removed downloaded jar '{}' for '{}'", file, artifactIdentifier);
}else{
LOG.warn("Could not remove downloaded jar '{}' for '{}'", file, artifactIdentifier);
}
}else{
LOG.warn("Downloaded jar does not exists, so it cannot be cleaned up '{}' for '{}'", file, artifactIdentifier);
}
}
示例9: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Class<? extends IService>, Object> removal)
{
final Class<? extends IService> serviceInterfaceClass = removal.getKey();
final Object serviceImpl = removal.getValue();
unloadService(serviceInterfaceClass, serviceImpl);
}
示例10: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(@NotNull final RemovalNotification<UUID, CPlayer> notification) {
final UUID uuid = notification.getKey();
if (uuid == null) return;
// Invalidate the titles being kept with this player
DefaultPlayerAPI.this.chatterbox.getAPI().getTitleAPI().invalidate(uuid);
}
示例11: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<ByteBuf, String> notification) {
ByteBuf key = notification.getKey();
if (key == null) {
throw new IllegalStateException("Unexpected null key");
}
boolean release = key.release();
if (!release) {
LOGGER.warn("The cached string ByteBuf with value {} was "
+ "removed but it had more references than expected", notification.getValue());
}
}
示例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<SchemaCacheKey<?>, Object> paramRemovalNotification) {
SchemaCacheKey<?> sck = paramRemovalNotification.getKey();
if (sck.getCacheSegment() != CacheSegment.UNCATEGORIZED) {
HashSet<PlanCacheKey> current = new HashSet<PlanCacheKey>(planCache.getROMap().keySet());
for(PlanCacheKey pck : current) {
CachedPlan cp = planCache.get(null,pck);
if (cp == null) continue;
if (cp.invalidate(sck))
planCache.invalidate(pck);
}
pstmtCache.invalidate(sck);
}
}
示例14: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
/**
* Atomically transitions the resource to a state where it can no longer be used. If the
* resource is idle or retired then it is immediately discarded. If the resource is
* currently in use then it is marked to be discarded when it has been released.
*/
@Override
public void onRemoval(RemovalNotification<ResourceKey<K>, R> notification) {
ResourceKey<K> resourceKey = notification.getKey();
for (;;) {
Status status = resourceKey.getStatus();
switch (status) {
case IDLE:
// The resource is not being used and may be immediately discarded
if (resourceKey.goFromIdleToDead()) {
discardFromIdle(resourceKey, notification.getValue());
return;
}
break;
case IN_FLIGHT:
// The resource is currently being used and should be discarded when released
if (resourceKey.goFromInFlightToRetired()) {
return;
}
break;
case RETIRED:
// A resource is already retired when it has been expired by the idle cache
if (resourceKey.goFromRetiredToDead()) {
discardFromRetired(resourceKey, notification.getValue());
return;
}
break;
default:
throw new IllegalStateException("Unnexpected state: " + status);
}
}
}
示例15: onRemoval
import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
public void onRemoval(RemovalNotification<String, TradeAccount> notification) {
this.removalCause = notification.getCause();
this.removedKey = notification.getKey();
this.removedValue = notification.getValue();
}