Search in sources :

Example 1 with PrivateMetadata

use of org.infinispan.metadata.impl.PrivateMetadata 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 PrivateMetadata

use of org.infinispan.metadata.impl.PrivateMetadata in project infinispan by infinispan.

the class EntryFactoryImpl method createWrappedEntry.

protected MVCCEntry<?, ?> createWrappedEntry(Object key, CacheEntry<?, ?> cacheEntry) {
    Object value = null;
    Metadata metadata = null;
    PrivateMetadata internalMetadata = null;
    if (cacheEntry != null) {
        synchronized (cacheEntry) {
            value = cacheEntry.getValue();
            metadata = cacheEntry.getMetadata();
            internalMetadata = cacheEntry.getInternalMetadata();
        }
    }
    if (log.isTraceEnabled())
        log.tracef("Creating new entry for key %s", toStr(key));
    MVCCEntry<?, ?> mvccEntry;
    if (useRepeatableRead) {
        if (useVersioning) {
            if (internalMetadata == null) {
                internalMetadata = nonExistingPrivateMetadata;
            }
            mvccEntry = new VersionedRepeatableReadEntry(key, value, metadata);
        } else {
            mvccEntry = new RepeatableReadEntry(key, value, metadata);
        }
    } else {
        mvccEntry = new ReadCommittedEntry(key, value, metadata);
    }
    mvccEntry.setInternalMetadata(internalMetadata);
    if (cacheEntry != null) {
        mvccEntry.setCreated(cacheEntry.getCreated());
        mvccEntry.setLastUsed(cacheEntry.getLastUsed());
    }
    return mvccEntry;
}
Also used : ReadCommittedEntry(org.infinispan.container.entries.ReadCommittedEntry) RepeatableReadEntry(org.infinispan.container.entries.RepeatableReadEntry) VersionedRepeatableReadEntry(org.infinispan.container.entries.VersionedRepeatableReadEntry) Metadata(org.infinispan.metadata.Metadata) PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata) PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata) VersionedRepeatableReadEntry(org.infinispan.container.entries.VersionedRepeatableReadEntry)

Example 3 with PrivateMetadata

use of org.infinispan.metadata.impl.PrivateMetadata 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 4 with PrivateMetadata

use of org.infinispan.metadata.impl.PrivateMetadata in project infinispan by infinispan.

the class MarshalledEntryUtil method createWithVersion.

public static <K, V> MarshallableEntry<K, V> createWithVersion(K key, V value, Cache cache) {
    ComponentRegistry registry = cache.getAdvancedCache().getComponentRegistry();
    MarshallableEntryFactory<K, V> entryFactory = registry.getComponent(MarshallableEntryFactory.class);
    VersionGenerator versionGenerator = registry.getVersionGenerator();
    PrivateMetadata metadata = new PrivateMetadata.Builder().entryVersion(versionGenerator.generateNew()).build();
    return entryFactory.create(key, value, null, metadata, -1, -1);
}
Also used : ComponentRegistry(org.infinispan.factories.ComponentRegistry) VersionGenerator(org.infinispan.container.versioning.VersionGenerator) PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata)

Example 5 with PrivateMetadata

use of org.infinispan.metadata.impl.PrivateMetadata in project infinispan by infinispan.

the class NonTxIracRemoteSiteInterceptor method setIracMetadataForOwner.

/**
 * Invoked by backup owners, it makes sure the entry has the same version as set by the primary owner.
 */
private void setIracMetadataForOwner(InvocationContext ctx, DataWriteCommand command, @SuppressWarnings("unused") Object rv) {
    final Object key = command.getKey();
    PrivateMetadata metadata = command.getInternalMetadata();
    iracVersionGenerator.updateVersion(command.getSegment(), metadata.iracMetadata().getVersion());
    setPrivateMetadata(ctx.lookupEntry(key), command.getSegment(), metadata, iracTombstoneManager, this);
}
Also used : PrivateMetadata(org.infinispan.metadata.impl.PrivateMetadata) IracUtils.setPrivateMetadata(org.infinispan.util.IracUtils.setPrivateMetadata)

Aggregations

PrivateMetadata (org.infinispan.metadata.impl.PrivateMetadata)19 IracMetadata (org.infinispan.metadata.impl.IracMetadata)9 Metadata (org.infinispan.metadata.Metadata)7 IOException (java.io.IOException)4 IracUtils.setPrivateMetadata (org.infinispan.util.IracUtils.setPrivateMetadata)3 ByteBuffer (java.nio.ByteBuffer)2 ByRef (org.infinispan.commons.util.ByRef)2 MarshallableEntry (org.infinispan.persistence.spi.MarshallableEntry)2 InputStream (java.io.InputStream)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 CompletionException (java.util.concurrent.CompletionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IracPutKeyCommand (org.infinispan.commands.irac.IracPutKeyCommand)1 WriteCommand (org.infinispan.commands.write.WriteCommand)1 CacheException (org.infinispan.commons.CacheException)1 ByteBuffer (org.infinispan.commons.io.ByteBuffer)1 Marshaller (org.infinispan.commons.marshall.Marshaller)1 MarshallingException (org.infinispan.commons.marshall.MarshallingException)1