Package org.rhq.core.domain.configuration.group

Examples of org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate


        return executeInTransaction(false, new TransactionCallbackReturnable<ConfigurationUpdateStatus>() {
            public ConfigurationUpdateStatus execute() throws Exception {
                try {
                    Query query = em.createNamedQuery(GroupResourceConfigurationUpdate.QUERY_FIND_LATEST_BY_GROUP_ID);
                    query.setParameter("groupId", groupId);
                    GroupResourceConfigurationUpdate latestConfigGroupUpdate = (GroupResourceConfigurationUpdate) query
                        .getSingleResult();
                    return latestConfigGroupUpdate.getStatus();
                } catch (NoResultException nre) {
                    // The group resource config history is empty, so there's obviously no update in progress.
                    return null;
                }
            }
View Full Code Here


        boolean updateInProgress;
        try {
            Query query = entityManager
                .createNamedQuery(GroupResourceConfigurationUpdate.QUERY_FIND_LATEST_BY_GROUP_ID);
            query.setParameter("groupId", groupId);
            GroupResourceConfigurationUpdate latestConfigGroupUpdate = (GroupResourceConfigurationUpdate) query
                .getSingleResult();
            if (!authorizationManager.canViewGroup(subject, latestConfigGroupUpdate.getGroup().getId())) {
                throw new PermissionException("User [" + subject.getName()
                    + "] does not have permission to view group Resource configuration for ["
                    + latestConfigGroupUpdate.getGroup() + "]");
            }

            updateInProgress = (latestConfigGroupUpdate.getStatus() == ConfigurationUpdateStatus.INPROGRESS);
        } catch (NoResultException nre) {
            // The group resource config history is empty, so there's obviously no update in progress.
            updateInProgress = false;
        }
View Full Code Here

        if (resourceConfigUpdate.getStatus() == ConfigurationUpdateStatus.INPROGRESS) {
            // If this update isn't done, then, by definition, the group update isn't done either.
            return;
        }

        GroupResourceConfigurationUpdate groupConfigUpdate = resourceConfigUpdate.getGroupConfigurationUpdate();
        if (groupConfigUpdate == null) {
            // The update isn't part of a group update - nothing we need to do.
            return;
        }

        Query inProgressResourcesCountQuery = PersistenceUtility.createCountQuery(this.entityManager,
            ResourceConfigurationUpdate.QUERY_FIND_BY_PARENT_UPDATE_ID_AND_STATUS);
        inProgressResourcesCountQuery.setParameter("parentUpdateId", groupConfigUpdate.getId());
        inProgressResourcesCountQuery.setParameter("status", ConfigurationUpdateStatus.INPROGRESS);
        long inProgressResourcesCount = (Long) inProgressResourcesCountQuery.getSingleResult();
        if (inProgressResourcesCount == 0) {
            // No more member updates in progress - the group update is complete.
            Query failedResourcesQuery = this.entityManager
                .createNamedQuery(ResourceConfigurationUpdate.QUERY_FIND_BY_PARENT_UPDATE_ID_AND_STATUS);
            failedResourcesQuery.setParameter("parentUpdateId", groupConfigUpdate.getId());
            failedResourcesQuery.setParameter("status", ConfigurationUpdateStatus.FAILURE);
            List<Resource> failedResources = failedResourcesQuery.getResultList();
            ConfigurationUpdateStatus groupStatus;
            if (failedResources.isEmpty()) {
                groupStatus = ConfigurationUpdateStatus.SUCCESS;
            } else {
                groupStatus = ConfigurationUpdateStatus.FAILURE;
                groupConfigUpdate.setErrorMessage("The following Resources failed to update their Configurations: "
                    + failedResources);
            }
            groupConfigUpdate.setStatus(groupStatus);
            LOG.info("Group Resource configuration update [" + groupConfigUpdate.getId() + "] for "
                + groupConfigUpdate.getGroup() + " has completed with status [" + groupStatus + "].");
            // TODO: Add support for alerting on completion of group resource config updates.
            //notifyAlertConditionCacheManager("checkForCompletedGroupResourceConfigurationUpdate", groupUpdate);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Group Resource configuration update [" + groupConfigUpdate.getId() + "] for "
                    + groupConfigUpdate.getGroup() + " has " + inProgressResourcesCount
                    + " member updates still in progress.");
            }
        }
        return;
    }
View Full Code Here

         * we need to create and persist the group update in a new/separate transaction before the rest of the
         * processing of this method; if we try to create and attach the PluginConfigurationUpdate children
         * to the parent group before the group update is actually persisted, we'll get StaleStateExceptions
         * from Hibernate because of our use of flush/clear (we're trying to update it before it actually exists)
         */
        GroupResourceConfigurationUpdate groupUpdate = new GroupResourceConfigurationUpdate(group, subject.getName());
        int updateId = -1;
        try {
            updateId = configurationManager.createGroupConfigurationUpdate(groupUpdate);
        } catch (SchedulerException sche) {
            String message = "Error scheduling resource configuration update for group[id=" + group.getId() + "]";
View Full Code Here

     * @deprecated use {@link #findGroupResourceConfigurationUpdatesByCriteria(org.rhq.core.domain.auth.Subject, org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria)}
     */
    @Deprecated
    @Override
    public GroupResourceConfigurationUpdate getGroupResourceConfigurationById(int configurationUpdateId) {
        GroupResourceConfigurationUpdate update = entityManager.find(GroupResourceConfigurationUpdate.class,
            configurationUpdateId);
        return update;
    }
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public Map<Integer, Configuration> getResourceConfigurationMapForGroupUpdate(Subject subject,
        Integer groupResourceConfigurationUpdateId) {
        // this method will perform the CONFIGURE_READ security check for us, no need to keep reference to result
        GroupResourceConfigurationUpdate groupResourceConfigurationUpdate = getGroupResourceConfigurationUpdate(
            subject, groupResourceConfigurationUpdateId);

        Tuple<String, Object> groupIdParameter = new Tuple<String, Object>("groupConfigurationUpdateId",
            groupResourceConfigurationUpdateId);
        Map<Integer, Configuration> results = executeGetConfigurationMapQuery(
            Configuration.QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_UPDATE_ID, 100, groupIdParameter);

        // Mask the configurations before returning them.
        for (Configuration configuration : results.values()) {
            configuration.getMap().size();
        }
        ConfigurationDefinition configurationDefinition = getResourceConfigurationDefinitionForResourceType(
            subjectManager.getOverlord(), groupResourceConfigurationUpdate.getGroup().getResourceType().getId());
        // We do not want the masked configurations persisted, so detach all entities before masking the configurations.
        entityManager.clear();
        for (Configuration configuration : results.values()) {
            ConfigurationMaskingUtility.maskConfiguration(configuration, configurationDefinition);
        }
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public ConfigurationUpdateStatus updateGroupResourceConfigurationUpdateStatus(
        int groupResourceConfigurationUpdateId, String errorMessages) {
        GroupResourceConfigurationUpdate groupResourceConfigUpdate = configurationManager
            .getGroupResourceConfigurationById(groupResourceConfigurationUpdateId);

        // NOTE: None of the individual updates should still be INPROGRESS at the time this method is called!
        Query query = entityManager.createNamedQuery(ResourceConfigurationUpdate.QUERY_FIND_STATUS_BY_PARENT_UPDATE_ID);
        query.setParameter("groupConfigurationUpdateId", groupResourceConfigUpdate.getId());
        List<ConfigurationUpdateStatus> updateStatusTuples = query.getResultList();

        return completeGroupConfigurationUpdate(groupResourceConfigUpdate, updateStatusTuples, errorMessages);
    }
View Full Code Here

                // break the resource configuration update links in order to preserve individual change history
                Query q = entityManager.createNamedQuery(ResourceConfigurationUpdate.QUERY_DELETE_GROUP_UPDATE);
                q.setParameter("arcuId", arcuId);
                q.executeUpdate();

                GroupResourceConfigurationUpdate update = getGroupResourceConfigurationById(arcuId);
                entityManager.remove(update);
                removed++;
            } catch (Exception e) {
                LOG.error("Problem removing group resource configuration update", e);
            }
View Full Code Here

    }

    @Override
    public GroupResourceConfigurationUpdate getGroupResourceConfigurationUpdate(Subject subject,
        int configurationUpdateId) {
        GroupResourceConfigurationUpdate update = getGroupResourceConfigurationById(configurationUpdateId);

        int groupId = update.getGroup().getId();
        if (authorizationManager.hasGroupPermission(subject, Permission.CONFIGURE_READ, groupId) == false) {
            throw new PermissionException("User[" + subject.getName()
                + "] does not have permission to view group resourceConfiguration[id=" + configurationUpdateId + "]");
        }
View Full Code Here

    }

    @Test
    public void serializationShouldCopyGroupConfigurationUpdate() throws Exception {
        ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
        update.setGroupConfigurationUpdate(new GroupResourceConfigurationUpdate(new ResourceGroup("resourceGroup"),
            "rhqadmin"));

        ResourceConfigurationUpdate serializedUpdate = TestUtil.serializeAndDeserialize(update);

        assertEquals(
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate

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.