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

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


        String descriptionAttrib = from.getAttribute(DESCRIPTION.propertyName());
        String typeNameAttrib = from.getAttribute(TYPE.propertyName());
        String pluginNameAttrib = from.getAttribute(PLUGIN.propertyName());
        ResourceType rt = null;

        ResourceGroup rg = new ResourceGroup(nameAttrib);
        rg.setId(idAttrib);
        rg.setDescription(descriptionAttrib);
        if (null != typeNameAttrib) {
            rt = new ResourceType();
            rt.setName(typeNameAttrib);
            rt.setPlugin(pluginNameAttrib);
            rg.setResourceType(rt);
        }

        return rg;
    }
View Full Code Here


        for (Integer id : favIds) {
            try {
                /*
                * In theory we should not have any bad group ids in favorites, but ...
                */
                ResourceGroup res = resourceGroupManager.getResourceGroup(caller, id);
                GroupRest rwt = fillGroup(res, uriInfo);
                ret.add(rwt);
            }
            catch (ResourceGroupNotFoundException e) {
                log.debug("Favorite group with id " + id + " not found - not returning to the user");
View Full Code Here

    public void testUpdateResourceGroupTags() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                ResourceGroup resourceGroup = createResourceGroup();
                resourceGroup.setTags(emptyTagSet());
                Set<Tag> tags = generateTagSet(7);
                tagManager.updateResourceGroupTags(overlord, resourceGroup.getId(), tags);
                assertEquals(tags, resourceGroup.getTags());
            }
        });
    }
View Full Code Here

            getRandomString(), getRandomString());
    }

    private BundleDestination createBundleDestination() throws Exception {
        Bundle bundle = createBundle();
        ResourceGroup resourceGroup = createResourceGroupForBundleDeployments();
        String destName = resourceGroup.getResourceType().getResourceTypeBundleConfiguration()
            .getBundleDestinationSpecifications().iterator().next().getName();

        return bundleManager.createBundleDestination(overlord, bundle.getId(), getRandomString(), getRandomString(),
            destName, getRandomString(), resourceGroup.getId());
    }
View Full Code Here

            getRandomString(), getRandomString());
        resourceType.setResourceTypeBundleConfiguration(resourceTypeBundleConfiguration);

        Resource resource = SessionTestHelper.createNewResource(em, getRandomString(), resourceType);

        ResourceGroup resourceGroup = createResourceGroup();
        resourceGroup.addExplicitResource(resource);
        resourceGroup.setResourceType(resourceType);

        return resourceGroup;
    }
View Full Code Here

                // 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

     * @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

            // 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

            // 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

        }
    }

    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

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.