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

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


*/
public class MiscTest extends AbstractIntegrationTest {

    public void testSetRollback() throws Exception {
        Operation op = new Operation("foo", new Address());
        Result res = getDomainControllerASConnection().execute(op);
        assertNotNull(res);
        assertFalse(res.isSuccess(), "Response outcome was success.");
        assertTrue(res.isRolledBack(), "Response was not rolled back: " + res);
        assertTrue(res.getFailureDescription().endsWith("rolled-back=true"), "Unexpected failure description: " + res);
    }
View Full Code Here


    private static final String ENABLED_ATTRIBUTE = "enabled";

    @Override
    public Configuration loadResourceConfiguration() throws Exception {
        ReadAttribute readAttributeOp = new ReadAttribute(getAddress(), ENABLED_ATTRIBUTE);
        Result result = getASConnection().execute(readAttributeOp);
        if (!result.isSuccess()) {
            throw new Exception(result.getFailureDescription(), result.getRhqThrowable());
        }
        Configuration configuration = new Configuration();
        PropertySimple enabledProperty = new PropertySimple(ENABLED_ATTRIBUTE, result.getResult());
        configuration.put(enabledProperty);
        includeOOBMessages(result, configuration);
        return configuration;
    }
View Full Code Here

        PropertyList queriesPropertyList = new PropertyList("queries");
        operationResult.getComplexResults().put(queriesPropertyList);

        ReadChildrenNames readQueryCacheChildrenNames = new ReadChildrenNames(getAddress(), "query-cache");
        Result readQueryCacheChildrenNamesResult = getASConnection().execute(readQueryCacheChildrenNames, timeoutSec);
        if (!readQueryCacheChildrenNamesResult.isSuccess()) {
            operationResult.setErrorMessage("Could not read query-cache children names: "
                + readQueryCacheChildrenNamesResult.getFailureDescription());
            return operationResult;
        }
        @SuppressWarnings("unchecked")
        List<String> childrenNames = (List<String>) readQueryCacheChildrenNamesResult.getResult();

        // Process children in batches to avoid sending too many queries if the PU has many query-cache nodes
        while (!childrenNames.isEmpty()) {
            if (context.getComponentInvocationContext().isInterrupted()) {
                // Operation canceled or timed out
                throw new InterruptedException();
            }

            List<String> childrenNamesSubList = childrenNames.subList(0, Math.min(batchSize, childrenNames.size()));

            // Create batch operation to read N query-cache nodes
            CompositeOperation batchOperation = new CompositeOperation();
            for (String childrenName : childrenNamesSubList) {
                Address address = new Address(getAddress());
                address.add("query-cache", childrenName);
                ReadResource readQueryCacheResource = new ReadResource(address);
                readQueryCacheResource.includeRuntime(true);
                batchOperation.addStep(readQueryCacheResource);
            }

            // Execute batch
            Result batchResult = getASConnection().execute(batchOperation, timeoutSec);
            if (!batchResult.isSuccess()) {
                operationResult.setErrorMessage("Could not read query-cache attributes: "
                    + batchResult.getFailureDescription());
                return operationResult;
            }

            // Iterate over batch results
            @SuppressWarnings("unchecked")
            Map<String, Map> mapResult = (Map<String, Map>) batchResult.getResult();
            for (Map stepResult : mapResult.values()) {
                PropertyMap queryPropertyMap = new PropertyMap("query");
                @SuppressWarnings("unchecked")
                Map<String, String> queryCacheAttributes = (Map<String, String>) stepResult.get("result");
                for (String queryCacheAttributeName : QUERY_CACHE_ATTRIBUTE_NAMES) {
View Full Code Here

        this.hash = hash;
        this.connection = connection;
    }

    boolean deploymentExists() {
        Result deploymentResources = connection.execute(new ReadChildrenResources(new Address(), "deployment"));
        for (Map.Entry<?, ?> deploymentResource : ((Map<?, ?>) deploymentResources.getResult()).entrySet()) {
            @SuppressWarnings("unchecked")
            Map<String, Object> deploymentResourceDetails = (Map<String, Object>) deploymentResource.getValue();
            if (runtimeName.equals(deploymentResourceDetails.get("runtime-name"))) {
                return true;
            }
View Full Code Here

            additionalProperties.put("proxies", "true");
            additionalProperties.put("include-runtime", "true");
            additionalProperties.put("include-defaults", "true");
            additionalProperties.put("attributes-only", "true");
            currentAttributesOp.setAdditionalProperties(additionalProperties);
            Result currentAttributes = getASConnection().execute(currentAttributesOp);
            if (currentAttributes.isSuccess()) {
                currentAttributeList = (Map<String, Object>) currentAttributes.getResult();
            }

            for (PropertyDefinition propDef : configDefCopy.getNonGroupedProperties()) {
                //with templated resources we should only parse the properties being used by this specific resource.
                if (currentAttributeList != null) {
View Full Code Here

            return entities;
        }

        Address addr = new Address(path);
        Operation op = new Operation(PROXY_INFO_OPERATION, addr);
        Result result = connection.execute(op);
        //get ProxyInfo and parse
        rawProxyInfo = extractRawProxyInfo(result);
        ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);

        //only discover the virtualhosts and webcontexts relevant to this modcluster node.
View Full Code Here

    public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException,
        Exception {
        OperationResult operationResult = new OperationResult();
        Address address = new Address(path);
        Operation operation = new Operation(name, address);
        Result asResult = getASConnection().execute(operation, false, JdrReportRunner.JDR_OPERATION_TIMEOUT);

        if (!asResult.isSuccess()) {
            operationResult.setErrorMessage(asResult.getFailureDescription());
            return operationResult;
        }

        Configuration operationComplexResult = operationResult.getComplexResults();
        Map<String, Object> asResultContext = (Map<String, Object>) asResult.getResult();

        for (Map.Entry<String, Object> resultEntry : asResultContext.entrySet()) {
            PropertySimple property = new PropertySimple(resultEntry.getKey(), resultEntry.getValue().toString());
            operationComplexResult.put(property);
        }
View Full Code Here

                subTypes.add(confPath);

            for (String cpath : subTypes) {

                Address addr = new Address(parentPath);
                Result result = connection.execute(new ReadChildrenNames(addr, cpath));

                if (result.isSuccess()) {

                    @SuppressWarnings("unchecked")
                    List<String> subsystems = (List<String>) result.getResult();

                    // There may be multiple children of the given type
                    for (String val : subsystems) {

                        String newPath = cpath + "=" + val;
                        Configuration config2 = context.getDefaultPluginConfiguration();

                        String resKey;

                        if (path == null || path.isEmpty())
                            resKey = newPath;
                        else {
                            if (path.startsWith(","))
                                path = path.substring(1);
                            resKey = path + "," + cpath + "=" + val;
                        }

                        PropertySimple pathProp = new PropertySimple("path", resKey);
                        config2.put(pathProp);

                        DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), // DataType
                            resKey, // Key
                            val, // Name
                            null, // Version
                            context.getResourceType().getDescription(), // subsystem.description
                            config2, null);
                        details.add(detail);
                    }
                }
            }
        } else {
            // Single subsystem
            path += "," + confPath;
            if (path.startsWith(","))
                path = path.substring(1);
            Result result = connection.execute(new ReadResource(new Address(path)));
            if (result.isSuccess()) {

                String resKey = path;
                String name = resKey.substring(resKey.lastIndexOf("=") + 1);
                Configuration config2 = context.getDefaultPluginConfiguration();
                PropertySimple pathProp = new PropertySimple("path", path);
View Full Code Here

    }

    public static List<PatchDetails> fromHistory(String patchHistoryOutcome) {
        ObjectMapper mapper = new ObjectMapper();

        Result result;
        try {
            result = mapper.readValue(patchHistoryOutcome, Result.class);
        } catch (IOException e) {
            LOG.warn("Failed to parse the output of the 'patch history' command with message '" + e.getMessage() +
                "'. The output was:\n" + patchHistoryOutcome);
            return Collections.emptyList();
        }

        if (!result.isSuccess()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("'patch history' command didn't succeed: " + result);
            }
            return Collections.emptyList();
        }

        // expecting a list of maps of string->string
        if (!(result.getResult() instanceof List)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unexpected patch history results. Expected list but found " +
                    (result.getResult() == null ? "null" : result.getResult().getClass().toString()));
            }

            return Collections.emptyList();
        }

        @SuppressWarnings("unchecked")
        List<Map<String, String>> patches = (List<Map<String, String>>) result.getResult();

        if (patches.isEmpty()) {
            return Collections.emptyList();
        }
View Full Code Here

    }

    public static List<PatchDetails> fromInfo(String patchInfoOutcome, String patchHistoryOutcome) {
        ObjectMapper mapper = new ObjectMapper();

        Result result;
        try {
            result = mapper.readValue(patchInfoOutcome, Result.class);
        } catch (IOException e) {
            LOG.warn("Failed to parse the output of the 'patch info' command with message '" + e.getMessage() +
                "'. The output was:\n" + patchInfoOutcome);
            return Collections.emptyList();
        }

        if (!result.isSuccess()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("'patch info' command didn't succeed: " + result);
            }
            return Collections.emptyList();
        }

        if (!(result.getResult() instanceof Map)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unexpected patch history results. Expected map but found " +
                    (result.getResult() == null ? "null" : result.getResult().getClass().toString()));
            }

            return Collections.emptyList();
        }

        List<PatchDetails> history = fromHistory(patchHistoryOutcome);

        List<PatchDetails> ret = new ArrayList<PatchDetails>();

        @SuppressWarnings("unchecked")
        Map<String, Object> resultMap = (Map<String, Object>) result.getResult();

        @SuppressWarnings("unchecked")
        List<String> oneOffs = (List<String>) resultMap.get("patches");

        for (String id : oneOffs) {
View Full Code Here

TOP

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

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.