use of org.apache.geode.test.dunit.RMIException in project geode by apache.
the class PartitionedRegionMetaDataCleanupDUnitTest method testCleanupOnCloseCache.
@Test
public void testCleanupOnCloseCache() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
createPR(vm0, "region1", 5);
createPR(vm1, "region2", 10);
// This should fail
IgnoredException ex = IgnoredException.addIgnoredException("IllegalStateException", vm1);
try {
createPR(vm1, "region1", 10);
fail("Should have received an exception");
} catch (RMIException e) {
// ok
} finally {
ex.remove();
}
closeCache(vm0);
waitForCreate(vm0, "region1", 15);
}
use of org.apache.geode.test.dunit.RMIException in project geode by apache.
the class PartitionedRegionMetaDataCleanupDUnitTest method testCleanupOnCloseRegion.
@Test
public void testCleanupOnCloseRegion() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
createPR(vm0, "region1", 5);
createPR(vm1, "region2", 10);
// This should fail
IgnoredException ex = IgnoredException.addIgnoredException("IllegalStateException", vm1);
try {
createPR(vm1, "region1", 10);
fail("Should have received an exception");
} catch (RMIException e) {
// ok
} finally {
ex.remove();
}
closePr(vm0, "region1");
waitForCreate(vm0, "region1", 15);
}
use of org.apache.geode.test.dunit.RMIException in project geode by apache.
the class RollingUpgrade2DUnitTest method testOldMemberCantJoinRolledLocators.
/**
* Demonstrate that an old process can't join a system that has upgraded locators. This is for
* bugs #50510 and #50742.
*/
@Test
public void testOldMemberCantJoinRolledLocators() throws Exception {
VM oldServer = Host.getHost(0).getVM(oldVersion, 1);
// uses the DUnit locator
Properties props = getSystemProperties();
try {
oldServer.invoke(invokeCreateCache(props));
} catch (RMIException e) {
Throwable cause = e.getCause();
if (cause != null && (cause instanceof AssertionError)) {
cause = cause.getCause();
if (cause != null && cause.getMessage() != null && !cause.getMessage().startsWith("Rejecting the attempt of a member using an older version of the product to join the distributed system")) {
throw e;
}
}
}
}
use of org.apache.geode.test.dunit.RMIException in project geode by apache.
the class DistributedLockServiceDUnitTest method testCreateDestroy.
@Test
public void testCreateDestroy() throws Exception {
final String serviceName = getUniqueName();
final String abc = "abc";
// create and destroy dls
assertNull(DistributedLockService.getServiceNamed(serviceName));
DistributedLockService service = DistributedLockService.create(serviceName, getSystem());
assertSame(service, DistributedLockService.getServiceNamed(serviceName));
DistributedLockService.destroy(serviceName);
// assert attempt to use dls throws LockServiceDestroyedException
try {
service.lock(abc, -1, -1);
fail("didn't get LockServiceDestroyedException");
} catch (LockServiceDestroyedException ex) {
}
// assert that destroyed dls is no longer available
service = DistributedLockService.getServiceNamed(serviceName);
assertNull("" + service, service);
// recreate the dls
service = DistributedLockService.create(serviceName, getSystem());
assertTrue(!((DLockService) service).isDestroyed());
((DLockService) service).checkDestroyed();
// get the same dls from another thread and hold a lock
Thread thread = new Thread(new Runnable() {
public void run() {
DistributedLockService dls = DistributedLockService.getServiceNamed(serviceName);
assertTrue(!((DLockService) dls).isDestroyed());
((DLockService) dls).checkDestroyed();
// get lock on abc and hold it
dls.lock(abc, -1, -1);
}
});
thread.start();
ThreadUtils.join(thread, 30 * 1000);
// start a new thread to wait for lock on abc
AsyncInvocation remoteWaitingThread = Host.getHost(0).getVM(0).invokeAsync(new SerializableRunnable() {
public void run() {
DistributedLockService dls = DistributedLockService.create(serviceName, getSystem());
try {
// waiting to get lock abc
dls.lock(abc, -1, -1);
fail("remoteWaitingThread got lock after dls destroyed");
} catch (LockServiceDestroyedException expected) {
return;
}
fail("remoteWaitingThread lock failed to throw LockServiceDestroyedException");
}
});
// loop will handle race condition with 1 sec sleep and retry
int retry = 10;
for (int i = 0; i < retry; i++) {
try {
// destroy DLS and free up remoteWaitingThread
Host.getHost(0).getVM(0).invoke(new SerializableRunnable() {
public void run() {
DistributedLockService.destroy(serviceName);
}
});
} catch (RMIException e) {
// race condition: remoteWaitingThread probably hasn't created DLS yet
if (i < retry && e.getCause() instanceof IllegalArgumentException) {
sleep(1000);
continue;
} else {
throw e;
}
}
// completed so break out of loop
break;
}
DistributedLockService.destroy(serviceName);
// make sure remoteWaitingThread stopped waiting and threw LockServiceDestroyedException
ThreadUtils.join(remoteWaitingThread, 10 * 1000);
if (remoteWaitingThread.exceptionOccurred()) {
Throwable e = remoteWaitingThread.getException();
org.apache.geode.test.dunit.Assert.fail(e.getMessage(), e);
}
// make sure LockServiceDestroyedException is thrown
try {
service.lock(abc, -1, -1);
fail("didn't get LockServiceDestroyedException");
} catch (LockServiceDestroyedException ex) {
}
// make sure getServiceNamed returns null
service = DistributedLockService.getServiceNamed(serviceName);
assertNull("" + service, service);
}
use of org.apache.geode.test.dunit.RMIException in project geode by apache.
the class SystemFailureDUnitTest method doCreateEntry.
protected void doCreateEntry(String name) {
LogWriter log = org.apache.geode.test.dunit.LogWriterUtils.getLogWriter();
log.info("<ExpectedException action=add>" + "dunit.RMIException" + "</ExpectedException>");
Object[] args = new Object[] { name };
Host host = Host.getHost(0);
VM vm = host.getVM(0);
try {
vm.invoke(this.getClass(), "createEntry", args);
} catch (RMIException e) {
// expected
}
log.info("<ExpectedException action=add>" + "dunit.RMIException" + "</ExpectedException>");
}
Aggregations