protected int cancel ( String [ ] args ) { // Parse command line options CommandLine line ; try { line = parser . parse ( CANCEL_OPTIONS , args , false ) ; } catch ( MissingOptionException e ) { System . out . println ( e . getMessage ( ) ) ; printHelpForCancel ( ) ; return 1 ; } catch ( UnrecognizedOptionException e ) { System . out . println ( e . getMessage ( ) ) ; printHelpForCancel ( ) ; return 2 ; } catch ( Exception e ) { return handleError ( e ) ; } if ( printHelp ) { printHelpForCancel ( ) ; return 0 ; } JobID jobId ; if ( line . hasOption ( ID_OPTION . getOpt ( ) ) ) { String jobIdString = line . getOptionValue ( ID_OPTION . getOpt ( ) ) ; try { jobId = new JobID ( StringUtils . hexStringToByte ( jobIdString ) ) ; } catch ( Exception e ) { System . out . println ( "Error: The value for the Job ID is not a valid ID." ) ; printHelpForCancel ( ) ; return 1 ; } } else { System . out . println ( "Error: Specify a Job ID to cancel a job." ) ; printHelpForCancel ( ) ; return 1 ; } ExtendedManagementProtocol jmConn = null ; try { jmConn = getJobManagerConnection ( line ) ; if ( jmConn == null ) { printHelpForCancel ( ) ; return 1 ; } jmConn . cancelJob ( jobId ) ; return 0 ; } catch ( Throwable t ) { return handleError ( t ) ; } finally { if ( jmConn != null ) { try { RPC . stopProxy ( jmConn ) ; } catch ( Throwable t ) { System . out . println ( "Warning: Could not cleanly shut down connection to the JobManager." ) ; } } jmConn = null ; } }
Executes the cancel action .