use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class DomainHostExcludesTest method test003PostBootUpdates.
@Test
public void test003PostBootUpdates() throws IOException, MgmtOperationException {
ModelControllerClient masterClient = testSupport.getDomainMasterLifecycleUtil().getDomainClient();
ModelControllerClient slaveClient = testSupport.getDomainSlaveLifecycleUtil().getDomainClient();
// Tweak an ignored profile and socket-binding-group to prove slave doesn't see it
updateExcludedProfile(masterClient);
updateExcludedSocketBindingGroup(masterClient);
// Verify profile cloning is ignored when the cloned profile is excluded
testProfileCloning(masterClient, slaveClient);
// Add more ignored extensions to verify slave doesn't see the ops
addExtensions(false, masterClient);
checkExtensions(slaveClient);
}
use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class ServerHelper method readLogFileFromModel.
public static List<JsonObject> readLogFileFromModel(final String logFileName, final String... addressPrefix) throws IOException {
final Collection<String> addr = new ArrayList<>();
if (addressPrefix != null) {
Collections.addAll(addr, addressPrefix);
}
addr.add("subsystem");
addr.add("logging");
addr.add("log-file");
addr.add(logFileName);
final ModelNode address = Operations.createAddress(addr);
final ModelNode op = Operations.createReadAttributeOperation(address, "stream");
try (ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient()) {
final OperationResponse response = client.executeOperation(Operation.Factory.create(op), OperationMessageHandler.logging);
final ModelNode result = response.getResponseNode();
if (Operations.isSuccessfulOutcome(result)) {
final OperationResponse.StreamEntry entry = response.getInputStream(Operations.readResult(result).asString());
if (entry == null) {
throw new RuntimeException(String.format("Failed to find entry with UUID %s for log file %s", Operations.readResult(result).asString(), logFileName));
}
final List<JsonObject> lines = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(entry.getStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
try (JsonReader jsonReader = Json.createReader(new StringReader(line))) {
lines.add(jsonReader.readObject());
}
}
}
return lines;
}
throw new RuntimeException(String.format("Failed to read log file %s: %s", logFileName, Operations.getFailureDescription(result).asString()));
}
}
use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class ScriptProcess method waitFor.
private void waitFor(final Process process, final Function<ModelControllerClient, Boolean> check) throws TimeoutException, InterruptedException {
@SuppressWarnings("Convert2Lambda") final Callable<Boolean> callable = new Callable<Boolean>() {
@Override
public Boolean call() throws InterruptedException, IOException {
long timeout = (ScriptProcess.this.timeout * 1000);
final long sleep = 100L;
try (ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient()) {
while (timeout > 0) {
if (!process.isAlive()) {
return false;
}
long before = System.currentTimeMillis();
if (check.apply(client)) {
return true;
}
timeout -= (System.currentTimeMillis() - before);
TimeUnit.MILLISECONDS.sleep(sleep);
timeout -= sleep;
}
}
return false;
}
};
final ExecutorService service = Executors.newSingleThreadExecutor();
try {
final Future<Boolean> future = service.submit(callable);
if (!future.get()) {
destroy(process);
throw new TimeoutException(getErrorMessage(String.format("The %s did not start within %d seconds.", script.getFileName(), this.timeout)));
}
} catch (ExecutionException e) {
throw new RuntimeException(getErrorMessage(String.format("Failed to determine if the %s server is running.", script.getFileName())), e);
} finally {
service.shutdownNow();
}
}
use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class StatelessBean method getJBossProperty.
public String getJBossProperty(String name) {
ModelControllerClient client = getClient();
String result = Utils.getProperty(name, client);
log.debug("JBoss system property " + name + " was resolved to be " + result);
return result;
}
use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.
the class GlobalDirectoryBasicTestCase method init.
@Before
public void init() throws Exception {
prepareGlobalDirectory();
controller.start(DEFAULT_JBOSSAS);
final ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient();
managementClient = new ManagementClient(client, TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), "remote+http");
setupServer(managementClient);
deployer.deploy(DEPLOYMENT_WAR);
deployer.deploy(DEPLOYMENT_EAR);
}
Aggregations