Search in sources :

Example 11 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class RemoteGemFireVM method addCacheServer.

public AdminBridgeServer addCacheServer(CacheInfo cache) throws AdminException {
    BridgeServerRequest request = BridgeServerRequest.createForAdd(cache);
    BridgeServerResponse response = (BridgeServerResponse) sendAndWait(request);
    if (response.getException() != null) {
        Exception ex = response.getException();
        throw new AdminException(ex.getMessage(), ex);
    } else {
        return response.getBridgeInfo();
    }
}
Also used : AdminException(org.apache.geode.admin.AdminException) AdminException(org.apache.geode.admin.AdminException) OperationCancelledException(org.apache.geode.admin.OperationCancelledException)

Example 12 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class RemoteGemFireVM method stopBridgeServer.

public AdminBridgeServer stopBridgeServer(CacheInfo cache, AdminBridgeServer bridge) throws AdminException {
    BridgeServerRequest request = BridgeServerRequest.createForStop(cache, (RemoteBridgeServer) bridge);
    BridgeServerResponse response = (BridgeServerResponse) sendAndWait(request);
    if (response.getException() != null) {
        Exception ex = response.getException();
        throw new AdminException(ex.getMessage(), ex);
    } else {
        return response.getBridgeInfo();
    }
}
Also used : AdminException(org.apache.geode.admin.AdminException) AdminException(org.apache.geode.admin.AdminException) OperationCancelledException(org.apache.geode.admin.OperationCancelledException)

Example 13 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class PersistentRecoveryOrderDUnitTest method testRevokeAMember.

/**
   * Tests to make sure that we stop waiting for a member that we revoke.
   * 
   * @throws Exception
   */
@Test
public void testRevokeAMember() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    LogWriterUtils.getLogWriter().info("Creating region in VM0");
    createPersistentRegion(vm0);
    LogWriterUtils.getLogWriter().info("Creating region in VM1");
    createPersistentRegion(vm1);
    putAnEntry(vm0);
    vm0.invoke(new SerializableRunnable("Check for waiting regions") {

        public void run() {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            PersistentMemberManager mm = cache.getPersistentMemberManager();
            Map<String, Set<PersistentMemberID>> waitingRegions = mm.getWaitingRegions();
            assertEquals(0, waitingRegions.size());
        }
    });
    LogWriterUtils.getLogWriter().info("closing region in vm0");
    closeRegion(vm0);
    updateTheEntry(vm1);
    LogWriterUtils.getLogWriter().info("closing region in vm1");
    closeCache(vm1);
    // This ought to wait for VM1 to come back
    LogWriterUtils.getLogWriter().info("Creating region in VM0");
    AsyncInvocation future = createPersistentRegionAsync(vm0);
    waitForBlockedInitialization(vm0);
    assertTrue(future.isAlive());
    vm2.invoke(new SerializableRunnable("Revoke the member") {

        public void run() {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            DistributedSystemConfig config;
            AdminDistributedSystem adminDS = null;
            try {
                config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
                adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
                adminDS.connect();
                Set<PersistentID> missingIds = adminDS.getMissingPersistentMembers();
                LogWriterUtils.getLogWriter().info("waiting members=" + missingIds);
                assertEquals(1, missingIds.size());
                PersistentID missingMember = missingIds.iterator().next();
                adminDS.revokePersistentMember(missingMember.getUUID());
            } catch (AdminException e) {
                throw new RuntimeException(e);
            } finally {
                if (adminDS != null) {
                    adminDS.disconnect();
                }
            }
        }
    });
    future.join(MAX_WAIT);
    if (future.isAlive()) {
        fail("Region not created within" + MAX_WAIT);
    }
    if (future.exceptionOccurred()) {
        throw new Exception(future.getException());
    }
    checkForRecoveryStat(vm0, true);
    // Check to make sure we recovered the old
    // value of the entry.
    SerializableRunnable checkForEntry = new SerializableRunnable("check for the entry") {

        public void run() {
            Cache cache = getCache();
            Region region = cache.getRegion(REGION_NAME);
            assertEquals("B", region.get("A"));
        }
    };
    vm0.invoke(checkForEntry);
    // Now, we should not be able to create a region
    // in vm1, because the this member was revoked
    LogWriterUtils.getLogWriter().info("Creating region in VM1");
    IgnoredException e = IgnoredException.addIgnoredException(RevokedPersistentDataException.class.getSimpleName(), vm1);
    try {
        createPersistentRegion(vm1);
        fail("We should have received a split distributed system exception");
    } catch (RuntimeException expected) {
        if (!(expected.getCause() instanceof RevokedPersistentDataException)) {
            throw expected;
        }
    } finally {
        e.remove();
    }
    closeCache(vm1);
    // Restart vm0
    closeCache(vm0);
    createPersistentRegion(vm0);
// Make sure we still get a RevokedPersistentDataException
// TODO - RVV - This won't work until we actually persist the revoked
// members. I want to refactor to use disk store id before we do that.
// getLogWriter().info("Creating region in VM1");
// e = addExpectedException(RevokedPersistentDataException.class.getSimpleName(), vm1);
// try {
// createPersistentRegion(vm1);
// fail("We should have received a split distributed system exception");
// } catch(RuntimeException expected) {
// if(!(expected.getCause() instanceof RevokedPersistentDataException)) {
// throw expected;
// }
// //Do nothing
// } finally {
// e.remove();
// }
}
Also used : AdminException(org.apache.geode.admin.AdminException) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) Set(java.util.Set) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) AdminDistributedSystem(org.apache.geode.admin.AdminDistributedSystem) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) AdminException(org.apache.geode.admin.AdminException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PersistentReplicatesOfflineException(org.apache.geode.cache.persistence.PersistentReplicatesOfflineException) IOException(java.io.IOException) DistributedSystemConfig(org.apache.geode.admin.DistributedSystemConfig) VM(org.apache.geode.test.dunit.VM) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) DiskRegion(org.apache.geode.internal.cache.DiskRegion) Region(org.apache.geode.cache.Region) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Map(java.util.Map) HashMap(java.util.HashMap) PersistentID(org.apache.geode.cache.persistence.PersistentID) Cache(org.apache.geode.cache.Cache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 14 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class PersistentRecoveryOrderDUnitTest method testWaitingMemberList.

/**
   * Test which members show up in the list of members we're waiting on.
   * 
   * @throws Exception
   */
@Test
public void testWaitingMemberList() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    VM vm3 = host.getVM(3);
    LogWriterUtils.getLogWriter().info("Creating region in VM0");
    createPersistentRegion(vm0);
    LogWriterUtils.getLogWriter().info("Creating region in VM1");
    createPersistentRegion(vm1);
    createPersistentRegion(vm2);
    putAnEntry(vm0);
    vm0.invoke(new SerializableRunnable("Check for waiting regions") {

        public void run() {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            PersistentMemberManager mm = cache.getPersistentMemberManager();
            Map<String, Set<PersistentMemberID>> waitingRegions = mm.getWaitingRegions();
            assertEquals(0, waitingRegions.size());
        }
    });
    LogWriterUtils.getLogWriter().info("closing region in vm0");
    closeRegion(vm0);
    updateTheEntry(vm1);
    LogWriterUtils.getLogWriter().info("closing region in vm1");
    closeRegion(vm1);
    updateTheEntry(vm2, "D");
    LogWriterUtils.getLogWriter().info("closing region in vm2");
    closeRegion(vm2);
    // These ought to wait for VM2 to come back
    LogWriterUtils.getLogWriter().info("Creating region in VM0");
    AsyncInvocation future0 = createPersistentRegionAsync(vm0);
    waitForBlockedInitialization(vm0);
    assertTrue(future0.isAlive());
    LogWriterUtils.getLogWriter().info("Creating region in VM1");
    final AsyncInvocation future1 = createPersistentRegionAsync(vm1);
    waitForBlockedInitialization(vm1);
    assertTrue(future1.isAlive());
    vm3.invoke(new SerializableRunnable("check waiting members") {

        public void run() {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            DistributedSystemConfig config;
            AdminDistributedSystem adminDS = null;
            try {
                config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
                adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
                adminDS.connect();
                Set<PersistentID> missingIds = adminDS.getMissingPersistentMembers();
                LogWriterUtils.getLogWriter().info("waiting members=" + missingIds);
                assertEquals(1, missingIds.size());
            } catch (AdminException e) {
                throw new RuntimeException(e);
            } finally {
                if (adminDS != null) {
                    adminDS.disconnect();
                }
            }
        }
    });
    vm1.invoke(new SerializableRunnable("close cache") {

        public void run() {
            getCache().close();
        }
    });
    Wait.waitForCriterion(new WaitCriterion() {

        public boolean done() {
            return !future1.isAlive();
        }

        public String description() {
            return "Waiting for blocked initialization to terminate because the cache was closed.";
        }
    }, 30000, 500, true);
    // Now we should be missing 2 members
    vm3.invoke(new SerializableRunnable("check waiting members again") {

        public void run() {
            GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
            DistributedSystemConfig config;
            AdminDistributedSystem adminDS = null;
            try {
                config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
                adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
                adminDS.connect();
                final AdminDistributedSystem connectedDS = adminDS;
                Wait.waitForCriterion(new WaitCriterion() {

                    public String description() {
                        return "Waiting for waiting members to have 2 members";
                    }

                    public boolean done() {
                        Set<PersistentID> missingIds;
                        try {
                            missingIds = connectedDS.getMissingPersistentMembers();
                        } catch (AdminException e) {
                            throw new RuntimeException(e);
                        }
                        return 2 == missingIds.size();
                    }
                }, MAX_WAIT, 500, true);
            } catch (AdminException e) {
                throw new RuntimeException(e);
            } finally {
                if (adminDS != null) {
                    adminDS.disconnect();
                }
            }
        }
    });
}
Also used : AdminException(org.apache.geode.admin.AdminException) Set(java.util.Set) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) AdminDistributedSystem(org.apache.geode.admin.AdminDistributedSystem) DistributedSystemConfig(org.apache.geode.admin.DistributedSystemConfig) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) VM(org.apache.geode.test.dunit.VM) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) Map(java.util.Map) HashMap(java.util.HashMap) PersistentID(org.apache.geode.cache.persistence.PersistentID) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 15 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class IncrementalBackupDUnitTest method baseline.

/**
   * Invokes {@link AdminDistributedSystem#backupAllMembers(File)} on a member.
   * 
   * @param vm a member of the distributed system
   * @return the status of the backup.
   */
private BackupStatus baseline(VM vm) {
    return (BackupStatus) vm.invoke(new SerializableCallable("Backup all members.") {

        @Override
        public Object call() {
            DistributedSystemConfig config;
            AdminDistributedSystem adminDS = null;
            try {
                config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
                adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
                adminDS.connect();
                return adminDS.backupAllMembers(getBaselineDir());
            } catch (AdminException e) {
                throw new RuntimeException(e);
            } finally {
                if (adminDS != null) {
                    adminDS.disconnect();
                }
            }
        }
    });
}
Also used : AdminException(org.apache.geode.admin.AdminException) DistributedSystemConfig(org.apache.geode.admin.DistributedSystemConfig) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) AdminDistributedSystem(org.apache.geode.admin.AdminDistributedSystem) BackupStatus(org.apache.geode.admin.BackupStatus)

Aggregations

AdminException (org.apache.geode.admin.AdminException)16 DistributedSystemConfig (org.apache.geode.admin.DistributedSystemConfig)8 AdminDistributedSystem (org.apache.geode.admin.AdminDistributedSystem)7 OperationCancelledException (org.apache.geode.admin.OperationCancelledException)6 Set (java.util.Set)4 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)4 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)4 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 BackupStatus (org.apache.geode.admin.BackupStatus)3 PersistentID (org.apache.geode.cache.persistence.PersistentID)3 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)3 Host (org.apache.geode.test.dunit.Host)3 VM (org.apache.geode.test.dunit.VM)3 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)3 Cache (org.apache.geode.cache.Cache)2 Region (org.apache.geode.cache.Region)2 DiskRegion (org.apache.geode.internal.cache.DiskRegion)2