Package org.rhq.core.pluginapi.operation

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


        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


        if (LOG.isDebugEnabled()) {
            LOG.debug("CLI results: exitcode=[" + results.getExitCode() + "]; error=[" + results.getError()
                + "]; output=" + message);
        }

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

    @Test(dependsOnMethods = "testServiceDiscovery")
    public void testOperation1() throws Exception {
        Set<Resource> childResources = getChildResourcesOfType(jmxServerResource, THREADING_RESOURCE_TYPE);
        assertEquals(childResources.size(), 1, String.valueOf(childResources));

        OperationResult operationResult = invokeOperation(childResources.iterator().next(), "threadDump",
            new Configuration());
        assertNotNull(operationResult);
        Configuration complexResults = operationResult.getComplexResults();
        assertNotNull(complexResults);
        assertTrue(isNotBlank(complexResults.getSimpleValue("totalCount")));
    }
View Full Code Here

        }
    }

    @Test(timeOut = 60 * 1000)
    public void testReloadOperation() throws Exception {
        OperationResult operationResult = serverComponent.invokeOperation("reload", new Configuration());
        assertEquals(operationResult.getSimpleResult(), "Success");
    }
View Full Code Here

        assertEquals(operationResult.getSimpleResult(), "Success");
    }

    @Test(timeOut = 60 * 1000)
    public void testShutdown() throws Exception {
        OperationResult operationResult = serverComponent.invokeOperation("shutdown", new Configuration());
        assertEquals(operationResult.getSimpleResult(), "Success");
    }
View Full Code Here

public class StatisticsComponent extends MBeanResourceComponent {
    @Override
    public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
        if ("viewQueries".equals(name)) {
            String[] queryStrings = (String[]) getEmsBean().getAttribute("Queries").refresh();
            OperationResult result = new OperationResult();
            PropertyList queries = new PropertyList("queries");
            result.getComplexResults().put(queries);

            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
                for (String queryString : queryStrings) {
View Full Code Here

            return AvailabilityType.DOWN;
        }
    }

    public OperationResult invokeOperation(String name, Configuration configuration) {
        OperationResult result = new OperationResult();

        try {
            if ("refresh".equals(name)) {
                prepareRules(true);
            } else {
                throw new UnsupportedOperationException(name);
            }
        } catch (Exception e) {
            result.setErrorMessage(ThrowableUtil.getAllMessages(e));
        }

        return result;
    }
View Full Code Here

        // reload, shutdown go to the remote server
        Operation op = new Operation(name, new Address());
        Result res = getASConnection().execute(op);

        OperationResult operationResult = postProcessResult(name, res);

        if (name.equals("shutdown")) {
            if (waitUntilDown()) {
                operationResult.setSimpleResult("Success");
            } else {
                operationResult.setErrorMessage("Was not able to shut down the server.");
            }
        }

        if (name.equals("reload")) {
            if (waitUntilReloaded()) {
                operationResult.setSimpleResult("Success");
            } else {
                operationResult.setErrorMessage("Was not able to reload the server.");
            }
        }

        context.getAvailabilityContext().requestAvailabilityCheck();
View Full Code Here

     * @see OperationFacet#invokeOperation(String, Configuration)
     */
    @Override
    public OperationResult invokeOperation(String name, Configuration configuration) throws Exception {

        OperationResult result = new OperationResult();

        String arguments = configuration.getSimpleValue(OPERATION_PARAM_ARGUMENTS, null);
        String waitTimeStr = configuration.getSimpleValue(OPERATION_PARAM_WAIT_TIME, null);
        String captureOutputStr = configuration.getSimpleValue(OPERATION_PARAM_CAPTURE_OUTPUT, null);
        String killOnTimeoutStr = configuration.getSimpleValue(OPERATION_PARAM_KILL_ON_TIMEOUT, null);

        long waitTime;
        boolean captureOutput;
        boolean killOnTimeout;

        if (waitTimeStr != null) {
            try {
                waitTime = Long.parseLong(waitTimeStr);
                waitTime *= 1000L; // the parameter is specified in seconds, but we need it in milliseconds
            } catch (NumberFormatException e) {
                throw new NumberFormatException("Wait time parameter value is invalid: " + waitTimeStr);
            }
        } else {
            waitTime = DEFAULT_MAX_WAIT_TIME;
        }

        captureOutput = captureOutputStr == null || Boolean.parseBoolean(captureOutputStr);
        killOnTimeout = killOnTimeoutStr == null || Boolean.parseBoolean(killOnTimeoutStr);

        ProcessExecutionResults exeResults = executeExecutable(arguments, waitTime, captureOutput, killOnTimeout);
        Integer exitcode = exeResults.getExitCode();
        String output = exeResults.getCapturedOutput();
        Throwable error = exeResults.getError();

        if (error != null) {
            result.setErrorMessage(ThrowableUtil.getAllMessages(error));
        }

        Configuration resultsConfig = result.getComplexResults();
        if (exitcode != null) {
            resultsConfig.put(new PropertySimple(OPERATION_RESULT_EXITCODE, exitcode));
        }
        if (output != null) {
            resultsConfig.put(new PropertySimple(OPERATION_RESULT_OUTPUT, output.trim()));
View Full Code Here

    public void testOperation1() throws Exception {
        for (Resource jmxServer : jmxServers) {
            Set<Resource> childResources = getChildResourcesOfType(jmxServer, THREADING_RESOURCE_TYPE);
            assertEquals(childResources.size(), 1, String.valueOf(childResources));

            OperationResult operationResult = invokeOperation(childResources.iterator().next(), "threadDump",
                new Configuration());
            assertNotNull(operationResult);
            Configuration complexResults = operationResult.getComplexResults();
            assertNotNull(complexResults);
            assertTrue(isNotBlank(complexResults.getSimpleValue("totalCount")));
        }
    }
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.