use of org.infinispan.container.entries.metadata.MetadataImmortalCacheValue in project infinispan by infinispan.
the class ScatteredDistributionInterceptor method handleWriteManyOnPrimary.
private Object handleWriteManyOnPrimary(InvocationContext ctx, WriteCommand cmd, Object rv) {
int numKeys = cmd.getAffectedKeys().size();
InternalCacheValue[] values = new InternalCacheValue[numKeys];
// keys are always iterated in order
int i = 0;
AggregateCompletionStage<Void> aggregateCompletionStage = CompletionStages.aggregateCompletionStage();
for (Object key : cmd.getAffectedKeys()) {
RepeatableReadEntry entry = (RepeatableReadEntry) ctx.lookupEntry(key);
EntryVersion nextVersion = svm.incrementVersion(keyPartitioner.getSegment(key));
entry.setMetadata(addVersion(entry.getMetadata(), nextVersion));
if (cmd.loadType() == DONT_LOAD) {
aggregateCompletionStage.dependsOn(commitSingleEntryIfNewer(entry, ctx, cmd));
} else {
aggregateCompletionStage.dependsOn(commitSingleEntryIfNoChange(entry, ctx, cmd));
}
values[i++] = new MetadataImmortalCacheValue(entry.getValue(), entry.getMetadata());
}
CompletionStage<Void> aggregatedStage = aggregateCompletionStage.freeze();
Object returnValue;
if (cmd.loadType() == DONT_LOAD) {
// Disable ignoring return value in response
cmd.setFlagsBitSet(cmd.getFlagsBitSet() & ~FlagBitSets.IGNORE_RETURN_VALUES);
returnValue = values;
} else {
returnValue = new Object[] { values, ((List) rv).toArray() };
}
return asyncValue(aggregatedStage).thenApply(ctx, cmd, ((rCtx, rCommand, rv1) -> manyWriteResponse(rCtx, cmd, returnValue)));
}
use of org.infinispan.container.entries.metadata.MetadataImmortalCacheValue in project infinispan by infinispan.
the class InternalEntryFactoryImpl method createValue.
@Override
public InternalCacheValue createValue(CacheEntry cacheEntry) {
Metadata metadata = cacheEntry.getMetadata();
long lifespan = cacheEntry.getLifespan();
long maxIdle = cacheEntry.getMaxIdle();
if (!isStoreMetadata(metadata, null)) {
if (lifespan < 0 && maxIdle < 0)
return new ImmortalCacheValue(cacheEntry.getValue());
if (lifespan > -1 && maxIdle < 0)
return new MortalCacheValue(cacheEntry.getValue(), cacheEntry.getCreated(), lifespan);
if (lifespan < 0 && maxIdle > -1)
return new TransientCacheValue(cacheEntry.getValue(), maxIdle, cacheEntry.getLastUsed());
return new TransientMortalCacheValue(cacheEntry.getValue(), cacheEntry.getCreated(), lifespan, maxIdle, cacheEntry.getLastUsed());
} else {
if (lifespan < 0 && maxIdle < 0)
return new MetadataImmortalCacheValue(cacheEntry.getValue(), cacheEntry.getMetadata());
if (lifespan > -1 && maxIdle < 0)
return new MetadataMortalCacheValue(cacheEntry.getValue(), cacheEntry.getMetadata(), cacheEntry.getCreated());
if (lifespan < 0 && maxIdle > -1)
return new MetadataTransientCacheValue(cacheEntry.getValue(), cacheEntry.getMetadata(), cacheEntry.getLastUsed());
return new MetadataTransientMortalCacheValue(cacheEntry.getValue(), cacheEntry.getMetadata(), cacheEntry.getCreated(), cacheEntry.getLastUsed());
}
}
use of org.infinispan.container.entries.metadata.MetadataImmortalCacheValue in project infinispan by infinispan.
the class MetadataImmortalCacheValueExternalizer method readObject.
@Override
public MetadataImmortalCacheValue readObject(ObjectInput input) throws IOException, ClassNotFoundException {
Object value = input.readObject();
Metadata metadata = (Metadata) input.readObject();
return new MetadataImmortalCacheValue(value, metadata);
}
Aggregations