Bug 813762 - findResourcesByCriteria(criteria) returns incomplete set of resources
findResourcesByCriteria(criteria) returns incomplete set of resources
Status: CLOSED CURRENTRELEASE
Product: JBoss Operations Network
Classification: JBoss
Component: Documentation (Show other bugs)
JON 3.1.0
Unspecified Unspecified
high Severity unspecified
: ---
: ---
Assigned To: Deon Ballard
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-18 07:38 EDT by Filip Brychta
Modified: 2012-06-29 11:13 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-29 11:13:51 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Filip Brychta 2012-04-18 07:38:29 EDT
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 11:50:44 EDT
doc issue per BZ triage 4/23 (crouch, loleary, asantos, foley)

please update the JON documentation
Comment 2 Filip Brychta 2012-04-26 08:33:07 EDT
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 10:35:59 EDT
>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 12:43:11 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.