This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours

Bug 803625

Summary: AS7 plugin does not support jboss.server.base.dir
Product: [Other] RHQ Project Reporter: Mattias Nilsson Grip <matn>
Component: PluginsAssignee: Libor Zoubek <lzoubek>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: high    
Version: 4.3CC: ccrouch, hrupp, theute
Target Milestone: ---   
Target Release: RHQ 4.4.0   
Hardware: All   
OS: All   
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=807008
https://jira.jboss.org/jira/browse/AS7-4271
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-08-31 06:16:21 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On:    
Bug Blocks: 707223    
Attachments:
Description Flags
Proposed patch 803625
none
Follow-up patch none

Description Mattias Nilsson Grip 2012-03-15 05:50:14 EDT
JBoss AS7 supports a system property jboss.server.base.dir for standalone mode that enables moving the standalone directory to a different location than $JBOSS_HOME/standalone. It also enables running several standalone instances from the same $JBOSS_HOME. See:
https://docs.jboss.org/author/display/AS7/Command+line+parameters

The AS7 plugin appears to use $JBOSS_HOME as the key for standalone instances. This means it will not detect a second instance launched from the same $JBOSS_HOME directory.

Wouldn't it be better to use jboss.server.base.dir as key for standalone instances?

Steps to Reproduce:
1. Copy $JBOSS_HOME/standalone to $JBOSS_HOME/standalone2 in AS7 install.
2. Start first instance with:
$JBOSS_HOME/bin/standalone.sh
3. Start second instance with:
$JBOSS_HOME/bin/standalone.sh -Djboss.server.base.dir=$JBOSS_HOME/standalone2 -Djboss.socket.binding.port-offset=100
  
Actual results:
RHQ discovery queue will only show the first instance.

Expected results:
RHQ should be able to discover and import both AS7 instances.
Comment 1 Heiko W. Rupp 2012-03-15 09:03:53 EDT
Interesting idea - even if I am not entirely sure it was intended that way by the AS guys, but I see that this should work without the need to duplicate all the modules etc.

Would you be able to provide a patch?
Comment 2 Mattias Nilsson Grip 2012-03-15 09:36:46 EDT
Yes, I think I should be able to provide a patch. Will give it a try during next week.
Comment 3 Mike Foley 2012-03-19 11:34:57 EDT
per BZ triage (crouch, loleary, mfoley)
Comment 4 Mattias Nilsson Grip 2012-03-22 09:33:32 EDT
Created attachment 571994 [details]
Proposed patch 803625

Attaching a patch that fixes the problem in my local Linux environment. I found another thing. The discovered management port is not correct if one uses -Djboss.socket.binding.port-offset. But that setting can be changed via RHQ web interface so I can report that as a lower priority bug.

Hope you find this patch useful!

Regards Mattias
Comment 5 Heiko W. Rupp 2012-03-22 12:40:13 EDT
Matthias,
thanks for the patch. It looks to me like it lacks two things
- setting the base directory 
- log file path (that should now also be standalone2/... 

To see what I mean, go to the inventory tab , connection settings 


Could you please look into this and either send a completely new patch or a follow up to the above?

Thanks
  Heiko
Comment 7 Mattias Nilsson Grip 2012-03-23 05:11:57 EDT
Hi Heiko,

before this patch the base directory value in connection settings was populated with $JBOSS_HOME. I saw that this value is used in BaseServerComponent.startServer to prepend the path to the start script so I did not change it. It still points to $JBOSS_HOME after my patch. Is this wrong? Maybe a JBoss 7 resource should have two directory paths ("Home directory" corresponding to $JBOSS_HOME and "Base directory" corresponding to system properties jboss.server.base.dir/jboss.domain.base.dir)?

The log file path was actually correctly evaluated even before my patch. In my environment it does point to standalone2/log/server.log, since it is deducted from the boot log path which is deducted from command line param -Dorg.jboss.boot.log.file (see BaseProcessDiscovery.getLogFileFromCommandLine). Does that code not work in your environment? I'm using JBoss AS 7.1.1.Final when testing.

Regards,
Mattias
Comment 8 Heiko W. Rupp 2012-03-23 06:14:50 EDT
Hi Mattias,

> before this patch the base directory value in connection settings was populated
> with $JBOSS_HOME. I saw that this value is used in
> BaseServerComponent.startServer to prepend the path to the start script so I
> did not change it. It still points to $JBOSS_HOME after my patch. Is this

Have you checked that for re-starts, this also uses the -Djboss.server.base.dir found?

> wrong? Maybe a JBoss 7 resource should have two directory paths ("Home
> directory" corresponding to $JBOSS_HOME and "Base directory" corresponding to
> system properties jboss.server.base.dir/jboss.domain.base.dir)?

Yes I think this is the right solution.
 
> The log file path was actually correctly evaluated even before my patch. In my
> environment it does point to standalone2/log/server.log, since it is deducted
> from the boot log path which is deducted from command line param
> -Dorg.jboss.boot.log.file (see BaseProcessDiscovery.getLogFileFromCommandLine).

I only specified -Djboss.server.base.dir - the server does not set the boot log file to this
base dir by itself. Interestingly enough the boot.log file is written to standalone/logs/
while the server.log is written to standalone2/logs/

See https://issues.jboss.org/browse/AS7-4271

> Does that code not work in your environment? I'm using JBoss AS 7.1.1.Final
> when testing.

Here too. As well as (internal) eap6 beta builds
Comment 9 Mattias Nilsson Grip 2012-03-23 06:40:33 EDT
(In reply to comment #8)
> Have you checked that for re-starts, this also uses the -Djboss.server.base.dir
> found?
I have not checked restarts actually... I will do that and adjust the patch if necessary.

>> Maybe a JBoss 7 resource should have two directory paths ("Home
>> directory" corresponding to $JBOSS_HOME and "Base directory" corresponding to
>> system properties jboss.server.base.dir/jboss.domain.base.dir)?
> 
> Yes I think this is the right solution.
Ok to introduce this new path as part of this patch? If it is ok I can look into it.

> I only specified -Djboss.server.base.dir - the server does not set the boot log
> file to this
> base dir by itself. Interestingly enough the boot.log file is written to
> standalone/logs/
> while the server.log is written to standalone2/logs/
> 
> See https://issues.jboss.org/browse/AS7-4271
>
Strangely, my standalone.sh script has code that sets JBOSS_LOG_DIR to $JBOSS_BASE_DIR/log and then -Dorg.jboss.boot.log.file=$JBOSS_LOG_DIR/boot.log so there seems to be some discrepancy between our AS7 versions/envs. I'll wait with adjusting this patch until AS7-4271 has been analyzed.
Comment 10 Heiko W. Rupp 2012-03-23 07:01:53 EDT
(In reply to comment #9)
> (In reply to comment #8)
> > Have you checked that for re-starts, this also uses the -Djboss.server.base.dir
> > found?
> I have not checked restarts actually... I will do that and adjust the patch if
> necessary.

Great.

> > Yes I think this is the right solution.
> Ok to introduce this new path as part of this patch? If it is ok I can look
> into it.

Yes. I don't mind if you send one or more individual .patch files.

> 
> > I only specified -Djboss.server.base.dir - the server does not set the boot log
> > file to this
> > base dir by itself. Interestingly enough the boot.log file is written to
> > standalone/logs/
> > while the server.log is written to standalone2/logs/
> > 
> > See https://issues.jboss.org/browse/AS7-4271
> >
> Strangely, my standalone.sh script has code that sets JBOSS_LOG_DIR to
> $JBOSS_BASE_DIR/log and then -Dorg.jboss.boot.log.file=$JBOSS_LOG_DIR/boot.log
> so there seems to be some discrepancy between our AS7 versions/envs. I'll wait
> with adjusting this patch until AS7-4271 has been analyzed.

The script has

"if $linux; then  " which explains it. The magic of turning -Djboss.server.base.dir and to update the other settings is only called on Linux. Which also means it will very probably fail on Solaris or HP/UX etc.
I have updated my initial description on AS7-4271

Thanks
  Heiko
Comment 11 Mattias Nilsson Grip 2012-03-29 05:54:26 EDT
Created attachment 573608 [details]
Follow-up patch

This is a follow-up patch that extends patch 0001. It fixes restarts for standalone AS7 servers that use -Djboss.server.base.dir.

This patch introduces two new connection setting properties for AS7:
homeDir: root directory of the JBoss installation (i.e. JBOSS_HOME)
startScriptArgs: arguments that need to be passed to the start script

The baseDir property is still there but now it points to jboss.server.base.dir or jboss.domain.base.dir instead of JBOSS_HOME.

I verified that AS7 in domain node is still discovered and possible to restart via RHQ after this patch.
Comment 12 Libor Zoubek 2012-05-21 09:31:58 EDT
verified on JON 3.1.Beta1
Comment 13 Heiko W. Rupp 2013-08-31 06:16:21 EDT
Bulk close of old bugs in VERIFIED state.