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);
}
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;
}
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();
}
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);
}
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);
}
Aggregations