use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testMultipleLocalAndRemoteLocks1.
/**
* @throws Exception If test failed.
*/
@Test
public void testMultipleLocalAndRemoteLocks1() throws Exception {
UUID nodeId = UUID.randomUUID();
GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
GridCacheContext<String, String> ctx = cache.context();
GridCacheTestEntryEx entry1 = new GridCacheTestEntryEx(ctx, "1");
GridCacheTestEntryEx entry2 = new GridCacheTestEntryEx(ctx, "2");
GridCacheTestEntryEx entry3 = new GridCacheTestEntryEx(ctx, "3");
GridCacheVersion ver1 = version(1);
GridCacheVersion ver2 = version(2);
GridCacheVersion ver3 = version(3);
GridCacheMvccCandidate c13 = entry1.addLocal(1, ver3, 0, true, false);
entry1.readyLocal(ver3);
checkLocalOwner(entry1.candidate(ver3), ver3, false);
GridCacheMvccCandidate c11 = entry1.addLocal(2, ver1, 0, true, true);
GridCacheMvccCandidate c21 = entry2.addLocal(2, ver1, 0, true, true);
GridCacheMvccCandidate c31 = entry3.addLocal(2, ver1, 0, true, true);
GridCacheMvccCandidate c33 = entry3.addLocal(1, ver3, 0, true, false);
linkCandidates(ctx, c11, c21, c31);
entry1.readyLocal(ver1);
entry2.readyLocal(ver1);
entry3.readyLocal(ver1);
checkLocal(entry1.candidate(ver1), ver1, true, false, false);
checkLocal(entry2.candidate(ver1), ver1, true, false, false);
checkLocal(entry3.candidate(ver1), ver1, true, false, false);
checkLocal(entry3.candidate(ver3), ver3, false, false, false);
linkCandidates(ctx, c13, c33);
entry2.addRemote(nodeId, 3, ver2, true);
checkLocal(entry2.candidate(ver1), ver1, true, false, false);
entry3.addRemote(nodeId, 3, ver2, false);
entry3.readyLocal(ver3);
checkLocal(entry1.candidate(ver3), ver3, true, true, false);
checkLocal(entry3.candidate(ver3), ver3, true, true, false);
checkLocal(entry1.candidate(ver1), ver1, true, false, false);
checkLocal(entry2.candidate(ver1), ver1, true, false, false);
checkLocal(entry3.candidate(ver1), ver1, true, false, false);
entry1.releaseLocal(1);
entry2.recheckLock();
checkLocal(entry1.candidate(ver1), ver1, true, true, false);
checkLocal(entry2.candidate(ver1), ver1, true, true, false);
checkLocal(entry3.candidate(ver1), ver1, true, false, false);
entry3.releaseLocal(1);
checkLocal(entry1.candidate(ver1), ver1, true, true, false);
checkLocal(entry2.candidate(ver1), ver1, true, true, false);
checkLocal(entry3.candidate(ver1), ver1, true, true, false);
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testReverseOrder4.
/**
* Tests local candidates with remote version in the middle on key2.
*
* @throws Exception If failed.
*/
@Test
public void testReverseOrder4() throws Exception {
UUID id = UUID.randomUUID();
GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
GridCacheContext<String, String> ctx = cache.context();
GridCacheTestEntryEx entry1 = new GridCacheTestEntryEx(ctx, "1");
GridCacheTestEntryEx entry2 = new GridCacheTestEntryEx(ctx, "2");
GridCacheVersion ver1 = version(1);
GridCacheVersion ver2 = version(2);
GridCacheVersion ver3 = version(3);
// Local with higher version.
GridCacheMvccCandidate v3k1 = entry1.addLocal(3, ver3, 0, true, false);
GridCacheMvccCandidate v3k2 = entry2.addLocal(3, ver3, 0, true, false);
linkCandidates(ctx, v3k1, v3k2);
entry1.readyLocal(ver3);
checkLocal(v3k1, ver3, true, true, false);
checkLocal(v3k2, ver3, false, false, false);
GridCacheMvccCandidate v1k1 = entry1.addLocal(4, ver1, 0, true, true);
GridCacheMvccCandidate v1k2 = entry2.addLocal(4, ver1, 0, true, true);
// Link up.
linkCandidates(ctx, v1k1, v1k2);
entry1.readyLocal(ver1);
entry2.readyLocal(ver1);
// Owner.
checkLocal(v3k1, ver3, true, true, false);
checkLocal(v3k2, ver3, false, false, false);
checkLocal(v1k1, ver1, true, false, false);
checkLocal(v1k2, ver1, true, false, false);
GridCacheMvccCandidate v2k2 = entry2.addRemote(id, 5, ver2, false);
checkRemote(v2k2, ver2, false, false);
entry2.readyLocal(v3k2);
checkLocal(v3k1, ver3, true, true, false);
checkLocal(v3k2, ver3, true, true, false);
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testUsedCandidates.
/**
* @throws Exception If failed.
*/
@Test
public void testUsedCandidates() throws Exception {
GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
GridCacheContext<String, String> ctx = cache.context();
GridCacheTestEntryEx entry = new GridCacheTestEntryEx(cache.context(), "1");
GridCacheVersion ver1 = version(1);
GridCacheVersion ver2 = version(2);
GridCacheVersion ver3 = version(3);
GridCacheVersion ver4 = version(4);
GridCacheMvccCandidate c1 = entry.addLocal(1, ver1, 0, true, false);
ctx.mvcc().addNext(ctx, c1);
ctx.mvcc().contextReset();
GridCacheMvccCandidate c2 = entry.addLocal(2, ver2, 0, true, false);
ctx.mvcc().addNext(ctx, c2);
ctx.mvcc().contextReset();
GridCacheMvccCandidate c3 = entry.addLocal(3, ver3, 0, true, true);
ctx.mvcc().addNext(ctx, c3);
ctx.mvcc().contextReset();
checkLocal(entry.candidate(ver1), ver1, false, false, false);
checkLocal(entry.candidate(ver2), ver2, false, false, false);
checkLocal(entry.candidate(ver3), ver3, false, false, false);
entry.readyLocal(ver1);
entry.readyLocal(ver3);
checkLocal(entry.candidate(ver1), ver1, true, true, false);
checkLocal(entry.candidate(ver2), ver2, false, false, false);
checkLocal(entry.candidate(ver3), ver3, true, false, false);
entry.removeLock(ver2);
assert c3 != null;
assert c2 != null;
checkLocal(c2, ver2, false, false, false, true);
checkLocal(entry.candidate(ver1), ver1, true, true, false);
checkLocal(entry.candidate(ver3), ver3, true, false, false);
entry.removeLock(ver1);
checkLocal(entry.candidate(ver3), ver3, true, true, false);
GridCacheMvccCandidate c4 = entry.addLocal(4, ver4, 0, true, true);
ctx.mvcc().addNext(ctx, c4);
assert c4 != null;
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testCompletedWithBaseNotPresentInTheBeginningNoChange.
/**
*/
@Test
public void testCompletedWithBaseNotPresentInTheBeginningNoChange() {
GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
GridCacheTestEntryEx entry = new GridCacheTestEntryEx(cache.context(), "1");
UUID node1 = UUID.randomUUID();
UUID node2 = UUID.randomUUID();
GridCacheVersion ver1 = version(1);
GridCacheVersion ver2 = version(2);
GridCacheVersion ver3 = version(3);
GridCacheVersion ver4 = version(4);
GridCacheVersion ver5 = version(5);
GridCacheVersion ver6 = version(6);
GridCacheVersion ver7 = version(7);
// Don't add version 6, 7
entry.addRemote(node1, 2, ver2, true);
entry.addRemote(node1, 3, ver3, true);
entry.addRemote(node2, 4, ver4, true);
entry.addRemote(node1, 5, ver5, true);
entry.addRemote(node1, 6, ver6, true);
entry.addRemote(node1, 7, ver7, true);
List<GridCacheVersion> committed = Arrays.asList(ver2, ver3);
entry.orderCompleted(ver1, committed, Collections.<GridCacheVersion>emptyList());
checkOrder(entry.remoteMvccSnapshot(), ver2, ver3, ver4, ver5, ver6, ver7);
checkRemote(entry.candidate(ver2), ver2, true, false);
checkRemote(entry.candidate(ver3), ver3, true, false);
checkRemote(entry.candidate(ver4), ver4, false, false);
checkRemote(entry.candidate(ver5), ver5, false, false);
checkRemote(entry.candidate(ver6), ver6, false, false);
checkRemote(entry.candidate(ver7), ver7, false, false);
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testCompletedWithBaseInTheBeginning.
/**
*/
@Test
public void testCompletedWithBaseInTheBeginning() {
GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
GridCacheTestEntryEx entry = new GridCacheTestEntryEx(cache.context(), "1");
UUID node1 = UUID.randomUUID();
UUID node2 = UUID.randomUUID();
GridCacheVersion ver1 = version(1);
GridCacheVersion ver2 = version(2);
GridCacheVersion ver3 = version(3);
GridCacheVersion ver4 = version(4);
GridCacheVersion ver5 = version(5);
GridCacheVersion ver6 = version(6);
GridCacheVersion ver7 = version(7);
entry.addRemote(node1, 1, ver1, false);
entry.addRemote(node2, 2, ver2, false);
entry.addRemote(node1, 3, ver3, false);
entry.addRemote(node2, 4, ver4, false);
entry.addRemote(node1, 5, ver5, false);
entry.addRemote(node2, 6, ver6, false);
entry.addRemote(node2, 7, ver7, false);
List<GridCacheVersion> committed = Arrays.asList(ver4, ver6, ver3);
entry.orderCompleted(ver1, committed, Collections.<GridCacheVersion>emptyList());
checkOrder(entry.remoteMvccSnapshot(), ver3, ver4, ver6, ver1, ver2, ver5, ver7);
checkRemote(entry.candidate(ver1), ver1, false, false);
checkRemote(entry.candidate(ver2), ver2, false, false);
checkRemote(entry.candidate(ver3), ver3, true, false);
checkRemote(entry.candidate(ver4), ver4, true, false);
checkRemote(entry.candidate(ver5), ver5, false, false);
checkRemote(entry.candidate(ver6), ver6, true, false);
checkRemote(entry.candidate(ver7), ver7, false, false);
}
Aggregations