Package org.rhq.core.pluginapi.operation

Examples of org.rhq.core.pluginapi.operation.OperationResult


                throw new Exception("Failed to " + name + " webapp (value of the 'state' attribute of MBean '"
                    + this.webModuleMBean.getBeanName() + "' is \"" + state + "\", not \"" + expectedState + "\").");
            }
        }

        return new OperationResult();
    }
View Full Code Here


    @SuppressWarnings("unchecked")
    @Override
    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

            EmsBean emsBean = getEmsBean();
            Map<String, Integer> before = (Map<String, Integer>) emsBean.getAttribute("CacheCounts").refresh();
            emsBean.getOperation("reloadCaches").invoke(); // void return
            Map<String, Integer> after = (Map<String, Integer>) emsBean.getAttribute("CacheCounts").refresh();

            OperationResult result = new OperationResult();
            PropertyList statistics = new PropertyList("reloadStatistics");
            result.getComplexResults().put(statistics);
            for (String cacheName : before.keySet()) {
                PropertyMap stat = new PropertyMap("stat");
                stat.put(new PropertySimple("cacheName", cacheName));
                stat.put(new PropertySimple("beforeReloading", before.get(cacheName)));
                stat.put(new PropertySimple("afterReloading", after.get(cacheName)));
View Full Code Here

        if ("retrieveStatistics".equals(name)) {

            Map<String, Map<String, Object>> allData;
            allData = (Map<String, Map<String, Object>>) getEmsBean().getAttribute("Statistics").refresh();
           
            OperationResult result = new OperationResult();
            PropertyList statistics = new PropertyList("statistics");
            result.getComplexResults().put(statistics);

            for (String groupDefinitionName : allData.keySet()) {

                PropertyMap stat = new PropertyMap("stat");
                stat.put(new PropertySimple("groupDefinitionName", groupDefinitionName));
View Full Code Here

    @Override
    public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
        if ("viewReceivedCallTimeData".equals(name)) {
            Map<String, long[]> allData;
            allData = (Map<String, long[]>) getEmsBean().getAttribute("CallTimeDataAsPrimitives").refresh();
            OperationResult result = new OperationResult();
            PropertyList commands = new PropertyList("requests");
            result.getComplexResults().put(commands);

            for (Map.Entry<String, long[]> data : allData.entrySet()) {
                String api = data.getKey();
                long[] calltime = data.getValue();
               
View Full Code Here

    public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
        if ("viewReceivedCallTimeData".equals(name)) {
            // we know our agent has the Calltime object in classpath - its in the comm module
            Map<String, Calltime> allData;
            allData = (Map<String, Calltime>) getEmsBean().getAttribute("CallTimeDataReceived").refresh();
            OperationResult result = new OperationResult();
            PropertyList commands = new PropertyList("commands");
            result.getComplexResults().put(commands);

            for (Map.Entry<String, Calltime> data : allData.entrySet()) {
                String commandName = data.getKey();
                Calltime calltime = data.getValue(); // do not alter the values in here, its a shallow copy
               
View Full Code Here

        args.add("-f");
        args.add(serverPluginConfiguration.getSimpleValue(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF, null));
    }

    private OperationResult createOperationResult(ProcessExecutionResults processExecutionResults) {
        OperationResult operationResult = new OperationResult();

        Integer exitCode = processExecutionResults.getExitCode();
        String output = processExecutionResults.getCapturedOutput(); // NOTE: this is stdout + stderr

        Configuration complexResults = operationResult.getComplexResults();
        complexResults.put(new PropertySimple(EXIT_CODE_RESULT_PROP, exitCode));
        complexResults.put(new PropertySimple(OUTPUT_RESULT_PROP, output));

        return operationResult;
    }
View Full Code Here

            String newName = parameters.getSimpleValue("name", "");
            String type = parameters.getSimpleValue("type", "jms-queue").toLowerCase();
            theAddress.add(type, newName);
            PropertyList jndiNamesProp = parameters.getList("entries");
            if (jndiNamesProp == null || jndiNamesProp.getList().isEmpty()) {
                OperationResult fail = new OperationResult();
                fail.setErrorMessage("No jndi bindings given");
                return fail;
            }
            List<String> jndiNames = new ArrayList<String>();
            for (Property p : jndiNamesProp.getList()) {
                PropertySimple ps = (PropertySimple) p;
                jndiNames.add(ps.getStringValue());
            }

            operation = new Operation(op, theAddress);
            operation.addAdditionalProperty("entries", jndiNames);
            if (type.equals("jms-queue")) {
                PropertySimple ps = (PropertySimple) parameters.get("durable");
                if (ps != null) {
                    boolean durable = Boolean.parseBoolean(ps.getStringValue());
                    operation.addAdditionalProperty("durable", durable);
                }
                String selector = parameters.getSimpleValue("selector", "");
                if (!selector.isEmpty())
                    operation.addAdditionalProperty("selector", selector);
            }

        } else if (what.equals("domain")) {
            operation = new Operation(op, new Address());
        } else if (what.equals("subsystem")) {
            operation = new Operation(op, new Address(this.path));
        } else {
            // We have a generic operation so we pass it literally
            // with the parameters it has.
            operation = new Operation(op, new Address((path)));
            for (Property prop : parameters.getProperties()) {
                if (prop instanceof PropertySimple) {
                    PropertySimple ps = (PropertySimple) prop;
                    if (ps.getStringValue() != null) {
                        Object val = getObjectForProperty(ps, op);
                        operation.addAdditionalProperty(ps.getName(), val);
                    }
                } else if (prop instanceof PropertyList) {
                    PropertyList pl = (PropertyList) prop;
                    List<Object> items = new ArrayList<Object>(pl.getList().size());
                    // Loop over the inner elements of the list
                    for (Property p2 : pl.getList()) {
                        if (p2 instanceof PropertySimple) {
                            PropertySimple ps = (PropertySimple) p2;
                            if (ps.getStringValue() != null) {
                                Object val = getObjectForPropertyList(ps, pl, op);
                                items.add(val);
                            }
                        }
                    }
                    operation.addAdditionalProperty(pl.getName(), items);
                } else {
                    LOG.error("PropertyMap for " + prop.getName() + " not yet supported");
                }
            }
        }

        OperationResult operationResult = new OperationResult();
        Result result = getASConnection().execute(operation);

        if (result == null) {
            operationResult.setErrorMessage("Connection was null - is the server running?");
            return operationResult;
        }

        if (!result.isSuccess()) {
            operationResult.setErrorMessage(result.getFailureDescription());
        } else {
            String tmp;
            if (result.getResult() == null)
                tmp = "-none provided by the server-";
            else
                tmp = result.getResult().toString();
            operationResult.setSimpleResult(tmp);
        }
        return operationResult;
    }
View Full Code Here

            message = storeConfig();
            break;
        }
        }

        OperationResult result = new OperationResult(message);
        return result;
    }
View Full Code Here

        if (name.equals("enable")) {
            return invokeSimpleOperation("deploy");
        } else if (name.equals("disable")) {
            return invokeSimpleOperation("undeploy");
        } else if (name.equals("restart")) {
            OperationResult result = invokeSimpleOperation("undeploy");

            if (result.getErrorMessage() == null) {
                result = invokeSimpleOperation("deploy");
            }

            return result;
        } else {
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.operation.OperationResult

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.