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

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


        }
    }

    private String getContextRootAttribute(Address address, ASConnection asConnection) {
        ReadAttribute readAttribute = new ReadAttribute(address, CONTEXT_ROOT_ATTRIBUTE);
        Result readAttributeResult = asConnection.execute(readAttribute);
        if (!readAttributeResult.isSuccess()) {
            throw new RuntimeException("Could not read [" + CONTEXT_ROOT_ATTRIBUTE + "] attribute of node ["
                + address.getPath() + "]: " + readAttributeResult.getFailureDescription());
        }
        return (String) readAttributeResult.getResult();
    }
View Full Code Here


    public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
        if (!metrics.isEmpty()) {
            ReadResource op = new ReadResource(getAddress());
            op.includeRuntime(true);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {
                @SuppressWarnings("unchecked")
                Map<String, Object> data = (Map<String, Object>) result.getResult();
                for (MeasurementScheduleRequest request : metrics) {
                    Object value = data.get(request.getName());
                    Double d = Double.parseDouble(getStringValue(value));
                    report.addData(new MeasurementDataNumeric(request, d));
                }
View Full Code Here

        //get root modcluster component
        String resourceKey = component.key;
        String[] resourceKeyComponents = resourceKey.split(":");

        Operation op = new Operation("read-proxies-info", new Address(resourceKeyComponents[0]));
        Result result = getASConnection().execute(op);
        //get ProxyInfo and parse
        rawProxyInfo = ModClusterContextDiscoveryComponent.extractRawProxyInfo(result);

        return rawProxyInfo;
    }
View Full Code Here

    public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
        if (name.equals(ENABLE_OPERATION)) {
            Operation operation = new Operation(ENABLE_OPERATION, getAddress());
            Boolean persistent = Boolean.valueOf(parameters.getSimpleValue("persistent", TRUE.toString()));
            operation.addAdditionalProperty("persistent", persistent);
            Result res = getASConnection().execute(operation);
            if (res.isSuccess()) {
                return new OperationResult();
            } else {
                OperationResult operationResult = new OperationResult();
                operationResult.setErrorMessage(res.getFailureDescription());
                return operationResult;
            }
        }
        if (name.equals(DISABLE_OPERATION)) {
            Operation operation = new Operation(DISABLE_OPERATION, getAddress());
            boolean allowResourceServiceRestart = Boolean.parseBoolean(parameters.getSimpleValue(
                "allow-resource-service-restart", FALSE.toString()));
            if (allowResourceServiceRestart) {
                operation.allowResourceServiceRestart();
            }
            Result res = getASConnection().execute(operation);
            if (res.isSuccess()) {
                return new OperationResult();
            } else {
                OperationResult operationResult = new OperationResult();
                operationResult.setErrorMessage(res.getFailureDescription());
                return operationResult;
            }
        }
        return super.invokeOperation(name, parameters);
    }
View Full Code Here

            }
        }

        // 5. Update config if needed
        if (updateOperation.numberOfSteps() > 0) {
            Result res = getASConnection().execute(updateOperation);
            if (res.isSuccess()) {
                configurationUpdateReport.setStatus(SUCCESS);
            } else {
                configurationUpdateReport.setStatus(FAILURE);
                configurationUpdateReport.setErrorMessage(res.getFailureDescription());
            }
        } else {
            configurationUpdateReport.setStatus(NOCHANGE);
        }
    }
View Full Code Here

            report.addData(data);
        }
    }

    private MeasurementDataTrait getConnectionAvailable(MeasurementScheduleRequest request) {
        Result res = getASConnection().execute(new Operation("test-connection-in-pool", getAddress()));
        return new MeasurementDataTrait(request, String.valueOf(res.isSuccess()));
    }
View Full Code Here

            Address theAddress = new Address();
            String host = pluginConfiguration.getSimpleValue("domainHost", "local");
            theAddress.add("host", host);
            theAddress.add("server-config", myServerName);
            Operation getStatus = new ReadAttribute(theAddress, "status");
            Result result;
            try {
                result = getASConnection().execute(getStatus, AVAIL_OP_TIMEOUT_SECONDS);
            } catch (Exception e) {
                getLog().warn(e.getMessage());
                return AvailabilityType.DOWN;
            }

            if (!result.isSuccess()) {
                if (result.isTimedout()) {
                    return AvailabilityType.UNKNOWN;
                }

                return AvailabilityType.DOWN;
            }

            String msg = result.getResult().toString();
            if (msg.contains("STARTED"))
                return AvailabilityType.UP;
            else
                return AvailabilityType.DOWN;
        }
View Full Code Here

                path = path.replace("server-config", "server");
                Address address = new Address(path);
                address.add("core-service", "platform-mbean");
                address.add("type", "runtime");
                Operation op = new ReadAttribute(address, "start-time");
                Result res = getASConnection().execute(op);

                if (res.isSuccess()) {
                    Long startTime = (Long) res.getResult();
                    MeasurementDataTrait data = new MeasurementDataTrait(request, new Date(startTime).toString());
                    report.addData(data);
                }
            } else if (request.getName().equals("multicastAddress")) {
                collectMulticastAddressTrait(report, request);
            } else {
                leftovers.add(request);
            }
        }

        // 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

    @Override
    public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException,
        Exception {
        Operation op = new Operation(name, getAddress());
        op.addAdditionalProperty("blocking", Boolean.valueOf(parameters.getSimpleValue("blocking", "false")));
        Result res = getASConnection().execute(op,
            Integer.parseInt(parameters.getSimpleValue("operationTimeout", "120")));
        OperationResult opRes;
        if (res.isSuccess()) {
            opRes = new OperationResult("successfully invoked [" + name + "]");
        } else {
            opRes = new OperationResult("Operation [" + name + "] failed");
            opRes.setErrorMessage(res.getFailureDescription());
        }
        return opRes;
    }
View Full Code Here

     */
    private String getHostName(ASConnection asConnection) {

        Operation op = new ReadAttribute(new Address(),"local-host-name");
        String hostname;
        Result res = asConnection.execute(op);
        if (res.isSuccess()) {
            hostname = (String) res.getResult();
            return hostname;
        }
        // Above failed. Now try falling back to host name resolution
        try {
            hostname = InetAddress.getLocalHost().getHostName();
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.