use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestTransferLeadership method transferWhenAlreadyTransferring.
@Test
public void transferWhenAlreadyTransferring() throws Exception {
mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_ALREADY_TRANSFERRING).setClusterName("EmbeddedJournalTransferLeadership_transferWhenAlreadyTransferring").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
mCluster.start();
int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % NUM_MASTERS;
// `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
// we can therefore access to the new leader's address this way
MasterNetAddress newLeaderAddr = mCluster.getMasterAddresses().get(newLeaderIdx);
NetAddress netAddress = masterEBJAddr2NetAddr(newLeaderAddr);
mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
// this second call should throw an exception
String transferId = mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
String exceptionMessage = mCluster.getJournalMasterClientForMaster().getTransferLeaderMessage(transferId).getTransMsg().getMsg();
Assert.assertFalse(exceptionMessage.isEmpty());
mCluster.notifySuccess();
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestTransferLeadership method resetPriorities.
@Test
public void resetPriorities() throws Exception {
mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_UNAVAILABLE_MASTER).setClusterName("EmbeddedJournalTransferLeadership_transferLeadershipToUnavailableMaster").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
mCluster.start();
boolean match = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().allMatch(info -> info.getPriority() == 0);
Assert.assertTrue(match);
for (int i = 0; i < NUM_MASTERS; i++) {
int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % NUM_MASTERS;
// `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
// we can therefore access to the new leader's address this way
MasterNetAddress newLeaderAddr = mCluster.getMasterAddresses().get(newLeaderIdx);
transferAndWait(newLeaderAddr);
match = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().allMatch(info -> info.getPriority() == (info.getIsLeader() ? 2 : 1));
Assert.assertTrue(match);
mCluster.getJournalMasterClientForMaster().resetPriorities();
match = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().allMatch(info -> info.getPriority() == 1);
Assert.assertTrue(match);
}
mCluster.notifySuccess();
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestTransferLeadership method transferLeadershipOutsideCluster.
@Test
public void transferLeadershipOutsideCluster() throws Exception {
mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_OUTSIDE_CLUSTER).setClusterName("EmbeddedJournalTransferLeadership_transferLeadership").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
mCluster.start();
NetAddress netAddress = NetAddress.newBuilder().setHost("hostname").setRpcPort(0).build();
String transferId = mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
String exceptionMessage = mCluster.getJournalMasterClientForMaster().getTransferLeaderMessage(transferId).getTransMsg().getMsg();
Assert.assertTrue(exceptionMessage.startsWith(String.format("<%s:%d> is not part of the quorum", netAddress.getHost(), netAddress.getRpcPort())));
for (MasterNetAddress address : mCluster.getMasterAddresses()) {
String host = address.getHostname();
int port = address.getEmbeddedJournalPort();
Assert.assertTrue(exceptionMessage.contains(String.format("%s:%d", host, port)));
}
mCluster.notifySuccess();
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestTransferLeadership method transferLeadershipToNewMember.
@Test
public void transferLeadershipToNewMember() throws Exception {
mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_NEW_MEMBER).setClusterName("EmbeddedJournalTransferLeadership_transferLeadershipToNewMember").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
mCluster.start();
mCluster.startNewMasters(1, false);
waitForQuorumPropertySize(info -> info.getServerState() == QuorumServerState.AVAILABLE, NUM_MASTERS + 1);
MasterNetAddress newLeaderAddr = mCluster.getMasterAddresses().get(NUM_MASTERS);
transferAndWait(newLeaderAddr);
mCluster.notifySuccess();
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestTransferLeadership method transferAndWait.
private String transferAndWait(MasterNetAddress newLeaderAddr) throws Exception {
NetAddress netAddress = NetAddress.newBuilder().setHost(newLeaderAddr.getHostname()).setRpcPort(newLeaderAddr.getEmbeddedJournalPort()).build();
String transferId = mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
waitForQuorumPropertySize(info -> info.getIsLeader() && info.getServerAddress().equals(netAddress), 1);
return transferId;
}
Aggregations