use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class DistributedCacheTestCase method remoteCloseCache.
/**
* Closes the Cache for the current VM. Returns whether or not an exception occurred in the
* distribution manager to which this VM is attached. Note that the exception flag is cleared by
* this method.
*
* @see DistributionManager#exceptionInThreads()
*/
private static boolean remoteCloseCache() throws CacheException {
Assert.assertTrue(cache != null, "No cache on this VM?");
Assert.assertTrue(!cache.isClosed(), "Who closed my cache?");
InternalDistributedSystem system = (InternalDistributedSystem) ((GemFireCacheImpl) cache).getDistributedSystem();
DistributionManager dm = (DistributionManager) system.getDistributionManager();
boolean exceptionInThreads = dm.exceptionInThreads();
DistributionManagerDUnitTest.clearExceptionInThreads(dm);
cache.close();
cache = null;
return exceptionInThreads;
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class RemoteFetchEntryMessageTest method shouldBeMockable.
@Test
public void shouldBeMockable() throws Exception {
RemoteFetchEntryMessage mockRemoteFetchEntryMessage = mock(RemoteFetchEntryMessage.class);
DistributionManager mockDistributionManager = mock(DistributionManager.class);
LocalRegion mockLocalRegion = mock(LocalRegion.class);
long startTime = System.currentTimeMillis();
when(mockRemoteFetchEntryMessage.operateOnRegion(eq(mockDistributionManager), eq(mockLocalRegion), eq(startTime))).thenReturn(true);
assertThat(mockRemoteFetchEntryMessage.operateOnRegion(mockDistributionManager, mockLocalRegion, startTime)).isTrue();
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testCrashDuringBucketGII2.
/**
* Another test for bug 41436. If the GII source crashes before the GII is complete, we need to
* make sure that later we can recover redundancy.
*
* In this test case, we bring the GII down before we bring the source back up, to make sure the
* source still discovers that the GII target is no longer hosting the bucket.
*
* @throws InterruptedException
*/
@Test
public void testCrashDuringBucketGII2() throws InterruptedException {
IgnoredException.addIgnoredException("PartitionOfflineException");
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
final VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
createPR(vm0, 1);
createData(vm0, 0, 1, "value");
// Add an observer which will close the cache when the GII starts
vm0.invoke(new SerializableRunnable("Set crashing observer") {
public void run() {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof RequestImageMessage) {
RequestImageMessage rim = (RequestImageMessage) message;
if (rim.regionPath.contains("_0")) {
DistributionMessageObserver.setInstance(null);
getCache().close();
}
}
}
});
}
});
createPR(vm1, 1);
// Make sure vm1 didn't create the bucket
assertEquals(Collections.emptySet(), getBucketList(vm1));
closeCache(vm1);
AsyncInvocation async0 = createPRAsync(vm0, 1, 0, 113);
async0.join(500);
// vm0 should get stuck waiting for vm1 to recover from disk,
// because vm0 thinks vm1 has the bucket
assertTrue(async0.isAlive());
createPR(vm1, 1, 0);
// Make sure vm0 recovers the bucket
assertEquals(Collections.singleton(0), getBucketList(vm0));
// vm1 should satisfy redundancy for the bucket as well
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
return (Collections.singleton(0).equals(getBucketList(vm1)));
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 30 * 1000, 200, true);
assertEquals(Collections.singleton(0), getBucketList(vm1));
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class PersistentPartitionedRegionDUnitTest method testBug42226.
/**
* Test for bug 4226. 1. Member A has the bucket 2. Member B starts creating the bucket. It tells
* member A that it hosts the bucket 3. Member A crashes 4. Member B destroys the bucket and
* throws a partition offline exception, because it wasn't able to complete initialization. 5.
* Member A recovers, and gets stuck waiting for member B.
*
* @throws Throwable
*/
// GEODE-1208: time sensitive, multiple non-thread-safe test hooks,
@Category(FlakyTest.class)
// async actions
@Test
public void testBug42226() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
// Add a hook which will disconnect from the distributed
// system when the initial image message shows up.
vm0.invoke(new SerializableRunnable() {
public void run() {
DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
@Override
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof RequestImageMessage) {
RequestImageMessage rim = (RequestImageMessage) message;
// Don't disconnect until we see a bucket
if (rim.regionPath.contains("_B_")) {
DistributionMessageObserver.setInstance(null);
disconnectFromDS();
}
}
}
@Override
public void afterProcessMessage(DistributionManager dm, DistributionMessage message) {
}
});
}
});
LogWriterUtils.getLogWriter().info("Creating region in VM0");
createPR(vm0, 1, 0, 1);
// Make sure we create a bucket
createData(vm0, 0, 1, "a");
// This should recover redundancy, which should cause vm0 to disconnect
IgnoredException ex = IgnoredException.addIgnoredException("PartitionOfflineException");
try {
LogWriterUtils.getLogWriter().info("Creating region in VM1");
createPR(vm1, 1, 0, 1);
// Make sure get a partition offline exception
try {
createData(vm1, 0, 1, "a");
} catch (RMIException e) {
// We expect a PartitionOfflineException
if (!(e.getCause() instanceof PartitionOfflineException)) {
throw e;
}
}
} finally {
ex.remove();
}
// Make sure vm0 is really disconnected (avoids a race with the observer).
vm0.invoke(new SerializableRunnable() {
public void run() {
disconnectFromDS();
}
});
// This should recreate the bucket
AsyncInvocation async1 = createPRAsync(vm0, 1, 0, 1);
async1.getResult(MAX_WAIT);
checkData(vm1, 0, 1, "a");
}
use of org.apache.geode.distributed.internal.DistributionManager in project geode by apache.
the class DeposePrimaryBucketMessageTest method shouldBeMockable.
@Test
public void shouldBeMockable() throws Exception {
DeposePrimaryBucketMessage mockDeposePrimaryBucketMessage = mock(DeposePrimaryBucketMessage.class);
DistributionManager mockDistributionManager = mock(DistributionManager.class);
PartitionedRegion mockPartitionedRegion = mock(PartitionedRegion.class);
long startTime = System.currentTimeMillis();
when(mockDeposePrimaryBucketMessage.operateOnPartitionedRegion(eq(mockDistributionManager), eq(mockPartitionedRegion), eq(startTime))).thenReturn(true);
assertThat(mockDeposePrimaryBucketMessage.operateOnPartitionedRegion(mockDistributionManager, mockPartitionedRegion, startTime)).isTrue();
}
Aggregations