Search in sources :

Example 36 with ForceReattemptException

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

the class DistributedRegionFunctionResultSender method sendResult.

public synchronized void sendResult(Object oneResult) {
    if (!this.functionObject.hasResult()) {
        throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
    }
    if (this.sender != null) {
        // Client-Server
        sender.sendResult(oneResult);
    } else {
        if (isLocal) {
            this.rc.addResult(dm.getDistributionManagerId(), oneResult);
            FunctionStats.getFunctionStats(functionObject.getId(), this.dm.getSystem()).incResultsReceived();
        } else {
            try {
                this.msg.sendReplyForOneResult(dm, oneResult, false, enableOrderedResultStreming);
            } catch (ForceReattemptException e) {
                throw new FunctionException(e);
            } catch (InterruptedException e) {
                throw new FunctionException(e);
            }
        }
        // incrementing result sent stats.
        FunctionStats.getFunctionStats(functionObject.getId(), this.dm.getSystem()).incResultsReturned();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) FunctionException(org.apache.geode.cache.execute.FunctionException)

Example 37 with ForceReattemptException

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

the class ParallelGatewaySenderQueue method peek.

// Need to improve here.If first peek returns NULL then look in another bucket.
@Override
public Object peek() throws InterruptedException, CacheException {
    Object object = null;
    int bucketId = -1;
    PartitionedRegion prQ = getRandomShadowPR();
    if (prQ != null && prQ.getDataStore().getAllLocalBucketRegions().size() > 0 && ((bucketId = getRandomPrimaryBucket(prQ)) != -1)) {
        BucketRegionQueue brq;
        try {
            brq = ((BucketRegionQueue) prQ.getDataStore().getInitializedBucketForId(null, bucketId));
            object = brq.peek();
        } catch (BucketRegionQueueUnavailableException e) {
            // since this is not set, it would be null
            return object;
        } catch (ForceReattemptException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Remove: Got ForceReattemptException for {} for bucke = {}", this, bucketId);
            }
        }
    }
    // OFFHEAP: ok since only callers uses it to check for empty queue
    return object;
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Example 38 with ForceReattemptException

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

the class ParallelGatewaySenderQueue method destroyEventFromQueue.

private void destroyEventFromQueue(PartitionedRegion prQ, int bucketId, Object key) {
    boolean isPrimary = prQ.getRegionAdvisor().getBucketAdvisor(bucketId).isPrimary();
    BucketRegionQueue brq = getBucketRegionQueueByBucketId(prQ, bucketId);
    // before destroying a key from it
    try {
        if (brq != null) {
            brq.destroyKey(key);
        }
        stats.decQueueSize();
    } catch (EntryNotFoundException e) {
        if (!this.sender.isBatchConflationEnabled() && logger.isDebugEnabled()) {
            logger.debug("ParallelGatewaySenderQueue#remove: Got EntryNotFoundException while removing key {} for {} for bucket = {} for GatewaySender {}", key, this, bucketId, this.sender);
        }
    } catch (ForceReattemptException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Bucket :{} moved to other member", bucketId);
        }
    } catch (PrimaryBucketException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Primary bucket :{} moved to other member", bucketId);
        }
    } catch (RegionDestroyedException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Caught RegionDestroyedException attempting to remove key {} from bucket {} in {}", key, bucketId, prQ.getFullPath());
        }
    }
    addRemovedEvent(prQ, bucketId, key);
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException)

Example 39 with ForceReattemptException

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

the class PartitionedTXRegionStub method containsKey.

public boolean containsKey(KeyInfo keyInfo) {
    PartitionedRegion pr = (PartitionedRegion) region;
    try {
        boolean retVal = pr.containsKeyRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), keyInfo.getKey());
        trackBucketForTx(keyInfo);
        return retVal;
    } 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) {
        if (isBucketNotFoundException(e)) {
            RuntimeException re = getTransactionException(keyInfo, e);
            re.initCause(e);
            throw re;
        }
        waitToRetry();
        RuntimeException 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);
        throw re;
    }
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 40 with ForceReattemptException

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

the class PartitionedTXRegionStub 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();
    PartitionedRegion pr = (PartitionedRegion) r;
    try {
        retVal = pr.putRemotely(state.getTarget(), event, ifNew, ifOld, expectedOldValue, requireOldValue);
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        waitToRetry();
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e);
        throw re;
    }
    trackBucketForTx(event.getKeyInfo());
    return retVal;
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException)

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