use of org.apache.ignite.internal.tx.message.TxFinishResponseBuilder in project ignite-3 by apache.
the class TxManagerImpl method onReceived.
/**
* {@inheritDoc}
*/
@Override
public void onReceived(NetworkMessage message, NetworkAddress senderAddr, @Nullable Long correlationId) {
// Support raft and transactions interop.
if (message instanceof TxFinishRequest) {
TxFinishRequest req = (TxFinishRequest) message;
Set<String> groups = req.groups();
CompletableFuture[] futs = new CompletableFuture[groups.size()];
int i = 0;
// Finish a tx for enlisted groups.
for (String grp : groups) {
futs[i++] = finish(grp, req.timestamp(), req.commit());
}
CompletableFuture.allOf(futs).thenCompose(ignored -> req.commit() ? commitAsync(req.timestamp()) : rollbackAsync(req.timestamp())).handle(new BiFunction<Void, Throwable, Void>() {
@Override
public Void apply(Void ignored, Throwable err) {
TxFinishResponseBuilder resp = FACTORY.txFinishResponse();
if (err != null) {
resp.errorMessage(err.getMessage());
}
clusterService.messagingService().respond(senderAddr, resp.build(), correlationId);
return null;
}
});
}
}
Aggregations