Search in sources :

Example 1 with JournalDomain

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;
}
Also used : JournalMasterClient(alluxio.client.journal.JournalMasterClient) QuorumServerInfo(alluxio.grpc.QuorumServerInfo) Arrays(java.util.Arrays) NetAddress(alluxio.grpc.NetAddress) ExceptionMessage(alluxio.exception.ExceptionMessage) Options(org.apache.commons.cli.Options) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) List(java.util.List) Context(alluxio.cli.fsadmin.command.Context) GetQuorumInfoPResponse(alluxio.grpc.GetQuorumInfoPResponse) AbstractFsAdminCommand(alluxio.cli.fsadmin.command.AbstractFsAdminCommand) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) CommandLine(org.apache.commons.cli.CommandLine) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) JournalDomain(alluxio.grpc.JournalDomain) InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) GetQuorumInfoPResponse(alluxio.grpc.GetQuorumInfoPResponse) QuorumServerInfo(alluxio.grpc.QuorumServerInfo) JournalMasterClient(alluxio.client.journal.JournalMasterClient) JournalDomain(alluxio.grpc.JournalDomain)

Example 2 with JournalDomain

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;
}
Also used : InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) JournalMasterClient(alluxio.client.journal.JournalMasterClient) JournalDomain(alluxio.grpc.JournalDomain)

Aggregations

JournalMasterClient (alluxio.client.journal.JournalMasterClient)2 InvalidArgumentException (alluxio.exception.status.InvalidArgumentException)2 JournalDomain (alluxio.grpc.JournalDomain)2 AbstractFsAdminCommand (alluxio.cli.fsadmin.command.AbstractFsAdminCommand)1 Context (alluxio.cli.fsadmin.command.Context)1 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 ExceptionMessage (alluxio.exception.ExceptionMessage)1 GetQuorumInfoPResponse (alluxio.grpc.GetQuorumInfoPResponse)1 NetAddress (alluxio.grpc.NetAddress)1 QuorumServerInfo (alluxio.grpc.QuorumServerInfo)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 CommandLine (org.apache.commons.cli.CommandLine)1 Options (org.apache.commons.cli.Options)1