void shutdownServers(String host, List<String> servers) throws IOException, InterruptedException, TimeoutException { Batch batch = new Batch(); for (String server : servers) { batch.invoke(Constants.STOP, Address.host(host).and(Constants.SERVER_CONFIG, server)); } ops.batch(batch); }
void shutdown(String host, int timeoutInSeconds) throws IOException { if (timeoutInSeconds == 0) { // older versions don't understand the "timeout" parameter ops.invoke(Constants.SHUTDOWN, Address.host(host)); } else { Batch batch = new Batch(); for (String server : allRunningServers(host)) { batch.invoke(Constants.STOP, Address.host(host).and(Constants.SERVER_CONFIG, server), Values.of(Constants.TIMEOUT, timeoutInSeconds)); } batch.invoke(Constants.SHUTDOWN, Address.host(host)); ops.batch(batch); } }
void restartServers(String host, List<String> servers) throws IOException, InterruptedException, TimeoutException { Batch batch = new Batch(); for (String server : servers) { batch.invoke(Constants.RESTART, Address.host(host).and(Constants.SERVER_CONFIG, server)); } boolean needsToReconnect = false; try { ops.batch(batch); } catch (Throwable e) { // server went down before we received the response, this can happen needsToReconnect = true; } domainOps.waitUntilServersAreRunning(host, servers, needsToReconnect); }
void shutdownServersGracefully(String host, List<String> servers, int timeoutInSeconds) throws IOException, InterruptedException, TimeoutException { client.version().assertAtLeast(ServerVersion.VERSION_3_0_0, "Graceful shutdown is only supported since WildFly 9"); Batch batch = new Batch(); for (String server : servers) { batch.invoke(Constants.STOP, Address.host(host).and(Constants.SERVER_CONFIG, server), Values.of(Constants.TIMEOUT, timeoutInSeconds)); } ops.batch(batch); }