Search in sources :

Example 1 with IracMetadata

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);
}
Also used : IracPutKeyCommand(org.infinispan.commands.irac.IracPutKeyCommand) IracMetadata(org.infinispan.metadata.impl.IracMetadata) PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata)

Example 2 with 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();
}
Also used : TransactionConfiguration(org.infinispan.configuration.cache.TransactionConfiguration) SimpleClusteredVersion(org.infinispan.container.versioning.SimpleClusteredVersion) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) AbstractSegmentedStoreConfiguration(org.infinispan.configuration.cache.AbstractSegmentedStoreConfiguration) TransactionConfiguration(org.infinispan.configuration.cache.TransactionConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) IracEntryVersion(org.infinispan.container.versioning.irac.IracEntryVersion) IracMetadata(org.infinispan.metadata.impl.IracMetadata) PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata)

Example 3 with IracMetadata

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;
}
Also used : IracMetadata(org.infinispan.metadata.impl.IracMetadata) PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata) IracUtils.setPrivateMetadata(org.infinispan.util.IracUtils.setPrivateMetadata)

Example 4 with IracMetadata

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;
}
Also used : PrepareResponse.asPrepareResponse(org.infinispan.remoting.responses.PrepareResponse.asPrepareResponse) PrepareResponse(org.infinispan.remoting.responses.PrepareResponse) IracEntryVersion(org.infinispan.container.versioning.irac.IracEntryVersion) HashMap(java.util.HashMap) IracMetadata(org.infinispan.metadata.impl.IracMetadata)

Example 5 with IracMetadata

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);
    }
}
Also used : ManualIracManager(org.infinispan.xsite.irac.ManualIracManager) IracMetadata(org.infinispan.metadata.impl.IracMetadata) ByteString(org.infinispan.util.ByteString)

Aggregations

IracMetadata (org.infinispan.metadata.impl.IracMetadata)41 ByteString (org.infinispan.util.ByteString)12 PrivateMetadata (org.infinispan.metadata.impl.PrivateMetadata)7 DefaultIracVersionGenerator (org.infinispan.container.versioning.irac.DefaultIracVersionGenerator)6 IracEntryVersion (org.infinispan.container.versioning.irac.IracEntryVersion)6 ManualIracManager (org.infinispan.xsite.irac.ManualIracManager)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 DefaultIracTombstoneManager (org.infinispan.container.versioning.irac.DefaultIracTombstoneManager)5 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)4 IracTombstoneCleanupCommand (org.infinispan.commands.irac.IracTombstoneCleanupCommand)4 HashMap (java.util.HashMap)3 IracTombstonePrimaryCheckCommand (org.infinispan.commands.irac.IracTombstonePrimaryCheckCommand)3 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 CompletionStage (java.util.concurrent.CompletionStage)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 CacheRpcCommand (org.infinispan.commands.remote.CacheRpcCommand)2 BackupConfiguration (org.infinispan.configuration.cache.BackupConfiguration)2