use of org.infinispan.remoting.responses.PrepareResponse.asPrepareResponse 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;
}
Aggregations