use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class JdrRunner method obtainServerUUID.
private String obtainServerUUID() throws OperationFailedException {
try {
ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), UUID);
operation.get(INCLUDE_RUNTIME).set(true);
ModelControllerClient client = env.getClient();
if (client == null) {
client = env.getCli().getCommandContext().getModelControllerClient();
}
ModelNode result = client.execute(operation);
if (Operations.isSuccessfulOutcome(result)) {
return Operations.readResult(result).asString();
}
return null;
} catch (IOException ex) {
return null;
}
}
use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class JdrRunner method obtainProductName.
private String obtainProductName() {
try {
ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), PRODUCT_NAME);
operation.get(INCLUDE_RUNTIME).set(false);
ModelControllerClient client = env.getClient();
if (client == null) {
client = env.getCli().getCommandContext().getModelControllerClient();
}
ModelNode result = client.execute(operation);
if (Operations.isSuccessfulOutcome(result)) {
return Operations.readResult(result).asString();
}
return "undefined";
} catch (IOException e) {
// In that case "undefined" is returned
return "undefined";
}
}
use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class ServerReload method waitForLiveServerToReload.
private static void waitForLiveServerToReload(int timeout, String serverAddress, int serverPort) {
long start = System.currentTimeMillis();
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).setEmptyList();
operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
operation.get(NAME).set("server-state");
while (System.currentTimeMillis() - start < timeout) {
try {
ModelControllerClient liveClient = ModelControllerClient.Factory.create(serverAddress, serverPort);
try {
ModelNode result = liveClient.execute(operation);
if ("running".equals(result.get(RESULT).asString())) {
return;
}
} catch (IOException e) {
} finally {
IoUtils.safeClose(liveClient);
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
fail("Live Server did not reload in the imparted time.");
}
Aggregations