Package org.rhq.core.domain.resource.group

Examples of org.rhq.core.domain.resource.group.ResourceGroup


    @Override
    public Map<Integer, Configuration> getPluginConfigurationsForCompatibleGroup(Subject subject, int groupId)
        throws ConfigurationUpdateStillInProgressException, Exception {
        // The below call will also handle the check to see if the subject has perms to view the group.
        ResourceGroup group = this.resourceGroupManager
            .getResourceGroupById(subject, groupId, GroupCategory.COMPATIBLE);

        // Check to make sure no config updates, group-level or resource-level, are in progress.
        ensureNoPluginConfigurationUpdatesInProgress(group);

        // If we got this far, no updates are in progress, so go ahead and load the plugin configs from the DB.
        Map<Integer, Configuration> currentPersistedConfigs = getPersistedPluginConfigurationsForCompatibleGroup(group);

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


        long startTime = System.currentTimeMillis();

        GroupDefinition groupDefinition = getById(groupDefinitionId);

        String groupByClause = result.getGroupByClause();
        ResourceGroup resourceGroup = resourceGroupManager.getByGroupDefinitionAndGroupByClause(
            groupDefinition.getId(), groupByClause);
        int resourceGroupId = 0;
        if (resourceGroup == null) {
            String newDynamicGroupName = getDynamicGroupName(groupDefinition.getName(), groupByClause);

            resourceGroup = new ResourceGroup(newDynamicGroupName);
            resourceGroupId = resourceGroupManager.createResourceGroup(overlord, resourceGroup).getId();

            resourceGroup.setRecursive(groupDefinition.isRecursive());
            resourceGroup.setGroupByClause(groupByClause);
            groupDefinition.addResourceGroup(resourceGroup);
        } else {
            resourceGroupId = resourceGroup.getId();
        }

        /*
         * group additions/deletions are actions made to the explicit group, the implicit group is modified (based on
         * the recursive bit) by the existing code in the resourceGroupManager
         *
         * use resourceManager.getExplicitResourceIdsByResourceGroup instead of resourceGroup.getExplicitResources to keep
         * the data we need to pull across the line from the database as small as possible
         */
        Collection<Integer> existingResourceIds = resourceManager.findExplicitResourceIdsByResourceGroup(resourceGroup
            .getId());

        Set<Integer> idsToAdd = new HashSet<Integer>(result.getData());
        idsToAdd.removeAll(existingResourceIds);

View Full Code Here

        if (memberPluginConfigurations == null) {
            throw new IllegalArgumentException(
                "GroupPluginConfigurationUpdate must have non-null member configurations.");
        }

        ResourceGroup group = getCompatibleGroupIfAuthorized(subject, compatibleGroupId);

        ensureModifyResourcePermission(subject, group);

        /*
         * we need to create and persist the group 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
         * actually exists)
         */
        GroupPluginConfigurationUpdate groupUpdate = new GroupPluginConfigurationUpdate(group, subject.getName());
        int updateId = -1;
        try {
            updateId = configurationManager.createGroupConfigurationUpdate(groupUpdate);
        } catch (SchedulerException sche) {
            String message = "Error scheduling plugin configuration update for group[id=" + group.getId() + "]";
            LOG.error(message, sche);
            throw new ResourceGroupUpdateException(message + ": " + sche);
        }

        // Create and persist updates for each of the members.
View Full Code Here

    @RequiredPermission(Permission.MANAGE_INVENTORY)
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void removeManagedResource_helper(Subject overlord, int groupDefinitionId, Integer doomedGroupId)
        throws GroupDefinitionDeleteException, GroupDefinitionNotFoundException {
        GroupDefinition groupDefinition = getById(groupDefinitionId);
        ResourceGroup doomedGroup = entityManager.getReference(ResourceGroup.class, doomedGroupId);
        groupDefinition.removeResourceGroup(doomedGroup);

        try {
            /*
             * using the group manager's delete method ensures that auditing data,
             * such as completed operations, is correctly removed
             */
            resourceGroupManager.deleteResourceGroup(subjectManager.getOverlord(), doomedGroupId);
        } catch (Exception e) {
            throw new GroupDefinitionDeleteException("Error removing managedGroup '" + doomedGroup.getName() + "' "
                + "from groupDefinition '" + groupDefinition.getName() + "': ", e);
        }
    }
View Full Code Here

        if (newResourceConfigurationMap == null) {
            throw new IllegalArgumentException(
                "GroupResourceConfigurationUpdate must have non-null member configurations.");
        }

        ResourceGroup group = getCompatibleGroupIfAuthorized(subject, compatibleGroupId);

        if (!authorizationManager.hasGroupPermission(subject, Permission.CONFIGURE_WRITE, group.getId())) {
            throw new PermissionException("User [" + subject.getName() + "] does not have permission "
                + "to modify Resource configurations for members of group [" + group + "].");
        }

        ensureNoResourceConfigurationUpdatesInProgress(group);

        /*
         * 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() + "]";
            LOG.error(message, sche);
            throw new ResourceGroupUpdateException(message + ": " + sche);
        }

        // Create and persist updates for each of the members.
View Full Code Here

        return updateId;
    }

    private ResourceGroup getCompatibleGroupIfAuthorized(Subject subject, int compatibleGroupId) {
        ResourceGroup group;

        try {
            // resourceGroupManager will test for necessary permissions too
            group = resourceGroupManager.getResourceGroupById(subject, compatibleGroupId, GroupCategory.COMPATIBLE);
        } catch (ResourceGroupNotFoundException e) {
View Full Code Here

        }

        @Override
        public PageList<GroupOperationHistory> fetchPage(PageControl pc) {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            ResourceGroup requestGroup = EnterpriseFacesContextUtility.getResourceGroup();
            OperationManagerLocal manager = LookupUtil.getOperationManager();

            if (requestGroup == null) {
                requestGroup = resourceGroup; // request not associated with a resource - use the resource we used before
            } else {
View Full Code Here

        }

        @Override
        public PageList<GroupOperationHistory> fetchPage(PageControl pc) {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            ResourceGroup requestGroup = EnterpriseFacesContextUtility.getResourceGroup();
            OperationManagerLocal manager = LookupUtil.getOperationManager();

            if (requestGroup == null) {
                requestGroup = resourceGroup; // request not associated with a resource - use the resource we used before
            } else {
                resourceGroup = requestGroup; // request switched the resource this UI bean is using
            }

            PageList<GroupOperationHistory> results;
            results = manager.findPendingGroupOperationHistories(subject, requestGroup.getId(), pc);
            return results;
        }
View Full Code Here

    private String nodeTitle;

    private void loadTree() {

        Integer parentGroupId = FacesContextUtility.getOptionalRequestParameter("parentGroupId", Integer.class);
        ResourceGroup parentGroup;
        if (parentGroupId != null) {
            parentGroup = groupManager.getResourceGroupById(EnterpriseFacesContextUtility.getSubject(), parentGroupId,
                GroupCategory.COMPATIBLE);
        } else {
            parentGroup = EnterpriseFacesContextUtility.getResourceGroup();
            if (parentGroup.getClusterResourceGroup() != null) {
                parentGroup = parentGroup.getClusterResourceGroup();
            }
        }

        long start = System.currentTimeMillis();
        long monitorId = HibernatePerformanceMonitor.get().start();
        List<ResourceFlyweight> resources = resourceManager.findResourcesByCompatibleGroup(EnterpriseFacesContextUtility
            .getSubject(), parentGroup.getId(), PageControl.getUnlimitedInstance());
        long end = System.currentTimeMillis();
        HibernatePerformanceMonitor.get().stop(monitorId, "ResourceGroupTree group resources");
        log.debug("Loaded  " + resources.size() + " resources by group in " + (end - start));

        start = System.currentTimeMillis();
        monitorId = HibernatePerformanceMonitor.get().start();
        List<Integer> members = resourceManager.findExplicitResourceIdsByResourceGroup(parentGroup.getId());
        end = System.currentTimeMillis();
        HibernatePerformanceMonitor.get().stop(monitorId, "ResourceGroupTree group members");
        log.debug("Loaded  " + members.size() + " members by group in " + (end - start));

        start = System.currentTimeMillis();
View Full Code Here

        }
        return null;
    }

    private boolean preopen(ResourceGroupTreeNode resourceTreeNode, CurrentSelection currentSelection, boolean setOpenState) {
        ResourceGroup currentGroup = currentSelection.resourceGroup;
        ClusterKey selectedClusterKey = currentSelection.clusterKey;
       
        boolean ret = false;
        for (ResourceGroupTreeNode child : resourceTreeNode.getChildren()) {
            if (child.getData() instanceof ClusterKey) {
                if (((ClusterKey) child.getData()).equals(selectedClusterKey)) {
                    ret = true;
                    break;
                }
            } else if (child.getData() instanceof ResourceGroup) {
                if (currentGroup.getId() == ((ResourceGroup) child.getData()).getId()) {
                    ret = true;
                    break;
                }
            }
           
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.group.ResourceGroup

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.