Search in sources :

Example 1 with ClientTxAwareRequest

use of org.apache.ignite.internal.processors.platform.client.tx.ClientTxAwareRequest in project ignite by apache.

the class ClientRequestHandler method handle.

/**
 * {@inheritDoc}
 */
@Override
public ClientListenerResponse handle(ClientListenerRequest req) {
    try {
        if (req instanceof ClientTxAwareRequest) {
            ClientTxAwareRequest req0 = (ClientTxAwareRequest) req;
            if (req0.isTransactional()) {
                int txId = req0.txId();
                ClientTxContext txCtx = ctx.txContext(txId);
                if (txCtx != null) {
                    try {
                        txCtx.acquire(true);
                        return ((ClientRequest) req).process(ctx);
                    } catch (IgniteCheckedException e) {
                        throw new IgniteClientException(ClientStatus.FAILED, e.getMessage(), e);
                    } finally {
                        try {
                            txCtx.release(true);
                        } catch (Exception e) {
                            log.warning("Failed to release client transaction context", e);
                        }
                    }
                }
            }
        }
        return ((ClientRequest) req).process(ctx);
    } catch (SecurityException ex) {
        throw new IgniteClientException(ClientStatus.SECURITY_VIOLATION, "Client is not authorized to perform this operation", ex);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ClientTxAwareRequest(org.apache.ignite.internal.processors.platform.client.tx.ClientTxAwareRequest) SecurityException(org.apache.ignite.plugin.security.SecurityException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteIllegalStateException(org.apache.ignite.IgniteIllegalStateException) SecurityException(org.apache.ignite.plugin.security.SecurityException) ClientTxContext(org.apache.ignite.internal.processors.platform.client.tx.ClientTxContext)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteIllegalStateException (org.apache.ignite.IgniteIllegalStateException)1 ClientTxAwareRequest (org.apache.ignite.internal.processors.platform.client.tx.ClientTxAwareRequest)1 ClientTxContext (org.apache.ignite.internal.processors.platform.client.tx.ClientTxContext)1 SecurityException (org.apache.ignite.plugin.security.SecurityException)1