Examples of OperationDefinition


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

        if (operationId <= 0) {
            operationId = Integer.valueOf(operationSelectItem.getValue().toString());
        }

        OperationDefinition def = ops.get(operationId);
        if (def != null) {
            ConfigurationDefinition paramDef = def.getParametersConfigurationDefinition();
            if (paramDef != null) {
                Configuration extraConfig = getExtraConfiguration();
                if (extraConfig == null) {
                    extraConfig = new Configuration();
                    setExtraConfiguration(extraConfig);
View Full Code Here

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

                }

                String operationName = cond.getName();
                OperationManagerLocal operationManager = LookupUtil.getOperationManager();

                OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName(
                    resourceTypeId, operationName, false);
                textValue.append(definition.getDisplayName()).append(' ');
            } catch (Exception e) {
                textValue.append(cond.getName()).append(' ');
            }
        } else if (category == AlertConditionCategory.RESOURCE_CONFIG) {
            textValue.append(RequestUtils.message(request, "alert.config.props.CB.Content.ResourceConfiguration"))
View Full Code Here

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

        resourceType.addMetricDefinition(measurement);

        ConfigurationDefinition params = new ConfigurationDefinition("dummy", null);
        params.put(new PropertyDefinitionSimple("parameter", null, true, PropertySimpleType.BOOLEAN));

        OperationDefinition operation = new OperationDefinition(resourceType, "operation");
        operation.setDisplayName("operation");
        operation.setParametersConfigurationDefinition(params);

        resourceType.addOperationDefinition(operation);

        getEntityManager().persist(resourceType);
View Full Code Here

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

        GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil.getGroupAlertDefinitionManager();

        Subject subject = RequestUtils.getSubject(request);
        AlertDefinition alertDefinition = AlertDefUtil.getAlertDefinition(request);

        OperationDefinition operationDefinition = null;

        if (selectedOperation.equals(EventConstants.CONTROL_ACTION_NONE) == false) {
            Integer operationId = Integer.parseInt(selectedOperation);

            operationDefinition = operationManager.getOperationDefinition(subject, operationId);
View Full Code Here

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

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

                + 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

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

        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

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

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

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

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

            return "<unknown selection mode>";
        }
    }

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

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

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