Examples of ResourceGroup


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

                // Create the test group
                final Subject subject = SessionTestHelper.createNewSubject(em, "testSubject");
                final Role roleWithSubject = SessionTestHelper
                    .createNewRoleForSubject(em, subject, "role with subject");
                roleWithSubject.addPermission(Permission.VIEW_RESOURCE);
                ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(em, roleWithSubject,
                    "accessible group");

                // before adding resources check for EMPTY
                List<ResourceGroupAvailability> avails;
                int groupId = group.getId();
                avails = availabilityManager.getAvailabilitiesForResourceGroup(overlord, groupId, 0, 20000L);
                assertEquals("Should have 1 EMPTY rgAvail", 1, avails.size());
                assertEquals("Should have 1 EMPTY rgAvail", GroupAvailabilityType.EMPTY, avails.get(0)
                    .getGroupAvailabilityType());
                assertEquals("Should cover whole range", 0L, avails.get(0).getStartTime().longValue());
                assertEquals("Should cover whole range", 20000L, avails.get(0).getEndTime().longValue());

                // add the resources to the group
                group.addExplicitResource(r1);
                group.addExplicitResource(r2);
                group.addExplicitResource(r3);
                em.merge(group);
                em.flush();

                avails = availabilityManager.getAvailabilitiesForResourceGroup(overlord, groupId, 5000L, 50000);
                assertEquals("Should have initial avail + 4 changes", 5, avails.size());
View Full Code Here

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

     * @return the group object if found
     * @throws org.rhq.enterprise.server.rest.StuffNotFoundException if the group is not found (or not accessible by the caller)
     * @throws BadArgumentException if a compatible group is required, but the found one is not a compatible one
     */
    protected ResourceGroup fetchGroup(int groupId, boolean requireCompatible) {
        ResourceGroup resourceGroup;
        resourceGroup = resourceGroupManager.getResourceGroup(caller, groupId);
        if (resourceGroup == null) {
            throw new StuffNotFoundException("Group with id " + groupId);
        }
        if (requireCompatible) {
            if (resourceGroup.getGroupCategory() != GroupCategory.COMPATIBLE) {
                throw new BadArgumentException("Group with id " + groupId,"it is no compatible group");
            }
        }
        return resourceGroup;
    }
View Full Code Here

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

            // setup simple test structures
            Subject subject = SessionTestHelper.createNewSubject(em, "subject-ClusterManagerBeanTest");
            Role role = SessionTestHelper.createNewRoleForSubject(em, subject, "role-ClusterManagerBeanTest",
                Permission.MANAGE_INVENTORY);

            ResourceGroup clusterGroup = SessionTestHelper.createNewCompatibleGroupForRole(em, role,
                "clusterGroup-ClusterManagerBeanTest");

            // setup two test resource trees to make into a resource cluster. Two compatible root nodes
            // with the exact same child hierarchy
            List<Resource> treeA = ResourceTreeHelper.createTree(em,
                "A=d1c1,d1c2; d1c1=d2c1,d2c2; d2c1=d3c1,d3c2; d2c2=d3c3,d3c4");
            List<Resource> treeB = ResourceTreeHelper.createTree(em,
                "B=d1c1,d1c2; d1c1=d2c1,d2c2; d2c1=d3c1,d3c2; d2c2=d3c3,d3c4");

            // test simple implicit resources
            Resource nodeA = ResourceTreeHelper.findNode(treeA, "A");
            Resource nodeB = ResourceTreeHelper.findNode(treeB, "B");

            resourceGroupManager.addResourcesToGroup(subject, clusterGroup.getId(), new int[] { nodeA.getId(),
                nodeB.getId() });

            PageList<Resource> AChildren = resourceManager.findChildResources(subject, nodeA.getId(), PageControl
                .getUnlimitedInstance());
            assert !AChildren.isEmpty() : "Expected Children for Node A";

            int AChildResourceTypeId = AChildren.get(0).getResourceType().getId();
            String AChildResourceKey = AChildren.get(0).getResourceKey();

            ClusterKey clusterKey = new ClusterKey(clusterGroup.getId(), AChildResourceTypeId, AChildResourceKey);
            assert clusterKey.getClusterGroupId() == clusterGroup.getId();
            assert clusterKey.getDepth() == 1;
            assert AChildResourceKey.equals(clusterKey.getHierarchy().get(0).getResourceKey());
            assert AChildResourceTypeId == clusterKey.getHierarchy().get(0).getResourceTypeId();
            assert AChildResourceTypeId == ClusterKey.getResourceType(clusterKey);
            assert ClusterKey.valueOf(clusterKey.toString()) != null;

            List<Resource> resources = clusterManager.getAutoClusterResources(subject, clusterKey);

            assert resources.size() == 2;
            assert resources.get(0).getId() != resources.get(1).getId();
            assert resources.get(0).getParentResource().getId() != resources.get(1).getParentResource().getId();
            assert resources.get(0).getParentResource().getId() == nodeA.getId()
                || resources.get(0).getParentResource().getId() == nodeB.getId();
            assert resources.get(1).getParentResource().getId() == nodeA.getId()
                || resources.get(1).getParentResource().getId() == nodeB.getId();

            assertNull(clusterManager.getAutoClusterBackingGroup(subject, clusterKey));

            ResourceGroup backingGroup = clusterManager.createAutoClusterBackingGroup(subject, clusterKey, true);
            assertNotNull(backingGroup);
            assertEquals(backingGroup.getClusterKey(), clusterKey.toString());
            assertEquals(backingGroup.getClusterResourceGroup(), clusterGroup);
            //Set<Resource> backingGroupResources = backingGroup.getExplicitResources();
            // explicitResources for backingGroup is lazy, so we need to hit resourceManager for the answer
            List<Resource> backingGroupResources = resourceManager.findExplicitResourcesByResourceGroup(subject,
                backingGroup, PageControl.getUnlimitedInstance());
            assertEquals(backingGroupResources.size(), resources.size());
View Full Code Here

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

            // setup simple test structures
            Subject subject = SessionTestHelper.createNewSubject(em, "subject-ClusterManagerBeanTest");
            Role role = SessionTestHelper.createNewRoleForSubject(em, subject, "role-ClusterManagerBeanTest",
                Permission.MANAGE_INVENTORY);

            ResourceGroup clusterGroup = SessionTestHelper.createNewCompatibleGroupForRole(em, role,
                "clusterGroup-ClusterManagerBeanTest");

            // setup two test resource trees to make into a resource cluster. Two compatible root nodes
            // with the exact same child hierarchy
            List<Resource> treeA = ResourceTreeHelper.createTree(em,
                "A=d1c1,d1c2; d1c1=d2c1,d2c2; d2c1=d3c1,d3c2; d2c2=d3c3,d3c4");
            List<Resource> treeB = ResourceTreeHelper.createTree(em,
                "B=d1c1,d1c2; d1c1=d2c1,d2c2; d2c1=d3c1,d3c2; d2c2=d3c3,d3c4");

            // test simple implicit resources
            Resource nodeA = ResourceTreeHelper.findNode(treeA, "A");
            Resource nodeB = ResourceTreeHelper.findNode(treeB, "B");

            resourceGroupManager.addResourcesToGroup(subject, clusterGroup.getId(), new int[] { nodeA.getId(),
                nodeB.getId() });

            PageList<Resource> AChildren = resourceManager.findChildResources(subject, nodeA.getId(), PageControl
                .getUnlimitedInstance());
            assert !AChildren.isEmpty() : "Expected Children for Node A";

            Resource AChild = AChildren.get(0);
            int AChildResourceTypeId = AChild.getResourceType().getId();
            String AChildResourceKey = AChild.getResourceKey();

            PageList<Resource> AGrandChildren = resourceManager.findChildResources(subject, AChild.getId(), PageControl
                .getUnlimitedInstance());

            Resource AGrandChild = AGrandChildren.get(0);
            int AGrandChildResourceTypeId = AGrandChild.getResourceType().getId();
            String AGrandChildResourceKey = AGrandChild.getResourceKey();

            ClusterKey clusterKey = new ClusterKey(clusterGroup.getId(), AChildResourceTypeId, AChildResourceKey);
            clusterKey.addChildToHierarchy(AGrandChildResourceTypeId, AGrandChildResourceKey);
            assert clusterKey.getClusterGroupId() == clusterGroup.getId();
            assert clusterKey.getDepth() == 2;
            assert AChildResourceKey.equals(clusterKey.getHierarchy().get(0).getResourceKey());
            assert AChildResourceTypeId == clusterKey.getHierarchy().get(0).getResourceTypeId();
            assert AGrandChildResourceKey.equals(clusterKey.getHierarchy().get(1).getResourceKey());
            assert AGrandChildResourceTypeId == clusterKey.getHierarchy().get(1).getResourceTypeId();
View Full Code Here

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

        }
    }

    public String toString() {
        if (level instanceof ResourceGroup) {
            ResourceGroup group = (ResourceGroup) level;
            return group.getName();
        } else if (level instanceof AutoGroupCompositeFlyweight) {
            AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) level;
            if (ag.getResourceType() != null) {
                return ag.getResourceType().getName();
            } else if (ag.getSubcategory() != null) {
View Full Code Here

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

    }

    @Override
    public List<GroupOperationSchedule> getOperationScheduleList() {
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        ResourceGroup requestGroup = EnterpriseFacesContextUtility.getResourceGroup();

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

        List<GroupOperationSchedule> results = null;
        try {
            results = manager.findScheduledGroupOperations(subject, requestGroup.getId());
        } catch (Exception e) {
            // throw up all known information to the caller for now
            throw new IllegalStateException(e.getMessage(), e);
        }
View Full Code Here

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

        if (resourceId != null) {
            Resource res = resourceManager.getResourceById(getSubject(), Integer.parseInt(resourceId));
            visit = new WebUserPreferences.ResourceVisit(Integer.parseInt(resourceId), res.getName(),
                WebUserPreferences.ResourceVisit.Kind.valueOf(res.getResourceType().getCategory().name()));
        } else if (groupId != null) {
            ResourceGroup group = groupManager.getResourceGroupById(getSubject(), Integer.parseInt(groupId), null);
            visit = new WebUserPreferences.ResourceVisit(Integer.parseInt(groupId), group.getName(),
                (group.getResourceType() != null ? WebUserPreferences.ResourceVisit.Kind.COMPATIBLE_GROUP
                    : WebUserPreferences.ResourceVisit.Kind.MIXED_GROUP));
        }

        if (visit != null) {
            prefs.addRecentResource(visit);
View Full Code Here

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

     * @return resource associated with the request.
     */
    @NotNull
    public static ResourceGroup getResourceGroup() {
        ExternalContext externalContext = FacesContextUtility.getFacesContext().getExternalContext();
        ResourceGroup resourceGroup = (ResourceGroup) externalContext.getRequestMap().get(
            AttrConstants.RESOURCE_GROUP_ATTR);
        if (resourceGroup == null) {
            int resourceGroupId = FacesContextUtility.getRequiredRequestParameter(ParamConstants.GROUP_ID_PARAM,
                Integer.class);

View Full Code Here

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

        if (schedule instanceof ResourceOperationSchedule) {
            Resource resource = ((ResourceOperationSchedule) schedule).getResource();
            type = resource.getResourceType();
        } else if (schedule instanceof GroupOperationSchedule) {
            ResourceGroup group = ((GroupOperationSchedule) schedule).getGroup();
            type = group.getResourceType();
        } else {
            throw new IllegalArgumentException("OperationParameters does not support objects of type "
                + schedule.getClass().getSimpleName());
        }
View Full Code Here

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

    public ResourceGroupOperationDefinitionUIBean() {
        super();

        resourceExecutionOption = ResourceGroupExecutionTypeUIBean.Type.CONCURRENT.name();

        ResourceGroup resourceGroup = EnterpriseFacesContextUtility.getResourceGroup();
        this.resourceNameItems = operationManager.getResourceNameOptionItems(resourceGroup.getId());
    }
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.