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


Java RemovalNotification.getCause方法代码示例

本文整理汇总了Java中com.google.common.cache.RemovalNotification.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java RemovalNotification.getCause方法的具体用法?Java RemovalNotification.getCause怎么用?Java RemovalNotification.getCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.cache.RemovalNotification的用法示例。


在下文中一共展示了RemovalNotification.getCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<K, V> notification)
{
    switch (notification.getCause())
    {
        case EXPIRED:
            notifyListeners(new GuavaCacheEntryEvent<>(this, EventType.EXPIRED, notification));
            break;

        case EXPLICIT:
            notifyListeners(new GuavaCacheEntryEvent<>(this, EventType.REMOVED, notification));
            break;

        case REPLACED:
            notifyListeners(new GuavaCacheEntryEvent<>(this, EventType.UPDATED, notification));
            break;
    }
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:19,代码来源:GuavaCache.java

示例2: testCacheExpire

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Test
public void testCacheExpire() throws InterruptedException {
    int total = 10;
    final Map<String, String> expired = new HashMap<>();
    RemovalListener removalListener = new RemovalListener<String, String>() {
        @Override
        public void onRemoval(RemovalNotification<String, String> notification) {
            if(RemovalCause.EXPIRED == notification.getCause()) {
                expired.put(notification.getKey(), notification.getValue());
            }
        }
    };
    Cache<String, String> myCache = CacheBuilder.newBuilder()
            .expireAfterWrite(2, TimeUnit.MILLISECONDS)
            .removalListener(removalListener)
            .build();
    for(int i = 0; i < total; i++) {
        myCache.put("key_" + i, "val_" + i);
    }
    Thread.sleep(10);
    myCache.cleanUp();
    assertEquals(total, expired.size());
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:24,代码来源:TransactionManagerTest.java

示例3: 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));
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:19,代码来源:NodeDocOffHeapCache.java

示例4: 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

示例5: 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();
    }
  }
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:17,代码来源:SingularityOfferCache.java

示例6: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<Object, Object> notification) {
    if (notification.getCause() == RemovalCause.SIZE) {
        if (evictionCounter % logInterval == 0) {
            logger.log(LogLevel.INFO, "Cache entries evicted. In-memory cache of {}: Size{{}} MaxSize{{}}, {} {}", cacheId, cache.size(), maxSize, cache.stats(), EVICTION_MITIGATION_MESSAGE);
        }
        evictionCounter++;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:LoggingEvictionListener.java

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

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

示例9: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(final RemovalNotification<File, Source> notification) {
  final RemovalCause cause = notification.getCause();

  final Config config = Config.load();
  if (config.useSourceCache() && cause.equals(RemovalCause.EXPLICIT)) {
    final Source source = notification.getValue();
    try {
      deleteSource(source);
    } catch (Exception e) {
      log.catching(e);
    }
  }
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:15,代码来源:JavaSourceLoader.java

示例10: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<String, String> notification) {
    // rollback transaction on expire
    if(RemovalCause.EXPIRED == notification.getCause()) {
        rollback(notification.getKey());
    }
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:8,代码来源:TransactionManager.java

示例11: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(final RemovalNotification<ChunkCoordIntPair, NBTTagCompound> notification) {
	try {
		// Only flush the entry if it was invalidated. Any entry could
		// be updated prior to it being written by an IO thread so we
		// want to avoid unnecessary writes.
		if (notification.getCause() == RemovalCause.EXPLICIT)
			AnvilChunkLoader.this.writeChunkNBTTags(notification.getKey(), notification.getValue());
	} catch (final Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:OreCruncher,项目名称:Jiffy,代码行数:13,代码来源:AnvilChunkLoader.java

示例12: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
@Override
public void onRemoval(RemovalNotification<TypedDirectionNamedPath, Notification> event) {
    switch (event.getCause()) {
        case SIZE: {
            LOG.warn(String.format("Evicted notification '%s' with %d events", event.getKey(), event.getValue().getCount()));
            break;
        }
        default: {
            break;
        }
    }
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:13,代码来源:ByTypedNamedPathCollector.java

示例13: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
/**
 * Callback method for removal of items from the histories cache. Items removed from the cache need to be acked or failed
 * according to the reason they were removed
 */
@Override
public void onRemoval(RemovalNotification<CVParticle, String> notification) {
	// make sure the CVParticle object is removed from the history (even if removal was automatic!)
	history.clear(notification.getKey(), notification.getValue());
	if(notification.getCause() == RemovalCause.EXPIRED || notification.getCause() == RemovalCause.SIZE){
		// item removed automatically --> fail the tuple
		collector.fail(notification.getKey().getTuple());
	}else{
		// item removed explicitly --> ack the tuple
		collector.ack(notification.getKey().getTuple());
	}
}
 
开发者ID:sensorstorm,项目名称:StormCV,代码行数:17,代码来源:BatchInputBolt.java

示例14: 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

示例15: onRemoval

import com.google.common.cache.RemovalNotification; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onRemoval(final RemovalNotification<String, StratumTcpServerConnection> notification)
{
    if (notification.getCause() == RemovalCause.EXPIRED)
        StratumTcpServer.this.onConnectionTimeout(notification.getValue());
}
 
开发者ID:GuyPaddock,项目名称:JStratum,代码行数:10,代码来源:StratumTcpServer.java


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