Bug 813762

Summary: findResourcesByCriteria(criteria) returns incomplete set of resources
Product: [JBoss] JBoss Operations Network Reporter: Filip Brychta <fbrychta>
Component: DocumentationAssignee: Deon Ballard <dlackey>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: high    
Version: JON 3.1.0CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-29 15:13:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Filip Brychta 2012-04-18 11:38:29 UTC
Description of problem:

According to http://rhq-project.org/display/JOPR2/Running+the+RHQ+CLI#RunningtheRHQCLI-CriteriaSearching (chapter Basic Criteria), following code should fetch all committed resources in our inventory:
var criteria = new ResourceCriteria();
var resources = ResourceManager.findResourcesByCriteria(criteria);

However this is not true. Returned set contains maximally 200 resources even if complete set of committed resources is larger.

SELECT count(id)
FROM rhq_resource 
WHERE ( inventory_status = 'COMMITTED' ) returns 533  


Version-Release number of selected component (if applicable):
Version: 4.4.0-SNAPSHOT
Build Number: ca5eecb

Database: postgresql-server-9.1.3-3

How reproducible:
Always

Steps to Reproduce:
1. Import more than 200 resources to your inventory 
2. execute following:
var criteria = new ResourceCriteria();
var resources = ResourceManager.findResourcesByCriteria(criteria);
println("CommitedResSize: "+resources.size());
3. execute following SQL query
SELECT count(id)
FROM rhq_resource 
WHERE ( inventory_status = 'COMMITTED' )
  
Actual results:
CommitedResSize: 200
SQL query result: 533

Expected results:
CommitedResSize and SQL query result should be the same.

Additional info:
hint- any default LIMIT added to the JPA-QL query??

Comment 1 Mike Foley 2012-04-23 15:50:44 UTC
doc issue per BZ triage 4/23 (crouch, loleary, asantos, foley)

please update the JON documentation

Comment 2 Filip Brychta 2012-04-26 12:33:07 UTC
Update: not really a bug. I didn't realize that ResourceManager.findResourcesByCriteria(criteria) returns PageList<Resource> so 
var resources = ResourceManager.findResourcesByCriteria(criteria);
println("CommitedResSize: "+resources.size());
prints just size of the current page. However i haven't fount straightforward way to get complete list of resources. It would be nice to have something like this:  
resources.getCompleteList();

Comment 4 Filip Brychta 2012-05-18 14:35:59 UTC
>I could be wrong, but is this at all related to bug 784571 where no more than
>200 children are visible for a resource in the tree?
Yes

>If so, is it possible to disable paging in the CLI with criteria.clearPaging()?
Yes

So the only problem seems to be that by default this code:
var criteria = new ResourceCriteria()
var resources = ResourceManager.findResourcesByCriteria(criteria)

returns paged list with 200 items but documentation states that this should return complete list of resources.

Comment 5 Deon Ballard 2012-05-18 16:43:11 UTC
Thanks for the info, Filip.

I think I have this right in the JON docs; I'll clear with someone when I get the new docs on staging and then update the wiki.