@ SuppressWarnings ( "static-access" ) public static void main ( String [ ] args ) throws IOException { Option configDirOpt = OptionBuilder . withArgName ( "config directory" ) . hasArg ( ) . withDescription ( "Specify configuration directory." ) . create ( "configDir" ) ; // tempDir option is used by the YARN client. Option tempDir = OptionBuilder . withArgName ( "temporary directory (overwrites configured option)" ) . hasArg ( ) . withDescription ( "Specify temporary directory." ) . create ( ARG_CONF_DIR ) ; configDirOpt . setRequired ( true ) ; tempDir . setRequired ( false ) ; Options options = new Options ( ) ; options . addOption ( configDirOpt ) ; options . addOption ( tempDir ) ; CommandLineParser parser = new GnuParser ( ) ; CommandLine line = null ; try { line = parser . parse ( options , args ) ; } catch ( ParseException e ) { System . err . println ( "CLI Parsing failed. Reason: " + e . getMessage ( ) ) ; System . exit ( FAILURE_RETURN_CODE ) ; } String configDir = line . getOptionValue ( configDirOpt . getOpt ( ) , null ) ; String tempDirVal = line . getOptionValue ( tempDir . getOpt ( ) , null ) ; // First, try to load global configuration GlobalConfiguration . loadConfiguration ( configDir ) ; if ( tempDirVal != null // the YARN TM runner has set a value for the temp dir // the configuration does not contain a temp direcory && GlobalConfiguration . getString ( ConfigConstants . TASK_MANAGER_TMP_DIR_KEY , null ) == null ) { Configuration c = GlobalConfiguration . getConfiguration ( ) ; c . setString ( ConfigConstants . TASK_MANAGER_TMP_DIR_KEY , tempDirVal ) ; LOG . info ( "Setting temporary directory to " + tempDirVal ) ; GlobalConfiguration . includeConfiguration ( c ) ; } System . err . println ( "Configuration " + GlobalConfiguration . getConfiguration ( ) ) ; LOG . info ( "Current user " + UserGroupInformation . getCurrentUser ( ) . getShortUserName ( ) ) ; { // log the available JVM memory long maxMemoryMiBytes = Runtime . getRuntime ( ) . maxMemory ( ) >>> 20 ; LOG . info ( "Starting TaskManager in a JVM with " + maxMemoryMiBytes + " MiBytes maximum heap size." ) ; } // Create a new task manager object try { new TaskManager ( ) ; } catch ( Exception e ) { LOG . fatal ( "Taskmanager startup failed: " + e . getMessage ( ) , e ) ; System . exit ( FAILURE_RETURN_CODE ) ; } // park the main thread to keep the JVM alive (all other threads may be daemon threads) Object mon = new Object ( ) ; synchronized ( mon ) { try { mon . wait ( ) ; } catch ( InterruptedException ex ) { } } }
Entry point for the program .