Search in sources :

Example 1 with ReplySender

use of org.apache.geode.distributed.internal.ReplySender in project geode by apache.

the class FindRemoteTXMessage method process.

@Override
protected void process(DistributionManager dm) {
    boolean sendReply = true;
    Throwable thr = null;
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("processing {}", this);
        }
        FindRemoteTXMessageReply reply = new FindRemoteTXMessageReply();
        InternalCache cache = GemFireCacheImpl.getInstance();
        if (cache != null) {
            TXManagerImpl mgr = (TXManagerImpl) cache.getCacheTransactionManager();
            // in case there is a lost commit going on
            mgr.waitForCompletingTransaction(txId);
            reply.isHostingTx = mgr.isHostedTxInProgress(txId) || mgr.isHostedTxRecentlyCompleted(txId);
            if (!reply.isHostingTx) {
                // lookup in CMTTracker if a partial commit message exists
                TXCommitMessage partialMessage = TXCommitMessage.getTracker().getTXCommitMessage(txId);
                if (partialMessage != null) {
                    reply.txCommitMessage = partialMessage;
                    reply.isPartialCommitMessage = true;
                }
                // cleanup the local txStateProxy fixes bug 43069
                mgr.removeHostedTXState(txId);
            }
        }
        reply.setRecipient(getSender());
        reply.setProcessorId(processorId);
        getReplySender(dm).putOutgoing(reply);
        sendReply = false;
        if (logger.isDebugEnabled()) {
            logger.debug("TX: FoundRemoteTXMessage: isHostingTx for txid:{}? {} isPartialCommit? {}", txId, reply.isHostingTx, reply.isPartialCommitMessage);
        }
    } catch (VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        // now, so don't let this thread continue.
        throw err;
    } catch (Throwable t) {
        // Whenever you catch Error or Throwable, you must also
        // catch VirtualMachineError (see above). However, there is
        // _still_ a possibility that you are dealing with a cascading
        // error condition, so you also need to check to see if the JVM
        // is still usable:
        SystemFailure.checkFailure();
        if (sendReply) {
            thr = t;
        }
    } finally {
        ReplySender rs = getReplySender(dm);
        if (sendReply && (this.processorId != 0 || (rs != dm))) {
            ReplyException rex = null;
            if (thr != null) {
                rex = new ReplyException(thr);
            }
            ReplyMessage.send(getSender(), this.processorId, rex, getReplySender(dm));
        }
    }
}
Also used : ReplyException(org.apache.geode.distributed.internal.ReplyException) ReplySender(org.apache.geode.distributed.internal.ReplySender)

Example 2 with ReplySender

use of org.apache.geode.distributed.internal.ReplySender in project geode by apache.

the class TXMessage method process.

@Override
protected void process(final DistributionManager dm) {
    Throwable thr = null;
    boolean sendReply = true;
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("processing {}", this);
        }
        InternalCache cache = GemFireCacheImpl.getInstance();
        if (checkCacheClosing(cache) || checkDSClosing(cache.getInternalDistributedSystem())) {
            thr = new CacheClosedException(LocalizedStrings.PartitionMessage_REMOTE_CACHE_IS_CLOSED_0.toLocalizedString(dm.getId()));
            return;
        }
        TXManagerImpl txMgr = cache.getTXMgr();
        TXStateProxy tx = null;
        try {
            assert this.txUniqId != TXManagerImpl.NOTX;
            TXId txId = new TXId(getMemberToMasqueradeAs(), this.txUniqId);
            tx = txMgr.masqueradeAs(this);
            sendReply = operateOnTx(txId, dm);
        } finally {
            txMgr.unmasquerade(tx);
        }
    } catch (CommitConflictException cce) {
        thr = cce;
    } catch (DistributedSystemDisconnectedException se) {
        sendReply = false;
        if (logger.isDebugEnabled()) {
            logger.debug("shutdown caught, abandoning message: " + se);
        }
    } catch (RegionDestroyedException rde) {
        thr = new ForceReattemptException(LocalizedStrings.PartitionMessage_REGION_IS_DESTROYED_IN_0.toLocalizedString(dm.getDistributionManagerId()), rde);
    } catch (VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        // now, so don't let this thread continue.
        throw err;
    } catch (Throwable t) {
        // Whenever you catch Error or Throwable, you must also
        // catch VirtualMachineError (see above). However, there is
        // _still_ a possibility that you are dealing with a cascading
        // error condition, so you also need to check to see if the JVM
        // is still usable:
        SystemFailure.checkFailure();
        if (sendReply) {
            thr = t;
        }
    } finally {
        ReplySender rs = getReplySender(dm);
        if (sendReply && (this.processorId != 0 || (rs != dm))) {
            ReplyException rex = null;
            if (thr != null) {
                rex = new ReplyException(thr);
            }
            sendReply(getSender(), this.processorId, dm, rex);
        }
    }
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ReplyException(org.apache.geode.distributed.internal.ReplyException) CommitConflictException(org.apache.geode.cache.CommitConflictException) ReplySender(org.apache.geode.distributed.internal.ReplySender)

Aggregations

ReplyException (org.apache.geode.distributed.internal.ReplyException)2 ReplySender (org.apache.geode.distributed.internal.ReplySender)2 CacheClosedException (org.apache.geode.cache.CacheClosedException)1 CommitConflictException (org.apache.geode.cache.CommitConflictException)1 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)1 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)1