Skip to content

Commit

Permalink
# IGNITE-56 Use IgniteCache in ignite-core module (3).
Browse files Browse the repository at this point in the history
  • Loading branch information
sevdokimov committed Feb 1, 2015
1 parent d6ed718 commit c10fad8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 113 deletions.
Expand Up @@ -92,15 +92,15 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
int fullCacheSize = 0; int fullCacheSize = 0;


for (int i = 0; i < gridCount(); i++) for (int i = 0; i < gridCount(); i++)
fullCacheSize += cache(i).primarySize(); fullCacheSize += jcache(i).localSize();


assertEquals("Invalid cache size", 10, fullCacheSize); assertEquals("Invalid cache size", fullCacheSize, cache.size());
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void testClear() throws Exception { @Override public void testClear() throws Exception {
IgniteCache<String, Integer> nearCache = jcache(); IgniteCache<String, Integer> nearCache = jcache();
GridCache<String, Integer> primary = fullCache(); IgniteCache<String, Integer> primary = fullCache();


Collection<String> keys = primaryKeysForCache(primary, 3); Collection<String> keys = primaryKeysForCache(primary, 3);


Expand Down Expand Up @@ -135,7 +135,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void testClearKeys() throws Exception { @Override public void testClearKeys() throws Exception {
IgniteCache<String, Integer> nearCache = jcache(); IgniteCache<String, Integer> nearCache = jcache();
GridCache<String, Integer> primary = fullCache(); IgniteCache<String, Integer> primary = fullCache();


Collection<String> keys = primaryKeysForCache(primary, 3); Collection<String> keys = primaryKeysForCache(primary, 3);


Expand All @@ -162,7 +162,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache


for (String key : subKeys) { for (String key : subKeys) {
assertNull(nearCache.localPeek(key)); assertNull(nearCache.localPeek(key));
assertNotNull(primary.peek(key)); assertNotNull(primary.localPeek(key));
} }


assertEquals(null, nearCache.localPeek(lastKey)); assertEquals(null, nearCache.localPeek(lastKey));
Expand All @@ -186,7 +186,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
Thread.sleep(ttl + 100); Thread.sleep(ttl + 100);


// Expired entry should not be swapped. // Expired entry should not be swapped.
cache.localEvict(Collections.<String>singleton(key)); cache.localEvict(Collections.singleton(key));


assertNull(cache.localPeek(key)); assertNull(cache.localPeek(key));


Expand All @@ -198,8 +198,8 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache


// Force reload on primary node. // Force reload on primary node.
for (int i = 0; i < gridCount(); i++) { for (int i = 0; i < gridCount(); i++) {
if (cache(i).entry(key).primary()) if (ignite(i).affinity(null).isPrimary(ignite(i).cluster().localNode(), key))
cache(i).reload(key); jcache(i).loadAll(Collections.singleton(key), true, null);
} }


// Will do near get request. // Will do near get request.
Expand Down Expand Up @@ -285,7 +285,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
@Override public void testEvict() throws Exception { @Override public void testEvict() throws Exception {
IgniteCache<String, Integer> cache = jcache(); IgniteCache<String, Integer> cache = jcache();


List<String> keys = primaryKeysForCache(cache(), 2); List<String> keys = primaryKeysForCache(jcache(), 2);


String key = keys.get(0); String key = keys.get(0);
String key2 = keys.get(1); String key2 = keys.get(1);
Expand Down
Expand Up @@ -76,7 +76,7 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void testClear() throws Exception { @Override public void testClear() throws Exception {
IgniteCache<String, Integer> nearCache = jcache(); IgniteCache<String, Integer> nearCache = jcache();
GridCache<String, Integer> primary = fullCache(); IgniteCache<String, Integer> primary = fullCache();


Collection<String> keys = primaryKeysForCache(primary, 3); Collection<String> keys = primaryKeysForCache(primary, 3);


Expand Down Expand Up @@ -114,7 +114,7 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void testEvictExpired() throws Exception { @Override public void testEvictExpired() throws Exception {
GridCache<String, Integer> cache = cache(); IgniteCache<String, Integer> cache = jcache();


String key = primaryKeysForCache(cache, 1).get(0); String key = primaryKeysForCache(cache, 1).get(0);


Expand All @@ -130,25 +130,25 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe
Thread.sleep(ttl + 100); Thread.sleep(ttl + 100);


// Expired entry should not be swapped. // Expired entry should not be swapped.
assertTrue(cache.evict(key)); cache.localEvict(Collections.<String>singleton(key));


assertNull(cache.peek(key)); assertNull(cache.localPeek(key));


assertNull(cache.promote(key)); cache.localPromote(Collections.singleton(key));


assertNull(cache.peek(key)); assertNull(cache.localPeek(key));


assertTrue(cache.isEmpty()); assertTrue(cache.localSize() == 0);


// Force reload on primary node. // Force reload on primary node.
for (int i = 0; i < gridCount(); i++) { for (int i = 0; i < gridCount(); i++) {
if (cache(i).entry(key).primary()) if (ignite(i).affinity(null).isPrimary(ignite(i).cluster().localNode(), key))
cache(i).reload(key); jcache(i).loadAll(Collections.singleton(key), true, null);
} }


// Will do near get request. // Will do near get request.
cache.reload(key); cache.loadAll(Collections.singleton(key), true, null);


assertEquals((Integer)1, cache.peek(key)); assertEquals((Integer)1, cache.localPeek(key));
} }
} }

0 comments on commit c10fad8

Please sign in to comment.