Search in sources :

Example 1 with PutMapCommand

use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.

the class ScatteredStateConsumerImpl method backupEntries.

private void backupEntries(List<InternalCacheEntry<?, ?>> entries) {
    long incrementedCounter = chunkCounter.incrementAndGet();
    if (log.isTraceEnabled())
        log.tracef("Backing up entries, chunk counter is %d", incrementedCounter);
    Map<Object, InternalCacheValue<?>> map = new HashMap<>();
    for (InternalCacheEntry<?, ?> entry : entries) {
        map.put(entry.getKey(), entry.toInternalCacheValue());
    }
    PutMapCommand putMapCommand = commandsFactory.buildPutMapCommand(map, null, STATE_TRANSFER_FLAGS);
    putMapCommand.setTopologyId(rpcManager.getTopologyId());
    rpcManager.invokeCommand(backupAddress, putMapCommand, SingleResponseCollector.validOnly(), rpcManager.getSyncRpcOptions()).whenComplete(((response, throwable) -> {
        try {
            if (throwable != null) {
                log.failedOutBoundTransferExecution(throwable);
            }
        } finally {
            long decrementedCounter = chunkCounter.decrementAndGet();
            if (log.isTraceEnabled())
                log.tracef("Backed up entries, chunk counter is %d", decrementedCounter);
            if (decrementedCounter == 0) {
                notifyEndOfStateTransferIfNeeded();
            }
        }
    }));
}
Also used : IntSets(org.infinispan.commons.util.IntSets) LogFactory(org.infinispan.util.logging.LogFactory) EntryVersion(org.infinispan.container.versioning.EntryVersion) RemoteMetadata(org.infinispan.container.entries.RemoteMetadata) ClusteredGetAllCommand(org.infinispan.commands.remote.ClusteredGetAllCommand) CONTAINER(org.infinispan.util.logging.Log.CONTAINER) CompletableFutures(org.infinispan.util.concurrent.CompletableFutures) Map(java.util.Map) PERSISTENCE(org.infinispan.util.logging.Log.PERSISTENCE) ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BlockingQueue(java.util.concurrent.BlockingQueue) CacheTopology(org.infinispan.topology.CacheTopology) ComponentStatus(org.infinispan.lifecycle.ComponentStatus) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) IntSet(org.infinispan.commons.util.IntSet) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) SuccessfulResponse(org.infinispan.remoting.responses.SuccessfulResponse) PutKeyValueCommand(org.infinispan.commands.write.PutKeyValueCommand) InboundTransferTask(org.infinispan.statetransfer.InboundTransferTask) GuardedBy(net.jcip.annotations.GuardedBy) InternalCacheValue(org.infinispan.container.entries.InternalCacheValue) InvalidateVersionsCommand(org.infinispan.commands.write.InvalidateVersionsCommand) InternalCacheEntry(org.infinispan.container.entries.InternalCacheEntry) HashMap(java.util.HashMap) Metadata(org.infinispan.metadata.Metadata) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) MapResponseCollector(org.infinispan.remoting.transport.impl.MapResponseCollector) FlagBitSets(org.infinispan.context.impl.FlagBitSets) InternalMetadataImpl(org.infinispan.metadata.impl.InternalMetadataImpl) Configurations(org.infinispan.configuration.cache.Configurations) SingleResponseCollector(org.infinispan.remoting.transport.impl.SingleResponseCollector) Log(org.infinispan.util.logging.Log) MarshallableEntry(org.infinispan.persistence.spi.MarshallableEntry) Address(org.infinispan.remoting.transport.Address) Response(org.infinispan.remoting.responses.Response) InternalEntryFactory(org.infinispan.container.impl.InternalEntryFactory) CacheException(org.infinispan.commons.CacheException) Flowable(io.reactivex.rxjava3.core.Flowable) Iterator(java.util.Iterator) Publisher(org.reactivestreams.Publisher) PutMapCommand(org.infinispan.commands.write.PutMapCommand) SimpleClusteredVersion(org.infinispan.container.versioning.SimpleClusteredVersion) Inject(org.infinispan.factories.annotations.Inject) StateConsumerImpl(org.infinispan.statetransfer.StateConsumerImpl) PrimitiveIterator(java.util.PrimitiveIterator) AtomicLong(java.util.concurrent.atomic.AtomicLong) CacheRpcCommand(org.infinispan.commands.remote.CacheRpcCommand) Collections(java.util.Collections) ScatteredVersionManager(org.infinispan.scattered.ScatteredVersionManager) SuspectException(org.infinispan.remoting.transport.jgroups.SuspectException) PutMapCommand(org.infinispan.commands.write.PutMapCommand) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) InternalCacheValue(org.infinispan.container.entries.InternalCacheValue)

Example 2 with PutMapCommand

use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitPutMapCommand.

public void testVisitPutMapCommand() throws Throwable {
    PutMapCommand command = new PutMapCommand(Collections.singletonMap(KEY, VALUE), null, 0, null);
    InvocationStage stage = makeStage(interceptor.visitPutMapCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocation(null);
    assertNull(stage.get());
    assertEquals(1, interceptor.getAverageWriteTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) PutMapCommand(org.infinispan.commands.write.PutMapCommand)

Example 3 with PutMapCommand

use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.

the class PutMapBackupWriteCommand method createWriteCommand.

@Override
WriteCommand createWriteCommand() {
    PutMapCommand cmd = new PutMapCommand(map, metadata, getFlags(), getCommandInvocationId());
    cmd.setForwarded(true);
    internalMetadataMap.forEach(cmd::setInternalMetadata);
    return cmd;
}
Also used : PutMapCommand(org.infinispan.commands.write.PutMapCommand)

Example 4 with PutMapCommand

use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.

the class TriangleFunctionsUtil method copy.

public static PutMapCommand copy(PutMapCommand command, Collection<Object> keys) {
    PutMapCommand copy = new PutMapCommand(command);
    copy.setMap(filterEntries(command.getMap(), keys));
    return copy;
}
Also used : PutMapCommand(org.infinispan.commands.write.PutMapCommand)

Example 5 with PutMapCommand

use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.

the class PutMapHelper method copyForBackup.

@Override
public PutMapCommand copyForBackup(PutMapCommand cmd, LocalizedCacheTopology topology, Address target, IntSet segments) {
    PutMapCommand copy = new PutMapCommand(cmd).withMap(new ReadOnlySegmentAwareMap(cmd.getMap(), topology, segments));
    copy.setForwarded(true);
    return copy;
}
Also used : PutMapCommand(org.infinispan.commands.write.PutMapCommand) ReadOnlySegmentAwareMap(org.infinispan.distribution.util.ReadOnlySegmentAwareMap)

Aggregations

PutMapCommand (org.infinispan.commands.write.PutMapCommand)10 HashMap (java.util.HashMap)3 Address (org.infinispan.remoting.transport.Address)3 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 PutKeyValueCommand (org.infinispan.commands.write.PutKeyValueCommand)2 InternalCacheValue (org.infinispan.container.entries.InternalCacheValue)2 RemoteMetadata (org.infinispan.container.entries.RemoteMetadata)2 Metadata (org.infinispan.metadata.Metadata)2 Response (org.infinispan.remoting.responses.Response)2 SuccessfulResponse (org.infinispan.remoting.responses.SuccessfulResponse)2 Flowable (io.reactivex.rxjava3.core.Flowable)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 PrimitiveIterator (java.util.PrimitiveIterator)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 BlockingQueue (java.util.concurrent.BlockingQueue)1