use of org.apache.ignite.internal.client.thin.ProtocolVersionFeature.TRANSACTIONS in project ignite by apache.
the class TcpClientTransactions method txStart0.
/**
* @param concurrency Concurrency.
* @param isolation Isolation.
* @param timeout Timeout.
*/
private ClientTransaction txStart0(TransactionConcurrency concurrency, TransactionIsolation isolation, Long timeout, String lb) {
TcpClientTransaction tx0 = tx();
if (tx0 != null)
throw new ClientException("A transaction has already been started by the current thread.");
tx0 = ch.service(ClientOperation.TX_START, req -> {
ProtocolContext protocolCtx = req.clientChannel().protocolCtx();
if (!protocolCtx.isFeatureSupported(TRANSACTIONS)) {
throw new ClientProtocolError(String.format("Transactions are not supported by the server's " + "protocol version %s, required version %s", protocolCtx.version(), TRANSACTIONS.verIntroduced()));
}
try (BinaryRawWriterEx writer = new BinaryWriterExImpl(marsh.context(), req.out(), null, null)) {
writer.writeByte((byte) (concurrency == null ? txCfg.getDefaultTxConcurrency() : concurrency).ordinal());
writer.writeByte((byte) (isolation == null ? txCfg.getDefaultTxIsolation() : isolation).ordinal());
writer.writeLong(timeout == null ? txCfg.getDefaultTxTimeout() : timeout);
writer.writeString(lb);
}
}, res -> new TcpClientTransaction(res.in().readInt(), res.clientChannel()));
threadLocTxUid.set(tx0.txUid);
txMap.put(tx0.txUid, tx0);
return tx0;
}
Aggregations