use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testNearRemoteWithOwned2.
/**
* Tests that orderOwned does not reorder owned locks.
*/
@Test
public void testNearRemoteWithOwned2() {
GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
GridCacheTestEntryEx entry = new GridCacheTestEntryEx(cache.context(), "1");
UUID node1 = UUID.randomUUID();
GridCacheVersion ver0 = version(0);
GridCacheVersion ver1 = version(1);
GridCacheVersion ver2 = version(2);
GridCacheVersion ver3 = version(3);
GridCacheVersion ver4 = version(4);
GridCacheVersion ver5 = version(5);
GridCacheVersion ver6 = version(6);
GridCacheMvccCandidate c0 = entry.addRemote(node1, 1, ver0, true);
GridCacheMvccCandidate c1 = entry.addRemote(node1, 1, ver1, true);
GridCacheMvccCandidate c2 = entry.addRemote(node1, 1, ver2, true);
GridCacheMvccCandidate c3 = entry.addRemote(node1, 1, ver3, true);
GridCacheMvccCandidate c4 = entry.addRemote(node1, 1, ver4, true);
GridCacheMvccCandidate c5 = entry.addRemote(node1, 1, ver5, true);
GridCacheMvccCandidate c6 = entry.addRemote(node1, 1, ver6, true);
GridCacheMvccCandidate[] candArr = new GridCacheMvccCandidate[] { c0, c1, c2, c3, c4, c5, c6 };
Collection<GridCacheMvccCandidate> cands = entry.remoteMvccSnapshot();
assert cands.size() == 7;
assert cands.iterator().next().version().equals(ver0);
entry.orderOwned(ver1, ver2);
cands = entry.remoteMvccSnapshot();
int i = 0;
for (GridCacheMvccCandidate cand : cands) {
assert cand == candArr[i];
assertTrue(ver2.equals(cand.ownerVersion()) || cand != c1);
i++;
}
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testCompletedWithBaseInTheBeginningNoChange.
/**
* This case should never happen, nevertheless we need to test for it.
*/
@Test
public void testCompletedWithBaseInTheBeginningNoChange() {
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);
List<GridCacheVersion> committed = Arrays.asList(ver6, ver7);
entry.orderCompleted(ver1, committed, Collections.<GridCacheVersion>emptyList());
checkOrder(entry.remoteMvccSnapshot(), ver1, ver2, ver3, ver4, ver5);
// Nothing set to owner since there is no change.
checkRemote(entry.candidate(ver1), ver1, false, false);
checkRemote(entry.candidate(ver2), ver2, false, false);
checkRemote(entry.candidate(ver3), ver3, false, false);
checkRemote(entry.candidate(ver4), ver4, false, false);
checkRemote(entry.candidate(ver5), ver5, false, false);
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccSelfTest method testMultipleLocalLocks.
/**
* @throws Exception If test failed.
*/
@Test
public void testMultipleLocalLocks() throws Exception {
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 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, false);
linkCandidates(ctx, c11, c21);
entry1.readyLocal(ver1);
entry2.readyLocal(ver1);
checkLocal(entry1.candidate(ver1), ver1, true, false, false);
checkLocal(entry2.candidate(ver1), ver1, true, false, false);
GridCacheMvccCandidate c23 = entry2.addLocal(1, ver3, 0, true, true);
linkCandidates(ctx, c13, c23);
entry2.readyLocal(ver3);
checkLocalOwner(entry2.candidate(ver3), ver3, false);
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridCacheMvccFlagsTest method testAllFalseFlags.
/**
*/
@Test
public void testAllFalseFlags() {
GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
GridCacheTestEntryEx entry = new GridCacheTestEntryEx(cache.context(), "1");
UUID id = UUID.randomUUID();
GridCacheVersion ver = new GridCacheVersion(1, 0, 0, 0);
GridCacheMvccCandidate c = new GridCacheMvccCandidate(entry, id, id, ver, 1, ver, false, false, false, false, false, false, null, false);
short flags = c.flags();
info("Candidate: " + c);
for (GridCacheMvccCandidate.Mask mask : GridCacheMvccCandidate.Mask.values()) assertFalse("Mask check failed [mask=" + mask + ", c=" + c + ']', mask.get(flags));
}
use of org.apache.ignite.internal.processors.cache.version.GridCacheVersion in project ignite by apache.
the class GridDhtLockFuture method loadMissingFromStore.
/**
*/
private void loadMissingFromStore() {
if (!skipStore && (read || cctx.loadPreviousValue()) && cctx.readThrough() && (needReturnVal || read)) {
final Map<KeyCacheObject, GridDhtCacheEntry> loadMap = new LinkedHashMap<>();
final GridCacheVersion ver = version();
for (GridDhtCacheEntry entry : entries) {
try {
entry.unswap(false);
if (!entry.hasValue())
loadMap.put(entry.key(), entry);
} catch (GridCacheEntryRemovedException e) {
assert false : "Should not get removed exception while holding lock on entry " + "[entry=" + entry + ", e=" + e + ']';
} catch (IgniteCheckedException e) {
onDone(e);
return;
}
}
try {
cctx.store().loadAll(null, loadMap.keySet(), new CI2<KeyCacheObject, Object>() {
@Override
public void apply(KeyCacheObject key, Object val) {
// No value loaded from store.
if (val == null)
return;
GridDhtCacheEntry entry0 = loadMap.get(key);
try {
CacheObject val0 = cctx.toCacheObject(val);
long ttl = createTtl;
long expireTime;
if (ttl == CU.TTL_ZERO)
expireTime = CU.expireTimeInPast();
else {
if (ttl == CU.TTL_NOT_CHANGED)
ttl = CU.TTL_ETERNAL;
expireTime = CU.toExpireTime(ttl);
}
entry0.initialValue(val0, ver, ttl, expireTime, false, topVer, GridDrType.DR_LOAD, true, false);
} catch (GridCacheEntryRemovedException e) {
assert false : "Should not get removed exception while holding lock on entry " + "[entry=" + entry0 + ", e=" + e + ']';
} catch (IgniteCheckedException e) {
onDone(e);
}
}
});
} catch (IgniteCheckedException e) {
onDone(e);
}
}
}
Aggregations