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

Examples of org.rhq.core.domain.resource.group.composite.ResourceGroupComposite


        Long implicitCount = Long.valueOf(from.getAttribute("implicitCount"));
        Long implicitDown = Long.valueOf(from.getAttribute("implicitDown"));
        Long implicitUnknown = Long.valueOf(from.getAttribute("implicitUnknown"));
        Long implicitDisabled = Long.valueOf(from.getAttribute("implicitDisabled"));

        ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitUnknown,
            explicitDisabled, implicitCount, implicitDown, implicitUnknown, implicitDisabled, rg);

        return composite;
    }
View Full Code Here


            AvailabilityType newFirstAvailabilityType = oldFirstAvailabilityPoint.getAvailabilityType();
            if (context.type == EntityContext.Type.Resource) {
                newFirstAvailabilityType = getCurrentAvailabilityTypeForResource(subject, context.resourceId);

            } else if (context.type == EntityContext.Type.ResourceGroup) {
                ResourceGroupComposite composite = resourceGroupManager.getResourceGroupComposite(subject,
                    context.groupId);
                switch (composite.getExplicitAvailabilityType()) {
                case EMPTY:
                    newFirstAvailabilityType = null;
                    break;
                case DOWN:
                case WARN:
View Full Code Here

            throw new PermissionException("User[name=" + subject.getName()
                + "] does not have permission to view configuration for group[id=" + groupId + "]");
        }

        // The below call will also handle the check to see if the subject has perms to view the group.
        ResourceGroupComposite groupComposite = this.resourceGroupManager.getResourceGroupComposite(subject, groupId);

        // if the group is empty (has no members) the availability will be null
        if (0 == groupComposite.getExplicitCount()) {
            return new HashMap<Integer, Configuration>();
        }

        if (groupComposite.getExplicitDown() > 0)
            throw new Exception("Current group Resource configuration for " + groupId
                + " cannot be calculated, because one or more of this group's member Resources are DOWN.");

        // If we got this far, all member Resources are UP. Now check to make sure no config updates, group-level or
        // resource-level, are in progress.
        ResourceGroup group = groupComposite.getResourceGroup();
        ensureNoResourceConfigurationUpdatesInProgress(group);

        // If we got this far, no updates are in progress. Now try to obtain the live configs from the Agents.
        // If any of the requests for live configs fail (e.g. because an Agent is down) or if all of the live
        // configs can't be obtained within the specified timeout, this call will throw an exception.
View Full Code Here

                facets = ResourceFacets.NONE;
            } else {
                // compatible group
                facets = resourceTypeManager.getResourceFacets(type.getId());
            }
            ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitUnknown,
                explicitDisabled, implicitCount, implicitDown, implicitUnknown, implicitDisabled, group, facets);
            Set<Permission> perms = authorizationManager.getImplicitGroupPermissions(subject, group.getId());
            composite.setResourcePermission(new ResourcePermission(perms));
            results.add(composite);
        }

        return new PageList<ResourceGroupComposite>(results, (int) count, pc);
    }
View Full Code Here

        } else {
            // compatible group
            facets = resourceTypeManager.getResourceFacets(group.getResourceType().getId());
        }

        ResourceGroupComposite composite = null;
        if (((Number) data[4]).longValue() > 0) {
            long explicitCount = ((Number) data[0]).longValue();
            long explicitDown = ((Number) data[1]).longValue();
            long explicitUnknown = ((Number) data[2]).longValue();
            long explicitDisabled = ((Number) data[3]).longValue();
            long implicitCount = ((Number) data[4]).longValue();
            long implicitDown = ((Number) data[5]).longValue();
            long implicitUnknown = ((Number) data[6]).longValue();
            long implicitDisabled = ((Number) data[7]).longValue();
            // In the past we had only DOWN/0 and UP/1 avails/ordinal and and the avails were just averages.
            // Now we have DISABLED and UNKNOWN. So group avail is done differently, instead of a ratio of
            // of UP vs DOWN it is now handled with counts. This is handled in the composite.

            composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitUnknown, explicitDisabled,
                implicitCount, implicitDown, implicitUnknown, implicitDisabled, group, facets);
        } else {
            composite = new ResourceGroupComposite(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, group, facets);
        }

        return composite;
    }
View Full Code Here

            // the permissions are already set by the query projection
            break;
        case SUBJECT_OWNED:
            Iterator<ResourceGroupComposite> iterator = groupComposites.iterator();
            while (iterator.hasNext()) {
                ResourceGroupComposite groupComposite = iterator.next();
                ResourceGroup group = groupComposite.getResourceGroup();
                Subject groupOwner = group.getSubject();
                if (null != groupOwner) {
                    // private group, we need to set the group resource permissions since we couldn't do it in
                    // the projection.
                    groupComposite.setResourcePermission(new ResourcePermission(authorizationManager
                        .getExplicitGroupPermissions(groupOwner, group.getId())));
                } else {
                    throw new IllegalStateException("Unexpected group, not subject owned: " + groupComposite);
                }
            }
View Full Code Here

                            MSG.view_titleBar_group_failInfo(group.getName(),
                                String.valueOf(ResourceGroupTitleBar.this.group.getId())));
                        return;
                    }

                    ResourceGroupComposite resultComposite = result.get(0);
                    setGroupIcons(resultComposite);

                    // Localize the default group name for an AutoCluster with disparate members (see setGroup()).
                    if (isAutoCluster) {
                        resultComposite.getResourceGroup().setName(group.getName());
                    }

                    generalProperties = new GeneralProperties(resultComposite, ResourceGroupTitleBar.this,
                        (!(isAutoGroup || isAutoCluster)));
                    generalProperties.setVisible(false);
View Full Code Here

        return record;
    }

    @Override
    protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
        final ResourceGroupComposite groupComposite = this.groupComposite;
        final ResourceGroup group = groupComposite.getResourceGroup();
        // Load the fully fetched ResourceType.
        ResourceType groupType = group.getResourceType();
        ResourceTypeRepository.Cache.getInstance().getResourceTypes(
            groupType.getId(),
            EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations,
View Full Code Here

            lgeWithTypes = env.get(0);
        }

        ResourceGroupCriteria criteria;
        PageList<ResourceGroupComposite> pageList;
        ResourceGroupComposite groupComp;
        long start;

        // test findResourceGroupCompositesByCriteria
        for (int i = 0; i < groupAvailCounts.size(); i++) {
            LargeGroupEnvironment lge = env.get(i);
            GroupAvailCounts gac = groupAvailCounts.get(i);

            SessionTestHelper.simulateLogin(lge.normalSubject);
            criteria = new ResourceGroupCriteria();
            start = System.currentTimeMillis();
            pageList = groupManager.findResourceGroupCompositesByCriteria(lge.normalSubject, criteria);
            System.out.println("findResourceGroupCompositesByCriteria #" + i + "==>"
                + (System.currentTimeMillis() - start) + "ms");
            assert pageList.size() == 1 : "the query should only have selected the one group for our user";
            groupComp = pageList.get(0);
            System.out.println("-->" + groupComp);
            assert groupComp.getExplicitCount() == gac.visibleTotal;
            assert groupComp.getExplicitCount() == groupComp.getImplicitCount(); // we aren't testing recursive groups
            assert groupComp.getExplicitUp() == gac.up;
            assert groupComp.getExplicitDown() == gac.down;
            assert groupComp.getExplicitUnknown() == gac.unknown;
            assert groupComp.getExplicitDisabled() == gac.disabled;

            // mainly to help test when there are uncommitted resources in the group - see BZ 820981
            Resource committed = pickAResourceWithInventoryStatus(lge.platformResource, InventoryStatus.COMMITTED);
            assert true == authManager.hasResourcePermission(lge.normalSubject, Permission.CONFIGURE_READ,
                Collections.singletonList(committed.getId()));
            assert false == authManager.hasResourcePermission(lge.normalSubject, Permission.CONTROL,
                Collections.singletonList(committed.getId())); // we weren't given CONTROL perms on the committed resource
            Resource uncommitted = pickAResourceWithInventoryStatus(lge.platformResource, InventoryStatus.NEW);
            if (uncommitted != null) {
                assert false == authManager.hasResourcePermission(lge.normalSubject, Permission.CONFIGURE_READ,
                    Collections.singletonList(uncommitted.getId())); // no permissions for uncommitted resource
            }
        }

        // test getResourceGroupComposite
        for (int i = 0; i < groupAvailCounts.size(); i++) {
            LargeGroupEnvironment lge = env.get(i);
            GroupAvailCounts gac = groupAvailCounts.get(i);

            SessionTestHelper.simulateLogin(lge.normalSubject);
            start = System.currentTimeMillis();
            groupComp = groupManager.getResourceGroupComposite(lge.normalSubject, lge.compatibleGroup.getId());
            System.out.println("getResourceGroupComposite #" + i + "==>" + (System.currentTimeMillis() - start) + "ms");
            System.out.println("-->" + groupComp);
            assert groupComp.getExplicitCount() == gac.visibleTotal;
            assert groupComp.getExplicitCount() == groupComp.getImplicitCount(); // we aren't testing recursive groups
            assert groupComp.getExplicitUp() == gac.up;
            assert groupComp.getExplicitDown() == gac.down;
            assert groupComp.getExplicitUnknown() == gac.unknown;
            assert groupComp.getExplicitDisabled() == gac.disabled;
        }
    }
View Full Code Here

                    } else {
                        Criteria criteria = new Criteria();
                        ResourceGroup emptyGroup = new ResourceGroup("");
                        emptyGroup.setId(-1);
                        Long zero = new Long(0);
                        groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, zero, zero, zero, zero,
                            emptyGroup);
                        groupOperations = new GroupOperationsCriteriaHistoryListView(
                            new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite,
                            isAutoGroup);
                    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.group.composite.ResourceGroupComposite

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.