Examples of ComplexResult


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

        Address address = new Address();

        ReadResource op = new ReadResource(address);
        op.includeRuntime(true);

        ComplexResult res = getASConnection().executeComplex(op);
        if (res.isSuccess()) {
            Map<String, Object> props = res.getResult();

            for (MeasurementScheduleRequest request : skmRequests) {
                String requestName = request.getName();
                String realName = requestName.substring(requestName.indexOf(':') + 1);
                String val = null;
                if (props.containsKey(realName)) {
                    val = getStringValue(props.get(realName));
                }

                if ("null".equals(val)) {
                    if (realName.equals("product-name"))
                        val = "JBoss AS";
                    else if (realName.equals("product-version"))
                        val = getStringValue(props.get("release-version"));
                    else if (LOG.isDebugEnabled()) {
                        LOG.debug("Value for " + realName + " was 'null' and no replacement found");
                    }
                }
                MeasurementDataTrait data = new MeasurementDataTrait(request, val);
                report.addData(data);
            }
        } else if (LOG.isDebugEnabled()) {
            LOG.debug("getSKMRequests failed: " + res.getFailureDescription());
        }
    }
View Full Code Here

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

            if (req.getName().equals("appuid")) {

                Address addr = new Address("core-service=platform-mbean,type=runtime");
                ReadAttribute op = new ReadAttribute(addr,"system-properties");
                ASConnection conn = parent.getASConnection();
                ComplexResult result = conn.executeComplex(op);

                if (result.isSuccess()) {
                    Map<String,Object> data = result.getResult();
                    if (data.containsKey("OPENSHIFT_APP_UUID")) {
                        String uid = (String) data.get("OPENSHIFT_APP_UUID");
                        MeasurementDataTrait res = new MeasurementDataTrait(req,uid);
                 report.addData(res);
                    }
                }
                else {
                    log.warn("Operation failed: " + result.getFailureDescription());
                }
            }
            // TODO add more metrics here
         }
    }
View Full Code Here

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

            }
        }


        ASConnection conn = getASConnection();
        ComplexResult result = conn.executeComplex(op);

        if (result.isSuccess()) {
            return new OperationResult("ok");
        }
        else {
            OperationResult failure = new OperationResult();
            failure.setErrorMessage(result.getFailureDescription());
            return failure;
        }


    }
View Full Code Here

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

    public void complexResult1() throws Exception {

        String resultString = " {\"outcome\" : \"success\", \"result\" : {\"alias\" : [\"example.com\"], \"access-log\" : null, \"rewrite\" : null}}";

        ObjectMapper mapper = new ObjectMapper();
        ComplexResult result = mapper.readValue(resultString, ComplexResult.class);

        assertNotSame(result, null);
        assertEquals(result.getOutcome(), "success");
        assertTrue(result.isSuccess());
        assertSame(result.getResult().size(), 3);
        String rewrite = (String) result.getResult().get("rewrite");
        assertSame(rewrite, null);

        @SuppressWarnings("unchecked")
        List<String> aliases = (List<String>) result.getResult().get("alias");
        assertNotSame(aliases, null);
        assertSame(aliases.size(), 1);
        assertEquals(aliases.get(0), "example.com");
    }
View Full Code Here

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

            + "          }\n" + "        }\n" + "      }\n" + "    }\n" + "  },\n"
            + "  \"failure-description\" : \"Operation was not applied successfully to any servers\"\n" + "}";
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);

        ComplexResult result = mapper.readValue(resultString, ComplexResult.class);
        assertFalse(result.isSuccess(), "Result should be 'failed', but was not");
        assertTrue(result.getFailureDescription().startsWith("Operation was not applied successfully to any servers"));

        assertTrue(result.getResult().containsKey("server-groups"));
        @SuppressWarnings("unchecked")
        Map<String, Object> sgs = (Map<String, Object>) result.getResult().get("server-groups");
        assertTrue(sgs.containsKey("main-server-group"));
        @SuppressWarnings("unchecked")
        Map<String, Object> mainSg = (Map<String, Object>) sgs.get("main-server-group");
        assertSame(mainSg.size(), 3, "Main server group does not have 3 servers, but " + mainSg.size());
        @SuppressWarnings("unchecked")
View Full Code Here

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

        Operation step1 = new ReadAttribute(a, "maxTime");
        cop.addStep(step1);
        Operation step2 = new ReadAttribute(a, "processingTime");
        cop.addStep(step2);

        ComplexResult res = getDomainControllerASConnection().executeComplex(cop);
        assertNotNull(res);
        assertTrue(res.isSuccess(), "Response outcome was failure.");
        Map<String, Object> resResult = res.getResult();
        assertNotNull(resResult);
        assertEquals(resResult.size(), 2);
    }
View Full Code Here

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

         * Those
         */
        ReadResource op = new ReadResource(address);
        op.includeRuntime(true);
        op.recursive(true);
        ComplexResult res = getASConnection().executeComplex(op);
        if (!res.isSuccess())
            return;

        Map<String, Object> results = new HashMap<String, Object>();
        @SuppressWarnings("unchecked")
        Map<String, Map<String, Object>> statistics = (Map<String, Map<String, Object>>) res.getResult().get(
            "statistics");
        if (statistics != null) {
            results.putAll(statistics.get("pool"));
            results.putAll(statistics.get("jdbc"));

View Full Code Here

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

        // Now handle the skm (this could go into a common method with BaseServerComponent's impl.
        if (skmRequests.size() > 0) {
            Address address = new Address();
            ReadResource op = new ReadResource(address);
            op.includeRuntime(true);
            ComplexResult res = getASConnection().executeComplex(op);
            if (res.isSuccess()) {
                Map<String, Object> props = res.getResult();

                for (MeasurementScheduleRequest request : skmRequests) {
                    String requestName = request.getName();
                    String realName = requestName.substring(requestName.indexOf(':') + 1);
                    String val = null;
                    if (props.containsKey(realName)) {
                        val = getStringValue(props.get(realName));
                    }

                    if ("null".equals(val)) {
                        if (realName.equals("product-name")) {
                            val = "JBoss AS";
                        }
                        else if (realName.equals("product-version")) {
                            val = getStringValue(props.get("release-version"));
                        }
                        else if (getLog().isDebugEnabled()) {
                            getLog().debug("Value for " + realName + " was 'null' and no replacement found");
                        }
                    }
                    MeasurementDataTrait data = new MeasurementDataTrait(request, val);
                    report.addData(data);
                }
            } else if (getLog().isDebugEnabled()) {
                getLog().debug("getSKMRequests failed: " + res.getFailureDescription());
            }
        }

        if (!leftovers.isEmpty())
            super.getValues(report, leftovers);
View Full Code Here

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

            throw new Exception("Failed to extract hostname from server path [" + serverPath + "].", e);
        }
        configuration.put(new PropertySimple("hostname", serverPath));

        Operation op = new ReadResource(getAddress());
        ComplexResult res = getASConnection().executeComplex(op);
        if (res.isSuccess()) {
            Map<String, Object> map = res.getResult();
            String group = (String) map.get("group");
            configuration.put(new PropertySimple("group", group));

            Map<String, Object> sgMap = getServerGroupMap(group);
View Full Code Here

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

     * @param group Name of the server group to query
     * @return Map with the properties of the group. Or an empty map if the group does not exist.
     */
    private Map<String, Object> getServerGroupMap(String group) {
        Operation op = new ReadResource("server-group", group);
        ComplexResult cr = getASConnection().executeComplex(op);
        if (cr.isSuccess()) {
            return cr.getResult();
        }

        return Collections.emptyMap();
    }
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.