Search in sources :

Example 21 with InvalidArgumentException

use of alluxio.exception.status.InvalidArgumentException 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)

Example 22 with InvalidArgumentException

use of alluxio.exception.status.InvalidArgumentException in project alluxio by Alluxio.

the class TestCase method run.

/**
 * Runs the test case.
 */
public void run() throws Exception {
    String expected = "";
    if (mExpectedResult != null) {
        switch(mOptions.getContentType()) {
            case TestCaseOptions.JSON_CONTENT_TYPE:
                {
                    ObjectMapper mapper = new ObjectMapper();
                    if (mOptions.isPrettyPrint()) {
                        expected = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(mExpectedResult);
                    } else {
                        expected = mapper.writeValueAsString(mExpectedResult);
                    }
                    break;
                }
            case TestCaseOptions.XML_CONTENT_TYPE:
                {
                    XmlMapper mapper = new XmlMapper();
                    if (mOptions.isPrettyPrint()) {
                        expected = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(mExpectedResult);
                    } else {
                        expected = mapper.writeValueAsString(mExpectedResult);
                    }
                    break;
                }
            default:
                throw new InvalidArgumentException("Invalid content type in TestCaseOptions!");
        }
    }
    String result = call();
    Assert.assertEquals(mEndpoint, expected, result);
}
Also used : InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper)

Aggregations

InvalidArgumentException (alluxio.exception.status.InvalidArgumentException)22 IOException (java.io.IOException)6 CommandLine (org.apache.commons.cli.CommandLine)5 AlluxioURI (alluxio.AlluxioURI)3 ParseException (org.apache.commons.cli.ParseException)3 JournalMasterClient (alluxio.client.journal.JournalMasterClient)2 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)2 AlluxioException (alluxio.exception.AlluxioException)2 InvalidPathException (alluxio.exception.InvalidPathException)2 JournalDomain (alluxio.grpc.JournalDomain)2 HashSet (java.util.HashSet)2 CommandLineParser (org.apache.commons.cli.CommandLineParser)2 DefaultParser (org.apache.commons.cli.DefaultParser)2 Options (org.apache.commons.cli.Options)2 AbstractFsAdminCommand (alluxio.cli.fsadmin.command.AbstractFsAdminCommand)1 Context (alluxio.cli.fsadmin.command.Context)1 ConfigurationCommand (alluxio.cli.fsadmin.doctor.ConfigurationCommand)1 StorageCommand (alluxio.cli.fsadmin.doctor.StorageCommand)1 CapacityCommand (alluxio.cli.fsadmin.report.CapacityCommand)1 JobServiceMetricsCommand (alluxio.cli.fsadmin.report.JobServiceMetricsCommand)1