use of alluxio.grpc.JournalDomain in project alluxio by Alluxio.
the class QuorumInfoCommand method run.
@Override
public int run(CommandLine cl) throws IOException {
JournalMasterClient jmClient = mMasterJournalMasterClient;
String domainVal = cl.getOptionValue(DOMAIN_OPTION_NAME);
try {
JournalDomain domain = JournalDomain.valueOf(domainVal);
if (domain == JournalDomain.JOB_MASTER) {
jmClient = mJobMasterJournalMasterClient;
}
} catch (IllegalArgumentException e) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_OPTION_VALUE.getMessage(DOMAIN_OPTION_NAME, Arrays.toString(JournalDomain.values())));
}
GetQuorumInfoPResponse quorumInfo = jmClient.getQuorumInfo();
Optional<QuorumServerInfo> leadingMasterInfoOpt = quorumInfo.getServerInfoList().stream().filter(QuorumServerInfo::getIsLeader).findFirst();
String leadingMasterAddr = leadingMasterInfoOpt.isPresent() ? netAddressToString(leadingMasterInfoOpt.get().getServerAddress()) : "UNKNOWN";
List<String[]> table = quorumInfo.getServerInfoList().stream().map(info -> new String[] { info.getServerState().toString(), Integer.toString(info.getPriority()), netAddressToString(info.getServerAddress()) }).collect(Collectors.toList());
table.add(0, new String[] { "STATE", "PRIORITY", "SERVER ADDRESS" });
mPrintStream.println(String.format(OUTPUT_HEADER_DOMAIN, quorumInfo.getDomain()));
mPrintStream.println(String.format(OUTPUT_HEADER_QUORUM_SIZE, quorumInfo.getServerInfoList().size()));
mPrintStream.println(String.format(OUTPUT_HEADER_LEADING_MASTER, leadingMasterAddr));
mPrintStream.println();
for (String[] output : table) {
mPrintStream.printf(OUTPUT_SERVER_INFO, output);
}
return 0;
}
use of alluxio.grpc.JournalDomain in project alluxio by Alluxio.
the class QuorumRemoveCommand method run.
@Override
public int run(CommandLine cl) throws IOException {
JournalMasterClient jmClient = mMasterJournalMasterClient;
String domainVal = cl.getOptionValue(DOMAIN_OPTION_NAME);
try {
JournalDomain domain = JournalDomain.valueOf(domainVal);
if (domain == JournalDomain.JOB_MASTER) {
jmClient = mJobMasterJournalMasterClient;
}
} catch (IllegalArgumentException e) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_OPTION_VALUE.getMessage(DOMAIN_OPTION_NAME, Arrays.toString(JournalDomain.values())));
}
String serverAddress = cl.getOptionValue(ADDRESS_OPTION_NAME);
jmClient.removeQuorumServer(QuorumCommand.stringToAddress(serverAddress));
mPrintStream.println(String.format(OUTPUT_RESULT, serverAddress, domainVal));
return 0;
}
Aggregations