private ModelNode executeForResponse(Operation op) { try { return client.execute(op); } catch (IOException e) { throw new RuntimeException(e); } }
private SortedMap<String, ServerIdentity> getValidServers(ServerStatus valid, ServerStatus... alsoValid) { Set<ServerStatus> validSet = EnumSet.of(valid, alsoValid); SortedMap<String, ServerIdentity> result = new TreeMap<String, ServerIdentity>(); for (Map.Entry<ServerIdentity, ServerStatus> entry : client.getServerStatuses().entrySet()) { if (validSet.contains(entry.getValue())) { result.put(entry.getKey().getServerName(), entry.getKey()); } } return result; }
public void close() { try { client.close(); } catch (IOException e) { throw new RuntimeException("Could not close connection", e); } }
.addStep(Operations.createReadAttributeOperation(hostAddress, "running-mode")) .addStep(Operations.createReadAttributeOperation(hostAddress, "host-state")); ModelNode response = domainClient.execute(builder.build()); if (Operations.isSuccessfulOutcome(response)) { response = Operations.readResult(response); final Map<ServerIdentity, ServerStatus> statuses = domainClient.getServerStatuses(); for (ServerIdentity id : statuses.keySet()) { final ServerStatus status = statuses.get(id);
ModelNode result = getManagementClient().getControllerClient().execute(op, null); if (Operations.isSuccessfulOutcome(result)) { final String hostName = Operations.readResult(result).asString(); op = Operations.createOperation("shutdown", Operations.createAddress(ClientConstants.HOST, hostName)); getManagementClient().getControllerClient().executeAsync(op, null);
@Override public Status execute() throws DeploymentExecutionException, DeploymentFailureException { try { final DomainDeploymentManager manager = client.getDeploymentManager(); final DeploymentPlanBuilder builder = manager.newDeploymentPlan(); DeploymentPlan plan = createPlan(builder); if (plan != null) { executePlan(manager, plan); } } catch (DeploymentFailureException e) { throw e; } catch (DeploymentExecutionException e) { throw e; } catch (Exception e) { throw new DeploymentExecutionException(e, "Error executing %s", type); } return Status.SUCCESS; }
private boolean listHostControllers() throws Exception { stdout.println("\nReading the list of active host controller s:\n"); List<String> hostControllers = client.getHostControllerNames(); for (String hc : hostControllers) { stdout.println(hc); } return continuePrompt(); }
private boolean runDeploymentPlan() throws Exception { DomainDeploymentManager deploymentManager = client.getDeploymentManager(); DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan(); ModelNode model = getDomainModel(); DeploymentActionsCompleteBuilder completionBuilder = null; String serverGroup = null; Set<String> includedGroups = new HashSet<String>(); do { completionBuilder = deploymentSetBuilder(builder, model); if (completionBuilder != null) { serverGroup = chooseServerGroup(model, includedGroups); } } while (serverGroup == null && completionBuilder != null); if (completionBuilder != null) { includedGroups.add(serverGroup); ServerGroupDeploymentPlanBuilder groupPlanBuilder = completionBuilder.toServerGroup(serverGroup); DeploymentPlan plan = completeDeploymentPlan(groupPlanBuilder, model, includedGroups); if (plan != null) { Future<DeploymentPlanResult> future = deploymentManager.execute(plan); writeDeploymentPlanResult(future.get()); } } return continuePrompt(); }
private boolean dumpHostController() throws Exception { List<String> hostControllers = client.getHostControllerNames(); if (hostControllers.size() == 0) { // this isn't possible :-) stdout.println("No host controllers available"); } else if (hostControllers.size() == 1) { writeHostController(hostControllers.get(0)); } else { stdout.println("Choose a Host Controller:"); Map<String, Object> choices = writeMenuBody(hostControllers); stdout.println("[C] Cancel"); String choice = readStdIn(); if (!"C".equals(choice.toUpperCase())) { Object hc = choices.get(choice); if (hc != null) { writeHostController(hc.toString()); } else { stdout.println(choice + " is not a valid selection"); return dumpHostController(); } } } return continuePrompt(); }
private ModelNode executeForResult(final ModelNode operation) throws Exception { final ModelNode result = client.execute(operation); checkSuccessful(result, operation); return result.get(RESULT); }
private boolean listServers() throws Exception { stdout.println("\nReading the list of configured servers:"); for (Map.Entry<ServerIdentity, ServerStatus> server : client.getServerStatuses().entrySet()) { ServerIdentity id = server.getKey(); stdout.println("\nServer:\n"); stdout.println("server name: " + id.getServerName()); stdout.println("host controller name: " + id.getHostName()); stdout.println("server group name: " + id.getServerGroupName()); stdout.println("status: " + server.getValue()); } return continuePrompt(); }
ArchiveDeployer archiveDeployer = new ArchiveDeployer(domainClient.getDeploymentManager()); archiveDeployerInst.set(archiveDeployer);
@Override public void run() { try { boolean quit = false; do { quit = mainMenu(); } while (!quit); } catch (Exception e) { e.printStackTrace(System.out); } finally { stdout.println("Closing connection to domain controller"); try { client.close(); } catch (IOException e) { e.printStackTrace(); } } stdout.println("Done"); }
List<String> hostControllers = client.getHostControllerNames(); if (hostControllers.size() == 1) { hostController = hostControllers.get(0);
public ModelNode executeForResult(Operation op) { try { ModelNode result = getDomainClient().execute(op); if (result.hasDefined("outcome") && "success".equals(result.get("outcome").asString())) { return result.get("result"); } else if (result.hasDefined("failure-description")) { throw new RuntimeException(result.get("failure-description").toString()); } else if (result.hasDefined("domain-failure-description")) { throw new RuntimeException(result.get("domain-failure-description").toString()); } else if (result.hasDefined("host-failure-descriptions")) { throw new RuntimeException(result.get("host-failure-descriptions").toString()); } else { throw new RuntimeException("Operation outcome is " + result.get("outcome").asString()); } } catch (IOException e) { throw new RuntimeException(e); } }
public boolean isDomainInRunningState() { final Map<ServerIdentity, ServerStatus> servers = new HashMap<>(); try { final Map<ServerIdentity, ServerStatus> statuses = client.getServerStatuses(); for (ServerIdentity id : statuses.keySet()) { final ServerStatus status = statuses.get(id); switch (status) { case DISABLED: case STARTED: { servers.put(id, status); break; } } } return statuses.size() == servers.size(); } catch (Exception e) { Logger.getLogger(ManagementClient.class).debug("Interrupted determining if domain is running", e); } return false; }
public ModelNode executeForResult(Operation op) { try { ModelNode result = getDomainClient().execute(op); if (result.hasDefined("outcome") && "success".equals(result.get("outcome").asString())) { return result.get("result"); } else if (result.hasDefined("failure-description")) { throw new RuntimeException(result.get("failure-description").toString()); } else if (result.hasDefined("domain-failure-description")) { throw new RuntimeException(result.get("domain-failure-description").toString()); } else if (result.hasDefined("host-failure-descriptions")) { throw new RuntimeException(result.get("host-failure-descriptions").toString()); } else { throw new RuntimeException("Operation outcome is " + result.get("outcome").asString()); } } catch (IOException e) { throw new RuntimeException(e); } }