use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSQuorumCheckerJUnitTest method testQuorumChecker10Servers2Locators5ServerAnd1LocatorWithLeadMemberLost.
@Test
public void testQuorumChecker10Servers2Locators5ServerAnd1LocatorWithLeadMemberLost() 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
// lead member
pongResponders.remove(mockMembers[2].getPort());
pongResponders.remove(mockMembers[8].getPort());
pongResponders.remove(mockMembers[9].getPort());
pongResponders.remove(mockMembers[10].getPort());
pongResponders.remove(mockMembers[11].getPort());
// remove locator
pongResponders.remove(mockMembers[0].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());
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class JGroupsMessengerJUnitTest method testEncryptedFindCoordinatorResponse.
@Test
public void testEncryptedFindCoordinatorResponse() throws Exception {
InternalDistributedMember otherMbr = new InternalDistributedMember("localhost", 8888);
Properties p = new Properties();
p.put(ConfigurationProperties.SECURITY_UDP_DHALGO, "AES:128");
initMocks(false, p);
NetView v = createView(otherMbr);
GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
otherMbrEncrptor.setPublicKey(messenger.getPublicKey(messenger.getMemberID()), messenger.getMemberID());
messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
messenger.initClusterKey();
FindCoordinatorResponse gfmsg = new FindCoordinatorResponse(messenger.getMemberID(), messenger.getMemberID(), messenger.getClusterSecretKey(), 1);
Set<InternalDistributedMember> recipients = new HashSet<>();
recipients.add(otherMbr);
gfmsg.setRecipients(recipients);
short version = Version.CURRENT_ORDINAL;
HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
messenger.writeEncryptedMessage(gfmsg, version, out);
byte[] requestBytes = out.toByteArray();
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
messenger.addRequestId(1, messenger.getMemberID());
DistributionMessage distributionMessage = messenger.readEncryptedMessage(dis, version, otherMbrEncrptor);
assertEquals(gfmsg, distributionMessage);
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class GMSQuorumCheckerJUnitTest method prepareView.
private NetView prepareView(int numMembers) throws IOException {
int viewId = 1;
List<InternalDistributedMember> mbrs = new LinkedList<InternalDistributedMember>();
for (int i = 0; i < numMembers; i++) {
mbrs.add(mockMembers[i]);
}
// prepare the view
NetView netView = new NetView(mockMembers[0], viewId, mbrs);
return netView;
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class JGroupsMessengerJUnitTest method ioExceptionDuringShutdownAvoidsSuspectProcessing.
@Test
public void ioExceptionDuringShutdownAvoidsSuspectProcessing() throws Exception {
// see GEODE-634
initMocks(false);
NetView v = createView();
when(joinLeave.getView()).thenReturn(v);
when(manager.shutdownInProgress()).thenReturn(true);
messenger.installView(v);
messenger.handleJGroupsIOException(new IOException("fichez-moi le camp"), new JGAddress(v.getMembers().get(1)));
verify(healthMonitor, never()).checkIfAvailable(isA(InternalDistributedMember.class), isA(String.class), isA(Boolean.class));
}
use of org.apache.geode.distributed.internal.membership.NetView in project geode by apache.
the class JGroupsMessengerJUnitTest method createView.
private NetView createView(InternalDistributedMember otherMbr) {
InternalDistributedMember sender = messenger.getMemberID();
List<InternalDistributedMember> mbrs = new ArrayList<>();
mbrs.add(sender);
mbrs.add(otherMbr);
NetView v = new NetView(sender, 1, mbrs);
return v;
}
Aggregations