Search in sources :

Example 1 with IgniteTxStateAware

use of org.apache.ignite.internal.processors.cache.transactions.IgniteTxStateAware in project ignite by apache.

the class GridCacheIoManager method processMessage.

/**
     * @param nodeId Node ID.
     * @param msg Message.
     * @param c Closure.
     */
private void processMessage(UUID nodeId, GridCacheMessage msg, IgniteBiInClosure<UUID, GridCacheMessage> c) {
    try {
        c.apply(nodeId, msg);
        if (log.isDebugEnabled())
            log.debug("Finished processing cache communication message [nodeId=" + nodeId + ", msg=" + msg + ']');
    } catch (Throwable e) {
        U.error(log, "Failed processing message [senderId=" + nodeId + ", msg=" + msg + ']', e);
        if (e instanceof Error)
            throw e;
    } finally {
        // Reset thread local context.
        cctx.tm().resetContext();
        GridCacheMvccManager mvcc = cctx.mvcc();
        if (mvcc != null)
            mvcc.contextReset();
        // Unwind eviction notifications.
        if (msg instanceof IgniteTxStateAware) {
            IgniteTxState txState = ((IgniteTxStateAware) msg).txState();
            if (txState != null)
                txState.unwindEvicts(cctx);
        } else {
            GridCacheContext ctx = cctx.cacheContext(msg.cacheId());
            if (ctx != null)
                CU.unwindEvicts(ctx);
        }
    }
}
Also used : IgniteTxStateAware(org.apache.ignite.internal.processors.cache.transactions.IgniteTxStateAware) IgniteTxState(org.apache.ignite.internal.processors.cache.transactions.IgniteTxState)

Example 2 with IgniteTxStateAware

use of org.apache.ignite.internal.processors.cache.transactions.IgniteTxStateAware in project ignite by apache.

the class GridCacheIoManager method onMessageProcessed.

/**
 * @param msg Message.
 */
public void onMessageProcessed(GridCacheMessage msg) {
    // Reset thread local context.
    cctx.tm().resetContext();
    GridCacheMvccManager mvcc = cctx.mvcc();
    if (mvcc != null)
        mvcc.contextReset();
    // Unwind eviction notifications.
    if (msg instanceof IgniteTxStateAware) {
        IgniteTxState txState = ((IgniteTxStateAware) msg).txState();
        if (txState != null)
            txState.unwindEvicts(cctx);
    } else if (msg instanceof GridCacheIdMessage) {
        GridCacheContext ctx = cctx.cacheContext(((GridCacheIdMessage) msg).cacheId());
        if (ctx != null)
            CU.unwindEvicts(ctx);
    }
}
Also used : IgniteTxStateAware(org.apache.ignite.internal.processors.cache.transactions.IgniteTxStateAware) IgniteTxState(org.apache.ignite.internal.processors.cache.transactions.IgniteTxState)

Aggregations

IgniteTxState (org.apache.ignite.internal.processors.cache.transactions.IgniteTxState)2 IgniteTxStateAware (org.apache.ignite.internal.processors.cache.transactions.IgniteTxStateAware)2