/** Retrieves all servers running on given {@code host}. */ public List<String> allRunningServers(String host) throws IOException { return domainOps.allRunningServers(host); }
@Override public boolean reloadIfRequired() throws IOException, InterruptedException, TimeoutException { if (isRestartOperationRequired(client.options().defaultHost, CommonRestartOperation.RELOAD)) { reload(); return true; } return false; }
/** * Reloads given {@code host}, which includes restarting all its servers. * This is a variant of {@link Administration#reload()}. */ public void reload(String host) throws IOException, InterruptedException, TimeoutException { domainOps.performRestartOperation(host, CommonRestartOperation.RELOAD); }
@Override public boolean restartIfRequired() throws IOException, InterruptedException, TimeoutException { if (isRestartOperationRequired(client.options().defaultHost, CommonRestartOperation.RESTART)) { restart(); return true; } return false; }
/** * Reload given {@code host} to a domain.xml snapshot. This method only makes sense in managed domain. */ public void perform(String host) throws InterruptedException, TimeoutException, IOException { if (!client.options().isDomain) { throw new IllegalStateException("Asked to reload host '" + host + "' to a snapshot, but the server isn't a domain controller"); } new DomainAdministrationOperations(client, timeoutInSeconds) .performRestartOperation(host, new ReloadToDomainSnapshotRestartOperation(snapshot)); }
void performRestartOperation(String host, RestartOperation restartOperation) throws IOException, TimeoutException, InterruptedException { List<String> allServers = allRunningServers(host); boolean needsToReconnect = false; try { restartOperation.perform(ops, Address.host(host)); } catch (Throwable e) { // server went down before we received the response, this can happen needsToReconnect = true; } waitUntilServersAreRunning(host, allServers, needsToReconnect); }
/** * Returns whether the {@code host} requires restart (that is, at least one of the servers on the host * requires restart). This is a variant of {@link Administration#isRestartRequired()}. */ public boolean isRestartRequired(String host) throws IOException { return domainOps.isRestartOperationRequired(host, CommonRestartOperation.RESTART); }
/** Waits until all the {@code servers} on given {@code host} are running. */ public void waitUntilServersRunning(String host, List<String> servers) throws InterruptedException, TimeoutException, IOException { domainOps.waitUntilServersAreRunning(host, servers, true); }
/** Shuts down given {@code host}. This is a variant of {@link Administration#shutdown()}. */ public void shutdown(String host) throws IOException, InterruptedException, TimeoutException { domainOps.shutdown(host, 0); }
public DomainAdministration(OnlineManagementClient client, int timeoutInSeconds) { super(client); this.client = client; this.ops = new Operations(client); this.domainOps = new DomainAdministrationOperations(client, timeoutInSeconds); }
while (System.currentTimeMillis() < endTime) { try { if (areServersRunning(host, servers)) { break; running = areServersRunning(host, servers); } catch (Throwable ignored) {
/** * Returns whether the {@code host} requires reload (that is, at least one of the servers on the host * requires reload). This is a variant of {@link Administration#isReloadRequired()}. */ public boolean isReloadRequired(String host) throws IOException { return domainOps.isRestartOperationRequired(host, CommonRestartOperation.RELOAD); }
/** * Waits until the the host controller of given {@code host} is running. * This is a variant of {@link Administration#waitUntilRunning()}. */ public void waitUntilRunning(String host) throws InterruptedException, TimeoutException, IOException { domainOps.waitUntilServersAreRunning(host, null, true); }
@Override public void shutdown(int timeoutInSeconds) throws IOException { shutdown(client.options().defaultHost, timeoutInSeconds); }
public Administration(OnlineManagementClient client, int timeoutInSeconds) { this.client = client; if (client.options().isDomain) { this.ops = new DomainAdministrationOperations(client, timeoutInSeconds); } else { this.ops = new StandaloneAdministrationOperations(client, timeoutInSeconds); } }
/** Restarts given {@code host} if required. This is a variant of {@link Administration#restartIfRequired()}. */ public boolean restartIfRequired(String host) throws IOException, InterruptedException, TimeoutException { if (domainOps.isRestartOperationRequired(host, CommonRestartOperation.RESTART)) { restart(host); return true; } return false; }
/** @see #waitUntilServersRunning(String, java.util.List) */ public void waitUntilServersRunning(List<String> servers) throws InterruptedException, TimeoutException, IOException { domainOps.waitUntilServersAreRunning(client.options().defaultHost, servers, true); }
/** Restarts given {@code host}. This is a variant of {@link Administration#restart()}. */ public void restart(String host) throws IOException, InterruptedException, TimeoutException { domainOps.performRestartOperation(host, CommonRestartOperation.RESTART); }
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); } }
/** * Shuts down given {@code host} gracefully. This is a variant of {@link Administration#shutdownGracefully(int)}. * * @param timeoutInSeconds if {@code == 0}, then the server will shutdown immediately without waiting * for the active requests to finish; if {@code <= 0}, then the server will wait indefinitely for the active * requests to finish */ public void shutdownGracefully(String host, int timeoutInSeconds) throws IOException, InterruptedException, TimeoutException { client.version().assertAtLeast(ServerVersion.VERSION_3_0_0, "Graceful shutdown is only supported since WildFly 9"); domainOps.shutdown(host, timeoutInSeconds); }