Search in sources :

Example 66 with ReplyException

use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.

the class RemoteGetMessage method operateOnRegion.

@Override
protected boolean operateOnRegion(final DistributionManager dm, LocalRegion r, long startTime) throws RemoteOperationException {
    if (logger.isTraceEnabled(LogMarker.DM)) {
        logger.trace(LogMarker.DM, "RemoteGetMessage operateOnRegion: {}", r.getFullPath());
    }
    if (this.getTXUniqId() != TXManagerImpl.NOTX) {
        assert r.getDataView() instanceof TXStateProxy;
    }
    if (!(r instanceof PartitionedRegion)) {
        // prs already wait on initialization
        // bug #43371 - accessing a region before it's initialized
        r.waitOnInitialization();
    }
    RawValue valueBytes;
    Object val = null;
    try {
        KeyInfo keyInfo = r.getKeyInfo(key, cbArg);
        val = r.getDataView().getSerializedValue(r, keyInfo, false, this.context, null, false);
        valueBytes = val instanceof RawValue ? (RawValue) val : new RawValue(val);
        if (logger.isTraceEnabled(LogMarker.DM)) {
            logger.trace(LogMarker.DM, "GetMessage sending serialized value {} back via GetReplyMessage using processorId: {}", valueBytes, getProcessorId());
        }
        // r.getPrStats().endPartitionMessagesProcessing(startTime);
        GetReplyMessage.send(getSender(), getProcessorId(), valueBytes, getReplySender(dm));
        // response
        return false;
    } catch (DistributedSystemDisconnectedException sde) {
        sendReply(getSender(), this.processorId, dm, new ReplyException(new RemoteOperationException(LocalizedStrings.GetMessage_OPERATION_GOT_INTERRUPTED_DUE_TO_SHUTDOWN_IN_PROGRESS_ON_REMOTE_VM.toLocalizedString(), sde)), r, startTime);
        return false;
    } catch (PrimaryBucketException pbe) {
        sendReply(getSender(), getProcessorId(), dm, new ReplyException(pbe), r, startTime);
        return false;
    } catch (DataLocationException e) {
        sendReply(getSender(), getProcessorId(), dm, new ReplyException(e), r, startTime);
        return false;
    } finally {
        OffHeapHelper.release(val);
    }
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) ReplyException(org.apache.geode.distributed.internal.ReplyException) RawValue(org.apache.geode.internal.cache.BucketRegion.RawValue)

Example 67 with ReplyException

use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.

the class RemotePutAllMessage method operateOnRegion.

@Override
protected boolean operateOnRegion(DistributionManager dm, LocalRegion r, long startTime) throws RemoteOperationException {
    final boolean sendReply;
    InternalDistributedMember eventSender = getSender();
    long lastModified = 0L;
    try {
        sendReply = doLocalPutAll(r, eventSender, lastModified);
    } catch (RemoteOperationException e) {
        sendReply(getSender(), getProcessorId(), dm, new ReplyException(e), r, startTime);
        return false;
    }
    if (sendReply) {
        sendReply(getSender(), getProcessorId(), dm, null, r, startTime);
    }
    return false;
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ReplyException(org.apache.geode.distributed.internal.ReplyException)

Example 68 with ReplyException

use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.

the class DLockRecoverGrantorProcessor method recoverLockGrantor.

// -------------------------------------------------------------------------
// Static operations for recovering from loss of the lock grantor
// -------------------------------------------------------------------------
/**
   * Sends DLockRecoverGrantorMessage to all participants of the DLockService in order to recover
   * from the loss of the previous lock grantor. Each member will reply with details on currently
   * held locks, pending locks, and known stuck locks.
   * <p>
   * This method should block until transfer of lock grantor has completed.
   */
static boolean recoverLockGrantor(Set members, DLockService service, DLockGrantor newGrantor, DM dm, InternalDistributedMember elder) {
    // proc will wait for replies from everyone including THIS member...
    DLockRecoverGrantorProcessor processor = new DLockRecoverGrantorProcessor(dm, members, newGrantor);
    DLockRecoverGrantorMessage msg = new DLockRecoverGrantorMessage();
    msg.serviceName = service.getName();
    msg.processorId = processor.getProcessorId();
    msg.grantorVersion = newGrantor.getVersionId();
    msg.grantorSerialNumber = service.getSerialNumber();
    msg.elder = elder;
    // send msg to all members EXCEPT this member...
    Set recipients = new HashSet(members);
    recipients.remove(dm.getId());
    if (!recipients.isEmpty()) {
        msg.setRecipients(recipients);
        dm.putOutgoing(msg);
    }
    // process msg and reply from this VM...
    if (msg.getSender() == null)
        msg.setSender(dm.getId());
    msg.scheduleMessage(dm);
    // keep waiting even if interrupted
    try {
        processor.waitForRepliesUninterruptibly();
    } catch (ReplyException e) {
        e.handleAsUnexpected();
    }
    if (processor.error) {
        return false;
    }
    // return newGrantor.makeReady(false);
    return true;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ReplyException(org.apache.geode.distributed.internal.ReplyException) HashSet(java.util.HashSet)

Example 69 with ReplyException

use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.

the class DLockReleaseProcessor method release.

/**
   * Returns true if release was acknowledged by the grantor; false means we targeted someone who is
   * not the grantor
   */
protected boolean release(InternalDistributedMember grantor, String serviceName, boolean lockBatch, int lockId) {
    DM dm = getDistributionManager();
    DLockReleaseMessage msg = new DLockReleaseMessage();
    msg.processorId = getProcessorId();
    msg.serviceName = serviceName;
    msg.objectName = this.objectName;
    msg.lockBatch = lockBatch;
    msg.lockId = lockId;
    msg.setRecipient(grantor);
    if (grantor.equals(dm.getId())) {
        // local... don't message...
        msg.setSender(grantor);
        msg.processLocally(dm);
    } else {
        dm.putOutgoing(msg);
    }
    // keep waiting even if interrupted
    try {
        waitForRepliesUninterruptibly();
    } catch (ReplyException e) {
        e.handleAsUnexpected();
    }
    if (this.reply == null)
        return false;
    return this.reply.replyCode == DLockReleaseReplyMessage.OK;
}
Also used : DM(org.apache.geode.distributed.internal.DM) ReplyException(org.apache.geode.distributed.internal.ReplyException)

Example 70 with ReplyException

use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.

the class MissingPersistentIDsRequest method send.

public static Set<PersistentID> send(DM dm) {
    Set recipients = dm.getOtherDistributionManagerIds();
    MissingPersistentIDsRequest request = new MissingPersistentIDsRequest();
    request.setRecipients(recipients);
    MissingPersistentIDProcessor replyProcessor = new MissingPersistentIDProcessor(dm, recipients);
    request.msgId = replyProcessor.getProcessorId();
    dm.putOutgoing(request);
    try {
        replyProcessor.waitForReplies();
    } catch (ReplyException e) {
        if (!(e.getCause() instanceof CancelException)) {
            throw e;
        }
    } catch (InterruptedException e) {
        logger.warn(e);
    }
    Set<PersistentID> results = replyProcessor.missing;
    Set<PersistentID> existing = replyProcessor.existing;
    MissingPersistentIDsResponse localResponse = (MissingPersistentIDsResponse) request.createResponse((DistributionManager) dm);
    results.addAll(localResponse.getMissingIds());
    existing.addAll(localResponse.getLocalIds());
    results.removeAll(existing);
    return results;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) CancelException(org.apache.geode.CancelException) ReplyException(org.apache.geode.distributed.internal.ReplyException) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) PersistentID(org.apache.geode.cache.persistence.PersistentID)

Aggregations

ReplyException (org.apache.geode.distributed.internal.ReplyException)75 CancelException (org.apache.geode.CancelException)24 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)20 Set (java.util.Set)16 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)16 HashSet (java.util.HashSet)12 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)10 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)8 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)8 IOException (java.io.IOException)7 CacheClosedException (org.apache.geode.cache.CacheClosedException)7 ReplyMessage (org.apache.geode.distributed.internal.ReplyMessage)7 Cache (org.apache.geode.cache.Cache)6 CacheException (org.apache.geode.cache.CacheException)6 Region (org.apache.geode.cache.Region)6 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)6 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)6 Released (org.apache.geode.internal.offheap.annotations.Released)6 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)5 ReplyProcessor21 (org.apache.geode.distributed.internal.ReplyProcessor21)5