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
cache
Fields 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 void
dropTransaction
(io.netty.channel.ChannelHandlerContext ctx) void
void
handleChannelDisconnect
(io.netty.channel.ChannelHandlerContext ctx) boolean
performingOperations
(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, typedCache
Methods inherited from class org.infinispan.server.resp.RespRequestHandler
handleRequest, initializeIfNecessary, myStage, respServer, stageToReturn, stageToReturn, stageToReturn, 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:RespRequestHandler
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.Implementations should never use the ByteBufAllocator in the context. Instead, they should use
RespRequestHandler.writer
to retrieve aResponseWriter
This 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:
actualHandleRequest
in 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:
commandNotFound
in classRespRequestHandler
-
handleChannelDisconnect
public void handleChannelDisconnect(io.netty.channel.ChannelHandlerContext ctx) - Overrides:
handleChannelDisconnect
in 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
null
return 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
null
if the transaction needs to be aborted.
-
unregisterListeners
public CompletionStage<List<WATCH.TxKeysListener>> unregisterListeners(io.netty.channel.ChannelHandlerContext ctx)
-