use of org.apache.activemq.artemis.core.server.cluster.qourum.ServerConnectVote in project activemq-artemis by apache.
the class QuorumVoteServerConnectTest method testSuccessfulVote.
@Test
public void testSuccessfulVote() {
QuorumVoteServerConnect quorum = new QuorumVoteServerConnect(size, "foo");
for (int i = 0; i < trueVotes - 1; i++) {
quorum.vote(new ServerConnectVote("foo", true));
}
if (size > 1) {
assertFalse(quorum.getDecision());
}
quorum = new QuorumVoteServerConnect(size, "foo");
for (int i = 0; i < trueVotes; i++) {
quorum.vote(new ServerConnectVote("foo", true));
}
assertTrue(quorum.getDecision());
}
use of org.apache.activemq.artemis.core.server.cluster.qourum.ServerConnectVote in project activemq-artemis by apache.
the class QuorumVoteServerConnectTest method testUnSuccessfulVote.
@Test
public void testUnSuccessfulVote() {
QuorumVoteServerConnect quorum = new QuorumVoteServerConnect(size, "foo");
for (int i = 0; i < trueVotes - 1; i++) {
quorum.vote(new ServerConnectVote("foo", true));
}
if (size > 1) {
assertFalse(quorum.getDecision());
}
quorum = new QuorumVoteServerConnect(size, "foo");
for (int i = 0; i < trueVotes - 1; i++) {
quorum.vote(new ServerConnectVote("foo", true));
}
if (size == 1) {
assertTrue(quorum.getDecision());
} else {
assertFalse(quorum.getDecision());
}
}
use of org.apache.activemq.artemis.core.server.cluster.qourum.ServerConnectVote in project activemq-artemis by apache.
the class ServerConnectVoteHandler method decode.
@Override
public Vote decode(ActiveMQBuffer voteBuffer) {
ServerConnectVote vote = new ServerConnectVote();
vote.decode(voteBuffer);
return vote;
}
use of org.apache.activemq.artemis.core.server.cluster.qourum.ServerConnectVote in project activemq-artemis by apache.
the class ServerConnectVoteHandler method vote.
@Override
public Vote vote(Vote vote) {
ServerConnectVote serverConnectVote = (ServerConnectVote) vote;
String nodeid = serverConnectVote.getNodeId();
TopologyMemberImpl member = server.getClusterManager().getDefaultConnection(null).getTopology().getMember(nodeid);
if (member != null && member.getLive() != null) {
ActiveMQServerLogger.LOGGER.nodeFoundInClusterTopology(nodeid);
return new ServerConnectVote(nodeid, (Boolean) vote.getVote());
}
ActiveMQServerLogger.LOGGER.nodeNotFoundInClusterTopology(nodeid);
return new ServerConnectVote(nodeid, !((Boolean) vote.getVote()));
}
Aggregations