Search in sources :

Example 6 with RemoveAllPRMessage

use of org.apache.geode.internal.cache.partitioned.RemoveAllPRMessage in project geode by apache.

the class PartitionedRegion method tryToSendOneRemoveAllMessage.

public VersionedObjectList tryToSendOneRemoveAllMessage(RemoveAllPRMessage prMsg, InternalDistributedMember currentTarget) throws DataLocationException {
    boolean putResult = false;
    VersionedObjectList versions = null;
    final boolean isLocal = (this.localMaxMemory > 0) && currentTarget.equals(getMyId());
    if (isLocal) {
        // local
        // It might throw retry exception when one key failed
        // InternalDS has to be set for each msg
        prMsg.initMessage(this, null, false, null);
        putResult = prMsg.doLocalRemoveAll(this, this.getDistributionManager().getDistributionManagerId(), true);
        versions = prMsg.getVersions();
    } else {
        RemoveAllPRMessage.RemoveAllResponse response = (RemoveAllPRMessage.RemoveAllResponse) prMsg.send(currentTarget, this);
        RemoveAllPRMessage.RemoveAllResult pr = null;
        if (response != null) {
            this.prStats.incPartitionMessagesSent();
            try {
                pr = response.waitForResult();
                putResult = pr.returnValue;
                versions = pr.versions;
            } catch (RegionDestroyedException rde) {
                if (logger.isDebugEnabled()) {
                    logger.debug("prMsg.send: caught RegionDestroyedException", rde);
                }
                throw new RegionDestroyedException(toString(), getFullPath());
            } catch (CacheException ce) {
                // Fix for bug 36014
                throw new PartitionedRegionDistributionException("prMsg.send on " + currentTarget + " failed", ce);
            }
        } else {
            // follow the same behavior of putRemotely()
            putResult = true;
        }
    }
    if (!putResult) {
        // retry exception when msg failed in waitForResult()
        ForceReattemptException fre = new ForceReattemptException("false result in PutAllMessage.send - retrying");
        fre.setHash(0);
        throw fre;
    }
    return versions;
}
Also used : CacheException(org.apache.geode.cache.CacheException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) RemoveAllPRMessage(org.apache.geode.internal.cache.partitioned.RemoveAllPRMessage) PartitionedRegionDistributionException(org.apache.geode.cache.PartitionedRegionDistributionException)

Aggregations

RemoveAllPRMessage (org.apache.geode.internal.cache.partitioned.RemoveAllPRMessage)6 HashMap (java.util.HashMap)3 Map (java.util.Map)2 CancelException (org.apache.geode.CancelException)2 CacheClosedException (org.apache.geode.cache.CacheClosedException)2 CacheException (org.apache.geode.cache.CacheException)2 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)2 PartitionedRegionDistributionException (org.apache.geode.cache.PartitionedRegionDistributionException)2 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)2 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)2 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)2 TransactionException (org.apache.geode.cache.TransactionException)2 VersionedObjectList (org.apache.geode.internal.cache.tier.sockets.VersionedObjectList)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 NoSuchElementException (java.util.NoSuchElementException)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1