Search in sources :

Example 21 with ForceReattemptException

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

the class PutAllPRMessage method send.

/**
   * Sends a PartitionedRegion PutAllPRMessage to the recipient
   * 
   * @param recipient the member to which the put message is sent
   * @param r the PartitionedRegion for which the put was performed
   * @return the processor used to await acknowledgement that the update was sent, or null to
   *         indicate that no acknowledgement will be sent
   * @throws ForceReattemptException if the peer is no longer available
   */
public PartitionResponse send(DistributedMember recipient, PartitionedRegion r) throws ForceReattemptException {
    // Assert.assertTrue(recipient != null, "PutAllPRMessage NULL recipient"); recipient can be null
    // for event notifications
    Set recipients = Collections.singleton(recipient);
    PutAllResponse p = new PutAllResponse(r.getSystem(), recipients);
    initMessage(r, recipients, false, p);
    setTransactionDistributed(r.getCache().getTxManager().isDistributed());
    if (logger.isDebugEnabled()) {
        logger.debug("PutAllPRMessage.send: recipient is {}, msg is {}", recipient, this);
    }
    Set failures = r.getDistributionManager().putOutgoing(this);
    if (failures != null && failures.size() > 0) {
        throw new ForceReattemptException("Failed sending <" + this + ">");
    }
    return p;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException)

Example 22 with ForceReattemptException

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

the class FetchEntriesMessage method send.

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

Example 23 with ForceReattemptException

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

the class FetchEntryMessage method operateOnPartitionedRegion.

@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException {
    // FetchEntryMessage is used in refreshing client caches during interest list recovery,
    // so don't be too verbose or hydra tasks may time out
    PartitionedRegionDataStore ds = r.getDataStore();
    EntrySnapshot val;
    if (ds != null) {
        try {
            KeyInfo keyInfo = r.getKeyInfo(key);
            val = (EntrySnapshot) r.getDataView().getEntryOnRemote(keyInfo, r, true);
            r.getPrStats().endPartitionMessagesProcessing(startTime);
            FetchEntryReplyMessage.send(getSender(), getProcessorId(), val, dm, null);
        } catch (TransactionException tex) {
            FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(tex));
        } catch (PRLocallyDestroyedException pde) {
            FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(new ForceReattemptException(LocalizedStrings.FetchEntryMessage_ENCOUNTERED_PRLOCALLYDESTROYED.toLocalizedString(), pde)));
        } catch (EntryNotFoundException enfe) {
            FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(LocalizedStrings.FetchEntryMessage_ENTRY_NOT_FOUND.toLocalizedString(), enfe));
        } catch (PrimaryBucketException pbe) {
            FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(pbe));
        } catch (ForceReattemptException pbe) {
            pbe.checkKey(key);
            // Slightly odd -- we're marshalling the retry to the peer on another host...
            FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(pbe));
        } catch (DataLocationException e) {
            FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(e));
        }
    } else {
        throw new InternalGemFireError(LocalizedStrings.FetchEntryMessage_FETCHENTRYMESSAGE_MESSAGE_SENT_TO_WRONG_MEMBER.toLocalizedString());
    }
    // response
    return false;
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) DataLocationException(org.apache.geode.internal.cache.DataLocationException) KeyInfo(org.apache.geode.internal.cache.KeyInfo) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) PartitionedRegionDataStore(org.apache.geode.internal.cache.PartitionedRegionDataStore) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) ReplyException(org.apache.geode.distributed.internal.ReplyException) EntrySnapshot(org.apache.geode.internal.cache.EntrySnapshot) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 24 with ForceReattemptException

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

the class FetchKeysMessage method operateOnPartitionedRegion.

@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) throws CacheException, ForceReattemptException {
    if (logger.isDebugEnabled()) {
        logger.debug("FetchKeysMessage operateOnRegion: {} bucketId: {} type: {} {}", r.getFullPath(), this.bucketId, InterestType.getString(interestType), (allowTombstones ? " with tombstones" : " without tombstones"));
    }
    PartitionedRegionDataStore ds = r.getDataStore();
    if (ds != null) {
        try {
            Set keys = ds.handleRemoteGetKeys(this.bucketId, interestType, interestArg, allowTombstones);
            if (logger.isTraceEnabled(LogMarker.DM)) {
                logger.debug("FetchKeysMessage sending {} keys back using processorId: : {}", keys.size(), getProcessorId(), keys);
            }
            r.getPrStats().endPartitionMessagesProcessing(startTime);
            FetchKeysReplyMessage.send(getSender(), getProcessorId(), dm, keys);
        } catch (PRLocallyDestroyedException pde) {
            if (logger.isDebugEnabled()) {
                logger.debug("FetchKeysMessage Encountered PRLocallyDestroyedException");
            }
            throw new ForceReattemptException(LocalizedStrings.FetchKeysMessage_ENCOUNTERED_PRLOCALLYDESTROYEDEXCEPTION.toLocalizedString(), pde);
        }
    } else {
        logger.warn(LocalizedMessage.create(LocalizedStrings.FetchKeysMessage_FETCHKEYSMESSAGE_DATA_STORE_NOT_CONFIGURED_FOR_THIS_MEMBER));
    }
    // Unless there was an exception thrown, this message handles sending the response
    return false;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegionDataStore(org.apache.geode.internal.cache.PartitionedRegionDataStore)

Example 25 with ForceReattemptException

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

the class ContainsKeyValueMessage method send.

/**
   * Sends a PartitionedRegion message for either
   * {@link org.apache.geode.cache.Region#containsKey(Object)}or
   * {@link org.apache.geode.cache.Region#containsValueForKey(Object)} depending on the
   * <code>valueCheck</code> argument
   * 
   * @param recipient the member that the contains keys/value message is sent to
   * @param r the PartitionedRegion that contains the bucket
   * @param key the key to be queried
   * @param bucketId the identity of the bucket to be queried
   * @param valueCheck true if {@link org.apache.geode.cache.Region#containsValueForKey(Object)} is
   *        desired, false if {@link org.apache.geode.cache.Region#containsKey(Object)}is desired
   * @return the processor used to read the returned keys
   * @throws ForceReattemptException if the peer is no longer available
   */
public static ContainsKeyValueResponse send(InternalDistributedMember recipient, PartitionedRegion r, Object key, Integer bucketId, boolean valueCheck) throws ForceReattemptException {
    Assert.assertTrue(recipient != null, "PRDistribuedContainsKeyValueMessage NULL reply message");
    ContainsKeyValueResponse p = new ContainsKeyValueResponse(r.getSystem(), Collections.singleton(recipient), key);
    ContainsKeyValueMessage m = new ContainsKeyValueMessage(recipient, r.getPRId(), p, key, bucketId, valueCheck);
    Set failures = r.getDistributionManager().putOutgoing(m);
    if (failures != null && failures.size() > 0) {
        throw new ForceReattemptException(LocalizedStrings.ContainsKeyValueMessage_FAILED_SENDING_0.toLocalizedString(m));
    }
    return p;
}
Also used : Set(java.util.Set) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException)

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