Search in sources :

Example 1 with GetWorkerReportOptions

use of alluxio.client.block.options.GetWorkerReportOptions in project alluxio by Alluxio.

the class CapacityCommand method getOptions.

/**
 * Gets the worker info options.
 *
 * @param cl CommandLine that contains the client options
 * @return GetWorkerReportOptions to get worker information
 */
private GetWorkerReportOptions getOptions(CommandLine cl) throws IOException {
    if (cl.getOptions().length > 1) {
        System.out.println(getUsage());
        throw new InvalidArgumentException("Too many arguments passed in.");
    }
    GetWorkerReportOptions workerOptions = GetWorkerReportOptions.defaults();
    Set<WorkerInfoField> fieldRange = new HashSet<>(Arrays.asList(WorkerInfoField.ADDRESS, WorkerInfoField.WORKER_CAPACITY_BYTES, WorkerInfoField.WORKER_CAPACITY_BYTES_ON_TIERS, WorkerInfoField.LAST_CONTACT_SEC, WorkerInfoField.WORKER_USED_BYTES, WorkerInfoField.WORKER_USED_BYTES_ON_TIERS));
    workerOptions.setFieldRange(fieldRange);
    if (cl.hasOption(ReportCommand.LIVE_OPTION_NAME)) {
        workerOptions.setWorkerRange(WorkerRange.LIVE);
    } else if (cl.hasOption(ReportCommand.LOST_OPTION_NAME)) {
        workerOptions.setWorkerRange(WorkerRange.LOST);
    } else if (cl.hasOption(ReportCommand.SPECIFIED_OPTION_NAME)) {
        workerOptions.setWorkerRange(WorkerRange.SPECIFIED);
        String addressString = cl.getOptionValue(ReportCommand.SPECIFIED_OPTION_NAME);
        String[] addressArray = addressString.split(",");
        // Addresses in GetWorkerReportOptions is only used when WorkerRange is SPECIFIED
        workerOptions.setAddresses(new HashSet<>(Arrays.asList(addressArray)));
    }
    return workerOptions;
}
Also used : InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) GetWorkerReportOptions(alluxio.client.block.options.GetWorkerReportOptions) WorkerInfoField(alluxio.client.block.options.GetWorkerReportOptions.WorkerInfoField) HashSet(java.util.HashSet)

Example 2 with GetWorkerReportOptions

use of alluxio.client.block.options.GetWorkerReportOptions in project alluxio by Alluxio.

the class CapacityCommand method run.

/**
 * Runs report capacity command.
 *
 * @param cl CommandLine to get client options
 * @return 0 on success, 1 otherwise
 */
public int run(CommandLine cl) throws IOException {
    if (cl.hasOption(ReportCommand.HELP_OPTION_NAME)) {
        System.out.println(getUsage());
        return 0;
    }
    GetWorkerReportOptions options = getOptions(cl);
    generateCapacityReport(options);
    return 0;
}
Also used : GetWorkerReportOptions(alluxio.client.block.options.GetWorkerReportOptions)

Aggregations

GetWorkerReportOptions (alluxio.client.block.options.GetWorkerReportOptions)2 WorkerInfoField (alluxio.client.block.options.GetWorkerReportOptions.WorkerInfoField)1 InvalidArgumentException (alluxio.exception.status.InvalidArgumentException)1 HashSet (java.util.HashSet)1