Forum OpenACS Q&A: nsjava is available on sourceforge

Collapse
Posted by Dan Wickstrom on
I've uploaded a version of nsjava at http://nsjava.sourceforge.net.
It seems to be pretty stable on solaris, but I'm seeing a few problems
still on the linux version, so I'm calling it a pre-alpha version.  If
anybody tries it out, I would be interested in hearing, how it goes
for you.  I'll be away traveling the 1st through the 4th of june, so I
might be slow in responding, if you have any questions.

For those of you that don't know, nsjava is a loadable module for
aolserver that embeds a java virtual machine.  Presently it supports
the calling of java static methods from tcl, and there are jni
wrappers around the ns_db, ns_pg and the ns_set api's, so that the
database can be accessed from within java.  The main motivation for
creating this module was to provide a means for porting of some of the
java/sqlj modules coming out of aD.  A prime example being webmail,
which is being used as a test case.

My short-term plans are to spend some time on testing, so that I can
make sure that it is as solid as possible.  I'll then port webmail
againg using nsjava, and do some benchmarks to compare it to the jdbc
version that I have working now.

A note on building.  I've set up autoconf, but it seems that every
vendor has a different directory structure for their jdk installation,
so it's probable that configure might not work if you use a different
jdk than the ones I've tested with.  I used ibm's jdk 1.1.8 on linux,
and sun's jdk 1.1.8 on solaris.  If you try it and get it to work on
something else, let me know, so that I can adjust autoconf.

Collapse
Posted by Roberto Mello on
Outstanding Dan ! This is really great ! Congratulations and keep it up.

Are you going to post this at the AOLserver list or do you want me to ? (I would be glad to do it).

Collapse
Posted by Jason Jones on
Dan,

Have you seen the nstomcat module available at http://www.ss.pub.ro/~gaburici/nstomcat/?

This embeds a JVM in the aolserver process and runs Tomcat in the JVM. The author has notes and results for use with a few different JVM's (1.3 looks good). I know your nsjava project has different aims, but the basics of a JNI connector are the same so I thought I would point it out.

Collapse
Posted by Don Baccus on
Yeah, he knows about it.  The great thing about Dan's work is that he's wrapped ns_db, ns_pg and ns_set in jni wrappers, so the Java code  has direct access to the database using AOLserver's database pool and  driver.  nstomcat needs to go through JDBC, which isn't nearly as useful.

This is great, Dan.

Collapse
Posted by Dan Wickstrom on
Yeh thanks.  I've already had some contact with the author of nstomcat.  I believe his module is intended for general use as a web development tool using .jsp pages as an alternative to aolserver's tcl and adp pages.  My focus is more to support the openacs porting effort by providing access to java library functions from tcl.  This is intended to provide a path to port the sqlj stuff that aD is now using in oracle.

I've also had some contact with one of the tclblend developers, and I now think it might be possible to embed tclblend in aolserver.  Though if I do that, it will only be supported for tcl 8.3 and higher.

Collapse
Posted by Dan Wickstrom on
nsjava version 0.0.4 is now available.  This is the first alpha
release and it is considered reasonably stable for use on solaris
using sun's jdk1.1.8 and on linux using blackdown's jdk1.1.8.  I've
run apache bench against both versions for extended periods of time
without any segfaults or memory leaks.

Version 0.0.4 is available at http://nsjava.sourceforge.net.

I've ported the webmail module to work with nsjava, and it is noticeably faster than using JDBC, though I haven't done any benchmarks yet.  I'm now thinking that it doesn't make sense to shuffle the whole mime-encoded message in and out of the db when sending and receiving messages, so I'm going to modify webmail slightly, so that the messages themselves are kept externally in the filesystem.

Collapse
Posted by Roberto Mello on
Great job Dan ! Though I am completely ignorant on Java, I'll give a shot and test it.

The guy who implemented nstomcat says the newer jdk's are faster. Is it ok to use one of those (>= 1.3) ?

Collapse
Posted by Don Baccus on
Dan - I second your motion to avoid shuffling stuff into and out of the  database.  Ben and I have talked about doing file storage the same way, i.e. store user files in the file system rather than in the database.  This would be more efficient even with "real" large objects  (rather than my kludged large objects).  Would need to develop a repository for binary objects, have all modules use it, etc.

The only reason to stuff the stuff into the database, as far as I can see, is that InterMedia can index it for searching.

Collapse
Posted by Dan Wickstrom on
The only reason to stuff the stuff into the database, as far as I can see, is that InterMedia can index it for searching.

In the case of webmail it sort of makes sense with java inside of oracle, as the mail message needs to be pulled inside the db to parse the message anyway. Of course they could probably write the encoded message back to the filesystem faster than stuffing it into a table in oracle, but not having access to an oracle set-up, I have no way of telling. The main problem that I have with webmail is that it stuffs the mime-encoded message into the db and then pulls it right back out and sends it. After the message is sent, it is deleted from the db, so I can't really any benifit to putting it into the db in the first place. Even with acs classic, I suspect that doing it that way is actually slower than using the filesystem - especially for messages with large attachemts.

I guess we can't really go about implementing a binary file storage module until we see the shape of acs 4.0 - can we?

Collapse
Posted by Don Baccus on
I guess we can't really go about implementing a binary file storage module until we see the shape of acs 4.0 - can we?
Right, which shouldn't be all that long though since they're putting out the core and bboard module first, rather than redoing all at once. Additional modules will roll out on their own schedule.

This is good, because we'll get an early look at the core.

Since very few places deal with binary files, using our own binary storage module and getting rid of my blob hack is one place I don't mind drifting from ACS Classic. If there's any hope of aD wanting to offer a non-db variant themselves, it would be easy to make modules call a binary store repository that could use either blobs or the filesystem, a configurable option. In act, we might want to do that anyway.

Collapse
Posted by Thomas Hundt on
Of course they could probably write the encoded message back to the filesystem faster than stuffing it into a table in oracle, but not having access to an oracle set-up, I have no way of telling. The main problem that I have with webmail is that it stuffs the mime-encoded message into the db and then pulls it right back out and sends it.

Using the database could be very fast: Oracle can keep the data in cache (i.e., memory) and be able to spit it back out immediately. (If we were talking about Sybase, I'd say "definitely is very fast" because everything goes into cache first. I'm not an Oracle guy, so don't know for sure.)

Collapse
Posted by Nima Mazloumi on
Hi, is anyone using nsjava or has some experience with it for productive environments?