Re: [PATCH] Support building and running Java apps in non-isolated mode

2016-11-02 Thread Waldek Kozaczuk
Yeah I agree it would be nice to remove the duplication of makefile and 
module.py. Is it possible to remove duplication of usr.manifest (mostly the 
same except for java_non_isolated.so vs java.so).

On related note I was wondering if near future the java non isolated mode 
should become the default one?

Waldek

On Wednesday, November 2, 2016 at 7:26:49 AM UTC-4, Nadav Har'El wrote:
>
> Hi, thanks. I committed patch because I think it is a good direction.
> However, I'd appreciate followon patches for:
>
> 1. While ./scripts/build image=java-non-isolated,java-example seems to 
> work, I tried ./scripts/build image=java-non-isolated,tomcat - and it 
> didn't work. I don't know if this will be solved by one of your later 
> patches?
>
> 2. modules/java-non-isolated now contains a copy of the Makefile and 
> module.py (with a couple more lines). This will likely bite us in the 
> future, when someone fixes one but forgets the other. Could you please have 
> the ones from java-non-isolated "read" the ones from ../java/ (there is 
> syntax to do that in both Python and Makefile), to avoid this duplication?
>
> Thanks,
> Nadav.
>
>
>
> --
> Nadav Har'El
> n...@scylladb.com 
>
> On Fri, Oct 14, 2016 at 11:13 PM, Waldemar Kozaczuk  > wrote:
>
>> Added new java-non-isolated module and refactored
>>  scripts/module.py to provide isolated_jvm and non_isolated_jvm as a way 
>> to
>>  build and run java apps in isolated (old default) and non-isolated mode.
>>
>> The non-isolated mode gets enabled by module.py that detects if selected
>>  java module (provides = ['java']) has following attribute set to true 
>> like so:
>>
>> non_isolated_jvm = True
>>
>> Example to build an image with isolated JVM (default):
>> ./scripts/build image=java,java-example
>>
>> Example to build an image with non-isolated JVM:
>> ./scripts/build image=java-non-isolated,java-example
>>
>> Fixes #800
>>
>> Signed-off-by: Waldemar Kozaczuk >
>> ---
>>  modules/java-non-isolated/Makefile | 10 ++
>>  modules/java-non-isolated/module.py| 28 
>>  modules/java-non-isolated/usr.manifest | 21 +
>>  scripts/module.py  | 25 ++---
>>  4 files changed, 81 insertions(+), 3 deletions(-)
>>  create mode 100644 modules/java-non-isolated/Makefile
>>  create mode 100644 modules/java-non-isolated/module.py
>>  create mode 100644 modules/java-non-isolated/usr.manifest
>>
>> diff --git a/modules/java-non-isolated/Makefile 
>> b/modules/java-non-isolated/Makefile
>> new file mode 100644
>> index 000..d5d916e
>> --- /dev/null
>> +++ b/modules/java-non-isolated/Makefile
>> @@ -0,0 +1,10 @@
>> +# TODO: need to move compilation of $(java-targets) from the main 
>> makefile
>> +# to here. Unfortunately, compiling with OSv header files is a big mess,
>> +# and much easier to do it in the main OSv makefile :-(
>> +SRC = $(shell readlink -f ../..)
>> +module:
>> +   cd $(SRC)/java && mvn package -DskipTests=true
>> +
>> +clean:
>> +   cd $(SRC)/java && mvn clean
>> +   -rm -f dependency-reduced-pom.xml
>> diff --git a/modules/java-non-isolated/module.py 
>> b/modules/java-non-isolated/module.py
>> new file mode 100644
>> index 000..1f5b401
>> --- /dev/null
>> +++ b/modules/java-non-isolated/module.py
>> @@ -0,0 +1,28 @@
>> +from osv.modules.filemap import FileMap
>> +from osv.modules import api
>> +import os, os.path
>> +
>> +usr_files = FileMap()
>> +
>> +provides = ['java']
>> +
>> +non_isolated_jvm = True
>> +
>> +api.require('fonts')
>> +api.require('ca-certificates')
>> +api.require('libz')
>> +api.require('josvsym')
>> +api.require('httpserver-jolokia-plugin')
>> +api.require('httpserver-jvm-plugin')
>> +
>> +jdkdir = os.path.basename(os.path.expandvars('${jdkbase}'))
>> +
>> +usr_files.add('${jdkbase}').to('/usr/lib/jvm/java') \
>> +.include('lib/**') \
>> +.include('jre/**') \
>> +.exclude('jre/lib/security/cacerts') \
>> +.exclude('jre/lib/audio/**')
>> +
>> +usr_files.link('/usr/lib/jvm/' + jdkdir).to('java')
>> +usr_files.link('/usr/lib/jvm/jre').to('java/jre')
>>
>> +usr_files.link('/usr/lib/jvm/java/jre/lib/security/cacerts').to('/etc/pki/java/cacerts')
>> diff --git a/modules/java-non-isolated/usr.manifest 
>> b/modules/java-non-isolated/usr.manifest
>> new file mode 100644
>> index 000..63b11bc
>> --- /dev/null
>> +++ b/modules/java-non-isolated/usr.manifest
>> @@ -0,0 +1,21 @@
>> +#
>> +# Copyright (C) 2013-2014 Cloudius Systems, Ltd.
>> +#
>> +# This work is open source software, licensed under the terms of the
>> +# BSD license as described in the LICENSE file in the top-level 
>> directory.
>> +#
>> +
>> +[manifest]
>> +/usr/lib/&/libexpat.so.1: %(miscbase)s/usr/lib64/&
>> +/usr/lib/&/libjpeg.so.62: %(miscbase)s/usr/lib64/&
>> +/usr/lib/jni/balloon.so: java/jni/balloon.so
>> +/usr/lib/jni/monitor.so: java/jni/monitor.so
>> +/usr/lib/&/jni/elf-loader.so: java/&
>> +/usr/lib/&/jni/networking.so: java/&
>> +/usr/l

Re: [PATCH] Support building and running Java apps in non-isolated mode

2016-11-02 Thread Nadav Har'El
Hi, thanks. I committed patch because I think it is a good direction.
However, I'd appreciate followon patches for:

1. While ./scripts/build image=java-non-isolated,java-example seems to
work, I tried ./scripts/build image=java-non-isolated,tomcat - and it
didn't work. I don't know if this will be solved by one of your later
patches?

2. modules/java-non-isolated now contains a copy of the Makefile and
module.py (with a couple more lines). This will likely bite us in the
future, when someone fixes one but forgets the other. Could you please have
the ones from java-non-isolated "read" the ones from ../java/ (there is
syntax to do that in both Python and Makefile), to avoid this duplication?

Thanks,
Nadav.



--
Nadav Har'El
n...@scylladb.com

On Fri, Oct 14, 2016 at 11:13 PM, Waldemar Kozaczuk 
wrote:

> Added new java-non-isolated module and refactored
>  scripts/module.py to provide isolated_jvm and non_isolated_jvm as a way to
>  build and run java apps in isolated (old default) and non-isolated mode.
>
> The non-isolated mode gets enabled by module.py that detects if selected
>  java module (provides = ['java']) has following attribute set to true
> like so:
>
> non_isolated_jvm = True
>
> Example to build an image with isolated JVM (default):
> ./scripts/build image=java,java-example
>
> Example to build an image with non-isolated JVM:
> ./scripts/build image=java-non-isolated,java-example
>
> Fixes #800
>
> Signed-off-by: Waldemar Kozaczuk 
> ---
>  modules/java-non-isolated/Makefile | 10 ++
>  modules/java-non-isolated/module.py| 28 
>  modules/java-non-isolated/usr.manifest | 21 +
>  scripts/module.py  | 25 ++---
>  4 files changed, 81 insertions(+), 3 deletions(-)
>  create mode 100644 modules/java-non-isolated/Makefile
>  create mode 100644 modules/java-non-isolated/module.py
>  create mode 100644 modules/java-non-isolated/usr.manifest
>
> diff --git a/modules/java-non-isolated/Makefile
> b/modules/java-non-isolated/Makefile
> new file mode 100644
> index 000..d5d916e
> --- /dev/null
> +++ b/modules/java-non-isolated/Makefile
> @@ -0,0 +1,10 @@
> +# TODO: need to move compilation of $(java-targets) from the main makefile
> +# to here. Unfortunately, compiling with OSv header files is a big mess,
> +# and much easier to do it in the main OSv makefile :-(
> +SRC = $(shell readlink -f ../..)
> +module:
> +   cd $(SRC)/java && mvn package -DskipTests=true
> +
> +clean:
> +   cd $(SRC)/java && mvn clean
> +   -rm -f dependency-reduced-pom.xml
> diff --git a/modules/java-non-isolated/module.py
> b/modules/java-non-isolated/module.py
> new file mode 100644
> index 000..1f5b401
> --- /dev/null
> +++ b/modules/java-non-isolated/module.py
> @@ -0,0 +1,28 @@
> +from osv.modules.filemap import FileMap
> +from osv.modules import api
> +import os, os.path
> +
> +usr_files = FileMap()
> +
> +provides = ['java']
> +
> +non_isolated_jvm = True
> +
> +api.require('fonts')
> +api.require('ca-certificates')
> +api.require('libz')
> +api.require('josvsym')
> +api.require('httpserver-jolokia-plugin')
> +api.require('httpserver-jvm-plugin')
> +
> +jdkdir = os.path.basename(os.path.expandvars('${jdkbase}'))
> +
> +usr_files.add('${jdkbase}').to('/usr/lib/jvm/java') \
> +.include('lib/**') \
> +.include('jre/**') \
> +.exclude('jre/lib/security/cacerts') \
> +.exclude('jre/lib/audio/**')
> +
> +usr_files.link('/usr/lib/jvm/' + jdkdir).to('java')
> +usr_files.link('/usr/lib/jvm/jre').to('java/jre')
> +usr_files.link('/usr/lib/jvm/java/jre/lib/security/cacerts'
> ).to('/etc/pki/java/cacerts')
> diff --git a/modules/java-non-isolated/usr.manifest
> b/modules/java-non-isolated/usr.manifest
> new file mode 100644
> index 000..63b11bc
> --- /dev/null
> +++ b/modules/java-non-isolated/usr.manifest
> @@ -0,0 +1,21 @@
> +#
> +# Copyright (C) 2013-2014 Cloudius Systems, Ltd.
> +#
> +# This work is open source software, licensed under the terms of the
> +# BSD license as described in the LICENSE file in the top-level directory.
> +#
> +
> +[manifest]
> +/usr/lib/&/libexpat.so.1: %(miscbase)s/usr/lib64/&
> +/usr/lib/&/libjpeg.so.62: %(miscbase)s/usr/lib64/&
> +/usr/lib/jni/balloon.so: java/jni/balloon.so
> +/usr/lib/jni/monitor.so: java/jni/monitor.so
> +/usr/lib/&/jni/elf-loader.so: java/&
> +/usr/lib/&/jni/networking.so: java/&
> +/usr/lib/&/jni/stty.so: java/&
> +/usr/lib/&/jni/tracepoint.so: java/&
> +/usr/lib/&/jni/power.so: java/&
> +/java.so: java/jvm/java_non_isolated.so
> +/usr/lib/libosv.so: libosv.so
> +/usr/lib/jvm/java/jre/lib/ext/runjava.jar: ${OSV_BASE}/java/runjava/
> target/runjava.jar
> +/java/cloudius.jar: ${OSV_BASE}/java/cloudius/target/cloudius.jar
> diff --git a/scripts/module.py b/scripts/module.py
> index aede2cf..19c39b5 100755
> --- a/scripts/module.py
> +++ b/scripts/module.py
> @@ -8,7 +8,7 @@ import argparse
>  from functools import reduce
>  from osv.modules i

[PATCH] Support building and running Java apps in non-isolated mode

2016-10-14 Thread Waldemar Kozaczuk
Added new java-non-isolated module and refactored
 scripts/module.py to provide isolated_jvm and non_isolated_jvm as a way to
 build and run java apps in isolated (old default) and non-isolated mode.

The non-isolated mode gets enabled by module.py that detects if selected 
 java module (provides = ['java']) has following attribute set to true like so:

non_isolated_jvm = True

Example to build an image with isolated JVM (default):
./scripts/build image=java,java-example

Example to build an image with non-isolated JVM:
./scripts/build image=java-non-isolated,java-example

Fixes #800

Signed-off-by: Waldemar Kozaczuk 
---
 modules/java-non-isolated/Makefile | 10 ++
 modules/java-non-isolated/module.py| 28 
 modules/java-non-isolated/usr.manifest | 21 +
 scripts/module.py  | 25 ++---
 4 files changed, 81 insertions(+), 3 deletions(-)
 create mode 100644 modules/java-non-isolated/Makefile
 create mode 100644 modules/java-non-isolated/module.py
 create mode 100644 modules/java-non-isolated/usr.manifest

diff --git a/modules/java-non-isolated/Makefile 
b/modules/java-non-isolated/Makefile
new file mode 100644
index 000..d5d916e
--- /dev/null
+++ b/modules/java-non-isolated/Makefile
@@ -0,0 +1,10 @@
+# TODO: need to move compilation of $(java-targets) from the main makefile
+# to here. Unfortunately, compiling with OSv header files is a big mess,
+# and much easier to do it in the main OSv makefile :-(
+SRC = $(shell readlink -f ../..)
+module:
+   cd $(SRC)/java && mvn package -DskipTests=true
+
+clean:
+   cd $(SRC)/java && mvn clean
+   -rm -f dependency-reduced-pom.xml
diff --git a/modules/java-non-isolated/module.py 
b/modules/java-non-isolated/module.py
new file mode 100644
index 000..1f5b401
--- /dev/null
+++ b/modules/java-non-isolated/module.py
@@ -0,0 +1,28 @@
+from osv.modules.filemap import FileMap
+from osv.modules import api
+import os, os.path
+
+usr_files = FileMap()
+
+provides = ['java']
+
+non_isolated_jvm = True
+
+api.require('fonts')
+api.require('ca-certificates')
+api.require('libz')
+api.require('josvsym')
+api.require('httpserver-jolokia-plugin')
+api.require('httpserver-jvm-plugin')
+
+jdkdir = os.path.basename(os.path.expandvars('${jdkbase}'))
+
+usr_files.add('${jdkbase}').to('/usr/lib/jvm/java') \
+.include('lib/**') \
+.include('jre/**') \
+.exclude('jre/lib/security/cacerts') \
+.exclude('jre/lib/audio/**')
+
+usr_files.link('/usr/lib/jvm/' + jdkdir).to('java')
+usr_files.link('/usr/lib/jvm/jre').to('java/jre')
+usr_files.link('/usr/lib/jvm/java/jre/lib/security/cacerts').to('/etc/pki/java/cacerts')
diff --git a/modules/java-non-isolated/usr.manifest 
b/modules/java-non-isolated/usr.manifest
new file mode 100644
index 000..63b11bc
--- /dev/null
+++ b/modules/java-non-isolated/usr.manifest
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2013-2014 Cloudius Systems, Ltd.
+#
+# This work is open source software, licensed under the terms of the
+# BSD license as described in the LICENSE file in the top-level directory.
+#
+
+[manifest]
+/usr/lib/&/libexpat.so.1: %(miscbase)s/usr/lib64/&
+/usr/lib/&/libjpeg.so.62: %(miscbase)s/usr/lib64/&
+/usr/lib/jni/balloon.so: java/jni/balloon.so
+/usr/lib/jni/monitor.so: java/jni/monitor.so
+/usr/lib/&/jni/elf-loader.so: java/&
+/usr/lib/&/jni/networking.so: java/&
+/usr/lib/&/jni/stty.so: java/&
+/usr/lib/&/jni/tracepoint.so: java/&
+/usr/lib/&/jni/power.so: java/&
+/java.so: java/jvm/java_non_isolated.so
+/usr/lib/libosv.so: libosv.so
+/usr/lib/jvm/java/jre/lib/ext/runjava.jar: 
${OSV_BASE}/java/runjava/target/runjava.jar
+/java/cloudius.jar: ${OSV_BASE}/java/cloudius/target/cloudius.jar
diff --git a/scripts/module.py b/scripts/module.py
index aede2cf..19c39b5 100755
--- a/scripts/module.py
+++ b/scripts/module.py
@@ -8,7 +8,7 @@ import argparse
 from functools import reduce
 from osv.modules import api, resolve, filemap
 
-class jvm(api.basic_app):
+class isolated_jvm(api.basic_app):
 multimain_manifest = '/etc/javamains'
 apps = []
 
@@ -33,6 +33,21 @@ class jvm(api.basic_app):
 def add(self, app):
 self.apps.append(app)
 
+def has_any_app(self):
+return self.apps
+
+class non_isolated_jvm(api.basic_app):
+app = None
+
+def get_launcher_args(self):
+return ['java.so'] + self.app.get_jvm_args() + 
self.app.get_multimain_lines()
+
+def add(self, app):
+self.app = app
+
+def has_any_app(self):
+return self.app
+
 def expand(text, variables):
 def resolve(m):
 name = m.group('name')
@@ -117,7 +132,11 @@ def flatten_list(elememnts):
 
 def get_basic_apps(apps):
 basic_apps = []
-_jvm = jvm()
+java = resolve.require('java')
+if hasattr(java,'non_isolated_jvm') and java.non_isolated_jvm:
+_jvm = non_isolated_jvm()
+else:
+_jvm = isolated_jvm()
 
 for app in flatten_list(apps):
 if isinstanc