/** * Set security domain name related configuration * @param securityDomainName */ public void setSecurityDomainName(String securityDomainName) { this.securityDomainName = securityDomainName; this.PICKETBOX_SECURITY_DOMAIN_ADDRESS=Address.subsystem("security").and("security-domain", securityDomainName); this.UNDERTOW_APPLICATION_SECURITY_DOMAIN_NAME=securityDomainName; this.UNDERTOW_APPLICATION_SECURITY_DOMAIN_ADDRESS = Address.subsystem("undertow").and("application-security-domain", UNDERTOW_APPLICATION_SECURITY_DOMAIN_NAME); }
public static Address host(String host) { return Address.of(Constants.HOST, host); }
public static Address root() { return new Address(Collections.<StringPair>emptyList()); }
/** * Removes given {@code server} from given {@code host} * * @return {@code true} if the server was actually removed, {@code false} otherwise */ public boolean removeServer(String host, String server) throws IOException, OperationException { return ops.removeIfExists(Address.host(host).and(Constants.SERVER_CONFIG, server)); } }
/** * 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(); }
@Override public ModelNode undefineAttribute(Address address, String attributeName) { ModelNode op = newOp(); op.get(Constants.OP).set(Constants.UNDEFINE_ATTRIBUTE_OPERATION); op.get(Constants.OP_ADDR).set(address.toModelNode()); op.get(Constants.NAME).set(attributeName); return op; }
@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(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); }
@Override public ModelNode readChildrenNames(Address address, String childType) { ModelNode op = newOp(); op.get(Constants.OP).set(Constants.READ_CHILDREN_NAMES_OPERATION); op.get(Constants.OP_ADDR).set(address.toModelNode()); op.get(Constants.CHILD_TYPE).set(childType); return op; }
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); }
/** 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(); }
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); } }
public static Address subsystem(String subsystemName) { return Address.of(Constants.SUBSYSTEM, subsystemName); }
@Override public ModelNode writeAttribute(Address address, String attributeName, ModelNode attributeValue) { ModelNode op = newOp(); op.get(Constants.OP).set(Constants.WRITE_ATTRIBUTE_OPERATION); op.get(Constants.OP_ADDR).set(address.toModelNode()); op.get(Constants.NAME).set(attributeName); op.get(Constants.VALUE).set(attributeValue); return op; }
private boolean isRestartOperationRequired(CommonRestartOperation restartOperation) throws IOException { return restartOperation.isRequired(ops.readAttribute(Address.root(), Constants.SERVER_STATE), false); }
public Address and(String key, String value) { List<StringPair> newAddress = new ArrayList<StringPair>(this.address); newAddress.add(new StringPair(key, value)); return new Address(newAddress); }