Search in sources :

Example 26 with ForceReattemptException

use of org.apache.geode.internal.cache.ForceReattemptException 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 27 with ForceReattemptException

use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.

the class PartitionedRegionFunctionResultSender method sendResult.

public void sendResult(Object oneResult) {
    if (!this.function.hasResult()) {
        throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
    }
    if (this.serverSender != null) {
        logger.debug("PartitionedRegionFunctionResultSender sending result from local node to client {}", oneResult);
        clientSend(oneResult, dm.getDistributionManagerId());
    } else {
        // P2P
        if (this.msg != null) {
            try {
                logger.debug("PartitionedRegionFunctionResultSender sending result from remote node {}", oneResult);
                this.msg.sendReplyForOneResult(dm, pr, time, oneResult, false, enableOrderedResultStreming);
            } catch (ForceReattemptException e) {
                throw new FunctionException(e);
            } catch (InterruptedException e) {
                throw new FunctionException(e);
            }
        } else {
            logger.debug("PartitionedRegionFunctionResultSender adding result to ResultCollector on local node {}", oneResult);
            this.rc.addResult(dm.getDistributionManagerId(), oneResult);
            FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
        }
        // incrementing result sent stats.
        FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) FunctionException(org.apache.geode.cache.execute.FunctionException)

Example 28 with ForceReattemptException

use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.

the class PartitionedRegionFunctionResultSender method lastResult.

// this must be getting called directly from function
public void lastResult(Object oneResult) {
    if (!this.function.hasResult()) {
        throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
    }
    if (this.serverSender != null) {
        // Client-Server
        if (this.localLastResultRecieved) {
            return;
        }
        if (onlyLocal) {
            checkForBucketMovement(oneResult);
            if (bme != null) {
                clientSend(oneResult, dm.getDistributionManagerId());
                lastClientSend(dm.getDistributionManagerId(), bme);
            } else {
                lastClientSend(dm.getDistributionManagerId(), oneResult);
            }
            this.rc.endResults();
            this.localLastResultRecieved = true;
        } else {
            // call a synchronized method as local node is also waiting to send lastResult
            lastResult(oneResult, rc, false, true, dm.getDistributionManagerId());
        }
    } else {
        if (this.msg != null) {
            checkForBucketMovement(oneResult);
            try {
                if (this.bme != null) {
                    this.msg.sendReplyForOneResult(dm, pr, time, oneResult, false, enableOrderedResultStreming);
                    throw bme;
                } else {
                    this.msg.sendReplyForOneResult(dm, pr, time, oneResult, true, enableOrderedResultStreming);
                }
            } catch (ForceReattemptException e) {
                throw new FunctionException(e);
            } catch (InterruptedException e) {
                throw new FunctionException(e);
            }
        } else {
            if (this.localLastResultRecieved) {
                return;
            }
            if (onlyLocal) {
                checkForBucketMovement(oneResult);
                if (bme != null) {
                    this.rc.addResult(dm.getDistributionManagerId(), oneResult);
                    this.rc.addResult(dm.getDistributionManagerId(), bme);
                } else {
                    this.rc.addResult(dm.getDistributionManagerId(), oneResult);
                }
                // exception thrown will do end result
                this.rc.endResults();
                this.localLastResultRecieved = true;
            } else {
                // call a synchronized method as local node is also waiting to send lastResult
                lastResult(oneResult, rc, false, true, dm.getDistributionManagerId());
            }
            FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
        }
        // incrementing result sent stats.
        // Bug : remote node as well as local node calls this method to send
        // the result When the remote nodes are added to the local result collector at that
        // time the stats for the result sent is again incremented : Once the PR team comes with the
        // concept of the Streaming FunctionOperation
        // for the partitioned Region then it will be simple to fix this problem.
        FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) FunctionException(org.apache.geode.cache.execute.FunctionException)

Example 29 with ForceReattemptException

use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.

the class BucketSizeMessage method send.

/**
   * Sends a BucketSize message to determine the number of bytes the bucket consumes
   * 
   * @param recipient the member that the contains keys/value message is sent to
   * @param r the PartitionedRegion that contains the bucket
   * @param bucketId the identity of the bucket whose size should be returned.
   * @return the processor used to read the returned size
   * @throws ForceReattemptException if the peer is no longer available
   */
public static BucketSizeResponse send(InternalDistributedMember recipient, PartitionedRegion r, int bucketId) throws ForceReattemptException {
    Assert.assertTrue(recipient != null, "BucketSizeMessage NULL reply message");
    BucketSizeResponse p = new BucketSizeResponse(r.getSystem(), Collections.singleton(recipient));
    BucketSizeMessage m = new BucketSizeMessage(recipient, r.getPRId(), p, bucketId);
    Set failures = r.getDistributionManager().putOutgoing(m);
    if (failures != null && failures.size() > 0) {
        throw new ForceReattemptException(LocalizedStrings.BucketSizeMessage_FAILED_SENDING_0.toLocalizedString(m));
    }
    return p;
}
Also used : Set(java.util.Set) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException)

Example 30 with ForceReattemptException

use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.

the class MemberFunctionResultSender method sendResult.

public void sendResult(Object oneResult) {
    if (!this.function.hasResult()) {
        throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
    }
    if (this.serverSender != null) {
        // Client-Server
        if (logger.isDebugEnabled()) {
            logger.debug("MemberFunctionResultSender sending result from local node to client {}", oneResult);
        }
        this.serverSender.sendResult(oneResult);
    } else {
        // P2P
        if (this.msg != null) {
            try {
                this.msg.sendReplyForOneResult(dm, oneResult, false, enableOrderedResultStreming);
            } catch (QueryException e) {
                throw new FunctionException(e);
            } catch (ForceReattemptException e) {
                throw new FunctionException(e);
            } catch (InterruptedException e) {
                throw new FunctionException(e);
            }
        } else {
            this.rc.addResult(this.dm.getDistributionManagerId(), oneResult);
            FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
        }
        // incrementing result sent stats.
        FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
    }
}
Also used : QueryException(org.apache.geode.cache.query.QueryException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) FunctionException(org.apache.geode.cache.execute.FunctionException)

Aggregations

ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)62 Set (java.util.Set)21 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)13 FunctionException (org.apache.geode.cache.execute.FunctionException)12 ReplyException (org.apache.geode.distributed.internal.ReplyException)11 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)11 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)9 TransactionException (org.apache.geode.cache.TransactionException)8 HashSet (java.util.HashSet)7 CacheException (org.apache.geode.cache.CacheException)7 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)7 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)6 CacheClosedException (org.apache.geode.cache.CacheClosedException)5 TransactionDataNodeHasDepartedException (org.apache.geode.cache.TransactionDataNodeHasDepartedException)5 Host (org.apache.geode.test.dunit.Host)5 VM (org.apache.geode.test.dunit.VM)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 Test (org.junit.Test)5 LinkedList (java.util.LinkedList)4 List (java.util.List)4