private static AlluxioFuseOptions parseOptions ( String [ ] args , AlluxioConfiguration alluxioConf ) { final Options opts = new Options ( ) ; final Option mntPoint = Option . builder ( "m" ) . hasArg ( ) . required ( true ) . longOpt ( "mount-point" ) . desc ( "Desired local mount point for alluxio-fuse." ) . build ( ) ; final Option alluxioRoot = Option . builder ( "r" ) . hasArg ( ) . required ( true ) . longOpt ( "alluxio-root" ) . desc ( "Path within alluxio that will be used as the root of the FUSE mount " + "(e.g., /users/foo; defaults to /)" ) . build ( ) ; final Option help = Option . builder ( "h" ) . required ( false ) . desc ( "Print this help" ) . build ( ) ; final Option fuseOption = Option . builder ( "o" ) . valueSeparator ( ' ' ) . required ( false ) . hasArgs ( ) . desc ( "FUSE mount options" ) . build ( ) ; opts . addOption ( mntPoint ) ; opts . addOption ( alluxioRoot ) ; opts . addOption ( help ) ; opts . addOption ( fuseOption ) ; final CommandLineParser parser = new DefaultParser ( ) ; try { CommandLine cli = parser . parse ( opts , args ) ; if ( cli . hasOption ( "h" ) ) { final HelpFormatter fmt = new HelpFormatter ( ) ; fmt . printHelp ( AlluxioFuse . class . getName ( ) , opts ) ; return null ; } String mntPointValue = cli . getOptionValue ( "m" ) ; String alluxioRootValue = cli . getOptionValue ( "r" ) ; List < String > fuseOpts = new ArrayList <> ( ) ; boolean noUserMaxWrite = true ; if ( cli . hasOption ( "o" ) ) { String [ ] fopts = cli . getOptionValues ( "o" ) ; // keep the -o for ( final String fopt : fopts ) { fuseOpts . add ( "-o" + fopt ) ; if ( noUserMaxWrite && fopt . startsWith ( "max_write" ) ) { noUserMaxWrite = false ; } } } // check if the user has specified his own max_write, otherwise get it // from conf if ( noUserMaxWrite ) { final long maxWrite = alluxioConf . getBytes ( PropertyKey . FUSE_MAXWRITE_BYTES ) ; fuseOpts . add ( String . format ( "-omax_write=%d" , maxWrite ) ) ; } final boolean fuseDebug = alluxioConf . getBoolean ( PropertyKey . FUSE_DEBUG_ENABLED ) ; return new AlluxioFuseOptions ( mntPointValue , alluxioRootValue , fuseDebug , fuseOpts ) ; } catch ( ParseException e ) { System . err . println ( "Error while parsing CLI: " + e . getMessage ( ) ) ; final HelpFormatter fmt = new HelpFormatter ( ) ; fmt . printHelp ( AlluxioFuse . class . getName ( ) , opts ) ; return null ; } }
Parses CLI options .