Bug 580210

Summary: Resource.getCurrentAvailability() always returns null
Product: [Other] RHQ Project Reporter: Larry O'Leary <loleary>
Component: CLIAssignee: Filip Drabek <fdrabek>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: low    
Version: 1.3.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-02 07:15:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Larry O'Leary 2010-04-07 17:49:00 UTC
Description of problem:
When invoking org.rhq.core.domain.resource.Resource.getCurrentAvailability() on a JBossAS resource, the result always seems to be null.  This seems to be the case regardless of the actual availability of the resource.  This is not the case if you invoke AvailabilityManager.getCurrentAvailabilityForResource(subject, resource.getId()).  Is this the expected behaviour?  What is this method intended for?

Version-Release number of selected component (if applicable):
RHQ 1.3.1 CLI

How reproducible:
Always

Steps to Reproduce:
1. Start-up and RHQ Server and RHQ Agent on the same host
2. Import the RHQ Server into inventory
3. Connect to the RHQ Server host/port using CLI
4. Execute the following commands:

var criteria = new ResourceCriteria();
criteria.addFilterResourceTypeName('JBossAS Server');
var asServers = ResourceManager.findResourcesByCriteria(criteria);
if (asServers != null && asServers.size() > 0) { \
   for (var i = 0; i < asServers.size(); i++) { \
      var resource = asServers.get(i); \
      if (resource.getName() != null && resource.getName().contains(" RHQ Server, ")) { \
         var av = AvailabilityManager.getCurrentAvailabilityForResource(subject, resource.getId()); \
         println("RHQ Server: " + resource.getName() + " [" + resource.getId() + "] has a current status from AvailabilityManager of '" + (av != null ? av.getAvailabilityType() : "null") + "'!"); \
         println("RHQ Server: " + resource.getName() + " [" + resource.getId() + "] has a current status from Resource of '" + (resource.getCurrentAvailability() != null ? resource.getCurrentAvailability().getAvailabilityType() : "null") + "'!"); \
      } \
   } \
}
  
Actual results:
RHQ Server: jonserver RHQ Server,  JBoss AS 4.2.3.GA default (0.0.0.0:2099) [10003] has a current status from AvailabilityManager of 'UP'!
RHQ Server: jonserver RHQ Server,  JBoss AS 4.2.3.GA default (0.0.0.0:2099) [10003] has a current status from Resource of 'null'!


Expected results:
RHQ Server: jonserver RHQ Server,  JBoss AS 4.2.3.GA default (0.0.0.0:2099) [10003] has a current status from AvailabilityManager of 'UP'!
RHQ Server: jonserver RHQ Server,  JBoss AS 4.2.3.GA default (0.0.0.0:2099) [10003] has a current status from Resource of 'UP'!


Additional info:
I have also tried this using ResourceManager.getResource(subject, resId) in the hopes that maybe the issue was with the named query.  It still doesn't work.  I am wondering what the impact of the named query doing a LEFT JOIN FETCH on the resource currentAvailability field is.

    @NamedQuery(name = Resource.QUERY_FIND_BY_ID, query = "" //
        + "         SELECT res " //
        + "           FROM Resource res " //
        + "LEFT JOIN FETCH res.currentAvailability " // fetch to remove extra query, LEFT so unit tests needn't set it
        + "     JOIN FETCH res.resourceType " // fetch to remove extra query
        + "          WHERE res.id =  :resourceId "),

Comment 3 Heiko W. Rupp 2011-01-13 19:50:25 UTC
Filip,
as you are already working on the CLI: can you please check if this is still 
true and if so, give an estimate for fixing it?

Comment 4 Filip Drabek 2011-01-14 09:00:38 UTC
I have tested it on build from master branch. Current results of the script are :

RHQ Server: xxx RHQ Server [10003] has a current status from AvailabilityManager of 'UP'!
RHQ Server: xxx RHQ Server [10003] has a current status from Resource of 'UP'!

so it works for me.

Comment 5 Mike Foley 2011-06-30 12:44:03 UTC
documenting the verification on 4.1 master.

[mfoley@foleymonsterbox1 bin]$ ./rhq-cli.sh -u rhqadmin -p rhqadmin -f myscript.js
Remote server version is: 4.1.0-SNAPSHOT (c57ee65)
Login successful
this is a test
asServers = 2
resource:localhost:1099 default
resource:foleymonsterbox1.foleyhomenetwork RHQ Server
RHQ Server: foleymonsterbox1.foleyhomenetwork RHQ Server [10003] has a current status from AvailabilityManager of 'UP'!
RHQ Server: foleymonsterbox1.foleyhomenetwork RHQ Server [10003] has a current status from Resource of 'UP'!
[mfoley@foleymonsterbox1 bin]$

Comment 6 Heiko W. Rupp 2013-09-02 07:15:37 UTC
Bulk closing of issues that were VERIFIED, had no target release and where the status changed more than a year ago.