本文整理了Java中org.infinispan.Cache.isEmpty()
方法的一些代码示例,展示了Cache.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.isEmpty()
方法的具体详情如下:
包路径:org.infinispan.Cache
类名称:Cache
方法名:isEmpty
暂无
代码示例来源:origin: apiman/apiman
/**
* @see java.util.Map#isEmpty()
*/
@Override
public boolean isEmpty() {
return cache.isEmpty();
}
代码示例来源:origin: org.infinispan/infinispan-core
protected void verifyNoData(Cache<Object, Object> c) {
assert c.isEmpty() : "Cache should be empty!";
}
代码示例来源:origin: org.infinispan/infinispan-core
private <K, V> void assertEmpty(List<Cache<K, V>> cacheList) {
for (Cache<K, V> cache : cacheList) {
assertTrue(cache + ".isEmpty()", cache.isEmpty());
}
}
代码示例来源:origin: org.infinispan/infinispan-core
private void assertCacheEmpty(int siteIndex, int nodeIndex, String cacheName) {
assertTrue(format("Cache '%s' is not empty in site '%d'", cacheName, siteIndex),
cache(siteIndex, nodeIndex, cacheName).isEmpty());
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testTxCommit3() throws Exception {
TransactionManager tm = TestingUtil.getTransactionManager(cache);
tm.begin();
cache.put("key", "value");
tm.commit();
assertFalse(cache.isEmpty());
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testTxCommit1() throws Exception {
TransactionManager tm = TestingUtil.getTransactionManager(cache);
tm.begin();
cache.put("key", "value");
Transaction t = tm.suspend();
assertTrue(cache.isEmpty());
tm.resume(t);
tm.commit();
assertFalse(cache.isEmpty());
}
代码示例来源:origin: org.infinispan/infinispan-core
protected void initAndTest() {
for (Cache<K, V> c : caches) assert c.isEmpty();
// TODO: A bit hacky, this should be moved somewhere else really...
Cache<Object, Object> firstCache = (Cache<Object, Object>) caches.get(0);
firstCache.put("k1", "value");
asyncWait("k1", PutKeyValueCommand.class);
assertOnAllCachesAndOwnership("k1", "value");
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testClear() throws Exception {
prepareClearTest();
c1.clear();
for (Cache<Object, String> c : caches) assert c.isEmpty();
for (int i = 0; i < 5; i++) {
String key = "k" + i;
assertRemovedFromStores(key);
}
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testClear() throws Exception {
ObjectName defaultOn = getCacheObjectName(JMX_DOMAIN);
tm().begin();
cache().put("k","v");
tm().commit();
assertFalse(cache().isEmpty());
server.invoke(defaultOn, "clear", new Object[]{}, new String[]{});
assertTrue(cache().isEmpty());
}
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testSizeAfterClear() {
for (int i = 0; i < 10; i++) {
cache.put(i, "value" + i);
}
cache.clear();
assertTrue(cache.isEmpty());
}
代码示例来源:origin: org.infinispan/infinispan-core
private void assertInitialValues(Cache<String, String> c1, Cache<String, String> c1Replica, Cache<String, String> c2, Cache<String, String> c2Replica) {
for (Cache<String, String> c : Arrays.asList(c1, c1Replica)) {
assertTrue(!c.isEmpty());
assertEquals(c.size(), 1);
assertEquals(c.get("c1key"), "c1value");
}
for (Cache<String, String> c : Arrays.asList(c2, c2Replica)) {
assertTrue(!c.isEmpty());
assertEquals(c.size(), 1);
assertEquals(c.get("c2key"), "c2value");
}
}
代码示例来源:origin: org.infinispan/infinispan-core
void initBeforeTest() {
takeSiteOffline();
assertOffline();
putData();
assertDataInSite(LON);
assertInSite(NYC, cache -> assertTrue(cache.isEmpty()));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testStartStateTransferWithoutLink() {
initBeforeTest();
List<ControllerTransport> transports = replaceTransportInSite();
for (ControllerTransport transport : transports) {
transport.fail = true;
}
assertTrue(!SUCCESS.equals(extractComponent(cache(LON, 0), XSiteAdminOperations.class).pushState(NYC)));
assertDataInSite(LON);
assertInSite(NYC, cache -> AssertJUnit.assertTrue(cache.isEmpty()));
assertTrue(getStatus().isEmpty());
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testBasicOperation() {
Cache<String, String> cache1 = cache(0, "replSync");
Cache cache2 = cache(1, "replSync");
assertClusterSize("Should only be 2 caches in the cluster!!!", 2);
assertNull("Should be null", cache1.get(k));
assertNull("Should be null", cache2.get(k));
cache1.put(k, v);
assertEquals(v, cache1.get(k));
assertEquals("Should have replicated", v, cache2.get(k));
cache2.remove(k);
assert cache1.isEmpty();
assert cache2.isEmpty();
}
代码示例来源:origin: org.infinispan/infinispan-clustered-counter
private TestCounter assertCounterManagerRemove(String name, TestCounter counter, Factory factory, int index) {
CounterManager manager = counterManager(index);
manager.remove(name);
assertTrue(cache(0, CounterModuleLifecycle.COUNTER_CACHE_NAME).isEmpty());
TestCounter anotherCounter = factory.get(manager, name);
if (counter != null) {
assertFalse(counter.isSame(anotherCounter));
}
return anotherCounter;
}
代码示例来源:origin: org.infinispan/infinispan-clustered-counter
private void assertCounterRemove(String name, TestCounter counter, Factory factory) {
CounterManager manager = counterManager(0);
counter.remove();
assertTrue(cache(0, CounterModuleLifecycle.COUNTER_CACHE_NAME).isEmpty());
TestCounter anotherCounter = factory.get(manager, name);
assertTrue(counter.isSame(anotherCounter));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testRollbackSpanningCaches2() throws Exception {
startAllCaches();
Cache<String, String> c1 = cache(0, "c1");
assertTrue(c1.getCacheConfiguration().clustering().cacheMode().isClustered());
Cache<String, String> c1Replica = cache(1, "c1");
assertTrue(c1.isEmpty());
assertTrue(c1Replica.isEmpty());
c1.put("c1key", "c1value");
assertEquals(c1.get("c1key"), "c1value");
assertEquals(c1Replica.get("c1key"), "c1value");
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testGrouper() throws Throwable {
for (Cache<Object, String> c : caches) assert c.isEmpty();
// Based on the grouping fn which uses computes a group by taking the digit from kX
// and doing a modulo 2 on it we can verify the owners of keys
Assert.assertNotSame(getOwners("k1"), getOwners("k2"));
Assert.assertNotSame(getOwners("k1"), getOwners("k4"));
Assert.assertNotSame(getOwners("k3"), getOwners("k2"));
Assert.assertNotSame(getOwners("k3"), getOwners("k4"));
Assert.assertEquals(getOwners("k1"), getOwners("k3"));
Assert.assertEquals(getOwners("k2"), getOwners("k4"));
}
代码示例来源:origin: org.infinispan/infinispan-core
private void assertCacheSize(int expectedSize) {
assertEquals(expectedSize, cache.size());
assertEquals(expectedSize, cache.keySet().size());
assertEquals(expectedSize, cache.values().size());
assertEquals(expectedSize, cache.entrySet().size());
boolean isEmpty = expectedSize == 0;
assertEquals(isEmpty, cache.isEmpty());
assertEquals(isEmpty, cache.keySet().isEmpty());
assertEquals(isEmpty, cache.values().isEmpty());
assertEquals(isEmpty, cache.entrySet().isEmpty());
}
代码示例来源:origin: org.infinispan/infinispan-core
private void assertCacheSize(int expectedSize) {
assertEquals(expectedSize, cache.size());
assertEquals(expectedSize, cache.keySet().size());
assertEquals(expectedSize, cache.values().size());
assertEquals(expectedSize, cache.entrySet().size());
boolean isEmpty = expectedSize == 0;
assertEquals(isEmpty, cache.isEmpty());
assertEquals(isEmpty, cache.keySet().isEmpty());
assertEquals(isEmpty, cache.values().isEmpty());
assertEquals(isEmpty, cache.entrySet().isEmpty());
}
内容来源于网络,如有侵权,请联系作者删除!