Search in sources :

Example 1 with TRANSACTIONS

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;
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) A(org.apache.ignite.internal.util.typedef.internal.A) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) ClientTransactions(org.apache.ignite.client.ClientTransactions) BinaryWriterExImpl(org.apache.ignite.internal.binary.BinaryWriterExImpl) AtomicLong(java.util.concurrent.atomic.AtomicLong) ClientException(org.apache.ignite.client.ClientException) ClientTransaction(org.apache.ignite.client.ClientTransaction) Map(java.util.Map) TRANSACTIONS(org.apache.ignite.internal.client.thin.ProtocolVersionFeature.TRANSACTIONS) ClientTransactionConfiguration(org.apache.ignite.configuration.ClientTransactionConfiguration) ClientException(org.apache.ignite.client.ClientException) BinaryWriterExImpl(org.apache.ignite.internal.binary.BinaryWriterExImpl) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx)

Aggregations

Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ClientException (org.apache.ignite.client.ClientException)1 ClientTransaction (org.apache.ignite.client.ClientTransaction)1 ClientTransactions (org.apache.ignite.client.ClientTransactions)1 ClientTransactionConfiguration (org.apache.ignite.configuration.ClientTransactionConfiguration)1 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)1 BinaryWriterExImpl (org.apache.ignite.internal.binary.BinaryWriterExImpl)1 TRANSACTIONS (org.apache.ignite.internal.client.thin.ProtocolVersionFeature.TRANSACTIONS)1 A (org.apache.ignite.internal.util.typedef.internal.A)1 TransactionConcurrency (org.apache.ignite.transactions.TransactionConcurrency)1 TransactionIsolation (org.apache.ignite.transactions.TransactionIsolation)1