Examples of ModelNode


Examples of org.apache.oodt.cas.workflow.gui.model.ModelNode

    }
  }

  private void saveGraph(ModelGraph graph, Element parentElem, Document document)
      throws FileNotFoundException, ParserConfigurationException {
    ModelNode node = graph.getModel();

    Element workflowElem = document.createElement(node.getExecutionType());
    parentElem.appendChild(workflowElem);

    if (node.isRef()) {
      workflowElem.setAttribute("id-ref", node.getModelId());
      if (node.getAlias() != null) {
        workflowElem.setAttribute("alias", node.getAlias());
      }
      saveConfiguration(node, workflowElem, document);
    } else {
      workflowElem.setAttribute("id", node.getModelId());
      workflowElem.setAttribute("name", node.getModelName());
      if (node.getInstanceClass() != null) {
        workflowElem.setAttribute("class", node.getInstanceClass());
      }

      saveConfiguration(node, workflowElem, document);

      // handle preconditions
      if (graph.getPreConditions() != null) {
        Element preConditions = document.createElement("conditions");
        workflowElem.appendChild(preConditions);
        preConditions.setAttribute("type", "pre");
        preConditions.setAttribute("execution", graph.getPreConditions()
            .getModel().getExecutionType());
        preConditions.setAttribute("timeout", String.valueOf(graph.getModel().getTimeout()));
        preConditions.setAttribute("optional", String.valueOf(graph.getModel().isOptional()));
        for (ModelGraph preCondition : graph.getPreConditions().getChildren()) {
          saveGraph(preCondition, preConditions, document);
        }
      }

      // handle subprocessors
      for (ModelGraph subProcessor : graph.getChildren()) {
        saveGraph(subProcessor, workflowElem, document);
      }

      // handle postconditions
      if (graph.getPostConditions() != null) {
        Element postConditions = document.createElement("conditions");
        workflowElem.appendChild(postConditions);
        postConditions.setAttribute("type", "post");
        postConditions.setAttribute("execution", graph.getPostConditions()
            .getModel().getExecutionType());
        postConditions.setAttribute("timeout", String.valueOf(graph.getModel().getTimeout()));
        postConditions.setAttribute("optional", String.valueOf(graph.getModel().isOptional()));
        for (ModelGraph postCondition : graph.getPostConditions().getChildren()) {
          saveGraph(postCondition, postConditions, document);
        }
      }
    }
    if (!node.getExcusedSubProcessorIds().isEmpty()) {
      workflowElem.setAttribute("excused",
          StringUtils.join(node.getExcusedSubProcessorIds(), ","));
    }
    if (node.isEntryPoint()) {
      workflowElem.setAttribute("entryPoint", "true");
    }
  }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

            System.out.println("Deploying " + realArchive.getName());
            Set<String> deployments = getDeploymentNames();
            int index = context.getInputStreamCount();
            context.addInputStream(new FileInputStream(realArchive));
            ModelNode result = new ModelNode();
            if (deployments.contains(archiveName)) {
                result.get("operation").set("full-replace-deployment");
                result.get("name").set(archiveName);
                result.get("input-stream-index").set(index);
            }
            else {
                result.get("operation").set("composite");
                ModelNode steps = result.get("steps");
                ModelNode add = steps.add();
                add.get("operation").set("add");
                add.get("address").add("deployment", archiveName);
                add.get("input-stream-index").set(index);
                ModelNode mainAdd = steps.add();
                mainAdd.get("operation").set("add");
                mainAdd.get("address").add("server-group", "main-server-group");
                mainAdd.get("address").add("deployment", archiveName);
                ModelNode mainDeploy = steps.add();
                mainDeploy.get("operation").set("deploy");
                mainDeploy.get("address").add("server-group", "main-server-group");
                mainDeploy.get("address").add("deployment", archiveName);
                ModelNode otherAdd = steps.add();
                otherAdd.get("operation").set("add");
                otherAdd.get("address").add("server-group", "other-server-group");
                otherAdd.get("address").add("deployment", archiveName);
                ModelNode otherDeploy = steps.add();
                otherDeploy.get("operation").set("deploy");
                otherDeploy.get("address").add("server-group", "other-server-group");
                otherDeploy.get("address").add("deployment", archiveName);
            }
            return result;
        }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

            return result;
        }

        public synchronized ModelNode removeDeployment() {
            System.out.println("Undeploying " + realArchive.getName());
            ModelNode result = new ModelNode();
            result.get("operation").set("composite");
            ModelNode steps = result.get("steps");
            ModelNode mainUndeploy = steps.add();
            mainUndeploy.get("operation").set("undeploy");
            mainUndeploy.get("address").add("server-group", "main-server-group");
            mainUndeploy.get("address").add("deployment", archiveName);
            ModelNode mainRemove = steps.add();
            mainRemove.get("operation").set("remove");
            mainRemove.get("address").add("server-group", "main-server-group");
            mainRemove.get("address").add("deployment", archiveName);
            ModelNode otherUndeploy = steps.add();
            otherUndeploy.get("operation").set("undeploy");
            otherUndeploy.get("address").add("server-group", "other-server-group");
            otherUndeploy.get("address").add("deployment", archiveName);
            ModelNode otherRemove = steps.add();
            otherRemove.get("operation").set("remove");
            otherRemove.get("address").add("server-group", "other-server-group");
            otherRemove.get("address").add("deployment", archiveName);
            ModelNode domainRemove = steps.add();
            domainRemove.get("operation").set("remove");
            domainRemove.get("address").add("deployment", archiveName);
            return result;
        }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

            System.out.println("Connecting");
            client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999);
            System.out.println("Connected");

            System.out.println("Dumping config as xml\n");
            ModelNode request = new ModelNode();
            request.get("operation").set("read-config-as-xml");
            request.get("address").setEmptyList();
            ModelNode r = client.execute(OperationBuilder.Factory.create(request).build());
            System.out.println(r.get("result").asString());

        } finally {
            StreamUtils.safeClose(client);
            System.out.println("Closed");
        }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

    public static void main(String[] args) throws Exception {

        final ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9999);
        try {
            final ModelNode domainOp = new ModelNode();
            domainOp.get(OP).set(READ_RESOURCE_OPERATION);
            domainOp.get(OP_ADDR).setEmptyList();
            domainOp.get(RECURSIVE).set(true);
            domainOp.get("proxies").set(false);

            ModelNode result = client.execute(domainOp);
            if(! SUCCESS.equals(result.get(OUTCOME).asString())) {
                throw new OperationFailedException(result.get(FAILURE_DESCRIPTION));
            }

            System.out.println("-- domain configuration");
            final ModelNode domainResult = result.get(RESULT).clone();
            System.out.println(domainResult);
            System.out.println("--");

            final ModelNode hostOp = new ModelNode();
            hostOp.get(OP).set(READ_RESOURCE_OPERATION);
            hostOp.get(OP_ADDR).setEmptyList().add(HOST, "local");
            hostOp.get(RECURSIVE).set(true);
            hostOp.get("proxies").set(false);

            result = client.execute(hostOp);
            if(! SUCCESS.equals(result.get(OUTCOME).asString())) {
                throw new OperationFailedException(result.get(FAILURE_DESCRIPTION));
            }

            System.out.println("-- host configuration");
            final ModelNode hostResult = result.get(RESULT).clone();
            System.out.println();
            System.out.println("--");

        } finally {
            StreamUtils.safeClose(client);
View Full Code Here

Examples of org.jboss.dmr.ModelNode

        // interfaces
        runInetface(client);
    }

    void runSysProperties(final ModelControllerClient client) throws Exception {
        final ModelNode address = new ModelNode();
        address.add(HOST, "local");

        final ModelNode operation = new ModelNode();
        operation.get(OP).set("add-system-property");
        operation.get(OP_ADDR).set(address);
        operation.get(NAME).set("test-property");
        operation.get(VALUE).set("test-value");

        runOperationAndRollback(operation, client);
    }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

        runOperationAndRollback(operation, client);
    }

    void runPaths(final ModelControllerClient client) throws Exception {
        final ModelNode address = new ModelNode();
        address.add(HOST, "local");
        address.add(PATH, "temp");

        final ModelNode operation = new ModelNode();
        operation.get(OP).set(ADD);
        operation.get(OP_ADDR).set(address);
        operation.get(NAME).set("temp");
        operation.get(PATH).set("temp");

        runOperationAndRollback(operation,client);
    }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

        runOperationAndRollback(operation,client);
    }

    void runInetface(final ModelControllerClient client) throws IOException {
        final ModelNode address = new ModelNode();
        address.add(HOST, "local");
        address.add(INTERFACE, "new");

        final ModelNode operation = new ModelNode();
        operation.get(OP).set(ADD);
        operation.get(OP_ADDR).set(address);
        operation.get(NAME).set("new");
        operation.get(CRITERIA).set("any-address");

        runOperationAndRollback(operation, client);
    }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

    public static void main(String[] args) throws Exception {

        final ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9999);
        try {

            final ModelNode hostNamesOp = new ModelNode();
            hostNamesOp.get(OP).set(READ_CHILDREN_NAMES_OPERATION);
            hostNamesOp.get(OP_ADDR).setEmptyList();
            hostNamesOp.get(CHILD_TYPE).set(HOST);

            final ModelNode hostNames = client.execute(hostNamesOp);
            final Map<String, Set<String>> hosts = new HashMap<String, Set<String>>();
            for(final ModelNode host : hostNames.get(RESULT).asList()) {

                final String hostName = host.asString();
                final Set<String> serverNames = new HashSet<String>();
                hosts.put(host.asString(), serverNames);

                final ModelNode serverOp = new ModelNode();
                serverOp.get(OP).set(READ_CHILDREN_NAMES_OPERATION);
                serverOp.get(OP_ADDR).setEmptyList().add(HOST, host.asString());
                serverOp.get(CHILD_TYPE).set(SERVER_CONFIG);

                final ModelNode serversResult = client.execute(serverOp);
                for(final ModelNode server : serversResult.get(RESULT).asList()) {
                    final String serverName = server.asString();
                    serverNames.add(serverName);

                    final ModelNode serverAddress = new ModelNode();
                    serverAddress.add(HOST, hostName);
                    serverAddress.add(SERVER_CONFIG, serverName);

                    final ModelNode serverConfigOp = new ModelNode();
                    serverConfigOp.get(OP).set(READ_RESOURCE_OPERATION);
                    serverConfigOp.get(OP_ADDR).set(serverAddress);
                    serverConfigOp.get(INCLUDE_RUNTIME).set(true);

                    final ModelNode serverConfig = client.execute(serverConfigOp);

                    System.out.println("\nServer:\n");
                    System.out.println("server name:          " + serverName);
                    System.out.println("host controller name: " + hostName);
                    System.out.println("server group name:    " + serverConfig.get(RESULT, GROUP).asString());
                    System.out.println("status:               " + serverConfig.get(RESULT, "status"));

                    if("STARTED".equals(serverConfig.get(RESULT, "status").asString())) {
                        serverNames.add(serverName);
                    }
                }
            }

            for(final Entry<String, Set<String>> entry : hosts.entrySet()) {
                final String hostName = entry.getKey();

                for(final String serverName : entry.getValue()) {
                    final ModelNode address = new ModelNode();
                    address.add(HOST, hostName);
                    address.add(SERVER_CONFIG, serverName);

                    runServerOperation(client, address, "stop");
                }
            }

            Thread.sleep(2000); //

            for(final Entry<String, Set<String>> entry : hosts.entrySet()) {
                final String hostName = entry.getKey();

                for(final String serverName : entry.getValue()) {
                    final ModelNode address = new ModelNode();
                    address.add(HOST, hostName);
                    address.add(SERVER_CONFIG, serverName);

                    runServerOperation(client, address, "start");
                }
            }

            Thread.sleep(10000); //

            for(final Entry<String, Set<String>> entry : hosts.entrySet()) {
                final String hostName = entry.getKey();

                for(final String serverName : entry.getValue()) {
                    final ModelNode address = new ModelNode();
                    address.add(HOST, hostName);
                    address.add(SERVER_CONFIG, serverName);

                    runServerOperation(client, address, "restart");
                }
            }
View Full Code Here

Examples of org.jboss.dmr.ModelNode

        runOperationAndRollback(operation, client);
    }

    void runOperationAndRollback(final ModelNode operation, final ModelControllerClient client) throws IOException {
        final ModelNode result = client.execute(operation);
        try {
            checkSuccess(result);

            final ModelNode readResource = new ModelNode();
            readResource.get(OP).set(READ_RESOURCE_OPERATION);
            readResource.get(OP_ADDR).set(operation.require(OP_ADDR));

            final ModelNode readResult = client.execute(readResource);
            checkSuccess(readResult);

        } finally {
            final ModelNode compensating = result.get(COMPENSATING_OPERATION);
            checkSuccess(client.execute(compensating));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.