use of org.apache.geode.internal.cache.SearchLoadAndWriteProcessor.NetSearchRequestMessage in project geode by apache.
the class NetSearchMessagingDUnitTest method testNetSearchFailoverFromReplicate.
/**
* Make sure that even if we start out by net searching replicates, we'll fall back to net
* searching normal members.
*/
@Test
public void testNetSearchFailoverFromReplicate() {
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);
// Install a listener to kill this member
// when we get the netsearch request
vm0.invoke(new SerializableRunnable("Install listener") {
public void run() {
DistributionMessageObserver ob = new DistributionMessageObserver() {
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof NetSearchRequestMessage) {
disconnectFromDS();
}
}
};
DistributionMessageObserver.setInstance(ob);
}
});
createReplicate(vm0);
createNormal(vm1);
createNormal(vm2);
createEmpty(vm3);
// Test with a real value value
{
put(vm3, "a", "b");
long vm0Count = getReceivedMessages(vm0);
long vm1Count = getReceivedMessages(vm1);
long vm2Count = getReceivedMessages(vm2);
long vm3Count = getReceivedMessages(vm3);
assertEquals("b", get(vm3, "a"));
// Make sure we were disconnected in vm0
vm0.invoke(new SerializableRunnable("check disconnected") {
public void run() {
assertNull(GemFireCacheImpl.getInstance());
}
});
}
}
use of org.apache.geode.internal.cache.SearchLoadAndWriteProcessor.NetSearchRequestMessage in project geode by apache.
the class NetSearchMessagingDUnitTest method testNetSearchFailoverFromOneReplicateToAnother.
@Test
public void testNetSearchFailoverFromOneReplicateToAnother() {
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);
// Install a listener to kill this member
// when we get the netsearch request
vm0.invoke(new SerializableRunnable("Install listener") {
public void run() {
DistributionMessageObserver ob = new DistributionMessageObserver() {
public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
if (message instanceof NetSearchRequestMessage) {
disconnectFromDS();
}
}
};
DistributionMessageObserver.setInstance(ob);
}
});
createReplicate(vm0);
createReplicate(vm1);
createEmpty(vm3);
// Test with a real value value
{
put(vm3, "a", "b");
boolean disconnected = false;
while (!disconnected) {
assertEquals("b", get(vm3, "a"));
// Make sure we were disconnected in vm0
disconnected = (Boolean) vm0.invoke(new SerializableCallable("check disconnected") {
public Object call() {
return GemFireCacheImpl.getInstance() == null;
}
});
}
}
}
Aggregations