use of org.infinispan.container.versioning.irac.DefaultIracVersionGenerator in project infinispan by infinispan.
the class IracVersionUnitTest method testCausality.
public void testCausality() {
DefaultIracVersionGenerator g1 = newGenerator(SITE_1);
DefaultIracVersionGenerator g2 = newGenerator(SITE_2);
// (0,1)
IracMetadata m2 = g2.generateNewMetadata(0);
assertNoSiteVersion(m2.getVersion(), SITE_1);
assertSiteVersion(m2.getVersion(), SITE_2, 1, 1);
g1.updateVersion(0, m2.getVersion());
// (1,1)
IracMetadata m1 = g1.generateNewMetadata(0);
assertSiteVersion(m1.getVersion(), SITE_1, 1, 1);
assertSiteVersion(m1.getVersion(), SITE_2, 1, 1);
// we have m1=(1,1) and m2=(0,1)
assertEquals(InequalVersionComparisonResult.BEFORE, m2.getVersion().compareTo(m1.getVersion()));
assertEquals(InequalVersionComparisonResult.AFTER, m1.getVersion().compareTo(m2.getVersion()));
}
use of org.infinispan.container.versioning.irac.DefaultIracVersionGenerator in project infinispan by infinispan.
the class IracVersionUnitTest method testConflictSameTopology.
public void testConflictSameTopology() {
DefaultIracVersionGenerator g1 = newGenerator(SITE_1);
DefaultIracVersionGenerator g2 = newGenerator(SITE_2);
// (1,0)
IracMetadata m1 = g1.generateNewMetadata(0);
// (0,1)
IracMetadata m2 = g2.generateNewMetadata(0);
assertEquals(SITE_1, m1.getSite());
assertEquals(SITE_2, m2.getSite());
assertSiteVersion(m1.getVersion(), SITE_1, 1, 1);
assertNoSiteVersion(m1.getVersion(), SITE_2);
assertNoSiteVersion(m2.getVersion(), SITE_1);
assertSiteVersion(m2.getVersion(), SITE_2, 1, 1);
// we have a conflict: (1,0) vs (0,1)
assertEquals(InequalVersionComparisonResult.CONFLICTING, m1.getVersion().compareTo(m2.getVersion()));
}
use of org.infinispan.container.versioning.irac.DefaultIracVersionGenerator in project infinispan by infinispan.
the class IracVersionUnitTest method testCompareSameTopology.
public void testCompareSameTopology() {
DefaultIracVersionGenerator g1 = newGenerator(SITE_1);
// (1,0)
IracMetadata m1 = g1.generateNewMetadata(0);
// (2,0)
IracMetadata m2 = g1.generateNewMetadata(0);
assertSiteVersion(m1.getVersion(), SITE_1, 1, 1);
assertNoSiteVersion(m1.getVersion(), SITE_2);
assertSiteVersion(m2.getVersion(), SITE_1, 1, 2);
assertNoSiteVersion(m2.getVersion(), SITE_2);
assertEquals(InequalVersionComparisonResult.BEFORE, m1.getVersion().compareTo(m2.getVersion()));
assertEquals(InequalVersionComparisonResult.AFTER, m2.getVersion().compareTo(m1.getVersion()));
}
use of org.infinispan.container.versioning.irac.DefaultIracVersionGenerator in project infinispan by infinispan.
the class IracRestartWithGlobalStateTest method snapshotPrimaryVersions.
private Map<Integer, IracEntryVersion> snapshotPrimaryVersions() {
Map<Integer, IracEntryVersion> versions = new HashMap<>(256);
for (Cache<?, ?> cache : caches(0)) {
DefaultIracVersionGenerator vGenerator = generator(cache);
LocalizedCacheTopology topology = extractCacheTopology(cache);
Map<Integer, IracEntryVersion> cacheVersions = vGenerator.peek();
log.tracef("Taking snapshot from %s (%s entries): %s", addressOf(cache), cacheVersions.size(), cacheVersions);
cacheVersions.forEach((segment, version) -> {
if (topology.getSegmentDistribution(segment).isPrimary()) {
IracEntryVersion v = versions.putIfAbsent(segment, version);
assertNull(v);
}
});
log.tracef("Global versions after %s (%s entries): %s", addressOf(cache), versions.size(), versions);
}
return versions;
}
use of org.infinispan.container.versioning.irac.DefaultIracVersionGenerator in project infinispan by infinispan.
the class IracVersionUnitTest method testCompareDifferentTopology.
public void testCompareDifferentTopology() {
DefaultIracVersionGenerator g1 = newGenerator(SITE_1);
// (1,0)
IracMetadata m1 = g1.generateNewMetadata(0);
triggerTopologyEvent(g1);
// (1+,0)
IracMetadata m2 = g1.generateNewMetadata(0);
assertSiteVersion(m1.getVersion(), SITE_1, 1, 1);
assertNoSiteVersion(m1.getVersion(), SITE_2);
assertSiteVersion(m2.getVersion(), SITE_1, 2, 1);
assertNoSiteVersion(m2.getVersion(), SITE_2);
// we have m1=(1,0) and m2=(1+,0)
assertEquals(InequalVersionComparisonResult.BEFORE, m1.getVersion().compareTo(m2.getVersion()));
assertEquals(InequalVersionComparisonResult.AFTER, m2.getVersion().compareTo(m1.getVersion()));
}
Aggregations