Search in sources :

Example 1 with TxFinishResponse

use of org.apache.ignite.internal.tx.message.TxFinishResponse in project ignite-3 by apache.

the class TxManagerImpl method finishRemote.

/**
 * {@inheritDoc}
 */
@Override
public CompletableFuture<Void> finishRemote(NetworkAddress addr, Timestamp ts, boolean commit, Set<String> groups) {
    assert groups != null && !groups.isEmpty();
    TxFinishRequest req = FACTORY.txFinishRequest().timestamp(ts).groups(groups).commit(commit).build();
    CompletableFuture<NetworkMessage> fut = clusterService.messagingService().invoke(addr, req, TIMEOUT);
    // Submit response to a dedicated pool to avoid deadlocks. TODO: IGNITE-15389
    return fut.thenApplyAsync(resp -> ((TxFinishResponse) resp).errorMessage()).thenCompose(msg -> msg == null ? completedFuture(null) : failedFuture(new TransactionException(msg)));
}
Also used : TransactionException(org.apache.ignite.tx.TransactionException) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) BiFunction(java.util.function.BiFunction) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) IgniteStringFormatter.format(org.apache.ignite.lang.IgniteStringFormatter.format) TxFinishRequest(org.apache.ignite.internal.tx.message.TxFinishRequest) ByteBuffer(java.nio.ByteBuffer) TxState(org.apache.ignite.internal.tx.TxState) Map(java.util.Map) TxMessageGroup(org.apache.ignite.internal.tx.message.TxMessageGroup) InternalTransaction(org.apache.ignite.internal.tx.InternalTransaction) NetworkMessageHandler(org.apache.ignite.network.NetworkMessageHandler) TxFinishResponse(org.apache.ignite.internal.tx.message.TxFinishResponse) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) NetworkMessage(org.apache.ignite.network.NetworkMessage) Timestamp(org.apache.ignite.internal.tx.Timestamp) TxManager(org.apache.ignite.internal.tx.TxManager) TxFinishResponseBuilder(org.apache.ignite.internal.tx.message.TxFinishResponseBuilder) NetworkAddress(org.apache.ignite.network.NetworkAddress) Objects(java.util.Objects) TestOnly(org.jetbrains.annotations.TestOnly) CompletableFuture.failedFuture(java.util.concurrent.CompletableFuture.failedFuture) Nullable(org.jetbrains.annotations.Nullable) LockException(org.apache.ignite.internal.tx.LockException) LockManager(org.apache.ignite.internal.tx.LockManager) TxMessagesFactory(org.apache.ignite.internal.tx.message.TxMessagesFactory) ClusterService(org.apache.ignite.network.ClusterService) IgniteUuid(org.apache.ignite.lang.IgniteUuid) TxFinishResponse(org.apache.ignite.internal.tx.message.TxFinishResponse) TxFinishRequest(org.apache.ignite.internal.tx.message.TxFinishRequest) TransactionException(org.apache.ignite.tx.TransactionException) NetworkMessage(org.apache.ignite.network.NetworkMessage)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 CompletableFuture.failedFuture (java.util.concurrent.CompletableFuture.failedFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 BiFunction (java.util.function.BiFunction)1 InternalTransaction (org.apache.ignite.internal.tx.InternalTransaction)1 LockException (org.apache.ignite.internal.tx.LockException)1 LockManager (org.apache.ignite.internal.tx.LockManager)1 Timestamp (org.apache.ignite.internal.tx.Timestamp)1 TxManager (org.apache.ignite.internal.tx.TxManager)1 TxState (org.apache.ignite.internal.tx.TxState)1 TxFinishRequest (org.apache.ignite.internal.tx.message.TxFinishRequest)1 TxFinishResponse (org.apache.ignite.internal.tx.message.TxFinishResponse)1 TxFinishResponseBuilder (org.apache.ignite.internal.tx.message.TxFinishResponseBuilder)1 TxMessageGroup (org.apache.ignite.internal.tx.message.TxMessageGroup)1