tietang / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 1 forks source link

Use JBoss' data directory and not Java's io.tmp folder for storage #336

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
By current implementation, javamelody checks if the storage paramter (from 
web.xml) is an absolute file.
If not, the storage folder is created within Java's temp folder (provided by 
the OS)

What is the expected change?
In most situations, I do want to store my javamelody stats close to the 
application server's data.
In case of jboss, this is %SERVER_PROFILE%/data
This is more persistent then the OS' temp folder which might be flushed during 
restart etc.
JBoss' data folder is never flushed automatically (containing also transactino 
logs etc)

As the data folder is provided by JBoss, a web.xml configuration has not to 
consider where the JBoss is installed.

Therefore I'd like to see a changed in 
net.bull.javamelody.Parameters.getStorageDirectory(String):
After the initalization, I propse the following code:

        final String directory;
        if (dir.length() > 0 && new File(dir).isAbsolute()) {
            directory = dir;
        } else {
            Properties systemProp = System.getProperties();
            if (systemProp.containsKey("jboss.server.data.dir")) {
                //This is Jboss
                directory = systemProp.getProperty("jboss.server.data.dir") + '/' + dir;
            } else {
                directory = TEMPORARY_DIRECTORY.getPath() + '/' + dir;
            }
        }
        if (servletContext != null) {
            return new File(directory + '/' + application);
        }
        return new File(directory);

(relevant changes between line 5-11)

This leaves the old behavoir in place for absolute path settings. Additionally, 
on JBoss, relative paths are considered relative to JBoss' data folder which is 
provided via the System properties

Thanks

Original issue reported on code.google.com by derj...@googlemail.com on 21 Aug 2013 at 12:27

GoogleCodeExporter commented 9 years ago
Hi

I also think it makes sense to use the JBoss datadir when running on JBoss.
Are there any problems with the code suggested above, or do you not want to 
include this in javamelody ?

One can of course use the storage-directory parameter to achieve the same thing.
Maybe the storage-directory parameter was added after this issue was created ?

Regards
Alf Høgemark

Original comment by alf.hoge...@gmail.com on 9 Aug 2014 at 12:54

GoogleCodeExporter commented 9 years ago
Using JBoss data dir may cause several problems:
- Adding specific code and behavior for JBoss is not great. For example, 
JBoss/RedHat or WildFly may choose to change "jboss.server.data.dir" to 
something else anytime. (I have already seen changes such as Hudson/Jenkins, 
Sybase / ASE, Sun JSAS / Glassfish, JBoss then "Undertow" then "WildFly".)
- When some users ask where data is stored, it's not great to say 
${java.io.tmpdir}/javamelody, but not if they are using JBoss or WildFly or 
anything using them.
- The storage-directory parameter exists to configure that.
- Current users of javamelody on JBoss/WildFly may be surprised when upgrading 
javamelody, about why data is not stored anymore where it always was or why 
historical data was lost in the reports.

So JBoss data dir is specific to JBoss and probably can't be used as a 
standard: I think that this issue could be Won't fix.
Do you agree?

By the way, issue 240 has suggested to use the standard 
"javax.servlet.context.tempdir" (ServletContext.TEMPDIR), which in fact is not 
a good idea at least in Tomcat.

Original comment by evernat@free.fr on 19 Dec 2014 at 5:38

GoogleCodeExporter commented 9 years ago
[Triage] Resolving as won't fix for the reasons given above.

Original comment by evernat@free.fr on 6 Apr 2015 at 2:53