Search in sources :

Example 46 with ReplyException

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

the class CheckTypeRegistryState method send.

public static void send(DM dm) {
    Set recipients = dm.getOtherDistributionManagerIds();
    ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, recipients);
    CheckTypeRegistryState msg = new CheckTypeRegistryState(replyProcessor.getProcessorId());
    msg.setRecipients(recipients);
    dm.putOutgoing(msg);
    try {
        replyProcessor.waitForReplies();
    } catch (ReplyException e) {
        if (e.getCause() instanceof PdxInitializationException) {
            throw new PdxInitializationException("Bad PDX configuration on member " + e.getSender() + ": " + e.getCause().getMessage(), e.getCause());
        } else {
            throw new InternalGemFireError("Unexpected exception", e);
        }
    } catch (InterruptedException e) {
        throw new InternalGemFireError("Unexpected exception", e);
    }
}
Also used : Set(java.util.Set) ReplyException(org.apache.geode.distributed.internal.ReplyException) PdxInitializationException(org.apache.geode.pdx.PdxInitializationException) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 47 with ReplyException

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

the class CheckTypeRegistryState method process.

@Override
protected void process(DistributionManager dm) {
    ReplyException e = null;
    try {
        InternalCache cache = GemFireCacheImpl.getInstance();
        if (cache != null && !cache.isClosed()) {
            TypeRegistry pdxRegistry = cache.getPdxRegistry();
            if (pdxRegistry != null) {
                TypeRegistration registry = pdxRegistry.getTypeRegistration();
                if (registry instanceof PeerTypeRegistration) {
                    PeerTypeRegistration peerRegistry = (PeerTypeRegistration) registry;
                    peerRegistry.verifyConfiguration();
                }
            }
        }
    } catch (Exception ex) {
        e = new ReplyException(ex);
    } finally {
        ReplyMessage rm = new ReplyMessage();
        rm.setException(e);
        rm.setProcessorId(processorId);
        rm.setRecipient(getSender());
        dm.putOutgoing(rm);
    }
}
Also used : InternalCache(org.apache.geode.internal.cache.InternalCache) ReplyException(org.apache.geode.distributed.internal.ReplyException) PdxInitializationException(org.apache.geode.pdx.PdxInitializationException) IOException(java.io.IOException) ReplyException(org.apache.geode.distributed.internal.ReplyException) ReplyMessage(org.apache.geode.distributed.internal.ReplyMessage)

Example 48 with ReplyException

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

the class PersistentPartitionedRegionDUnitTest method testRevokeBeforeStartup.

// GEODE-974: async actions, time sensitive, 65 second timeouts
@Category(FlakyTest.class)
@Test
public void testRevokeBeforeStartup() throws Throwable {
    IgnoredException.addIgnoredException("RevokeFailedException");
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    int numBuckets = 50;
    createPR(vm0, 1);
    createPR(vm1, 1);
    createData(vm0, 0, numBuckets, "a");
    Set<Integer> vm0Buckets = getBucketList(vm0);
    Set<Integer> vm1Buckets = getBucketList(vm1);
    assertEquals(vm0Buckets, vm1Buckets);
    // This should fail with a revocation failed message
    try {
        revokeAllMembers(vm2);
        fail("The revoke should have failed, because members are running");
    } catch (RMIException e) {
        if (!(e.getCause() instanceof ReplyException && e.getCause().getCause() instanceof RevokeFailedException)) {
            throw e;
        }
    }
    closeCache(vm0);
    createData(vm1, 0, numBuckets, "b");
    File vm1Directory = getDiskDirectory(vm1);
    closeCache(vm1);
    vm0.invoke(new SerializableRunnable("get cache") {

        public void run() {
            getCache();
        }
    });
    revokeMember(vm2, vm1Directory);
    AsyncInvocation a1 = createPRAsync(vm0, 1);
    a1.getResult(MAX_WAIT);
    assertEquals(vm0Buckets, getBucketList(vm0));
    checkData(vm0, 0, numBuckets, "a");
    createData(vm0, numBuckets, 113, "b");
    checkData(vm0, numBuckets, 113, "b");
    IgnoredException ex = IgnoredException.addIgnoredException(RevokedPersistentDataException.class.getName(), vm1);
    try {
        createPR(vm1, 1);
        fail("Should have recieved a SplitDistributedSystemException");
    } catch (RMIException e) {
        // We revoked this member.
        if (!(e.getCause() instanceof RevokedPersistentDataException)) {
            throw e;
        }
    }
    ex.remove();
}
Also used : RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) RMIException(org.apache.geode.test.dunit.RMIException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) ReplyException(org.apache.geode.distributed.internal.ReplyException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) File(java.io.File) RevokeFailedException(org.apache.geode.cache.persistence.RevokeFailedException) Category(org.junit.experimental.categories.Category) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 49 with ReplyException

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

the class TXLockServiceImpl method updateParticipants.

@Override
public void updateParticipants(TXLockId txLockId, final Set updatedParticipants) {
    synchronized (this.txLockIdList) {
        if (!this.txLockIdList.contains(txLockId)) {
            throw new IllegalArgumentException(LocalizedStrings.TXLockServiceImpl_INVALID_TXLOCKID_NOT_FOUND_0.toLocalizedString(txLockId));
        }
    }
    if (updatedParticipants == null) {
        throw new IllegalArgumentException(LocalizedStrings.TXLockServiceImpl_INVALID_UPDATEDPARTICIPANTS_NULL.toLocalizedString());
    }
    if (updatedParticipants.isEmpty()) {
        return;
    }
    if (!this.recovering) {
        // Serializable grantorId = this.dlock.getLockGrantorId();
        if (this.dlock.isLockGrantor()) {
            // Don't need to send a message (or wait for a reply)
            // logger.info("DEBUG: [TXLockServiceImpl.updateParticipants] this VM is the Grantor");
            TXLockUpdateParticipantsMessage.updateParticipants(this.dlock, txLockId, updatedParticipants);
        } else {
            // not lock grantor
            LockGrantorId lockGrantorId = txLockId.getLockGrantorId();
            if (lockGrantorId == null || !this.dlock.isLockGrantorId(lockGrantorId)) {
                // grantor is gone so we cannot update him
                return;
            }
            InternalDistributedMember grantorId = lockGrantorId.getLockGrantorMember();
            // logger.info("DEBUG: [TXLockServiceImpl.updateParticipants] sending update message to
            // Grantor " + grantorId);
            ReplyProcessor21 processor = new ReplyProcessor21(this.dlock.getDistributionManager(), grantorId);
            TXLockUpdateParticipantsMessage dlup = new TXLockUpdateParticipantsMessage(txLockId, this.dlock.getName(), updatedParticipants, processor.getProcessorId());
            dlup.setRecipient(grantorId);
            this.dlock.getDistributionManager().putOutgoing(dlup);
            // for() loop removed for bug 36983 - you can't loop on waitForReplies()
            this.dlock.getDistributionManager().getCancelCriterion().checkCancelInProgress(null);
            try {
                processor.waitForRepliesUninterruptibly();
            } catch (ReplyException e) {
                e.handleAsUnexpected();
            }
        }
    // not lock grantor
    }
// not recovering
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) LockGrantorId(org.apache.geode.distributed.internal.locks.LockGrantorId) ReplyException(org.apache.geode.distributed.internal.ReplyException) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21)

Example 50 with ReplyException

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

the class TXOriginatorRecoveryProcessor method sendMessage.

static void sendMessage(Set members, InternalDistributedMember originator, TXLockId txLockId, DLockGrantor grantor, DM dm) {
    TXOriginatorRecoveryProcessor processor = new TXOriginatorRecoveryProcessor(dm, members);
    TXOriginatorRecoveryMessage msg = new TXOriginatorRecoveryMessage();
    msg.processorId = processor.getProcessorId();
    msg.txLockId = txLockId;
    // send msg to all members EXCEPT this member...
    Set recipients = new HashSet(members);
    recipients.remove(dm.getId());
    msg.setRecipients(members);
    if (logger.isDebugEnabled()) {
        logger.debug("Sending TXOriginatorRecoveryMessage: {}", msg);
    }
    dm.putOutgoing(msg);
    // process msg and reply directly if this VM is a participant...
    if (members.contains(dm.getId())) {
        if (msg.getSender() == null)
            msg.setSender(dm.getId());
        msg.process((DistributionManager) dm);
    }
    // keep waiting even if interrupted
    // for() loop removed for bug 36983 - you can't loop on waitForReplies()
    dm.getCancelCriterion().checkCancelInProgress(null);
    try {
        processor.waitForRepliesUninterruptibly();
    } catch (ReplyException e) {
        e.handleAsUnexpected();
    }
    // release txLockId...
    if (logger.isDebugEnabled()) {
        logger.debug("TXOriginatorRecoveryProcessor releasing: {}", txLockId);
    }
    // dtls.release(txLockId);
    try {
        grantor.releaseLockBatch(txLockId, originator);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ReplyException(org.apache.geode.distributed.internal.ReplyException) HashSet(java.util.HashSet)

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