public final List<String> stringListValue(List<String> defaultValue) { return hasDefinedValue() ? stringListValue() : defaultValue; }
private void checkStandaloneVsDomain() throws IOException { ModelNode op = new ModelNode(); op.get(Constants.OP).set(Constants.READ_CHILDREN_TYPES); op.get(Constants.OP_ADDR).setEmptyList(); ModelNodeResult result = this.execute(op); List<String> rootChildrenTypes = result.stringListValue(); if (options.isStandalone && !rootChildrenTypes.contains(Constants.SUBSYSTEM)) { throw new IllegalStateException("According to the options, this client should be connected" + " to a standalone server, but the server appears to be something else"); } else if (options.isDomain && !rootChildrenTypes.contains(Constants.PROFILE)) { throw new IllegalStateException("According to the options, this client should be connected" + " to a domain controller, but the server appears to be something else"); } }
/** 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(); }
/** Retrieves all configured servers on given {@code host}. */ public List<String> allServers(String host) throws IOException { ModelNodeResult result = ops.readChildrenNames(Address.host(host), Constants.SERVER_CONFIG); result.assertDefinedValue(); return result.stringListValue(); }
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; }