Package org.rhq.core.domain.operation

Examples of org.rhq.core.domain.operation.OperationDefinition


    }

    @Test(dependsOnMethods = { "changingMaxPoolSizeShouldNotRequireDisablingTheDatasourceNorReloadingServer" })
    public void disableWithRestartThenChangeThenEnableShouldNotRequireReload() throws Exception {
        // First disable datasource (allow service restart)
        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
        Configuration configuration = pluginContainer.getConfigurationManager().loadResourceConfiguration(
            datasourceTestResource.getId());
        assertFalse(Boolean.parseBoolean(configuration.getSimpleValue("enabled")), "");
        // Make a working copy
        configuration = configuration.deepCopy(false);
        // Change values
        PropertySimple propertySimple = configuration.getSimple("prepared-statements-cache-size");
        Long currentCacheSize = propertySimple.getLongValue();
        long newCacheSize = currentCacheSize == null ? 40 : currentCacheSize + 1;
        propertySimple.setStringValue(String.valueOf(newCacheSize));
        PropertyList connectionPropertiesListWrapper = configuration.getList("*1");
        assertNotNull(connectionPropertiesListWrapper, "Connection properties list wrapper is null");
        List<Property> connectionPropertiesList = connectionPropertiesListWrapper.getList();
        connectionPropertiesList.add(new PropertyMap("*:pname", new PropertySimple("pname", "pipo"),
            new PropertySimple("value", "molo")));
        ConfigurationUpdateRequest configurationUpdateRequest = new ConfigurationUpdateRequest(-1, configuration,
            datasourceTestResource.getId());
        ConfigurationUpdateResponse configurationUpdateResponse = pluginContainer.getConfigurationManager()
            .executeUpdateResourceConfigurationImmediately(configurationUpdateRequest);
        assertSame(configurationUpdateResponse.getStatus(), ConfigurationUpdateStatus.SUCCESS);
        configuration = pluginContainer.getConfigurationManager().loadResourceConfiguration(
            datasourceTestResource.getId());
        assertFalse(Boolean.parseBoolean(configuration.getSimpleValue("enabled")), "");
        assertEquals(configuration.getSimple("prepared-statements-cache-size").getLongValue(),
            Long.valueOf(newCacheSize));
        connectionPropertiesListWrapper = configuration.getList("*1");
        assertNotNull(connectionPropertiesListWrapper, "Connection properties list wrapper is null");
        connectionPropertiesList = connectionPropertiesListWrapper.getList();
        String connectionPropertyValue = null;
        for (Property property : connectionPropertiesList) {
            assertTrue(property instanceof PropertyMap, "Connection properties should be a list of maps");
            PropertyMap propertyMap = (PropertyMap) property;
            String pname = propertyMap.getSimpleValue("pname", null);
            assertNotNull(pname, "Connection property key is null");
            String value = propertyMap.getSimpleValue("value", null);
            assertNotNull(value, "Connection property value is null");
            if ("pipo".equals(pname)) {
                connectionPropertyValue = value;
                break;
            }
        }
        assertEquals(connectionPropertyValue, "molo");
        assertFalse(
            configuration.getNames().contains("__OOB"),
            "The configuration object should not contain out of band messages: "
                + configuration.getSimpleValue("__OOB"));

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


                + configuration.getSimpleValue("__OOB"));
    }

    private OperationDefinition getOperationDefinition(String operationName) {
        Set<OperationDefinition> operationDefinitions = datasourceResourceType.getOperationDefinitions();
        OperationDefinition operationDefinition = null;
        for (OperationDefinition opDef : operationDefinitions) {
            if (opDef.getName().equals(operationName)) {
                operationDefinition = opDef;
                break;
            }
View Full Code Here

        try {
            if (operationHistory instanceof ResourceOperationHistory) {
                ResourceOperationHistory resourceOperationHistory = (ResourceOperationHistory) operationHistory;

                Resource resource = resourceOperationHistory.getResource();
                OperationDefinition operationDefinition = resourceOperationHistory.getOperationDefinition();
                OperationRequestStatus operationStatus = resourceOperationHistory.getStatus();

                List<ResourceOperationCacheElement> cacheElements = lookupResourceOperationHistoryCacheElements(
                    resource.getId(), operationDefinition.getId());

                processCacheElements(cacheElements, operationStatus, resourceOperationHistory.getModifiedTime(), stats);
            } else {
                if (log.isDebugEnabled())
                    log.debug(getClass().getSimpleName() + " does not support checking conditions against "
View Full Code Here

        if (errorInfo != null) {
            return errorInfo;
        }

        String resourceInfo = getResourceInfo();
        OperationDefinition operation = getOperationDefinition();
        return "'" + operation.getDisplayName() + "' on " + resourceInfo;
    }
View Full Code Here

            return "<unknown selection mode>";
        }
    }

    public OperationDefinition getOperationDefinition() {
        OperationDefinition operation = LookupUtil.getOperationManager().getOperationDefinition(getOverlord(),
            operationId);
        return operation;
    }
View Full Code Here

            return SenderResult.getSimpleFailure(info.error);
        }

        Subject subject = LookupUtil.getSubjectManager().getOverlord(); // TODO get real subject for authz?

        OperationDefinition operation = info.getOperationDefinition();
        Configuration parameters = info.getArguments();

        Resource targetResource = null;
        try {
            targetResource = info.getTargetResource(alert);
        } catch (Throwable t) {
            String message = getResultMessage(info, "could not calculate which resources to execute the operation on: "
                + t.getMessage());
            return SenderResult.getSimpleFailure(message);
        }

        Configuration replacedParameters = null;
        try {
            if (parameters != null) {
                // the parameter-replaced configuration object will be persisted separately from the original
                replacedParameters = parameters.deepCopy(false);

                AlertTokenReplacer replacementEngine = new AlertTokenReplacer(alert, operation, targetResource);
                for (PropertySimple simpleProperty : replacedParameters.getSimpleProperties().values()) {
                    String temp = simpleProperty.getStringValue();
                    if (temp == null) {
                        continue; // do not process 'UNSET' properties
                    }
                    temp = replacementEngine.replaceTokens(temp);
                    simpleProperty.setStringValue(temp);
                }
            }
        } catch (Exception e) {
            String message = getResultMessage(info, "parameterized argument replacement failed with " + e.getMessage());
            return SenderResult.getSimpleFailure(message);
        }

        // Now fire off the operation with no delay and no repetition.
        try {
            String description = "Alert operation for " + alert.getAlertDefinition().getName();
            ResourceOperationSchedule schedule = LookupUtil.getOperationManager().scheduleResourceOperation(subject,
                targetResource.getId(), operation.getName(), 0, 0, 0, 0, replacedParameters, description);
            String message = getResultMessage(info, getHyperLinkForOperationSchedule(subject, targetResource.getId(),
                operation.getName(), schedule.getJobId()));
            return SenderResult.getSimpleDeffered(message);
        } catch (Throwable t) {
            String message = getResultMessage(info, "invocation failed with " + t.getMessage());
            return SenderResult.getSimpleFailure(message);
        }
View Full Code Here

    protected Canvas buildResultsSection(ResourceOperationHistory operationHistory) {
        OperationRequestStatus status = operationHistory.getStatus();
        if (status == OperationRequestStatus.SUCCESS || status == OperationRequestStatus.FAILURE) {
            EnhancedVLayout resultsSection = new EnhancedVLayout();

            OperationDefinition operationDefinition = operationHistory.getOperationDefinition();
            ConfigurationDefinition resultsConfigurationDefinition = operationDefinition
                .getResultsConfigurationDefinition();
            if (resultsConfigurationDefinition != null
                && !resultsConfigurationDefinition.getPropertyDefinitions().isEmpty()
                && operationHistory.getResults() != null) {
                ConfigurationEditor editor = new ConfigurationEditor(
                    operationDefinition.getResultsConfigurationDefinition(), operationHistory.getResults());
                editor.setPreserveTextFormatting(true);
                editor.setReadOnly(true);
                resultsSection.addMember(editor);
            } else {
                Label noResultsLabel = new Label(MSG.view_operationHistoryDetails_noResults());
View Full Code Here

            for (OperationDefinition o : resourceType.getOperationDefinitions()) {
                ordered.add(o.getDisplayName());
                definitionMap.put(o.getDisplayName(), o);
            }
            for (String displayName : ordered) {
                final OperationDefinition operationDefinition = definitionMap.get(displayName);

                MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName());
                operationItem.addClickHandler(new ClickHandler() {

                    public void onClick(MenuItemClickEvent event) {
                        String viewPath = LinkManager.getResourceTabLink(resource.getId(),
                            ResourceDetailView.Tab.Operations.NAME, "Schedules") + "/0/" + operationDefinition.getId();
                        CoreGUI.goToView(viewPath);
                    }
                });
                opSubMenu.addItem(operationItem);
            }
View Full Code Here

        Resource resource = newResource;

        assert operationManager.isResourceOperationSupported(overlord(), resource.getId());
        assert operationManager.isGroupOperationSupported(overlord(), newGroup.getId());

        OperationDefinition op;
        List<OperationDefinition> ops;

        // need to eager load the definition because .equals compares the resource type objects
        op = operationManager.getSupportedGroupOperation(overlord(), newGroup.getId(), PREFIX + "testOp", true);
        assert op != null;
        assert op.getId() > 0;
        assert op.getName().equals(PREFIX + "testOp");
        assert op.equals(newOperation);

        // need to eager load the definition because .equals compares the resource type objects
        ops = operationManager.findSupportedGroupOperations(overlord(), newGroup.getId(), true);
        assert ops != null;
        assert ops.size() == 1;
        op = ops.iterator().next();
        assert op != null;
        assert op.getId() > 0;
        assert op.getName().equals(PREFIX + "testOp");
        assert op.equals(newOperation);

        // need to eager load the definition because .equals compares the resource type objects
        op = operationManager.getSupportedResourceOperation(overlord(), newResource.getId(), PREFIX + "testOp", true);
        assert op != null;
        assert op.getId() > 0;
        assert op.getName().equals(PREFIX + "testOp");
        assert op.equals(newOperation);

        // need to eager load the definition because .equals compares the resource type objects
        ops = operationManager.findSupportedResourceOperations(overlord(), newResource.getId(), true);
        assert ops != null;
        assert ops.size() == 1;
        op = ops.iterator().next();
        assert op != null;
        assert op.getId() > 0;
        assert op.getName().equals(PREFIX + "testOp");
        assert op.equals(newOperation);
    }
View Full Code Here

        try {
            ResourceType resourceType = new ResourceType(PREFIX + "platformType", PREFIX + "plugin",
                ResourceCategory.PLATFORM, null);

            OperationDefinition def = new OperationDefinition(resourceType, PREFIX + "testOp");
            def.setTimeout(10);
            def.setDisplayName("Test Operation");
            resourceType.addOperationDefinition(def);

            em.persist(resourceType);

            Agent agent = new Agent(PREFIX + "agent", PREFIX + "address", 1, "", PREFIX + "token");
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.operation.OperationDefinition

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.