@Override public void shutdown(int timeoutInSeconds) throws IOException { if (timeoutInSeconds == 0) { // older versions don't understand the "timeout" parameter ops.invoke(Constants.SHUTDOWN, Address.root()); } else { ops.invoke(Constants.SHUTDOWN, Address.root(), Values.of(Constants.TIMEOUT, timeoutInSeconds)); } }
void performRestartOperation(RestartOperation restartOperation) throws IOException, InterruptedException, TimeoutException { boolean needsToReconnect = false; try { restartOperation.perform(ops, Address.root()); } catch (Throwable e) { // server went down before we received the response, this can happen needsToReconnect = true; } waitUntilServerIsRunning(needsToReconnect); }
private boolean isRestartOperationRequired(CommonRestartOperation restartOperation) throws IOException { return restartOperation.isRequired(ops.readAttribute(Address.root(), Constants.SERVER_STATE), false); }
/** Retrieves all hosts in domain. */ public List<String> hosts() throws IOException { ModelNodeResult result = ops.readChildrenNames(Address.root(), Constants.HOST); result.assertDefinedValue(); return result.stringListValue(); }
/** Retrieves all server groups in domain. */ public List<String> serverGroups() throws IOException { ModelNodeResult result = ops.readChildrenNames(Address.root(), Constants.SERVER_GROUP); result.assertDefinedValue(); return result.stringListValue(); }
private boolean isServerRunning() throws IOException { ModelNodeResult result = ops.readAttribute(Address.root(), Constants.SERVER_STATE); result.assertDefinedValue(); return ServerState.isRunning(result.stringValue()); } }
/** * Returns the Java command the server / host controller was started with. It's read from the platform MBean * server via the management interface. * * @param host should be {@code null} for standalone server or for default host in managed domain; * should only be non-{@code null} if a specific host in managed domain is checked */ private static String commandUsedToStartTheServer(OnlineManagementClient client, String host) throws IOException { Address baseAddress = Address.root(); if (host != null) { baseAddress = Address.host(host); } ModelNodeResult systemProperties = new Operations(client).readAttribute( baseAddress.and(Constants.CORE_SERVICE, Constants.PLATFORM_MBEAN).and("type", "runtime"), "system-properties" ); systemProperties.assertDefinedValue(); // the "sun.java.command" system property exists at least on OpenJDK, Oracle Java and IBM Java return systemProperties.value().get("sun.java.command").asString(); }