Package org.rhq.core.clientapi.server.configuration

Examples of org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse


        UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(null, resourceType,
            configMgmt, updateRequest);

        final NullPointerException exception = new NullPointerException("Unexpected error during update");

        final ConfigurationUpdateResponse failureResponse = new ConfigurationUpdateResponse(configUpdateId, config,
            exception);

        context.checking(new Expectations() {{
            oneOf(configMgmt).executeUpdate(resourceId, config);
            will(throwExceptionFromFacet(exception));
        }});

        ConfigurationUpdateResponse actualResponse = updateRunner.call();

        assertConfigurationUpdateResponseMatches(failureResponse, actualResponse, "Expected a failure response");
    }
View Full Code Here


     * does); instead, it will block until an update response is retrieved from the agent-side resource
     */
    @Override
    public void completePluginConfigurationUpdate(PluginConfigurationUpdate update) {
        // use EJB3 reference to ourself so that transaction semantics are correct
        ConfigurationUpdateResponse response = configurationManager.executePluginConfigurationUpdate(update);
        Resource resource = update.getResource();

        // link to the newer, persisted configuration object -- regardless of errors
        resource.setAgentSynchronizationNeeded();
        resource.setPluginConfiguration(update.getConfiguration());

        if (response.getStatus() == ConfigurationUpdateStatus.SUCCESS) {
            update.setStatus(ConfigurationUpdateStatus.SUCCESS);

            resource.setConnected(true);

            removeAnyExistingInvalidPluginConfigurationErrors(resource);
            // Flush before merging to ensure the update has been persisted and avoid StaleStateExceptions.
            entityManager.flush();
            entityManager.merge(update);

        } else {
            handlePluginConfiguratonUpdateRemoteException(resource, response.getStatus().toString(),
                response.getErrorMessage());

            update.setStatus(response.getStatus());
            update.setErrorMessage(response.getErrorMessage());
        }
    }
View Full Code Here

    public ConfigurationUpdateResponse executePluginConfigurationUpdate(PluginConfigurationUpdate update) {
        Resource resource = update.getResource();
        Configuration configuration = update.getConfiguration();
        configuration = configuration.deepCopy(false);

        ConfigurationUpdateResponse response = null;

        try {
            // now let's tell the agent to actually update the resource component's plugin configuration
            AgentClient agentClient = this.agentManager.getAgentClient(resource.getAgent());

            agentClient.getDiscoveryAgentService().updatePluginConfiguration(resource.getId(), configuration);
            try {
                agentClient.getDiscoveryAgentService().executeServiceScanDeferred(resource.getId());
            } catch (Exception e) {
                LOG.warn("Failed to execute service scan - cannot detect children of the newly connected resource ["
                    + resource + "]", e);
            }

            response = new ConfigurationUpdateResponse(update.getId(), null, ConfigurationUpdateStatus.SUCCESS, null);
        } catch (Exception e) {
            response = new ConfigurationUpdateResponse(update.getId(), null, e);
        }

        return response;
    }
View Full Code Here

            getThreadPool().submit(runnable);
        } catch (PluginContainerException e) {
            log.error("Failed to submit config update task. Cause: " + e);

            if (configurationServerService != null) {
                ConfigurationUpdateResponse error;

                error = new ConfigurationUpdateResponse(request.getConfigurationUpdateId(), request.getConfiguration(),
                    e);

                configurationServerService.completeConfigurationUpdate(error);
            }
        }
View Full Code Here

        return;
    }

    public ConfigurationUpdateResponse executeUpdateResourceConfigurationImmediately(ConfigurationUpdateRequest request)
        throws PluginContainerException {
        ConfigurationUpdateResponse response;

        try {
            ConfigurationServerService configurationServerService = getConfigurationServerService();
            ResourceType resourceType = getResourceType(request.getResourceId());
View Full Code Here

            log.error("Error while chaining run to call", e);
        }
    }

    public ConfigurationUpdateResponse call() throws Exception {
        ConfigurationUpdateResponse response;
        int requestId = request.getConfigurationUpdateId();
        try {
            response = new ConfigurationUpdateResponse(requestId, request.getConfiguration(), SUCCESS, null);
            try {
                configMgmt.executeUpdate(request.getResourceId(), request.getConfiguration());
            } catch (UpdateInProgressException e) {
                response.setStatus(INPROGRESS);
                response.setErrorMessage("Configuration facet did not indicate success or failure - assuming failure.");
            } catch (ConfigurationUpdateException e) {
                response.setStatus(FAILURE);
                response.setErrorMessage(e.getMessage());
            }

            ConfigurationDefinition configurationDefinition = resourceType.getResourceConfigurationDefinition();

            // Normalize and validate the config.
            configUtilService.normalizeConfiguration(response.getConfiguration(), configurationDefinition);
            List<String> errorMessages = configUtilService.validateConfiguration(response.getConfiguration(),
                configurationDefinition);
            for (String errorMessage : errorMessages) {
                log.warn("Plugin Error: Invalid " + resourceType.getName() + " Resource configuration returned by "
                    + resourceType.getPlugin() + " plugin - " + errorMessage);
            }

            // If it was successful, there is no need to waste bandwidth and send back the entire configuration again.
            // Just set it to null - the remote client will see it was a success and assume the configuration that was
            // saved is the same configuration that was passed in via the request.
            if (response.getStatus() == ConfigurationUpdateStatus.SUCCESS) {
                response.setConfiguration(null);
            }
        } catch (Throwable t) {
            log.error("Plugin Error: Exception thrown while updating Resource configuration for "
                    + resourceType.getName() + " Resource with id [" + request.getResourceId() + "].", t);
            response = new ConfigurationUpdateResponse(requestId, request.getConfiguration(), t);           
        }

        if (this.configurationServerService != null) {
            this.configurationServerService.completeConfigurationUpdate(response);
        }
View Full Code Here

            try {
                Configuration configUnderTest = configManager.loadResourceConfiguration(resource.getId());

                ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(1, configUnderTest,
                    resource.getId());
                ConfigurationUpdateResponse updateResponse = configManager
                    .executeUpdateResourceConfigurationImmediately(updateRequest);

                if (updateResponse == null) {
                    log.error("------------------------------");
                    log.error(resource);
                    log.error("Update Response is NULL!!!!");
                    log.error("------------------------------\n");
                }
                if (updateResponse.getErrorMessage() != null) {
                    log.error("------------------------------");
                    log.error(resource);
                    log.error(updateResponse.getErrorMessage());
                    log.error("------------------------------\n");
                }
            } catch (Exception e) {
                log.error(resource, e);
            }
View Full Code Here

        Long currentMaxPoolSize = propertySimple.getLongValue();
        long newMaxPoolSize = currentMaxPoolSize == null ? 40 : currentMaxPoolSize + 1;
        propertySimple.setStringValue(String.valueOf(newMaxPoolSize));
        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());
        assertTrue(Boolean.parseBoolean(configuration.getSimpleValue("enabled")), "");
        assertEquals(configuration.getSimple("max-pool-size").getLongValue(), Long.valueOf(newMaxPoolSize));
        assertFalse(
View Full Code Here

        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));
View Full Code Here

        newProp.put(new PropertySimple("name", "Hulla"));
        newProp.put(new PropertySimple("value", "Hopp"));
        starList.add(newProp);

        ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1, config, getServerResource().getId());
        ConfigurationUpdateResponse response = pluginContainer.getConfigurationManager()
            .executeUpdateResourceConfigurationImmediately(request);
        assert response != null;
        assert response.getErrorMessage() == null : "Adding a property resulted in this error: "
            + response.getErrorMessage();

        config = loadResourceConfiguration(getServerResource());
        starList = (PropertyList) config.get("*2");
        List<Property> propertyList = starList.getList();
        for (Property prop : propertyList) {
View Full Code Here

TOP

Related Classes of org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse

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.