Search in sources :

Example 1 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class DistributedTXRegionStub method destroyExistingEntry.

public void destroyExistingEntry(EntryEventImpl event, boolean cacheWrite, Object expectedOldValue) {
    // this.prStats.incPartitionMessagesSent();
    try {
        RemoteOperationResponse response = RemoteDestroyMessage.send(state.getTarget(), event.getLocalRegion(), event, expectedOldValue, DistributionManager.PARTITIONED_REGION_EXECUTOR, true, false);
        response.waitForCacheException();
    } catch (EntryNotFoundException enfe) {
        throw enfe;
    } catch (TransactionDataNotColocatedException enfe) {
        throw enfe;
    } catch (CacheException ce) {
        throw new PartitionedRegionException(LocalizedStrings.PartitionedRegion_DESTROY_OF_ENTRY_ON_0_FAILED.toLocalizedString(state.getTarget()), ce);
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
}
Also used : PartitionedRegionException(org.apache.geode.internal.cache.PartitionedRegionException) CacheException(org.apache.geode.cache.CacheException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) RemoteOperationResponse(org.apache.geode.internal.cache.RemoteOperationMessage.RemoteOperationResponse) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 2 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class DistributedTXRegionStub method putEntry.

public boolean putEntry(EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue, long lastModified, boolean overwriteDestroyed) {
    boolean retVal = false;
    final LocalRegion r = event.getLocalRegion();
    try {
        RemotePutResponse response = RemotePutMessage.txSend(state.getTarget(), r, event, lastModified, ifNew, ifOld, expectedOldValue, requireOldValue);
        PutResult result = response.waitForResult();
        event.setOldValue(result.oldValue, true);
        retVal = result.returnValue;
    } catch (TransactionDataNotColocatedException enfe) {
        throw enfe;
    } catch (CacheException ce) {
        throw new PartitionedRegionException(LocalizedStrings.PartitionedRegion_DESTROY_OF_ENTRY_ON_0_FAILED.toLocalizedString(state.getTarget()), ce);
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
    return retVal;
}
Also used : PartitionedRegionException(org.apache.geode.internal.cache.PartitionedRegionException) CacheException(org.apache.geode.cache.CacheException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) RemotePutResponse(org.apache.geode.internal.cache.RemotePutMessage.RemotePutResponse) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PutResult(org.apache.geode.internal.cache.RemotePutMessage.PutResult) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 3 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class DistributedTXRegionStub method findObject.

public Object findObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks, Object value, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent) {
    Object retVal = null;
    final Object key = keyInfo.getKey();
    final Object callbackArgument = keyInfo.getCallbackArg();
    try {
        RemoteGetMessage.RemoteGetResponse response = RemoteGetMessage.send((InternalDistributedMember) state.getTarget(), region, key, callbackArgument, requestingClient);
        retVal = response.waitForResponse(preferCD);
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
    return retVal;
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) RemoteGetMessage(org.apache.geode.internal.cache.RemoteGetMessage) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 4 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class PartitionedTXRegionStub method getEntry.

public Entry getEntry(KeyInfo keyInfo, boolean allowTombstones) {
    PartitionedRegion pr = (PartitionedRegion) region;
    try {
        Entry e = pr.getEntryRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), keyInfo.getKey(), false, allowTombstones);
        trackBucketForTx(keyInfo);
        return e;
    } catch (EntryNotFoundException enfe) {
        return null;
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        RuntimeException re;
        if (isBucketNotFoundException(e)) {
            re = new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TRANSACTIONAL_DATA_MOVED_DUE_TO_REBALANCING.toLocalizedString());
        } else {
            re = new TransactionDataNodeHasDepartedException(LocalizedStrings.PartitionedRegion_TRANSACTION_DATA_NODE_0_HAS_DEPARTED_TO_PROCEED_ROLLBACK_THIS_TRANSACTION_AND_BEGIN_A_NEW_ONE.toLocalizedString(state.getTarget()));
        }
        re.initCause(e);
        waitToRetry();
        throw re;
    }
}
Also used : Entry(org.apache.geode.cache.Region.Entry) TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 5 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class TXFailoverCommand method cmdExecute.

@Override
public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start) throws IOException, ClassNotFoundException, InterruptedException {
    serverConnection.setAsTrue(REQUIRES_RESPONSE);
    // Build the TXId for the transaction
    InternalDistributedMember client = (InternalDistributedMember) serverConnection.getProxyID().getDistributedMember();
    int uniqId = clientMessage.getTransactionId();
    if (logger.isDebugEnabled()) {
        logger.debug("TX: Transaction {} from {} is failing over to this server", uniqId, client);
    }
    TXId txId = new TXId(client, uniqId);
    TXManagerImpl mgr = (TXManagerImpl) serverConnection.getCache().getCacheTransactionManager();
    // in case it's already completing here in another
    mgr.waitForCompletingTransaction(txId);
    // thread
    if (mgr.isHostedTxRecentlyCompleted(txId)) {
        writeReply(clientMessage, serverConnection);
        serverConnection.setAsTrue(RESPONDED);
        mgr.removeHostedTXState(txId);
        return;
    }
    // fixes bug 43350
    boolean wasInProgress = mgr.setInProgress(true);
    TXStateProxy tx = mgr.getTXState();
    Assert.assertTrue(tx != null);
    if (!tx.isRealDealLocal()) {
        // send message to all peers to find out who hosts the transaction
        FindRemoteTXMessageReplyProcessor processor = FindRemoteTXMessage.send(serverConnection.getCache(), txId);
        try {
            processor.waitForRepliesUninterruptibly();
        } catch (ReplyException e) {
            e.handleAsUnexpected();
        }
        // if hosting member is not null, bootstrap PeerTXStateStub to that member
        // if hosting member is null, rebuild TXCommitMessage from partial TXCommitMessages
        InternalDistributedMember hostingMember = processor.getHostingMember();
        if (hostingMember != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("TX: txState is not local, bootstrapping PeerTXState stub for targetNode: {}", hostingMember);
            }
            // inject the real deal
            tx.setLocalTXState(new PeerTXStateStub(tx, hostingMember, client));
        } else {
            // bug #42228 and bug #43504 - this cannot return until the current view
            // has been installed by all members, so that dlocks are released and
            // the same keys can be used in a new transaction by the same client thread
            InternalCache cache = serverConnection.getCache();
            try {
                WaitForViewInstallation.send((DistributionManager) cache.getDistributionManager());
            } catch (InterruptedException e) {
                cache.getDistributionManager().getCancelCriterion().checkCancelInProgress(e);
                Thread.currentThread().interrupt();
            }
            // tx host has departed, rebuild the tx
            if (processor.getTxCommitMessage() != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("TX: for txId: {} rebuilt a recently completed tx", txId);
                }
                mgr.saveTXCommitMessageForClientFailover(txId, processor.getTxCommitMessage());
            } else {
                writeException(clientMessage, new TransactionDataNodeHasDepartedException("Could not find transaction host for " + txId), false, serverConnection);
                serverConnection.setAsTrue(RESPONDED);
                mgr.removeHostedTXState(txId);
                return;
            }
        }
    }
    if (!wasInProgress) {
        mgr.setInProgress(false);
    }
    writeReply(clientMessage, serverConnection);
    serverConnection.setAsTrue(RESPONDED);
}
Also used : TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) TXId(org.apache.geode.internal.cache.TXId) InternalCache(org.apache.geode.internal.cache.InternalCache) FindRemoteTXMessageReplyProcessor(org.apache.geode.internal.cache.FindRemoteTXMessage.FindRemoteTXMessageReplyProcessor) ReplyException(org.apache.geode.distributed.internal.ReplyException) PeerTXStateStub(org.apache.geode.internal.cache.PeerTXStateStub) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Aggregations

TransactionDataNodeHasDepartedException (org.apache.geode.cache.TransactionDataNodeHasDepartedException)15 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)6 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)6 RemoteOperationException (org.apache.geode.internal.cache.RemoteOperationException)6 TransactionException (org.apache.geode.cache.TransactionException)5 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)5 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)5 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)5 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)3 TXId (org.apache.geode.internal.cache.TXId)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Cache (org.apache.geode.cache.Cache)2 CacheException (org.apache.geode.cache.CacheException)2 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)2 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)2 Execution (org.apache.geode.cache.execute.Execution)2 FunctionException (org.apache.geode.cache.execute.FunctionException)2 DistributedMember (org.apache.geode.distributed.DistributedMember)2 PartitionedRegionException (org.apache.geode.internal.cache.PartitionedRegionException)2