Class RespTransactionHandler
The transaction state is entered when the MULTI command is received
and exited when the EXEC or DISCARD command is received. Additional
commands that change the handler include QUIT and the
subscribe commands.
The handler will queue all commands and copy the arguments received. Observe that, this information is kept in-memory, so it will not survive restarts. If the node stops in some way and come back, the queued commands are lost. In the same way, it does not offer atomicity during execution. If the server stops mid-way applying operations, it does not recover, leaving a half-applied transaction.
Talking in isolation levels, this implementation is next to read-uncommitted. Another client could see the state of the transaction before it is finished, even on a single node.
- Author:
- José Bolina
- See Also:
-
Field Summary
Fields inherited from class org.infinispan.server.resp.CacheRespRequestHandler
cacheFields inherited from class org.infinispan.server.resp.RespRequestHandler
BYTE_BUF_POOL_ATTRIBUTE_KEY, myStage, respServer, writer -
Constructor Summary
ConstructorsConstructorDescriptionRespTransactionHandler(RespServer respServer, AdvancedCache<byte[], byte[]> cache) -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletionStage<RespRequestHandler> actualHandleRequest(io.netty.channel.ChannelHandlerContext ctx, RespCommand command, List<byte[]> arguments) Handles the RESP request returning a stage that when complete notifies the command has completed as well as providing the request handler for subsequent commands.protected voiddropTransaction(io.netty.channel.ChannelHandlerContext ctx) voidvoidhandleChannelDisconnect(io.netty.channel.ChannelHandlerContext ctx) booleanperformingOperations(io.netty.channel.ChannelHandlerContext ctx) Prepare for performing the queued operations.unregisterListeners(io.netty.channel.ChannelHandlerContext ctx) Methods inherited from class org.infinispan.server.resp.CacheRespRequestHandler
cache, setCache, typedCacheMethods inherited from class org.infinispan.server.resp.RespRequestHandler
handleRequest, initializeIfNecessary, myStage, respServer, stageToReturn, stageToReturn, stageToReturn, writer, writer
-
Constructor Details
-
RespTransactionHandler
-
-
Method Details
-
actualHandleRequest
protected CompletionStage<RespRequestHandler> actualHandleRequest(io.netty.channel.ChannelHandlerContext ctx, RespCommand command, List<byte[]> arguments) Description copied from class:RespRequestHandlerHandles the RESP request returning a stage that when complete notifies the command has completed as well as providing the request handler for subsequent commands.Implementations should never use the ByteBufAllocator in the context. Instead, they should use
RespRequestHandler.writerto retrieve aResponseWriterThis ByteBuffer should only have bytes written to it adding up to the size requested. The ByteBuffer itself should never be written to the context or channel and flush should also never be invoked. Failure to do so may cause mis-ordering or responses as requests support pipelining and a ByteBuf may not be sent down stream until later in the pipeline.- Overrides:
actualHandleRequestin classRespRequestHandler- Parameters:
ctx- Netty context pipeline for this requestcommand- The command typearguments- The remaining arguments to the command- Returns:
- stage that when complete returns the new handler to instate. This stage must be completed on the event loop
-
commandNotFound
protected void commandNotFound()- Overrides:
commandNotFoundin classRespRequestHandler
-
handleChannelDisconnect
public void handleChannelDisconnect(io.netty.channel.ChannelHandlerContext ctx) - Overrides:
handleChannelDisconnectin classRespRequestHandler
-
errorInTransactionContext
public void errorInTransactionContext() -
hasFailed
public boolean hasFailed() -
dropTransaction
-
performingOperations
public CompletionStage<List<TransactionCommand>> performingOperations(io.netty.channel.ChannelHandlerContext ctx) Prepare for performing the queued operations.This method verifies for possible watched keys to verify if the operation needs to be aborted. A
nullreturn means the transaction needs to be aborted. After this execution, all keys are un-watched, removing the listeners from the cache.- Returns:
- The list of commands to be executed, or
nullif the transaction needs to be aborted.
-
unregisterListeners
public CompletionStage<List<WATCH.TxKeysListener>> unregisterListeners(io.netty.channel.ChannelHandlerContext ctx)
-