Package org.jboss.as.controller.client

Examples of org.jboss.as.controller.client.OperationBuilder


        ModelNode steps = op.get(STEPS);
        steps.setEmptyList();
        op.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(plan.isGlobalRollback());
        // FIXME deal with shutdown params

        OperationBuilder builder = new OperationBuilder(op);

        int stream = 0;
        for (DeploymentActionImpl action : plan.getDeploymentActionImpls()) {
            ModelNode step = new ModelNode();
            String uniqueName = action.getDeploymentUnitUniqueName();
            switch (action.getType()) {
            case ADD: {
                configureDeploymentOperation(step, ADD, uniqueName);
                step.get(RUNTIME_NAME).set(action.getNewContentFileName());
                builder.addInputStream(action.getContentStream());
                //step.get(INPUT_STREAM_INDEX).set(stream++);
                step.get(CONTENT).get(0).get(INPUT_STREAM_INDEX).set(stream++);
                break;
            }
            case DEPLOY: {
                configureDeploymentOperation(step, DEPLOYMENT_DEPLOY_OPERATION, uniqueName);
                break;
            }
            case FULL_REPLACE: {
                step.get(OP).set(DEPLOYMENT_FULL_REPLACE_OPERATION);
                step.get(OP_ADDR).setEmptyList();
                step.get(NAME).set(uniqueName);
                step.get(RUNTIME_NAME).set(action.getNewContentFileName());
                builder.addInputStream(action.getContentStream());
                step.get(CONTENT).get(0).get(INPUT_STREAM_INDEX).set(stream++);
                break;
            }
            case REDEPLOY: {
                configureDeploymentOperation(step, DEPLOYMENT_REDEPLOY_OPERATION, uniqueName);
                break;
            }
            case REMOVE: {
                configureDeploymentOperation(step, DEPLOYMENT_REMOVE_OPERATION, uniqueName);
                break;
            }
            case REPLACE: {
                step.get(OP).set(DEPLOYMENT_REPLACE_OPERATION);
                step.get(OP_ADDR).setEmptyList();
                step.get(NAME).set(uniqueName);
                step.get(TO_REPLACE).set(action.getReplacedDeploymentUnitUniqueName());
                break;
            }
            case UNDEPLOY: {
                configureDeploymentOperation(step, DEPLOYMENT_UNDEPLOY_OPERATION, uniqueName);
                break;
            }
            default: {
                throw MESSAGES.unknownActionType(action.getType());
            }
            }
            steps.add(step);
        }

        return builder.build();
    }
View Full Code Here


    @Override
    public byte[] addDeploymentContent(InputStream stream) {
        ModelNode op = new ModelNode();
        op.get("operation").set("upload-deployment-stream");
        op.get("input-stream-index").set(0);
        Operation operation = new OperationBuilder(op).addInputStream(stream).build();
        ModelNode result = executeForResult(operation);
        return result.asBytes();
    }
View Full Code Here

    @Override
    public List<String> getHostControllerNames() {
        ModelNode op = new ModelNode();
        op.get("operation").set("read-children-names");
        op.get("child-type").set("host");
        ModelNode result = executeForResult(new OperationBuilder(op).build());
        List<String> hosts = new ArrayList<String>();
        for (ModelNode host : result.asList()) {
            hosts.add(host.asString());
        }
        return hosts;
View Full Code Here

    private Set<String> getServerNames(String host) {
        ModelNode op = new ModelNode();
        op.get("operation").set("read-children-names");
        op.get("child-type").set("server-config");
        op.get("address").add("host", host);
        ModelNode result = executeForResult(new OperationBuilder(op).build());
        Set<String> servers = new HashSet<String>();
        for (ModelNode server : result.asList()) {
            servers.add(server.asString());
        }
        return servers;
View Full Code Here

    private ModelNode readAttribute(String name, ModelNode address) {
        ModelNode op = new ModelNode();
        op.get("operation").set("read-attribute");
        op.get("address").set(address);
        op.get("name").set(name);
        return executeForResult(new OperationBuilder(op).build());
    }
View Full Code Here

        final ModelNode op = new ModelNode();
        op.get("operation").set("start");
        ModelNode address = op.get("address");
        address.add("host", hostControllerName);
        address.add("server-config", serverName);
        ModelNode result = executeForResult(new OperationBuilder(op).build());
        String status = result.asString();
        return Enum.valueOf(ServerStatus.class, status);
    }
View Full Code Here

        op.get("operation").set("stop");
        ModelNode address = op.get("address");
        address.add("host", hostControllerName);
        address.add("server-config", serverName);
        // FIXME add graceful shutdown
        ModelNode result = executeForResult(new OperationBuilder(op).build());
        String status = result.asString();
        return Enum.valueOf(ServerStatus.class, status);
    }
View Full Code Here

        op.get("operation").set("restart");
        ModelNode address = op.get("address");
        address.add("host", hostControllerName);
        address.add("server-config", serverName);
        // FIXME add graceful shutdown
        ModelNode result = executeForResult(new OperationBuilder(op).build());
        String status = result.asString();
        return Enum.valueOf(ServerStatus.class, status);
    }
View Full Code Here

    boolean isDeploymentNameUnique(final String deploymentName) {
        final ModelNode op = new ModelNode();
        op.get("operation").set("read-children-names");
        op.get("child-type").set("deployment");
        final ModelNode result = executeForResult(new OperationBuilder(op).build());
        final Set<String> deploymentNames = new HashSet<String>();
        if (result.isDefined()) {
            for (ModelNode node : result.asList()) {
                deploymentNames.add(node.asString());
            }
View Full Code Here

        ModelNode steps = op.get(STEPS);
        steps.setEmptyList();
        op.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(plan.isSingleServerRollback());
        // FIXME deal with shutdown params

        OperationBuilder builder = new OperationBuilder(op);
        int stepNum = 1;
        for (DeploymentActionImpl action : plan.getDeploymentActionImpls()) {

            actionsById.put(action.getId(), "step-" + stepNum);
            stepNum++;

            List<ModelNode> actionSteps = new ArrayList<ModelNode>();
            String uniqueName = action.getDeploymentUnitUniqueName();
            switch (action.getType()) {
            case ADD: {
                if (!deployments.contains(uniqueName)) {
                    // We need to add to the domain
                    ModelNode step = configureDeploymentOperation(ADD, uniqueName, null);
                    step.get(RUNTIME_NAME).set(action.getNewContentFileName());
                    step.get(CONTENT).get(0).get("hash").set(action.getNewContentHash());
                    actionSteps.add(step);
                }
                for (String group : serverGroups) {
                    ModelNode groupStep = configureDeploymentOperation(ADD, uniqueName, group);
                    actionSteps.add(groupStep);
                }
                break;
            }
            case DEPLOY: {
                for (String group : serverGroups) {
                    ModelNode groupStep = configureDeploymentOperation(DEPLOYMENT_DEPLOY_OPERATION, uniqueName, group);
                    actionSteps.add(groupStep);
                }
                break;
            }
            case FULL_REPLACE: {
                ModelNode step = new ModelNode();
                step.get(OP).set(DEPLOYMENT_FULL_REPLACE_OPERATION);
                step.get(OP_ADDR).setEmptyList();
                step.get(NAME).set(uniqueName);
                step.get(RUNTIME_NAME).set(action.getNewContentFileName());
                step.get(CONTENT).get(0).get("hash").set(action.getNewContentHash());
                actionSteps.add(step);
                break;
            }
            case REDEPLOY: {
                for (String group : serverGroups) {
                    ModelNode groupStep = configureDeploymentOperation(DEPLOYMENT_REDEPLOY_OPERATION, uniqueName, group);
                    actionSteps.add(groupStep);
                }
                break;
            }
            case REMOVE: {
                // From each group
                for (String group : serverGroups) {
                    ModelNode groupStep = configureDeploymentOperation(DEPLOYMENT_REMOVE_OPERATION, uniqueName, group);
                    actionSteps.add(groupStep);
                }
                // and from the domain
                ModelNode step = configureDeploymentOperation(DEPLOYMENT_REMOVE_OPERATION, uniqueName, null);
                actionSteps.add(step);
                break;
            }
            case REPLACE: {
                for (String group : serverGroups) {
                    ModelNode groupStep = new ModelNode();
                    groupStep.get(OP).set(DEPLOYMENT_REPLACE_OPERATION);
                    groupStep.get(OP_ADDR).add("server-group", group);
                    groupStep.get(NAME).set(uniqueName);
                    groupStep.get(TO_REPLACE).set(action.getReplacedDeploymentUnitUniqueName());
                    actionSteps.add(groupStep);
                }
                break;
            }
            case UNDEPLOY: {
                for (String group : serverGroups) {
                    ModelNode groupStep = configureDeploymentOperation(DEPLOYMENT_UNDEPLOY_OPERATION, uniqueName, group);
                    actionSteps.add(groupStep);
                }
                break;
            }
            default: {
                throw MESSAGES.unknownActionType(action.getType());
            }
            }

            for (ModelNode actionStep : actionSteps) {
                steps.add(actionStep);
            }
        }

        return builder.build();
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.controller.client.OperationBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.