use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class JGroupsMessengerJUnitTest method testSendToMultipleMembers.
@Test
public void testSendToMultipleMembers() throws Exception {
initMocks(false);
InternalDistributedMember sender = messenger.getMemberID();
InternalDistributedMember other = createAddress(8888);
NetView v = new NetView(sender);
v.add(other);
when(joinLeave.getView()).thenReturn(v);
messenger.installView(v);
List<InternalDistributedMember> recipients = v.getMembers();
SerialAckedMessage msg = new SerialAckedMessage();
msg.setRecipients(recipients);
messenger.send(msg);
int sentMessages = interceptor.unicastSentDataMessages;
assertTrue("expected 2 message to be sent but found " + sentMessages, sentMessages == 2);
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class JGroupsMessengerJUnitTest method testJGroupsIOExceptionHandler.
@Test
public void testJGroupsIOExceptionHandler() throws Exception {
initMocks(false);
InternalDistributedMember mbr = createAddress(8888);
NetView v = new NetView(mbr);
v.add(messenger.getMemberID());
messenger.installView(v);
IOException ioe = new IOException("test exception");
messenger.handleJGroupsIOException(ioe, new JGAddress(mbr));
// should be ignored
messenger.handleJGroupsIOException(ioe, new JGAddress(mbr));
verify(healthMonitor).suspect(mbr, "Unable to send messages to this member via JGroups");
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class JGroupsMessengerJUnitTest method testMessageFiltering.
@Test
public void testMessageFiltering() throws Exception {
initMocks(true);
InternalDistributedMember mbr = createAddress(8888);
NetView view = new NetView(mbr);
// the digest should be set in an outgoing join response
JoinResponseMessage joinResponse = new JoinResponseMessage(mbr, view, 0);
messenger.filterOutgoingMessage(joinResponse);
assertNotNull(joinResponse.getMessengerData());
// save the view digest for later
byte[] data = joinResponse.getMessengerData();
// the digest should be used and the message bytes nulled out in an incoming join response
messenger.filterIncomingMessage(joinResponse);
assertNull(joinResponse.getMessengerData());
// the digest shouldn't be set in an outgoing rejection message
joinResponse = new JoinResponseMessage("you can't join my distributed system. nyah nyah nyah!", 0);
messenger.filterOutgoingMessage(joinResponse);
assertNull(joinResponse.getMessengerData());
// the digest shouldn't be installed from an incoming rejection message
joinResponse.setMessengerData(data);
messenger.filterIncomingMessage(joinResponse);
assertNotNull(joinResponse.getMessengerData());
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSQuorumCheckerJUnitTest method testQuorumCheckerNoQuorumNoResponders.
@Test
public void testQuorumCheckerNoQuorumNoResponders() throws Exception {
NetView view = prepareView();
Set<Integer> pongResponders = new HashSet<Integer>();
PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
qc.initialize();
boolean quorum = qc.checkForQuorum(500);
assertFalse(quorum);
assertSame(view.getMembers().size(), answerer.getPingCount());
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSQuorumCheckerJUnitTest method testQuorumChecker10Servers2Locators5ServersAnd2LocatorsButNotLeadMemberLost.
@Test
public void testQuorumChecker10Servers2Locators5ServersAnd2LocatorsButNotLeadMemberLost() throws Exception {
NetView view = prepareView();
mockMembers[0].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
mockMembers[1].setVmKind(DistributionManager.LOCATOR_DM_TYPE);
Set<Integer> pongResponders = new HashSet<Integer>();
for (int i = 0; i < mockMembers.length; i++) {
pongResponders.add(mockMembers[i].getPort());
}
// remove 5 servers
pongResponders.remove(mockMembers[7].getPort());
pongResponders.remove(mockMembers[8].getPort());
pongResponders.remove(mockMembers[9].getPort());
pongResponders.remove(mockMembers[10].getPort());
pongResponders.remove(mockMembers[11].getPort());
// remove locators
pongResponders.remove(mockMembers[0].getPort());
pongResponders.remove(mockMembers[1].getPort());
PingMessageAnswer answerer = new PingMessageAnswer(channel, pongResponders);
Mockito.doAnswer(answerer).when(channel).send(any(Message.class));
GMSQuorumChecker qc = new GMSQuorumChecker(view, 51, channel);
qc.initialize();
boolean quorum = qc.checkForQuorum(500);
assertFalse(quorum);
assertSame(view.getMembers().size(), answerer.getPingCount());
}
Aggregations