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 ; }
Gets the worker info options .