public static void request ( String resourceManagerContact , GramJob job , boolean batchJob , boolean limitedDelegation ) throws GramException , GSSException { GSSCredential cred = getJobCredentials ( job ) ; // at this point proxy cannot be null String callbackURL = null ; CallbackHandler handler = null ; if ( ! batchJob ) { handler = initCallbackHandler ( cred ) ; callbackURL = handler . getURL ( ) ; logger . debug ( "Callback url: " + callbackURL ) ; } else { callbackURL = "\"\"" ; } ResourceManagerContact rmc = new ResourceManagerContact ( resourceManagerContact ) ; Socket socket = gatekeeperConnect ( cred , rmc , true , limitedDelegation ) ; GatekeeperReply hd = null ; try { OutputStream out = socket . getOutputStream ( ) ; InputStream in = socket . getInputStream ( ) ; String msg = GRAMProtocol . REQUEST ( rmc . getServiceName ( ) , rmc . getHostName ( ) , GRAMConstants . STATUS_ALL , callbackURL , job . getRSL ( ) ) ; // send message out . write ( msg . getBytes ( ) ) ; out . flush ( ) ; debug ( "REQ SENT:" , msg ) ; // receive reply hd = new GatekeeperReply ( in ) ; } catch ( IOException e ) { throw new GramException ( GramException . ERROR_PROTOCOL_FAILED , e ) ; } finally { try { socket . close ( ) ; } catch ( Exception e ) { } } debug ( "REQ RECEIVED:" , hd ) ; // must be 200 checkHttpReply ( hd . httpCode ) ; // protocol version must match checkProtocolVersion ( hd . protocolVersion ) ; if ( hd . status == 0 || hd . status == GramException . WAITING_FOR_COMMIT ) { try { job . setID ( hd . jobManagerUrl ) ; } catch ( MalformedURLException ex ) { throw new GramException ( GramException . INVALID_JOB_CONTACT , ex ) ; } if ( ! batchJob ) handler . registerJob ( job ) ; if ( hd . status == GramException . WAITING_FOR_COMMIT ) { throw new WaitingForCommitException ( ) ; } } else { throw new GramException ( hd . status ) ; } }
Submits a GramJob to specified gatekeeper as a interactive or batch job .