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; } }
@Override public void execute() throws Exception { ModelNode request = new ModelNode(); request.get("operation").set(this.operation); assert this.resource.size() % 2 == 0; while (this.resource.size() > 0) { request.get("address").add(this.resource.removeFirst(), this.resource.removeFirst()); } for (Map.Entry<String, String> entry : parameters.entrySet()) { request.get(entry.getKey()).set(entry.getValue()); } if (this.env.getHostControllerName() != null) { request.get("host").set(this.env.getHostControllerName()); } if (this.env.getServerName() != null) { request.get("server").set(this.env.getServerName()); } this.env.getZip().add(this.env.getClient().execute(request).toJSONString(true), this.name); } }
/** * Execute an operation synchronously, optionally receiving progress reports. * * @param operation the operation to execute * @param messageHandler the message handler to use for operation progress reporting, or {@code null} for none * @return the result of the operation * @throws IOException if an I/O error occurs while executing the operation */ default ModelNode execute(ModelNode operation, OperationMessageHandler messageHandler) throws IOException { return execute(Operation.Factory.create(operation), messageHandler); }
@Override public void close() throws IOException { client.close(); } }
private Operation sanitizeOperation(Operation operation) { ModelNode sanitized = sanitizeOperation(operation.getOperation()); return Operation.Factory.create(sanitized, operation.getInputStreams(), operation.isAutoCloseStreams()); }
/** * Execute an operation in another thread. * * @param operation the operation to execute * @return the future result of the operation */ default AsyncFuture<ModelNode> executeAsync(ModelNode operation) { return executeAsync(Operation.Factory.create(operation), OperationMessageHandler.DISCARD); }
/** * {@inheritDoc} */ @Override protected Future<ModelNode> executeOperation(Operation executionContext) { return client.executeAsync(executionContext, null); }
/** * Create an operation builder. * * @param operation the operation * @return the builder */ public static OperationBuilder create(final ModelNode operation) { return new OperationBuilder(operation); }
@Override public CompositeOperationBuilder addFileAsAttachment(final File file) { super.addFileAsAttachment(file); return this; }
@Override public void report(final MessageSeverity severity, final String message) { try { if(messageHandler != null) { messageHandler.handleReport(severity, message); } } catch (Throwable t) { // ignored } }
@Override public void close() throws IOException { streamEntry.close(); closed = true; } }
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) { // This should not be needed since a product name is always returned, even if it doesn't exist. // In that case "undefined" is returned return "undefined"; } }
/** * Execute an operation synchronously. * * @param operation the operation to execute * @return the result of the operation * @throws IOException if an I/O error occurs while executing the operation */ default ModelNode execute(ModelNode operation) throws IOException{ return execute(Operation.Factory.create(operation), OperationMessageHandler.DISCARD); }
@Override public void close() throws IOException { client.close(); } }
/** * Execute an operation in another thread, optionally receiving progress reports. * * @param operation the operation to execute * @param messageHandler the message handler to use for operation progress reporting, or {@code null} for none * @return the future result of the operation */ default AsyncFuture<ModelNode> executeAsync(ModelNode operation, OperationMessageHandler messageHandler) { return executeAsync(Operation.Factory.create(operation), messageHandler); }
/** * {@inheritDoc} */ @Override protected Future<ModelNode> executeOperation(Operation executionContext) { return client.executeAsync(executionContext, null); }
private ServerGroupDeploymentPlan(final String serverGroupName, final boolean rollback, final boolean rollingToServers, final int maxFailures, final int maxFailurePercentage) { if (serverGroupName == null) { throw MESSAGES.nullVar("serverGroupName"); } this.serverGroupName = serverGroupName; this.rollback = rollback; this.rollingToServers = rollingToServers; this.maxFailures = maxFailures; this.maxFailurePercentage = maxFailurePercentage; }
private String obtainProductVersion() { try { ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), PRODUCT_VERSION); 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) { // This should not be needed since a product version is always returned, even if it doesn't exist. // In that case "undefined" is returned return "undefined"; } } }
@Override public void close() throws IOException { wrapped.close(); } }