use of org.infinispan.container.versioning.irac.IracEntryVersion in project infinispan by infinispan.
the class SingleFileStore method generateMissingInternalMetadata.
// Initialise missing internal metadata state for corrupt data
private PrivateMetadata generateMissingInternalMetadata() {
// Optimistic Transactions
AdvancedCache<?, ?> cache = ctx.getCache().getAdvancedCache();
Configuration config = cache.getCacheConfiguration();
TransactionConfiguration txConfig = config.transaction();
PrivateMetadata.Builder builder = new PrivateMetadata.Builder();
if (txConfig.transactionMode() == TransactionMode.TRANSACTIONAL && txConfig.lockingMode() == LockingMode.OPTIMISTIC) {
builder.entryVersion(new SimpleClusteredVersion(1, 1));
}
// Async XSite
if (config.sites().hasAsyncEnabledBackups()) {
String siteName = cache.getRpcManager().getTransport().localSiteName();
IracEntryVersion version = IracEntryVersion.newVersion(XSiteNamedCache.cachedByteString(siteName), TopologyIracVersion.newVersion(1));
builder.iracMetadata(new IracMetadata(siteName, version));
}
return builder.build();
}
use of org.infinispan.container.versioning.irac.IracEntryVersion in project infinispan by infinispan.
the class PessimisticTxIracLocalInterceptor method requestNewMetadata.
private CompletionStage<IracMetadata> requestNewMetadata(int segment, CacheEntry<?, ?> cacheEntry) {
LocalizedCacheTopology cacheTopology = getCacheTopology();
DistributionInfo dInfo = cacheTopology.getSegmentDistribution(segment);
if (dInfo.isPrimary()) {
IracEntryVersion versionSeen = getIracVersionFromCacheEntry(cacheEntry);
return CompletableFuture.completedFuture(iracVersionGenerator.generateNewMetadata(segment, versionSeen));
} else {
return requestNewMetadataFromPrimaryOwner(dInfo, cacheTopology.getTopologyId(), cacheEntry);
}
}
use of org.infinispan.container.versioning.irac.IracEntryVersion in project infinispan by infinispan.
the class OptimisticTxIracLocalSiteInterceptor method afterRemoteTwoPhasePrepare.
private Object afterRemoteTwoPhasePrepare(InvocationContext ctx, PrepareCommand command, Object rv) {
if (isTraceEnabled()) {
getLog().tracef("[IRAC] After successful remote prepare for tx %s. Return Value: %s", command.getGlobalTransaction(), rv);
}
PrepareResponse rsp = PrepareResponse.asPrepareResponse(rv);
Iterator<StreamData> iterator = streamKeysFromModifications(command.getModifications()).filter(this::isPrimaryOwner).distinct().iterator();
Map<Integer, IracEntryVersion> maxVersionSeen = new HashMap<>();
while (iterator.hasNext()) {
StreamData data = iterator.next();
IracEntryVersion versionSeen = getIracVersionFromCacheEntry(ctx.lookupEntry(data.key));
if (versionSeen != null) {
maxVersionSeen.merge(data.segment, versionSeen, IracEntryVersion::merge);
} else {
maxVersionSeen.putIfAbsent(data.segment, null);
}
}
Map<Integer, IracMetadata> segmentMetadata = new HashMap<>();
maxVersionSeen.forEach((segment, version) -> segmentMetadata.put(segment, iracVersionGenerator.generateNewMetadata(segment, version)));
rsp.setNewIracMetadata(segmentMetadata);
if (isTraceEnabled()) {
getLog().tracef("[IRAC] After successful remote prepare for tx %s. New Return Value: %s", command.getGlobalTransaction(), rsp);
}
return rsp;
}
use of org.infinispan.container.versioning.irac.IracEntryVersion in project infinispan by infinispan.
the class IracRestartWithoutGlobalStateTest method assertVersions.
private <K> void assertVersions(Map<K, IracEntryVersion> v1, Map<K, IracEntryVersion> v2, InequalVersionComparisonResult expected) {
assertEquals(v1.size(), v2.size());
Iterator<K> iterator = Stream.concat(v1.keySet().stream(), v2.keySet().stream()).distinct().iterator();
while (iterator.hasNext()) {
K key = iterator.next();
IracEntryVersion version1 = v1.get(key);
IracEntryVersion version2 = v2.get(key);
assertNotNull(format("'%s' version is null for Map 1", key), version1);
assertNotNull(format("'%s' version is null for Map 2", key), version2);
InequalVersionComparisonResult result = version1.compareTo(version2);
assertEquals(format("'%s' version mismatch: %s and %s", key, version1, version2), expected, result);
}
}
use of org.infinispan.container.versioning.irac.IracEntryVersion in project infinispan by infinispan.
the class IracWriteSkewTest method checkKey.
private void checkKey(String key, String value) {
// irac version is the same in all nodes & sites. extract it from one site and check everywhere.
IracEntryVersion iracVersion = extractIracEntryVersion(key);
assertNotNull(iracVersion);
assertIracEntryVersion(key, value, iracVersion);
// NYC has the EntryVersion for write-skew check
IncrementableEntryVersion entryVersion = extractEntryVersion(key);
assertNotNull(entryVersion);
assertIracEntryVersion(key, value, iracVersion, entryVersion);
}
Aggregations