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

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


    @Override
    public void updateResourceConfiguration(ConfigurationUpdateReport report) {
        Configuration sgConfig = new Configuration();
        loadAssignedServerGroups(sgConfig);
        CompositeOperation operation = new CompositeOperation();
        boolean needDiscovery = false; // we will request deferred child discovery on parent HC only in case new assignment was added

        // load assigned server-groups to map, so we can easily look them up
        Map<String, PropertyMap> assignedCurrent = new HashMap<String, PropertyMap>();
        for (Property p : sgConfig.getList("*1").getList()) {
            PropertyMap map = (PropertyMap) p;
            assignedCurrent.put(map.getSimpleValue("server-group", null), map);
        }
        // also put new assignment to map, to detect possible duplicates
        Map<String, PropertyMap> assignedNew = new HashMap<String, PropertyMap>();
        // detect changes (enable/disable changes and new assignments)
        for (Property prop : report.getConfiguration().getList("*1").getList()) {
            PropertyMap mapNew = (PropertyMap) prop;
            PropertyMap duplicate = assignedNew.put(mapNew.getSimpleValue("server-group", null), mapNew);
            if (duplicate != null) {
                report.setStatus(ConfigurationUpdateStatus.FAILURE);
                report.setErrorMessage("Duplicate assignment to [" + duplicate.getSimpleValue("server-group", null)
                    + "] you cannot assign deployment to server-group more than once");
                return;
            }
            String key = mapNew.getSimpleValue("server-group", null);
            String runtimeNew = mapNew.getSimpleValue("runtime-name", null);
            boolean enabledNew = mapNew.getSimple("enabled").getBooleanValue();
            PropertyMap mapCurrent = assignedCurrent.remove(key);
            if (mapCurrent == null) {
                // new assignment was added
                operation.addStep(createServerGroupAssignmentStep("add", key, runtimeNew, enabledNew));
                needDiscovery = true;
            } else {
                boolean enabledCurrent = mapCurrent.getSimple("enabled").getBooleanValue();
                if (enabledCurrent != enabledNew) {
                    // deployment status change
                    String action = "undeploy";
                    if (enabledNew) {
                        action = "deploy";
                    }
                    operation.addStep(createServerGroupAssignmentStep(action, key, null, false));
                }
            }
        }
        // detect removals, items left in map (exist in old config, but were not sent in the new one) should be removed
        for (PropertyMap map : assignedCurrent.values()) {
            operation.addStep(createServerGroupAssignmentStep("remove", map.getSimpleValue("server-group", null), null,
                false));
        }
        if (operation.numberOfSteps() == 0) {
            report.setStatus(ConfigurationUpdateStatus.NOCHANGE);
            return;
        }
        Result res = getASConnection().execute(operation, 120); // wait up to 2 minutes
        if (res.isSuccess()) {
View Full Code Here


                    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);

                    Result result = connection.execute(cop);
                    if (!result.isSuccess()) // TODO get failure message into response
                        response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),
                            ContentResponseResult.FAILURE));
View Full Code Here

        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);

        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();

        Thread.sleep(1000);

        cop = new CompositeOperation();
        cop.addStep(step3);
        cop.addStep(step3a);
        cop.addStep(step4);
        ret = connection.executeRaw(cop);

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

        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);
        System.out.flush();
View Full Code Here

        Configuration conf = new Configuration();
        conf.put(new PropertySimple("needed", "test"));
        conf.put(new PropertySimple("optional", null));

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        Assert.assertEquals(cop.numberOfSteps(), 2);

        for (int i = 0; i < cop.numberOfSteps(); i++) {
            Operation step = cop.step(0);
            Assert.assertEquals(step.getOperation(), "write-attribute");
            Map<String, Object> stepProps = step.getAdditionalProperties();
            Assert.assertEquals(stepProps.size(), 2);

            if (stepProps.get("name").equals("needed")) {
View Full Code Here

        PropertyList propertyList = new PropertyList("foo", new PropertySimple("optional", "Hello"),
            new PropertySimple("optional", null), new PropertySimple("optional", "world"));

        conf.put(propertyList);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        List<String> values = (List<String>) props.get("value");
        assert values.size() == 2 : "Values had " + values.size() + " entries"; // The optional null must not be present
View Full Code Here

        PropertyMap propertyMap = new PropertyMap("foo", new PropertySimple("needed", "Hello"), new PropertySimple(
            "optional", "world"));

        conf.put(propertyMap);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        Map<String, Object> values = (Map<String, Object>) props.get("value");
        assert values.size() == 2 : "Values had " + values.size() + " entries instead of 2"; // The optional null must not be present
View Full Code Here

        PropertyMap propertyMap = new PropertyMap("foo", new PropertySimple("needed", "Hello"), new PropertySimple(
            "readOnly", "world"));

        conf.put(propertyMap);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        Map<String, Object> values = (Map<String, Object>) props.get("value");
        assert values.size() == 1 : "Values had " + values.size() + " entries instead of 1"; // The optional null must not be present
View Full Code Here

        Configuration conf = new Configuration();
        PropertyMap propertyMap = new PropertyMap("foo", new PropertySimple("needed", "Hello"));

        conf.put(propertyMap);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        Map<String, Object> values = (Map<String, Object>) props.get("value");
        assert values.size() == 1 : "Values had " + values.size() + " entries instead of 1"; // The optional null must not be present
View Full Code Here

        PropertyList propertyList = new PropertyList("foo", propertyMap);

        conf.put(propertyList);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        List<Map<String, Object>> values = (List<Map<String, Object>>) props.get("value");
        assert values.size() == 1 : "Values had " + values.size() + " entries instead of 1"; // The optional null must not be present
View Full Code Here

TOP

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

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.