本文整理匯總了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();
}