public static void shutdown ( GSSCredential cred , GlobusURL gassURL ) throws IOException , GSSException { OutputStream output = null ; InputStream input = null ; Socket socket = null ; try { if ( gassURL . getProtocol ( ) . equalsIgnoreCase ( "https" ) ) { GSSManager manager = ExtendedGSSManager . getInstance ( ) ; ExtendedGSSContext context = ( ExtendedGSSContext ) manager . createContext ( null , GSSConstants . MECH_OID , cred , GSSContext . DEFAULT_LIFETIME ) ; context . setOption ( GSSConstants . GSS_MODE , GSIConstants . MODE_SSL ) ; GssSocketFactory factory = GssSocketFactory . getDefault ( ) ; socket = factory . createSocket ( gassURL . getHost ( ) , gassURL . getPort ( ) , context ) ; ( ( GssSocket ) socket ) . setAuthorization ( SelfAuthorization . getInstance ( ) ) ; } else { SocketFactory factory = SocketFactory . getDefault ( ) ; socket = factory . createSocket ( gassURL . getHost ( ) , gassURL . getPort ( ) ) ; } output = socket . getOutputStream ( ) ; input = socket . getInputStream ( ) ; String msg = GASSProtocol . SHUTDOWN ( SHUTDOWN_STR , gassURL . getHost ( ) ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Shutdown msg: " + msg ) ; } output . write ( msg . getBytes ( ) ) ; output . flush ( ) ; HttpResponse rp = new HttpResponse ( input ) ; if ( rp . httpCode == - 1 && rp . httpMsg == null ) { /* this is a workaround for C gass-server. * The server just shuts down - it does * not send the reply */ } else if ( rp . httpCode != 200 ) { throw new IOException ( "Remote shutdown failed (" + rp . httpCode + " " + rp . httpMsg + ")" ) ; } } finally { try { if ( output != null ) output . close ( ) ; if ( input != null ) input . close ( ) ; if ( socket != null ) socket . close ( ) ; } catch ( Exception e ) { } } }
Shutdowns a remote gass server . The server must have the CLIENT_SHUTDOWN option enabled for this to work .