Package org.rhq.modules.plugins.jbossas7.json

Examples of org.rhq.modules.plugins.jbossas7.json.Operation


    private static final String OUTCOME = "outcome";

    @Override
    public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException,
        Exception {
        Operation op = new Operation(name, getAddress());
        Result res = getASConnection().execute(op, parameters.getSimple("responseTimeout").getIntegerValue());
        OperationResult result = new OperationResult();
        if (res.isSuccess()) {
            result.setSimpleResult(SUCCESS);
        } else {
View Full Code Here


                    String hash = resultNode.get("BYTES_VALUE").getTextValue();
                    ASConnection connection = getASConnection();

                    Address deploymentsAddress = new Address();
                    deploymentsAddress.add("deployment", packageName);
                    Operation step1 = new Operation("add", deploymentsAddress);
                    //                    step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
                    List<Object> content = new ArrayList<Object>(1);
                    Map<String, Object> contentValues = new HashMap<String, Object>();
                    contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
                    content.add(contentValues);
                    step1.addAdditionalProperty("content", content);

                    step1.addAdditionalProperty("name", packageName);

                    Address serverGroupAddress = new Address(context.getResourceKey());
                    serverGroupAddress.add("deployment", packageName);
                    Operation step2 = new Operation("add", serverGroupAddress);
                    Operation step3 = new Operation("deploy", serverGroupAddress);

                    CompositeOperation cop = new CompositeOperation();
                    cop.addStep(step1);
                    cop.addStep(step2);
                    cop.addStep(step3);
View Full Code Here

    }

    @Override
    public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {

        Operation op = new ReadChildrenNames(address, "deployment"); // TODO read full packages not only names
        Result node = getASConnection().execute(op);
        if (!node.isSuccess())
            return null;

        List<String> resultList = (List<String>) node.getResult(); // TODO needs checking
View Full Code Here

        System.out.println();
        ASConnection connection = getDomainControllerASConnection();

        Address deploymentsAddress = new Address("deployment", TEST_WAR_FILE_NAME);
        Operation op = new Operation("add", deploymentsAddress);
        List<Object> content = new ArrayList<Object>(1);
        Map<String, Object> contentValues = new HashMap<String, Object>();
        contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", bytes_value));
        content.add(contentValues);
        op.addAdditionalProperty("content", content);
        op.addAdditionalProperty("name", TEST_WAR_FILE_NAME); // this needs to be unique per upload
        op.addAdditionalProperty("runtime-name", TEST_WAR_FILE_NAME);
        System.out.flush();
        JsonNode ret = connection.executeRaw(op);
        System.out.println("Add to /deploy done " + ret);
        System.out.flush();

        assert ret.toString().contains("success") : ret;

        Address serverGroupAddress = new Address();
        serverGroupAddress.add("server-group", "main-server-group");
        serverGroupAddress.add("deployment", TEST_WAR_FILE_NAME);

        Operation attach = new Operation("add", serverGroupAddress);//,"enabled","true");
        //        deploy.addAdditionalProperty("runtime-name", TEST_WAR);
        System.out.flush();
        ret = connection.executeRaw(attach);
        System.out.println("Add to server group done: " + ret);
        System.out.flush();

        assert ret.has("outcome") : "Ret not valid " + ret.toString();
        assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();

        Operation deploy = new Operation("deploy", serverGroupAddress);
        Result depRes = connection.execute(deploy);

        assert depRes.isSuccess() : "Deploy went wrong: " + depRes.getFailureDescription();

        Thread.sleep(500);

        Operation undeploy = new Operation("undeploy", serverGroupAddress);
        depRes = connection.execute(undeploy);

        assert depRes.isSuccess() : "Undeploy went wrong: " + depRes.getFailureDescription();

        // Now tear down stuff again

        Operation unattach = new Operation("remove", serverGroupAddress);
        ret = connection.executeRaw(unattach);

        assert ret.has("outcome") : "Ret not valid " + ret.toString();
        assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success "
            + ret.getTextValue();

        // remove from domain

        Operation remove = new Operation("remove", deploymentsAddress);
        ret = connection.executeRaw(remove);

        assert ret.has("outcome") : "Ret not valid " + ret.toString();
        assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success "
            + ret.getTextValue();
View Full Code Here

        System.out.println("sha: " + bytes_value);

        System.out.println();
        ASConnection connection = getDomainControllerASConnection();

        Operation op = addDeployment(TEST_WAR_FILE_NAME, bytes_value);
        JsonNode ret = connection.executeRaw(op);

        System.out.println("Add to /deploy done " + ret);
        System.out.flush();

        assert ret.toString().contains("success") : ret;

        Address serverGroupAddress = new Address();
        serverGroupAddress.add("server-group", "main-server-group");
        serverGroupAddress.add("deployment", TEST_WAR_FILE_NAME);

        Operation attach = new Operation("add", serverGroupAddress);
        attach.addAdditionalProperty("enabled", true);
        System.out.flush();
        ret = connection.executeRaw(attach);
        System.out.println("Add to server group done: " + ret);
        System.out.flush();

        assert ret.has("outcome") : "Ret not valid " + ret.toString();
        assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();

        Result depRes;// = connection.execute(deploy);

        Thread.sleep(500);

        Operation undeploy = new Operation("undeploy", serverGroupAddress);
        depRes = connection.execute(undeploy);

        assert depRes.isSuccess() : "Undeploy went wrong: " + depRes.getFailureDescription();

        // Now tear down stuff again

        Operation unattach = new Remove(serverGroupAddress);
        ret = connection.executeRaw(unattach);

        assert ret.has("outcome") : "Ret not valid " + ret.toString();
        assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success "
            + ret.getTextValue();

        // remove from domain

        Operation remove = new Remove("deployment", TEST_WAR_FILE_NAME);
        ret = connection.executeRaw(remove);

        assert ret.has("outcome") : "Ret not valid " + ret.toString();
        assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success "
            + ret.getTextValue();
View Full Code Here

        System.out.println("Prepare done");
        System.out.flush();

        Address deploymentsAddress = new Address();
        deploymentsAddress.add("deployment", TEST_WAR_FILE_NAME);
        Operation step1 = new Operation("add", deploymentsAddress);
        List<Object> content = new ArrayList<Object>(1);
        Map<String, Object> contentValues = new HashMap<String, Object>();
        contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", bytes_value));
        content.add(contentValues);
        step1.addAdditionalProperty("content", content);
        step1.addAdditionalProperty("name", TEST_WAR_FILE_NAME); // this needs to be unique per upload

        Address serverGroupAddress = new Address();
        serverGroupAddress.add("server-group", "main-server-group");
        serverGroupAddress.add("deployment", TEST_WAR_FILE_NAME);
        Operation step2 = new Operation("add", serverGroupAddress);// ,"enabled","true");
        Operation step2a = new Operation("deploy", serverGroupAddress);

        Operation step3 = new Operation("undeploy", serverGroupAddress);
        Operation step3a = new Operation("remove", serverGroupAddress);

        Operation step4 = new Operation("remove", deploymentsAddress);

        CompositeOperation cop = new CompositeOperation();
        cop.addStep(step1);
        cop.addStep(step2);
        cop.addStep(step2a);
View Full Code Here

        System.out.println("Prepare done");
        System.out.flush();

        Address deploymentsAddress = new Address("deployment", TEST_WAR_FILE_NAME);
        Operation step1 = new Operation("add", deploymentsAddress);
        List<Object> content = new ArrayList<Object>(1);
        Map<String, Object> contentValues = new HashMap<String, Object>();
        contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", bytes_value));
        content.add(contentValues);
        step1.addAdditionalProperty("content", content);
        step1.addAdditionalProperty("name", TEST_WAR_FILE_NAME); // this needs to be unique per upload

        CompositeOperation cop = new CompositeOperation();
        cop.addStep(step1);

        ASConnection connection = getDomainControllerASConnection();
        JsonNode ret = connection.executeRaw(cop);
        System.out.println(ret);
        System.out.flush();

        assert ret.has("outcome") : "Ret not valid " + ret.toString();
        assert ret.get("outcome").getTextValue().equals("success") : "Composite deploy was no success "
            + ret.getTextValue();

        // Wait for AS to settle
        Thread.sleep(1000);

        // Now undeploy again to clean up

        cop = new CompositeOperation();
        Operation step4 = new Operation("remove", deploymentsAddress);

        cop.addStep(step4);
        ret = connection.executeRaw(cop);

        System.out.println(ret);
View Full Code Here

                "Unexpected IOException while converting host config file path to its canonical form", e);
        }
    }

    private <T> T getServerAttribute(ASConnection connection, String attributeName) {
        Operation op = new ReadAttribute(null, attributeName);
        Result res = connection.execute(op);
        if (!res.isSuccess()) {
            throw new InvalidPluginConfigurationException("Could not connect to remote server ["
                + res.getFailureDescription() + "]. Did you enable management?");
        }
View Full Code Here

                    boolean isAddEnabled = mapName.endsWith("+");

                    if (groupEnabled) {
                        if (isAddEnabled) {
                            // check if this exists already
                            Operation testOp = new ReadResource(address1);
                            Result res = connection.execute(testOp);
                            if (!res.isSuccess()) {
                                // and try to add it
                                Operation add = new Operation("add", address1);
                                res = connection.execute(add);
                                if (!res.isSuccess()) {
                                    // Not much we can do here when the add fails
                                    log.error("Adding of node " + address1 + " failed");
                                }
View Full Code Here

            PropertyList pl = (PropertyList) conf.get(propDefName);

            // check if we need to see if that property exists - get the current state of affairs from the AS
            List<String> existingPropnames = new ArrayList<String>();
            if (addNewChildren) {
                Operation op = new ReadChildrenResources(baseAddress, type);
                Result tmp = connection.execute(op);
                if (tmp.isSuccess()) {
                    Map<String, Object> tmpResMap = (Map<String, Object>) tmp.getResult();
                    existingPropnames.addAll(tmpResMap.keySet());
                }
            }

            // Loop over the list - i.e. the individual rows that come from the server
            for (Property prop2 : pl.getList()) {
                updateHandlePropertyMapSpecial(cop, (PropertyMap) prop2, (PropertyDefinitionMap) propDef, baseAddress,
                    existingPropnames);
            }
            // now check about removed properties
            for (String existingName : existingPropnames) {
                boolean found = false;
                for (Property prop2 : pl.getList()) {
                    PropertyMap propMap2 = (PropertyMap) prop2;
                    String itemName = propMap2.getSimple(namePropLocator).getStringValue();
                    if (itemName == null) {
                        throw new IllegalArgumentException("Map contains no entry with name [" + namePropLocator + "]");
                    }
                    if (itemName.equals(existingName)) {
                        found = true;
                        break;
                    }
                }
                // We may still have an entry in the map, that does not
                // match an existing name, but is marked as immutable
                if (!found) {
                    for (Property prop2 : pl.getList()) {
                        PropertyMap propMap2 = (PropertyMap) prop2;
                        String itemName = propMap2.getSimple(namePropLocator).getStringValue();
                        String errorMessage = propMap2.getErrorMessage();
                        boolean contains = existingPropnames.contains(itemName);
                        if (!contains && LOGICAL_REMOVED.equals(errorMessage)) {
                            found = true; // we pretend this still exists on the server, so nothing to update
                        }
                    }
                }

                // In properties on server and not in map or immutable, lets remove it
                if (!found) {
                    Address tmpAddr = new Address(baseAddress);
                    tmpAddr.add(type, existingName);
                    Operation operation = new Operation("remove", tmpAddr);
                    cop.addStep(operation);
                }
            }

        } else {
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.json.Operation

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.