W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 2000

Handling multiple requests (Request Queueing/Pooling?)

From: Sanath Jayasena <sanath@math.edu>
Date: Tue, 15 Feb 2000 14:40:48 -0600 (CST)
To: www-jigsaw@w3.org
cc: ylafon@w3.org
Message-ID: <Pine.LNX.3.96.1000212114830.17705C-100000@math.edu>

HI All, 

I am referring the following discussion; I also have a similar problem,
which is described (in detail:-)) subsequently.

<begin previous discussion>

On Wed, 19 Jan 2000, Veena T wrote:
> I am using jigsaw server for my web tool that uses the applet and
> servlets. The servlets form the back end and they are going to connect
> to the database.
> For managing the transactions I am planning to use the connection
> pooling concept. Will jigsaw readily support database connection
> pooling? I am asking this doubt since I came to know that it is not just
> enough if the server supports servlets. Only if the server is supports
> the connection pooling concept then only it mey be implemented.
> Please reply as soon as possible

A while ago, I started to do one, it is not finished yet, and not yet in
the cvs base, I can give it to you in an unfinished state, it should
already work, only some limit checks are missing.
Regards,

      /\          - Yves Lafon - World Wide Web Consortium - 



If this can help :
as I understand, you're using servlets to connect to a database; so it might
not be a Jigsaw problem but a servlet problem, for having a pool of
connection to a database.
....snipped.....

Regards J Brax  

<end of previous discussion>

Here is my story. I appreciate some help/pointers or alpha/beta code
done by others. NOTE: I am NOT using servlets now ! So, please advise me
if servlets is the best way to go. 

I wanted to EXTEND jigsaw so that I could query a database
with a web-browser interface. THe database is implemented 
in native binaries (coded in C/C++ and compiled). Re-writing these in
Java is not an option for me.

I subclassed from 'PostableFrame' a new java class called
"DBFrame". Then I re-wrote the handle() and perform() to take care
of the POST requests coming from a browser. (POST is currently sufficient for
my needs). The database API provides a 'connection' abstraction API that
can be used to send query requests to the DB and then to getback
results. Query requests have to be sent ONE AT A TIME; until
the result is returned for a request, another should NOT be sent. If one tries 
to interfere in the connection when the query is in progress, the 
connection and/or query fails.

I used JNI (Java Native Interface) to integrate the database connection
API into the DBFrame class I created in Jigsaw,  and created a DLL (in WINdows)
and a ".so" (in Linux) that provide  necessary functionality as native methods.
Then I mapped a URL to the new class using JigAdmin. 

Now the problem: when MULTIPLE browsers send POST requests SIMULATANEOUSLY
I need a way to ensure a single request (thread) accesses the database (=>
the connection API) at a time. I tried a simple 'busy' flag in native C code
(in the DLL) as well as in the 'DBFrame' class. None worked correctly.
(I am not expecting hundreds or more concurrent requests; Max is ~ 100)

I tried using 'synchronized' (instance) methods in DBFrame class; didn't 
work either. I suspect independent threads are already created by Jigsaw,
so my techniques are not really blocking these threads. ???
 
Is this  really a Jigsaw issue or (Java/JNI + Multi-threading) issue?

As the above discussion suggests, should I have to do explicit
pooling and queueing of requests using some custom Queue class?
(In the latter case, incoming requests will first go to this queue/pool?)

I would like to see if Yves code would work for me. Could you send me
the code/a pointer to the code please?

Thanks.

Sanath
Received on Tuesday, 15 February 2000 14:42:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:34 GMT