Package org.rhq.enterprise.server.resource

Examples of org.rhq.enterprise.server.resource.ResourceManagerLocal


        return;
    }

    private void generateServersReport() throws Exception {
        Subject user = getOverlord();
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        ResourceCategory category = ResourceCategory.SERVER;
        int committed = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.COMMITTED);
        int ignored = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.IGNORED);
        int deleted = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.DELETED);
        int uninventoried = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.UNINVENTORIED);

        File file = new File(this.reportDir, "servers.txt");
        PrintStream ps = new PrintStream(file);
        try {
            printHeader(ps);
View Full Code Here


        return;
    }

    private void generateServicesReport() throws Exception {
        Subject user = getOverlord();
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        ResourceCategory category = ResourceCategory.SERVICE;
        int committed = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.COMMITTED);
        int ignored = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.IGNORED);
        int deleted = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.DELETED);
        int uninventoried = resourceManager.getResourceCountByCategory(user, category, InventoryStatus.UNINVENTORIED);

        File file = new File(this.reportDir, "services.txt");
        PrintStream ps = new PrintStream(file);
        try {
            printHeader(ps);
View Full Code Here

     * @param resourceId the ID of the resource whose availability is to be checked
     * @return the resource availability
     */
    private ResourceAvailability pingResource(int resourceId) {
        Subject user = getOverlord();
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
        ResourceAvailability avail = resourceManager.getLiveResourceAvailability(user, resourceId);
        return avail;
    }
View Full Code Here

                log.trace("Multiple resources not yet handled"); // TODO what to we do here?
            } else // single resource
            {
                Integer resourceId = WebUtility.getRequiredIntRequestParameter(request,
                    ParamConstants.RESOURCE_ID_PARAM);
                ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
                Resource resource = resourceManager.getResourceById(subject, resourceId);
                ResourceUIBean resourceUIBean = new ResourceUIBean(resource, subject);
                request.setAttribute(AttrConstants.RESOURCE_ATTR, resource);
                request.setAttribute(AttrConstants.RESOURCE_ID_ATTR, resourceId);
                request.setAttribute(AttrConstants.TITLE_PARAM_ATTR, resource.getName());
                request.setAttribute(AttrConstants.PERFORMANCE_SUPPORTED_ATTR, resourceUIBean.getFacets().isCallTime());
View Full Code Here

        //make sure these attributes aren't already in the request.

        try {
            HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
            user = RequestUtils.getSubject(request);
            ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
            Resource resource = resourceManager.getResourceById(user, getResource());

            Set<Permission> permissions = LookupUtil.getAuthorizationManager().getImplicitResourcePermissions(user,
                resource.getId());
            ResourcePermission resourcePermission = null;
            if (LookupUtil.getAuthorizationManager().isInventoryManager(user)) {
View Full Code Here

    // TODO GH: Fixme (setup non-super user and group)@Test(groups = "integration.ejb3")
    public void testFindResourceComposite() throws Exception {
        getTransactionManager().begin();

        try {
            ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
            SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
            PageControl pc = new PageControl(1, 5, new OrderingField("res.name", PageOrdering.ASC));
            Subject subject = subjectManager.loginUnauthenticated("ghinkle");

            //Subject subject = subjectManager.getOverlord();
            subject = createSession(subject);
            ResourceType t = em.getReference(ResourceType.class, new Integer(501064));
            String typeNameFilter = t == null ? null : t.getName();
            PageList<ResourceComposite> resources = resourceManager.findResourceComposites(subject,
                ResourceCategory.SERVER, typeNameFilter, null, null, "g", false, pc);
            System.out.println("Found resource composites: " + resources.size());
            for (ResourceComposite resourceComposite : resources) {
                System.out.println("\t" + resourceComposite);
            }
View Full Code Here

    @SuppressWarnings("unused")
    @Test(groups = "integration.ejb3")
    public void resourceTest() throws Exception {
        // TODO GH: Implement actual tests

        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();

        AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager();
View Full Code Here

     */
    @Test(groups = "integration.ejb3")
    public void testParsingCriteriaQueryResults() throws Exception {
        getTransactionManager().begin();
        EntityManager entityMgr = getEntityManager();
        final ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        //verify that all resource objects are actually parsed.
        Map<String, Object> resourceNames = new HashMap<String, Object>();
        int resourceCount = 700; //assuming 200 per page at least 4 pages of results.

        try {
            final Subject subject = SessionTestHelper.createNewSubject(entityMgr, "testSubject");

            Role roleWithSubject = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role with subject");
            roleWithSubject.addPermission(Permission.VIEW_RESOURCE);

            ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, roleWithSubject,
                "accessible group");

            String tuid = "" + new Random().nextInt();
            //create large number of resources
            String prefix = "largeResultSet-" + tuid + "-";
            System.out.println("-------- Creating " + resourceCount + " resource(s). This may take a while ....");

            long start = System.currentTimeMillis();
            for (int i = 0; i < resourceCount; i++) {
                String name = prefix + i;
                Resource r = SessionTestHelper.createNewResourceForGroup(entityMgr, group, name);
                //store away each resource name/key
                resourceNames.put(String.valueOf(r.getId()), name);
            }
            entityMgr.flush();

            System.out.println("----------- Created " + resourceCount + " resource(s) in "
                + (System.currentTimeMillis() - start) + " ms.");

            assert resourceNames.size() == resourceCount;//assert all resources loaded/created

            //query the results and delete the resources
            ResourceCriteria criteria = new ResourceCriteria();
            criteria.addFilterName(prefix);
            criteria.addSortName(PageOrdering.DESC); // use DESC just to make sure sorting on name is different than insert order
            criteria.setPaging(0, 47);

            //iterate over the results with CriteriaQuery
            CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
                @Override
                public PageList<Resource> execute(ResourceCriteria criteria) {
                    return resourceManager.findResourcesByCriteria(subject, criteria);
                }
            };

            //initiate first/(total depending on page size) request.
            CriteriaQuery<Resource, ResourceCriteria> resources = new CriteriaQuery<Resource, ResourceCriteria>(
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testParsingCriteriaQueryResults_2() throws Exception {
        // Same test as above but makes sure default id search works. use different numbers just for variety       
        getTransactionManager().begin();
        EntityManager entityMgr = getEntityManager();
        final ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        //verify that all resource objects are actually parsed.
        Map<String, Object> resourceNames = new HashMap<String, Object>();
        int resourceCount = 344;

        try {
            final Subject subject = SessionTestHelper.createNewSubject(entityMgr, "testSubject");

            Role roleWithSubject = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role with subject");
            roleWithSubject.addPermission(Permission.VIEW_RESOURCE);

            ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, roleWithSubject,
                "accessible group");

            String tuid = "" + new Random().nextInt();
            //create large number of resources
            String prefix = "largeResultSet-" + tuid + "-";
            System.out.println("-------- Creating " + resourceCount + " resource(s). This may take a while ....");

            long start = System.currentTimeMillis();
            for (int i = 0; i < resourceCount; i++) {
                String name = prefix + i;
                Resource r = SessionTestHelper.createNewResourceForGroup(entityMgr, group, name);
                //store away each resource name/key
                resourceNames.put(String.valueOf(r.getId()), name);
            }
            entityMgr.flush();

            System.out.println("----------- Created " + resourceCount + " resource(s) in "
                + (System.currentTimeMillis() - start) + " ms.");

            assert resourceNames.size() == resourceCount;//assert all resources loaded/created

            //query the results and delete the resources, use default ID search
            ResourceCriteria criteria = new ResourceCriteria();
            criteria.addFilterName(prefix);
            criteria.setPaging(0, 25);

            //iterate over the results with CriteriaQuery
            CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
                @Override
                public PageList<Resource> execute(ResourceCriteria criteria) {
                    return resourceManager.findResourcesByCriteria(subject, criteria);
                }
            };

            //initiate first/(total depending on page size) request.
            CriteriaQuery<Resource, ResourceCriteria> resources = new CriteriaQuery<Resource, ResourceCriteria>(
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testParsingCriteriaQueryResults_3() throws Exception {
        // Same test as above but makes sure pageoverrides default id search works. use different numbers just for variety       
        getTransactionManager().begin();
        EntityManager entityMgr = getEntityManager();
        final ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        //verify that all resource objects are actually parsed.
        Map<String, Object> resourceNames = new HashMap<String, Object>();
        int resourceCount = 423;

        try {
            final Subject subject = SessionTestHelper.createNewSubject(entityMgr, "testSubject");

            Role roleWithSubject = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role with subject");
            roleWithSubject.addPermission(Permission.VIEW_RESOURCE);

            ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, roleWithSubject,
                "accessible group");

            String tuid = "" + new Random().nextInt();
            //create large number of resources
            String prefix = "largeResultSet-" + tuid + "-";
            System.out.println("-------- Creating " + resourceCount + " resource(s). This may take a while ....");

            long start = System.currentTimeMillis();
            for (int i = 0; i < resourceCount; i++) {
                String name = prefix + i;
                Resource r = SessionTestHelper.createNewResourceForGroup(entityMgr, group, name);
                //store away each resource name/key
                resourceNames.put(String.valueOf(r.getId()), name);
            }
            entityMgr.flush();

            System.out.println("----------- Created " + resourceCount + " resource(s) in "
                + (System.currentTimeMillis() - start) + " ms.");

            assert resourceNames.size() == resourceCount;//assert all resources loaded/created

            //query the results and delete the resources, use default ID search
            ResourceCriteria criteria = new ResourceCriteria();
            criteria.addFilterName(prefix);
            PageControl pc = new PageControl(0, 73);
            criteria.setPageControl(pc);
            assert pc.getOrderingFields().isEmpty() : "Should not have had any sorting defined";

            //iterate over the results with CriteriaQuery
            CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
                @Override
                public PageList<Resource> execute(ResourceCriteria criteria) {
                    return resourceManager.findResourcesByCriteria(subject, criteria);
                }
            };

            //initiate first/(total depending on page size) request.
            CriteriaQuery<Resource, ResourceCriteria> resources = new CriteriaQuery<Resource, ResourceCriteria>(
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.resource.ResourceManagerLocal

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.