use of com.linkedin.d2.quorum.ZKPeer in project rest.li by linkedin.
the class TestD2ZKQuorumFailover method testD2WithQuorumFollowerServerKilled.
public void testD2WithQuorumFollowerServerKilled() throws Exception {
setup();
// Kill quorum peer follower zk server
ZKPeer follower = _quorum.getQuorumFollower();
// Simulate zk server crash
follower.killPeerZkServer();
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
assertFalse(follower.getZKServer().isRunning(), "quorum Peer #" + follower.getId() + "/port " + follower.getClientPort() + " server has not shut down.");
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
use of com.linkedin.d2.quorum.ZKPeer in project rest.li by linkedin.
the class TestD2ConfigWithZKQuorum method testD2ConfigWithZKQuorumV3DegraderCustomPartitionLeaderPeerDown.
public void testD2ConfigWithZKQuorumV3DegraderCustomPartitionLeaderPeerDown() throws Exception {
setup();
String connectionString = _quorum.getHosts();
ZKPeer leader = _quorum.getQuorumLeader();
leader.shutdownPeer();
assertEquals(LoadBalancerClientCli.runDiscovery(connectionString, "/d2", D2_CONFIG_DEFAULT_PARTITION_DATA), 0);
}
use of com.linkedin.d2.quorum.ZKPeer in project rest.li by linkedin.
the class TestD2ZKQuorumFailover method testD2WithQuorumLeaderPeerDown.
public void testD2WithQuorumLeaderPeerDown() throws Exception {
setup();
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
// Shutdown zk _quorum leader peer
ZKPeer peer = _quorum.getQuorumLeader();
if (peer != null) {
int peerId = peer.getId();
peer.shutdownPeer();
// Verify requests are processed while leader goes down
long start = System.currentTimeMillis();
while (_quorum.getQuorumLeader() != null && _quorum.getQuorumLeader().equals(peer) && System.currentTimeMillis() < (start + TIMEOUT)) {
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
start = System.currentTimeMillis();
while (_quorum.getQuorumLeader() == null && System.currentTimeMillis() < (start + TIMEOUT)) {
// wait while zookeeper is establishing a new leader
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
if (_quorum.getQuorumLeader() == null) {
_quorum.restartAll();
} else {
assertTrue(!_quorum.getQuorumLeader().equals(peer), "No new _quorum leader was established. New leader id=" + _quorum.getQuorumLeader().getId());
// Restart leader peer
_quorum.restart(peerId);
}
start = System.currentTimeMillis();
peer = _quorum.get(peerId);
// Verify requests are processed while peer is restarting
while (System.currentTimeMillis() < (start + TIMEOUT) && (peer.getZKServer() == null || !_quorum.areAllPeersUp() || !peer.getZKServer().isRunning())) {
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
// After restart
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
} else {
fail("Quorum is unable to identify zk leader. No tests were executed.");
}
}
use of com.linkedin.d2.quorum.ZKPeer in project rest.li by linkedin.
the class TestD2ZKQuorumFailover method testD2WithQuorumFollowerPeerDown.
public void testD2WithQuorumFollowerPeerDown() throws Exception {
setup();
// Shutdown zk _quorum follower peer (non-leader member of a zk _quorum)
ZKPeer follower = _quorum.getQuorumFollower();
follower.shutdownPeer();
// Assert requests are processed while follower goes down
long start = System.currentTimeMillis();
while (follower.getZKServer() != null && System.currentTimeMillis() < start + TIMEOUT) {
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
assertFalse(follower.isRunning(), "_quorum Peer #" + follower.getId() + "/port " + follower.getClientPort() + " server has not shut down.");
// Restart peer
_quorum.restart(follower.getId());
// Assert requests processed while follower is restarting
start = System.currentTimeMillis();
while ((_quorum.getPeerZKServer(follower.getId()) == null || !_quorum.getPeerZKServer(follower.getId()).isRunning()) && System.currentTimeMillis() < start + TIMEOUT) {
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
// Assert requests are processed after peer restart
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
use of com.linkedin.d2.quorum.ZKPeer in project rest.li by linkedin.
the class TestD2ZKQuorumFailover method testD2WithQuorumLeaderServerKilled.
public void testD2WithQuorumLeaderServerKilled() throws Exception {
setup();
// Kill _quorum leader peer zk server
ZKPeer peer = _quorum.getQuorumLeader();
if (peer != null) {
peer.killPeerZkServer();
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
assertFalse(peer.getZKServer().isRunning(), "_quorum Peer #" + peer.getId() + "/port " + peer.getClientPort() + " server has not shut down.");
// Restart peer zk server
peer.startupPeerZkServer();
// Assert requests are processed while peer is restarting
long start = System.currentTimeMillis();
while (peer.getZKServer() == null && System.currentTimeMillis() < start + TIMEOUT) {
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
}
_quorum.assertAllPeersUp();
// After restart
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
} else {
fail("Quorum unable to identify zk leader. No tests were executed.");
}
}
Aggregations