use of org.infinispan.metadata.impl.IracMetadata in project infinispan by infinispan.
the class CommandsFactoryImpl method buildIracPutKeyCommand.
@Override
public <K, V> IracPutKeyCommand buildIracPutKeyCommand(InternalCacheEntry<K, V> entry) {
PrivateMetadata internalMetadata = entry.getInternalMetadata();
assert internalMetadata != null : "[IRAC] Metadata to send to remote site is null! key=" + entry.getKey();
IracMetadata iracMetadata = internalMetadata.iracMetadata();
return new IracPutKeyCommand(cacheName, entry.getKey(), entry.getValue(), entry.getMetadata(), iracMetadata);
}
use of org.infinispan.metadata.impl.IracMetadata 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.metadata.impl.IracMetadata in project infinispan by infinispan.
the class NonTxIracRemoteSiteInterceptor method getIracMetadata.
private IracMetadata getIracMetadata(CacheEntry<?, ?> entry) {
PrivateMetadata privateMetadata = entry.getInternalMetadata();
if (privateMetadata == null) {
// new entry!
return iracTombstoneManager.getTombstone(entry.getKey());
}
IracMetadata metadata = privateMetadata.iracMetadata();
return metadata == null ? iracTombstoneManager.getTombstone(entry.getKey()) : metadata;
}
use of org.infinispan.metadata.impl.IracMetadata 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.metadata.impl.IracMetadata in project infinispan by infinispan.
the class IracMetadataStoreTest method testPreload.
public void testPreload(Method method) {
final String key = TestingUtil.k(method, 1);
final Cache<String, Object> pOwnerCache = findPrimaryOwner(key);
final ManualIracVersionGenerator vGenerator = createManualIracVerionGenerator(pOwnerCache);
final ManualIracManager iracManager = createManualIracManager(pOwnerCache);
IracMetadata metadata = generateNew();
// next write will have this version
vGenerator.metadata = metadata;
// we evict the key and then invoke the preload() method
// to avoid killing and starting a node.
pOwnerCache.put(key, "v4");
iracManager.sendKeys();
assertEventuallyInSite(NYC, cache -> "v4".equals(cache.get(key)), 30, TimeUnit.SECONDS);
evictKey(LON, key);
assertNotInDataContainer(LON, key);
assertInCacheStore(LON, key, "v4", metadata);
preload();
assertInDataContainer(LON, key, "v4", metadata);
if (!passivation) {
assertInCacheStore(LON, key, "v4", metadata);
}
}
Aggregations