use of org.apache.geode.distributed.internal.SizeableRunnable in project geode by apache.
the class DistributedSystemDUnitTest method testWaitForDeparture.
/**
* ensure that waitForMemberDeparture correctly flushes the serial message queue for the given
* member
*/
@Test
public void testWaitForDeparture() throws Exception {
Properties config = new Properties();
config.put(LOCATORS, "");
config.put(START_LOCATOR, "localhost[" + this.locatorPort + "]");
config.put(DISABLE_TCP, "true");
InternalDistributedSystem system = (InternalDistributedSystem) DistributedSystem.connect(config);
// construct a member ID that will represent a departed member
InternalDistributedMember member = new InternalDistributedMember("localhost", 12345, "", "", NORMAL_DM_TYPE, null, null);
// schedule a message in order to create a queue for the fake member
DistributionManager distributionManager = (DistributionManager) system.getDistributionManager();
final FakeMessage message = new FakeMessage(null);
distributionManager.getExecutor(SERIAL_EXECUTOR, member).execute(new SizeableRunnable(100) {
@Override
public void run() {
// always throws NullPointerException
message.doAction(distributionManager, false);
}
@Override
public String toString() {
return "Processing fake message";
}
});
Assert.assertTrue("expected the serial queue to be flushed", distributionManager.getMembershipManager().waitForDeparture(member));
Assert.assertTrue(message.processed);
}
use of org.apache.geode.distributed.internal.SizeableRunnable in project geode by apache.
the class GMSMembershipManager method waitForSerialMessageProcessing.
/**
* wait for serial executor messages from the given member to be processed
*/
public boolean waitForSerialMessageProcessing(InternalDistributedMember idm) throws InterruptedException {
// run a message through the member's serial execution queue to ensure that all of its
// current messages have been processed
boolean result = false;
OverflowQueueWithDMStats serialQueue = listener.getDM().getSerialQueue(idm);
if (serialQueue != null) {
final boolean[] done = new boolean[1];
final FlushingMessage msg = new FlushingMessage(done);
serialQueue.add(new SizeableRunnable(100) {
public void run() {
msg.invoke();
}
public String toString() {
return "Processing fake message";
}
});
synchronized (done) {
while (!done[0]) {
done.wait(10);
}
result = true;
}
}
return result;
}
Aggregations