Package org.rhq.core.pluginapi.operation

Examples of org.rhq.core.pluginapi.operation.OperationFacet.invokeOperation()


        long timeoutMillis = timeout * 1000;
        OperationFacet operationFacet = resourceContainer.createResourceComponentProxy(OperationFacet.class,
            FacetLockType.WRITE, timeoutMillis, false, false, false);
        OperationResult operationResult;
        try {
            operationResult = operationFacet.invokeOperation(operationName, params);
        } catch (Exception e) {
            String paramsString = (params != null) ? params.toString(true) : String.valueOf(params);
            System.out.println("====== Error occurred during invocation of operation [" + operationName
                + "] with parameters [" + paramsString + "] on " + resource + ": " + e);
            e.printStackTrace(System.out);
View Full Code Here


    public void testInterruptedComponentInvocationContext() throws Exception {
        ResourceContainer resourceContainer = getResourceContainer();
        OperationFacet proxy = resourceContainer.createResourceComponentProxy(OperationFacet.class,
            FacetLockType.WRITE, SECONDS.toMillis(1L), true, false, true);
        try {
            proxy.invokeOperation("op", new Configuration());
            fail("Expected invokeOperation to throw a TimeoutException");
        } catch (TimeoutException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Caught expected TimeoutException: " + e.getMessage());
            }
View Full Code Here

    public void testUninterruptedComponentInvocationContext() throws Exception {
        ResourceContainer resourceContainer = getResourceContainer();
        OperationFacet proxy = resourceContainer.createResourceComponentProxy(OperationFacet.class,
            FacetLockType.WRITE, SECONDS.toMillis(10L), true, false, true);
        try {
            OperationResult op = proxy.invokeOperation("op", new Configuration());
            assertTrue(op.getSimpleResult().equals(MockResourceComponent.OPERATION_RESULT));
        } catch (Exception e) {
            fail("Caught unexpected Exception: " + e.getClass().getName());
            assertFalse(((MockResourceComponent) resourceContainer.getResourceComponent())
                    .caughtInterruptedComponentInvocation());
View Full Code Here

        OperationDefinition disableOperation = getOperationDefinition("disable");
        Configuration disableOperationParams = disableOperation.getParametersConfigurationDefinition()
            .getDefaultTemplate().createConfiguration();
        disableOperationParams.setSimpleValue("allow-resource-service-restart", TRUE.toString());
        OperationFacet operationFacet = getOperationFacet(datasourceTestResource);
        OperationResult operationResult = operationFacet.invokeOperation(disableOperation.getName(),
            disableOperationParams);
        assertNull(operationResult.getErrorMessage(),
            "Disable operation failed with error: " + operationResult.getErrorMessage());

        // Then update properties which can only be changed when datasource is in disabled state
View Full Code Here

        // Now re-enable datasource
        OperationDefinition enableOperation = getOperationDefinition("enable");
        Configuration enableOperationParams = enableOperation.getParametersConfigurationDefinition()
            .getDefaultTemplate().createConfiguration();
        operationResult = operationFacet.invokeOperation(enableOperation.getName(), enableOperationParams);
        assertNull(operationResult.getErrorMessage(),
            "Enable operation failed with error: " + operationResult.getErrorMessage());

        // Check server state
        configuration = pluginContainer.getConfigurationManager().loadResourceConfiguration(
View Full Code Here

    public static OperationResult invokeOperation(Resource resource, String operationName, Configuration parameters)
        throws Exception {

        OperationFacet operationFacet = getResourceComponentFacet(resource, OperationFacet.class);
        OperationResult operationResult = operationFacet.invokeOperation(operationName, parameters);

        if (operationResult != null && operationResult.getErrorMessage() != null) {
            fail("Operation (" + operationName + ") failed : " + operationResult.getErrorMessage());
        }
        return operationResult;
View Full Code Here

        for (Resource resource : resources) {
            OperationFacet operationFacet = getOperationFacet(resource);
            Configuration parameters = new Configuration();
            parameters.setSimpleValue("batchSize", "50");
            parameters.setSimpleValue("managementQueryTimeout", "180");
            OperationResult operationResult = operationFacet.invokeOperation("viewQueries", parameters);
            String errorMessage = operationResult.getErrorMessage();
            assertNull(errorMessage, errorMessage);
            Configuration complexResults = operationResult.getComplexResults();
            assertNotNull(complexResults, "ComplexResults is null");
            PropertyList queriesPropList = complexResults.getList("queries");
View Full Code Here

                    //the 3 seconds to finish. Otherwise all the operations would have to finish in 3 secs
                    //which can be a bit harsh limit.
                    OperationFacet operationFacet = ComponentUtil.getComponent(resource.getId(), OperationFacet.class,
                        FacetLockType.WRITE, OPERATION_FACET_METHOD_TIMEOUT, true, true, true);
                    //String name = operationDefinition.getName();
                    OperationResult result = operationFacet.invokeOperation(name, getTestOperationParameters(name));
                    System.out.println("Validating operation '" + name + "' result (" + result + ")...");
                    validateOperationResult(name, result, resource);
                }
            }
        }
View Full Code Here

            if (resource.getName().equals(getDestinationName())) {
                foundDestination = true;
                OperationFacet operationFacet = ComponentUtil.getComponent(resource.getId(), OperationFacet.class,
                    FacetLockType.WRITE, 3000, true, true, true);
                String name = "removeAllMessages";
                operationFacet.invokeOperation(name, getTestOperationParameters(name));
            }
        }
        if (!foundDestination)
            throw new Exception("cannot find " + getDestinationName());
        Thread.sleep(4000);
View Full Code Here

            true, true, true);

        for (OperationDefinition operationDefinition : operationDefinitions) {
          String name = operationDefinition.getName();

          OperationResult result = operationFacet.invokeOperation(
              name, new Configuration());

          log.info("Validating operation '" + name + "' result ("
              + result + ")...");
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.