use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestTransferLeadership method transferLeadershipToUnavailableMaster.
@Test
public void transferLeadershipToUnavailableMaster() 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();
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);
mCluster.stopMaster(newLeaderIdx);
try {
transferAndWait(newLeaderAddr);
Assert.fail("Transfer should have failed");
} catch (TimeoutException e) {
// expected exception
}
mCluster.notifySuccess();
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class ZookeeperFailureIntegrationTest method rpcServiceAvailable.
/*
* This method uses a client with an explicit master address to ensure that the master has shut
* down its rpc service.
*/
private boolean rpcServiceAvailable() throws Exception {
MasterNetAddress netAddress = mCluster.getMasterAddresses().get(0);
InetSocketAddress address = new InetSocketAddress(netAddress.getHostname(), netAddress.getRpcPort());
try {
GrpcChannel channel = GrpcChannelBuilder.newBuilder(GrpcServerAddress.create(address), ServerConfiguration.global()).build();
FileSystemMasterClientServiceGrpc.FileSystemMasterClientServiceBlockingStub client = FileSystemMasterClientServiceGrpc.newBlockingStub(channel);
client.listStatus(ListStatusPRequest.getDefaultInstance());
} catch (Exception e) {
return false;
}
return true;
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class QuorumCommandIntegrationTest method infoAfterElect.
@Test
public void infoAfterElect() throws Exception {
final int MASTER_INDEX_WAIT_TIME = 5_000;
int numMasters = 3;
mCluster = MultiProcessCluster.newBuilder(PortCoordination.QUORUM_SHELL_REMOVE).setClusterName("QuorumShellElect").setNumMasters(numMasters).setNumWorkers(0).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();
try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % numMasters;
// `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
// we can therefore access to the new leader's address this ways
MasterNetAddress netAddress = mCluster.getMasterAddresses().get(newLeaderIdx);
String newLeaderAddr = String.format("%s:%s", netAddress.getHostname(), netAddress.getEmbeddedJournalPort());
int success = shell.run("journal", "quorum", "elect", "-address", newLeaderAddr);
Assert.assertEquals("elect command failed", 0, success);
mOutput.reset();
shell.run("journal", "quorum", "info", "-domain", "MASTER");
String output = mOutput.toString().trim();
for (MasterNetAddress masterAddr : mCluster.getMasterAddresses()) {
String expected = String.format(QuorumInfoCommand.OUTPUT_SERVER_INFO, "AVAILABLE", "1", String.format("%s:%d", masterAddr.getHostname(), masterAddr.getEmbeddedJournalPort()));
Assert.assertTrue(output.contains(expected.trim()));
}
}
mCluster.notifySuccess();
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class QuorumCommandIntegrationTest method elect.
@Test
public void elect() throws Exception {
final int MASTER_INDEX_WAIT_TIME = 5_000;
int numMasters = 3;
mCluster = MultiProcessCluster.newBuilder(PortCoordination.QUORUM_SHELL_REMOVE).setClusterName("QuorumShellElect").setNumMasters(numMasters).setNumWorkers(0).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();
try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % numMasters;
// `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
// we can therefore access to the new leader's address this ways
MasterNetAddress netAddress = mCluster.getMasterAddresses().get(newLeaderIdx);
String newLeaderAddr = String.format("%s:%s", netAddress.getHostname(), netAddress.getEmbeddedJournalPort());
mOutput.reset();
shell.run("journal", "quorum", "elect", "-address", newLeaderAddr);
String output = mOutput.toString().trim();
String expected = String.format("%s\n%s\n%s\n%s", String.format(QuorumElectCommand.TRANSFER_INIT, newLeaderAddr), String.format(QuorumElectCommand.TRANSFER_SUCCESS, newLeaderAddr), String.format(QuorumElectCommand.RESET_INIT, "successful"), QuorumElectCommand.RESET_SUCCESS);
Assert.assertEquals(expected, output);
}
mCluster.notifySuccess();
}
use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestResizing method replaceAll.
@Ignore
@Test
public void replaceAll() throws Exception {
final int NUM_MASTERS = 5;
final int NUM_WORKERS = 0;
mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_REPLACE_ALL).setClusterName("EmbeddedJournalResizing_replaceAll").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();
AlluxioURI testDir = new AlluxioURI("/" + CommonUtils.randomAlphaNumString(10));
FileSystem fs = mCluster.getFileSystemClient();
fs.createDirectory(testDir);
assertTrue(fs.exists(testDir));
List<MasterNetAddress> originalMasters = new ArrayList<>(mCluster.getMasterAddresses());
for (MasterNetAddress masterNetAddress : originalMasters) {
// remove a master from the Alluxio cluster (could be the leader)
int masterIdx = mCluster.getMasterAddresses().indexOf(masterNetAddress);
mCluster.stopAndRemoveMaster(masterIdx);
waitForQuorumPropertySize(info -> info.getServerState() == QuorumServerState.UNAVAILABLE, 1);
// remove said master from the Ratis quorum
NetAddress toRemove = masterEBJAddr2NetAddr(masterNetAddress);
mCluster.getJournalMasterClientForMaster().removeQuorumServer(toRemove);
waitForQuorumPropertySize(info -> true, NUM_MASTERS - 1);
waitForQuorumPropertySize(info -> info.getServerAddress() == toRemove, 0);
// start a new master to replace the lost master
mCluster.startNewMasters(1, false);
waitForQuorumPropertySize(info -> true, NUM_MASTERS);
// verify that the cluster is still operational
fs = mCluster.getFileSystemClient();
assertTrue(fs.exists(testDir));
}
Set<NetAddress> og = originalMasters.stream().map(this::masterEBJAddr2NetAddr).collect(Collectors.toSet());
Set<NetAddress> curr = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().map(QuorumServerInfo::getServerAddress).collect(Collectors.toSet());
Set<NetAddress> intersection = new HashSet<>(og);
intersection.retainAll(curr);
// assert that none of the current masters are part of the original
assertTrue(intersection.isEmpty());
// assert the quorum remained the same size as the start
assertEquals(NUM_MASTERS, curr.size());
mCluster.notifySuccess();
}
Aggregations