private boolean isRestartOperationRequired(CommonRestartOperation restartOperation) throws IOException { return restartOperation.isRequired(ops.readAttribute(Address.root(), Constants.SERVER_STATE), false); }
private boolean isServerRunning() throws IOException { ModelNodeResult result = ops.readAttribute(Address.root(), Constants.SERVER_STATE); result.assertDefinedValue(); return ServerState.isRunning(result.stringValue()); } }
List<String> allRunningServers(String host) throws IOException { ModelNodeResult result = ops.readChildrenNames(Address.host(host), Constants.SERVER); result.assertDefinedValue(); List<String> servers = result.stringListValue(); List<String> startedServers = new ArrayList<String>(); for (String server : servers) { ModelNodeResult serverStatus = ops.readAttribute(Address.host(host).and(Constants.SERVER_CONFIG, server), Constants.STATUS); serverStatus.assertDefinedValue(); if ("STARTED".equals(serverStatus.stringValue())) { startedServers.add(server); } } return startedServers; }
private boolean areServersRunning(String host, List<String> servers) throws IOException { Address hostAddress = Address.host(host); if (servers == null || servers.isEmpty()) { ModelNodeResult result = ops.readAttribute(Address.host(host), Constants.HOST_STATE); result.assertDefinedValue(); return ServerState.isRunning(result.stringValue()); } else { for (String server : servers) { Address serverAddress = hostAddress.and(Constants.SERVER, server); ModelNodeResult result = ops.readAttribute(serverAddress, Constants.SERVER_STATE); if (!result.hasDefinedValue() || !ServerState.isRunning(result.stringValue())) { return false; } } return true; } } }
/** * 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(); }