Search in sources :

Example 26 with KeyValuePair

use of org.infinispan.util.KeyValuePair in project infinispan by infinispan.

the class ProtobufMetadataManagerInterceptor method visitRemoveCommand.

@Override
public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) {
    if (!ctx.isOriginLocal()) {
        return invokeNext(ctx, command);
    }
    if (!(command.getKey() instanceof String)) {
        throw log.keyMustBeString(command.getKey().getClass());
    }
    String key = (String) command.getKey();
    if (!shouldIntercept(key)) {
        return invokeNext(ctx, command);
    }
    // lock global errors key
    long flagsBitSet = copyFlags(command);
    LockControlCommand lockCommand = commandsFactory.buildLockControlCommand(ERRORS_KEY_SUFFIX, flagsBitSet, null);
    InvocationStage stage = invoker.running().invokeStage(ctx, lockCommand);
    stage = stage.thenApplyMakeStage(ctx, command, (rCtx, rCommand, __) -> {
        if (serializationContext.getFileDescriptors().containsKey(key)) {
            serializationContext.unregisterProtoFile(key);
        }
        if (serializationContextRegistry.getUserCtx().getFileDescriptors().containsKey(key)) {
            serializationContextRegistry.removeProtoFile(SerializationContextRegistry.MarshallerType.USER, key);
        }
        // put error key for all unresolved files and remove error key for all resolved files
        // Error keys to be removed have a null value
        List<KeyValuePair<String, String>> errorUpdates = computeErrorUpdatesAfterRemove(key);
        return updateSchemaErrorsIterator(rCtx, flagsBitSet, errorUpdates.iterator());
    });
    return asyncInvokeNext(ctx, command, stage);
}
Also used : WriteCommand(org.infinispan.commands.write.WriteCommand) Log(org.infinispan.query.remote.impl.logging.Log) ReplaceCommand(org.infinispan.commands.write.ReplaceCommand) InvocationContext(org.infinispan.context.InvocationContext) ComponentRef(org.infinispan.factories.impl.ComponentRef) TxInvocationContext(org.infinispan.context.impl.TxInvocationContext) Map(java.util.Map) SerializationContextRegistry(org.infinispan.marshall.protostream.impl.SerializationContextRegistry) KeyValuePair(org.infinispan.util.KeyValuePair) PrepareCommand(org.infinispan.commands.tx.PrepareCommand) RemoveCommand(org.infinispan.commands.write.RemoveCommand) CommandsFactory(org.infinispan.commands.CommandsFactory) EmbeddedMetadata(org.infinispan.metadata.EmbeddedMetadata) ReadWriteManyEntriesCommand(org.infinispan.commands.functional.ReadWriteManyEntriesCommand) ReadWriteKeyValueCommand(org.infinispan.commands.functional.ReadWriteKeyValueCommand) Set(java.util.Set) DescriptorParserException(org.infinispan.protostream.DescriptorParserException) List(java.util.List) PutKeyValueCommand(org.infinispan.commands.write.PutKeyValueCommand) AsyncInterceptorChain(org.infinispan.interceptors.AsyncInterceptorChain) InvocationStage(org.infinispan.interceptors.InvocationStage) FlagAffectedCommand(org.infinispan.commands.FlagAffectedCommand) AbstractVisitor(org.infinispan.commands.AbstractVisitor) ComputeCommand(org.infinispan.commands.write.ComputeCommand) ERRORS_KEY_SUFFIX(org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX) Metadata(org.infinispan.metadata.Metadata) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) WriteOnlyManyEntriesCommand(org.infinispan.commands.functional.WriteOnlyManyEntriesCommand) FlagBitSets(org.infinispan.context.impl.FlagBitSets) KeyPartitioner(org.infinispan.distribution.ch.KeyPartitioner) LockControlCommand(org.infinispan.commands.control.LockControlCommand) SyncInvocationStage(org.infinispan.interceptors.SyncInvocationStage) ClearCommand(org.infinispan.commands.write.ClearCommand) FileDescriptorSource(org.infinispan.protostream.FileDescriptorSource) FileDescriptor(org.infinispan.protostream.descriptors.FileDescriptor) ReplicableCommand(org.infinispan.commands.ReplicableCommand) Iterator(java.util.Iterator) PROTO_KEY_SUFFIX(org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.PROTO_KEY_SUFFIX) WriteOnlyKeyValueCommand(org.infinispan.commands.functional.WriteOnlyKeyValueCommand) WriteOnlyManyCommand(org.infinispan.commands.functional.WriteOnlyManyCommand) ProtobufMetadataManager(org.infinispan.query.remote.ProtobufMetadataManager) PutMapCommand(org.infinispan.commands.write.PutMapCommand) Inject(org.infinispan.factories.annotations.Inject) ProtobufMetadataManagerConstants(org.infinispan.query.remote.client.ProtobufMetadataManagerConstants) TreeMap(java.util.TreeMap) BaseCustomAsyncInterceptor(org.infinispan.interceptors.BaseCustomAsyncInterceptor) ReadWriteKeyCommand(org.infinispan.commands.functional.ReadWriteKeyCommand) ComputeIfAbsentCommand(org.infinispan.commands.write.ComputeIfAbsentCommand) WriteOnlyKeyCommand(org.infinispan.commands.functional.WriteOnlyKeyCommand) LogFactory(org.infinispan.commons.logging.LogFactory) VisitableCommand(org.infinispan.commands.VisitableCommand) ReadWriteManyCommand(org.infinispan.commands.functional.ReadWriteManyCommand) SerializationContext(org.infinispan.protostream.SerializationContext) InvocationStage(org.infinispan.interceptors.InvocationStage) SyncInvocationStage(org.infinispan.interceptors.SyncInvocationStage) List(java.util.List) ArrayList(java.util.ArrayList) LockControlCommand(org.infinispan.commands.control.LockControlCommand)

Aggregations

KeyValuePair (org.infinispan.util.KeyValuePair)26 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)8 ArrayList (java.util.ArrayList)7 List (java.util.List)6 UserPB (org.infinispan.client.hotrod.query.testdomain.protobuf.UserPB)6 ContinuousQueryListener (org.infinispan.query.api.continuous.ContinuousQueryListener)6 QueryFactory (org.infinispan.query.dsl.QueryFactory)6 User (org.infinispan.query.dsl.embedded.testdomain.User)6 HotRodClient (org.infinispan.server.hotrod.test.HotRodClient)4 Iterator (java.util.Iterator)3 Map (java.util.Map)3 Set (java.util.Set)3 InvocationStage (org.infinispan.interceptors.InvocationStage)3 SyncInvocationStage (org.infinispan.interceptors.SyncInvocationStage)3 Metadata (org.infinispan.metadata.Metadata)3 Flowable (io.reactivex.rxjava3.core.Flowable)2 ByteBuffer (java.nio.ByteBuffer)2 TreeSet (java.util.TreeSet)2 CompletionStage (java.util.concurrent.CompletionStage)2 Predicate (java.util.function.Predicate)2