public static void shutdownDomain ( final ModelControllerClient client , final int timeout ) throws IOException , OperationExecutionException { // Note the following two operations used to shutdown a domain don't seem to work well in a composite operation. // The operation occasionally sees a java.util.concurrent.CancellationException because the operation client // is likely closed before the AsyncFuture.get() is complete. Using a non-composite operation doesn't seem to // have this issue. // First shutdown the servers final ModelNode stopServersOp = Operations . createOperation ( "stop-servers" ) ; stopServersOp . get ( "blocking" ) . set ( true ) ; stopServersOp . get ( "timeout" ) . set ( timeout ) ; ModelNode response = client . execute ( stopServersOp ) ; if ( ! Operations . isSuccessfulOutcome ( response ) ) { throw new OperationExecutionException ( "Failed to stop servers." , stopServersOp , response ) ; } // Now shutdown the host final ModelNode address = determineHostAddress ( client ) ; final ModelNode shutdownOp = Operations . createOperation ( "shutdown" , address ) ; response = client . execute ( shutdownOp ) ; if ( Operations . isSuccessfulOutcome ( response ) ) { // Wait until the process has died while ( true ) { if ( isDomainRunning ( client , true ) ) { try { TimeUnit . MILLISECONDS . sleep ( 20L ) ; } catch ( InterruptedException e ) { LOGGER . trace ( "Interrupted during sleep" , e ) ; } } else { break ; } } } else { throw new OperationExecutionException ( "Failed to shutdown host." , shutdownOp , response ) ; } }
Shuts down a managed domain container . The servers are first stopped then the host controller is shutdown .