We're Hiring!

Java Options

Having a problem deploying OMERO? Please ask new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

The OMERO.server installation documentation begins here and you can find OMERO.web deployment documentation here.

Java Options

Postby bernhard » Wed Aug 19, 2009 11:07 am

Hi together!

How can add command line args to the java interpreter that is called by bin/omero admin start. I'd like to change the memory footprint and set the value for the location of the system preferences file to a folder where none root users can write to.

I went through the lib/python/omero/cli.py code and lib/python/omero/plugins but could not really figure out where I can add args, that they get picked up by the program. I tried adding omero.blitz.xargs to etc/grid/default.xml but this did not work. Finally, I modified lib/omero/java.py that it adds JAVA_OPTS found in the environment.

Thanks! Bernhard
bernhard
 
Posts: 37
Joined: Mon Jun 22, 2009 7:18 am

Re: Java Options

Postby jmoore » Wed Aug 19, 2009 12:16 pm

Hi Bernhard,

the problem with bin/omero admin start is that it doesn't actually call java(.exe). Instead, it just starts the icegridnode process which will eventually execute java. Support for JAVA_OPTS is in omero/java.py:

https://trac.openmicroscopy.org.uk/omer ... ava.py#L57

though there may have been a bug somewhere in the chain. Could you post the change you made?

"omero.blitz.xargs" is also supported, but it's not an environment property but rather a "bin/omero config" setting. How did you try to set it?

Finally, "server.py" used by the BlitzTemplate is intended primarily as a convenience. If you want complete control over the call to Java from your default.xml, take a look at the WinBlitzTemplate in templates.xml.

Hope that helps,
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Java Options

Postby bernhard » Wed Aug 19, 2009 1:01 pm

Hi Josh!

Thanks for your answer.

Could you explain the relationship between default.xml and template.xml. I never understood their dependency. When are the settings from the template.xml taken anyway.

It tried to add the following to default.xml, but it did not change the java cmd that is launched by bin/omero.
Code: Select all
<properties id="Profile">
      <!--                   
      Any properties beginning with "omero" set here will
      be passed to the servers as if via "-Domero.example=value"
      were set on the command line. These values may be overwritten
      by `bin/omero config` values.                               
      -->     
     <property name="omero.blitz.xargs" value="-Xms512m -Xmx1024 -Djava.util.prefs.systemRoot=/home/bernhard/.java"/>
</properties>


Adding an option to the BlitzTemplate node in templates.xml similar to the WinBlitzTemplate node does not work, the server won't start anymore. I'm clearly missing some understanding of the configuration system :-(

Here's the change I did to java.py's cmd function:
Code: Select all

--- java.py~    2009-05-08 13:32:22.000000000 +0200
+++ java.py     2009-08-19 13:09:02.000000000 +0200
@@ -38,12 +38,13 @@
     command += [ "-Dlog4j.configuration=%s" % os.path.join("etc", "log4j.xml") ]

     # Preapre arguments
-    if xargs == None:
-        if os.environ.has_key("JAVA_OPTS"):
-            command += shlex.split(os.environ["JAVA_OPTS"])
-    else:
+
+    if xargs is not None:
         command += xargs

+    if os.environ.has_key("JAVA_OPTS"):
+           command += shlex.split(os.environ["JAVA_OPTS"])
+
     # Prepare debugging
     if debug == None:
         if os.environ.has_key("DEBUG"):


Instead of using JAVA_OPTS from the environment only when xargs is not set, now they are always recoginzed and they are added at last so they are superseding values from configuration files.

FYI, the xargs is never unset for the "blitz" application as there is a default -Xmx400m arg in the blitz method of the ServerControl in server.py.

Thanks for you help! Bernhard
bernhard
 
Posts: 37
Joined: Mon Jun 22, 2009 7:18 am

Re: Java Options

Postby jmoore » Wed Aug 19, 2009 1:16 pm

bernhard wrote:Could you explain the relationship between default.xml and template.xml. I never understood their dependency. When are the settings from the template.xml taken anyway.


If you look in etc/master.cfg you'll see the line:
Code: Select all
IceGrid.Registry.DefaultTemplates=etc/grid/templates.xml


This tells the registry (which is started via bin/omero admin start) to read the etc/grid/templates.xml file. Those definitions are then used to instantiate the "service-templates" in default.xml. An alternative way to do this would be via an "<import/>" statement in default.xml. If that's clearer, we can test moving to that syntax.

bernhard wrote:It tried to add the following to default.xml, but it did not change the java cmd that is launched by bin/omero.
Code: Select all
<properties id="Profile">
...snipe...
     <property name="omero.blitz.xargs" value="-Xms512m -Xmx1024 -Djava.util.prefs....
</properties>



Right, that defines a property in the Ice.Config file which is passed to icegridnode. (You can see that in var/master/servers/Blitz-0/config/config). I.e. it doesn't get used early enough to influence the Java executable. The only way to add values to the command line is via server.py and java.py or directly in the default.xml.


bernhard wrote:Adding an option to the BlitzTemplate node in templates.xml similar to the WinBlitzTemplate node does not work, the server won't start anymore. I'm clearly missing some understanding of the configuration system :-(

Would you mind showing me your new template?

bernhard wrote:Here's the change I did to java.py's cmd function:
...snipe...
Instead of using JAVA_OPTS from the environment only when xargs is not set, now they are always recoginzed and they are added at last so they are superseding values from configuration files.

FYI, the xargs is never unset for the "blitz" application as there is a default -Xmx400m arg in the blitz method of the ServerControl in server.py.


I'll try to check and see if alwasys appending JAVA_OPTS will invalidate any of the other uses of the library. If not, I'll apply the patch. Thanks.

~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Java Options

Postby bernhard » Wed Aug 19, 2009 1:41 pm

Would you mind showing me your new template?

Here it is:
Code: Select all
<server-template id="BlitzTemplate">
      <parameter name="index"/>
      <parameter name="config" default="default"/>
      <server id="Blitz-${index}" exe="bin/omero" activation="always">
        <option>server</option>
        <option>blitz</option>
        <option>-Domero.name=Blitz-${index}</option>
        <option>-Xmx1024m</option>
        <env>${PYTHONPATH}</env>
        <adapter name="BlitzAdapter" replica-group="BlitzAdapters" register-process="true" endpoints="tcp"/>
        <properties>
          <properties refid="Profile"/>
          <properties refid="Blitz"/>
          <properties refid="Basics"/>
          <properties refid="MultiThreaded"/>
          <property name="omero.name" value="${server}"/>
        </properties>
      </server>
    </server-template>


The only way to add values to the command line is via server.py and java.py or directly in the default.xml.

What do you mean by "directly in the default.xml" can you give an example?

Those definitions are then used to instantiate the "service-templates" in default.xml. An alternative way to do this would be via an "<import/>" statement in default.xml. If that's clearer, we can test moving to that syntax.

Yes, import might be a bit clearer. However, for an outsider the configuration and start-up system is too complicated to understand without proper documentation and this change does not help much :-(

If you don't expect your users to change parameters except those you mention in the installation docs it's fine, otherwise it would be great if there would be configuration guide.

As always, thanks a lot for your help! Bernhard
bernhard
 
Posts: 37
Joined: Mon Jun 22, 2009 7:18 am

Re: Java Options

Postby jmoore » Thu Sep 17, 2009 7:08 pm

Fixed: https://trac.openmicroscopy.org.uk/omero/ticket/1439

One word of caution: there is a change in semantics that even bit us. We previously had "-Xmx1024M" in "omero.blitz.xargs". On adding JAVA_OPTS at the end, an old setting from JAVA_OPTS ("-Xmx512M") was appended, overwriting the intended value.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany


Return to Installation and Deployment

Who is online

Users browsing this forum: No registered users and 1 guest