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; } }
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"; } } }
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"; } }
Result cmdResult = cli.cmd("/subsystem=jdr:generate-jdr-report()"); ModelNode response = cmdResult.getResponse(); if(Operations.isSuccessfulOutcome(response) || !embedded) { reportFailure(response); ModelNode result = response.get(ClientConstants.RESULT);
@Override public Set<String> getDeploymentNames() throws IOException { final ModelNode readDeployments = Operations.createOperation(READ_CHILDREN_NAMES_OPERATION); readDeployments.get(CHILD_TYPE).set(DEPLOYMENT); final Set<String> deployments = new LinkedHashSet<>(); final ModelNode result = client.execute(readDeployments); if (Operations.isSuccessfulOutcome(result)) { for (ModelNode deployment : Operations.readResult(result).asList()) { final String deploymentName = deployment.asString(); deployments.add(deploymentName); } return deployments; } throw new RuntimeException("Failed to get listing of deployments. Reason: " + Operations.getFailureDescription(result).asString()); }
private ModelNode executeForSuccess(final ModelNode op) throws IOException { final ModelControllerClient client = Objects.requireNonNull(getModelControllerClient(), "The client cannot be null"); final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { throw new RuntimeException(Operations.getFailureDescription(result).asString()); } return Operations.readResult(result); } }
protected ModelNode executeOperation(final ModelNode op) throws IOException { final ModelNode result = client.execute(op); if (!Operations.isSuccessfulOutcome(result)) { fail(Operations.getFailureDescription(result).asString()); } return result; }
private boolean isEnabled(final ModelNode address) { final ModelNode op = Operations.createReadAttributeOperation(address, DeploymentOperations.ENABLED); try { final ModelNode result = client.execute(op); // Check to make sure there is an outcome if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asBoolean(); } else { throw new IllegalStateException(Operations.getFailureDescription(result).asString()); } } catch (IOException e) { throw new IllegalStateException(String.format("Could not execute operation '%s'", op), e); } }
/** * Creates a new deployment result based on the DMR result from the deployment operation. * * @param result the DMR result from the operation */ DeploymentResult(final ModelNode result) { successful = Operations.isSuccessfulOutcome(result); if (successful) { failureMessage = null; } else { failureMessage = Operations.getFailureDescription(result).asString(); } this.result = result.clone(); this.result.protect(); }
@Override public void configure(ModelControllerClient controller) { ModelNode removeLoggingOp = createRemoveOperation(loggingSubsystemAddress()); try { ModelNode result = controller.execute(removeLoggingOp); if (isSuccessfulOutcome(result)) { reload(controller); } } catch (IOException e) { throw new RuntimeException("Unable to disable logging subsystem.", e); } }
@Override public boolean isServerStarted(final String hostName, final String serverName) { checkState(true); final ModelNode op = Operations.createReadAttributeOperation(Operations.createAddress(ClientConstants.HOST, hostName, ClientConstants.SERVER_CONFIG, serverName), "status"); try { final ModelNode result = getModelControllerClient().execute(op); if (Operations.isSuccessfulOutcome(result)) { return "STARTED".equals(Operations.readResult(result).asString()); } } catch (IOException ignore) { } return false; }
private ModelNode execute(ModelNode op) throws IOException { ModelNode outcome = managementClient.getControllerClient().execute( op ); if ( !Operations.isSuccessfulOutcome( outcome ) ) { throw new IllegalStateException( "Unsuccessful API call outcome: " + outcome ); } return outcome; } }
public long restart(long executionId, Properties properties) throws IOException { ModelNode op = Operations.createOperation( "restart-job", jberetSubsystemAddress.toModelNode() ); op.get( "execution-id" ).set( executionId ); if ( properties != null ) { op.get( "properties" ).set( toModelNode( properties ) ); } final ModelNode outcome = managementClient.getControllerClient().execute( op ); if ( !Operations.isSuccessfulOutcome( outcome ) ) { throw new IllegalStateException( "Could not restart job: " + outcome ); } return outcome.get( "result" ).asLong(); }
public long start(Properties properties) throws IOException { ModelNode op = Operations.createOperation( "start-job", jberetSubsystemAddress.toModelNode() ); op.get( "job-xml-name" ).set( MassIndexingJob.NAME ); if ( properties != null ) { op.get( "properties" ).set( toModelNode( properties ) ); } final ModelNode outcome = managementClient.getControllerClient().execute( op ); if ( !Operations.isSuccessfulOutcome( outcome ) ) { throw new IllegalStateException( "Could not start job: " + outcome ); } return outcome.get( "result" ).asLong(); }
private BatchStatus getExecutionStatus(long executionId) throws IOException { ModelNode address = PathAddress.pathAddress( jberetSubsystemAddress ) .append( "job", xmlJobName ) .append( "execution", String.valueOf( executionId ) ) .toModelNode(); ModelNode op = Operations.createOperation( "read-resource", address ); op.get( "recursive" ).set( true ); op.get( "include-runtime" ).set( true ); final ModelNode outcome = managementClient.getControllerClient().execute( op ); if ( !Operations.isSuccessfulOutcome( outcome ) ) { throw new IllegalStateException( "Could not restart job: " + outcome ); } return BatchStatus.valueOf( outcome.get( "result" ).get( "batch-status" ).asString() ); }
private void addLogger(ModelNode node, String loggerLevel) throws IOException { ModelNode op = Operations.createAddOperation( node ); op.get( "level" ).set( loggerLevel ); final ModelNode result = managementClient.get().getControllerClient() .execute( op ); if ( !Operations.isSuccessfulOutcome( result ) ) { logger.warning( "Can't create " + node + " logger: " + result.toJSONString( false ) ); } }
@Override public void tearDown(ManagementClient managementClient, String s) throws Exception { ModelNode op = Operations.createUndefineAttributeOperation( ADDRESS_TRANSACTIONS_SUBSYSTEM, "default-timeout" ); ModelNode result = managementClient.getControllerClient().execute( op ); if ( !Operations.isSuccessfulOutcome( result ) ) { logger.warning( "Can't reset default transaction timeout: " + result.toJSONString( false ) ); } }
private void removeLogger(ModelNode node) throws IOException { final ModelNode result = managementClient.get().getControllerClient() .execute( Operations.createRemoveOperation( node ) ); if ( !Operations.isSuccessfulOutcome( result ) ) { logger.warning( "Can't remove " + node + " logger: " + result.toJSONString( false ) ); } }
public void afterStart(@Observes AfterStart event, ArquillianDescriptor descriptor) throws IOException { ModelNode result = managementClient.get().getControllerClient() .execute( createAddDataSourceOperation() ); if ( !Operations.isSuccessfulOutcome( result ) ) { log.severe( "Can't create data source: " + result.toJSONString( false ) ); } }
public void beforeShutdown(@Observes BeforeStop event, ArquillianDescriptor descriptor) throws IOException { ModelNode result = managementClient.get().getControllerClient() .execute( Operations.createRemoveOperation( DATA_SOURCE_ADDRESS ) ); if ( !Operations.isSuccessfulOutcome( result ) ) { log.warning( "Can't remove data source: " + result.toJSONString( false ) ); } }