Re: Cross-session Persistent Object?

2020-02-12 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jerry,

On 2/11/20 6:55 PM, Jerry Malcolm wrote:
> 
> On 2/11/2020 4:32 PM, Christopher Schultz wrote:
> 
> Jerry,
> 
> On 2/11/20 3:11 PM, Jerry Malcolm wrote:
 I need some advice.  I need to maintain a set of
 long-running threads. When a request comes in, I need to
 determine if I have a thread started for a particular id
 found in the request.  So I need to have a hashmap of threads
 keyed by the ids.  That part is simple enough.  But I'm
 struggling with where to keep that hashmap object so that it
 is available to all incoming requests (any session). This
 object should persistently remain as long as Tomcat is
 active. It must be scoped to the virtual host and only needs
 to be available in one webapp context within that host.
 Suggestions on how to proceed will be greatly appreciated.
> Can you give more details?
> 
> - Does this HAVE TO remain available even when no web applications
> are deployed -- particularly the one(s) which established the
> registry to begin with?
> 
>> It only needs to be available while the particular web app is
>> running. But the web app should start when TC boots and remain
>> running until TC stops.

Ok.

> - Does this HAVE TO be limited to a single web app? Or is it okay
> to have separate thread-registries in each web application where
> this will be used?
>> It needs to be one global registry for the entire virtual host.

I'm not sure I understand this: will multiple web applications be
using this? Or just the one? Your answer to my first question makes it
seem like this is really just for one webapp, but your answer to the
second question makes it sound like this is really a cross-webapp servic
e.

> - Does this HAVE TO be shared between all the web applications 
> deployed within a VirtualHost?
>> I'm pretty sure I can keep it all contained within one web app in
>> the host.

Hmm. More evidence for a single-webapp solution, which doesn't sound
like it really needs to be shared amongst all the webapps in a virtual
host.

> - Do you need to be able to actually touch the java.lang.Thread 
> object, or do you just need to be able to determine whether a 
> particular id has a thread running for it?
> 
>> I'm going to need to communicate a little bit with the threads
>> during processing of requests.  But I could use a dropbox/queue
>> approach for communication if necessary.

I'm trying to understand if an out-of-process mechanism will work. For
example, you could just have an RDBMS table like this:

+++
| request-id | thread-started |
+++
| 1234567890 |   true |
| 9876543210 |   true |
+++

Whenever you start a thread for a request, you pop a record into the
db. Whenever it stops, it removes the record. The value for
"thread-started" is always "true". I suppose you could remove the
thread-started column because it doesn't do anything except remind the
humans what's happening. Maybe you want a date in that field. Maybe
you want to know when it *stopped*.

You could have as many of these tables as required, for whatever
applications you need. The applications who need to share these data
will all use the same table.

You only asked about knowing whether or not a thread was running. This
will work. I'm guessing you have other requirements that make this
solution too simple.

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5EHQoACgkQHPApP6U8
pFgtyw/+NW7hivOQBhKGqdLgWjUtZkaDP1a5hkW4xMQFvBCkQTxowFDb42bAbIxF
cT/nEeDOeiYhDXJEdU+SI/KvWNUc4SLXTuY4oxDTSyCn0bk9/QwRz0Z2+BVM7R6M
9lS0PLRoRZv/kvMeH/tLJa3RCBK/8N/yb++vSPsZzeNfrJIdlf27dgMHE7B9RDkg
yAR5s3+zNFRn2eULGvul9HSauBG3V9+cPI2mBDk0LK2fcxe9M++8ZF3oYg0za/Js
b3fm3rC0fGy+Zf9TVkstdXZN0ncwUXpjuml/7TogirEQxVK9SoxpnnAxYIG45Oz5
ERRGkwyGZcc4DdAp+xhHcJzXKR46a+tzYG+DruXXWBynAJAbyHzfx4bXtgbId7Zo
qV0YsmAIqWUZMlHMwCL+T7Fx4wsOROY+SklYKvgPswKe0s/BzXLG+QBgAdvWfesD
Ty64Tb61V5/XUnAI0rYDOAoRLKYDzknJiGRnElp02hqZHRNQ1yOP7rI1JtZ5rHTS
nO09XyYrSxc3qCba2n3t5cwIAnJFE29QufPox2l0AM1ikCVt9y2d1B+GYy4PfvyO
eJ7w9iHU1cQ3IJKZx3TkzyahJeObcPXC+QuX0eW+8+VrWzcGoXxlJ7Hvx53JFYKx
P/jDOUPlSgMGy8Zdryi+E5CO9DIqJY6/kh085guUkzeBv4a8pRg=
=QRJU
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Cross-session Persistent Object?

2020-02-11 Thread Jerry Malcolm


On 2/11/2020 4:32 PM, Christopher Schultz wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jerry,

On 2/11/20 3:11 PM, Jerry Malcolm wrote:

I need some advice.  I need to maintain a set of long-running
threads. When a request comes in, I need to determine if I have a
thread started for a particular id found in the request.  So I need
to have a hashmap of threads keyed by the ids.  That part is simple
enough.  But I'm struggling with where to keep that hashmap object
so that it is available to all incoming requests (any session).
This object should persistently remain as long as Tomcat is active.
It must be scoped to the virtual host and only needs to be
available in one webapp context within that host. Suggestions on
how to proceed will be greatly appreciated.

Can you give more details?

- - Does this HAVE TO remain available even when no web applications are
deployed -- particularly the one9s0 which established the registry to
begin with?
It only needs to be available while the particular web app is running.  
But the web app should start when TC boots and remain running until TC 
stops.


- - Does this HAVE TO be limited to a single web app? Or is it okay to
have separate thread-registries in each web application where this
will be used?

It needs to be one global registry for the entire virtual host.


- - Does this HAVE TO be shared between all the web applications
deployed within a VirtualHost?

I'm pretty sure I can keep it all contained within one web app in the host.


- - Do you need to be able to actually touch the java.lang.Thread
object, or do you just need to be able to determine whether a
particular id has a thread running for it?
I'm going to need to communicate a little bit with the threads during 
processing of requests.  But I could use a dropbox/queue approach for 
communication if necessary.


- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5DK2UACgkQHPApP6U8
pFjcNA//Uiclpr76o0TJcsJb0qaIJ5WdAwK6D9gpHJwf4CzqUn6P0gRZeNpvRrFc
hevwZPvcZyZnDxhJU/wRFBVnPiaYdkeNU2u+9nDsJ6BgfCmQHtfQCh57Mab9KUPU
8i5aIx9jdZwGGF9gdGDmYCmwg7Vs6MV78jAX0BYNvx4emLly3xnCWzvRT9OR24dw
6/eFHX83XObuAN5TatEe1Sptx0Ko2sR52EzhyCGXCEkU/iBcMKOyui16eStwdTzS
R3FZNpUYQKK6immYKL1Jx5xBJiSrgZQT++GTIaOYrhmYUReo974NB8liLEK6DEGY
vlL30oH5sKBwqZgW+jjng2MaFyV/LXm/D2TN7cF4vWgdwBOqlRQ3LxL+YrQdzS81
cpwV30nAGm71B3V+0/AMRisPTdvTmxF/nOt5E7cIb9bJCDZwNWDcNUzR8G9lJBC+
3a1CX+NZnUYEV5yZ59O3wpNlBfj1FLn5VP22JvtRR027ibeFPCje034L5qNBGCJm
61pJRPBV7cnXmdhG/VTzFCJLTQ36qfuf9v0plY8hS1HuikYP90bMtHO67HGBT2Nm
tseZ/dLs4YpyuwnpvNAxEEYEtz6YfU9O85DbUPOH++ZzLVjP6GNRpJ2km/do95/S
RQ3g9q5fylgyeXf2xuhTQLYRC8m++Fwv+PaxGvyIkTzpayE3p0g=
=knui
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
On 2/11/2020 4:32 PM, Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jerry,

On 2/11/20 3:11 PM, Jerry Malcolm wrote:

I need some advice.  I need to maintain a set of long-running
threads. When a request comes in, I need to determine if I have a
thread started for a particular id found in the request.  So I need
to have a hashmap of threads keyed by the ids.  That part is simple
enough.  But I'm struggling with where to keep that hashmap object
so that it is available to all incoming requests (any session).
This object should persistently remain as long as Tomcat is active.
It must be scoped to the virtual host and only needs to be
available in one webapp context within that host. Suggestions on
how to proceed will be greatly appreciated.

Can you give more details?

- - Does this HAVE TO remain available even when no web applications are
deployed -- particularly the one9s0 which established the registry to
begin with?

- - Does this HAVE TO be limited to a single web app? Or is it okay to
have separate thread-registries in each web application where this
will be used?

- - Does this HAVE TO be shared between all the web applications
deployed within a VirtualHost?

- - Do you need to be able to actually touch the java.lang.Thread
object, or do you just need to be able to determine whether a
particular id has a thread running for it?

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5DK2UACgkQHPApP6U8
pFjcNA//Uiclpr76o0TJcsJb0qaIJ5WdAwK6D9gpHJwf4CzqUn6P0gRZeNpvRrFc
hevwZPvcZyZnDxhJU/wRFBVnPiaYdkeNU2u+9nDsJ6BgfCmQHtfQCh57Mab9KUPU
8i5aIx9jdZwGGF9gdGDmYCmwg7Vs6MV78jAX0BYNvx4emLly3xnCWzvRT9OR24dw
6/eFHX83XObuAN5TatEe1Sptx0Ko2sR52EzhyCGXCEkU/iBcMKOyui16eStwdTzS
R3FZNpUYQKK6immYKL1Jx5xBJiSrgZQT++GTIaOYrhmYUReo974NB8liLEK6DEGY
vlL30oH5sKBwqZgW+jjng2MaFyV/LXm/D2TN7cF4vWgdwBOqlRQ3LxL+YrQdzS81
cpwV30nAGm71B3V+0/AMRisPTdvTmxF/nOt5E7cIb9bJCDZwNWDcNUzR8G9lJBC+

Re: Cross-session Persistent Object?

2020-02-11 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jerry,

On 2/11/20 3:11 PM, Jerry Malcolm wrote:
> I need some advice.  I need to maintain a set of long-running
> threads. When a request comes in, I need to determine if I have a
> thread started for a particular id found in the request.  So I need
> to have a hashmap of threads keyed by the ids.  That part is simple
> enough.  But I'm struggling with where to keep that hashmap object
> so that it is available to all incoming requests (any session).
> This object should persistently remain as long as Tomcat is active.
> It must be scoped to the virtual host and only needs to be
> available in one webapp context within that host. Suggestions on
> how to proceed will be greatly appreciated.

Can you give more details?

- - Does this HAVE TO remain available even when no web applications are
deployed -- particularly the one9s0 which established the registry to
begin with?

- - Does this HAVE TO be limited to a single web app? Or is it okay to
have separate thread-registries in each web application where this
will be used?

- - Does this HAVE TO be shared between all the web applications
deployed within a VirtualHost?

- - Do you need to be able to actually touch the java.lang.Thread
object, or do you just need to be able to determine whether a
particular id has a thread running for it?

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5DK2UACgkQHPApP6U8
pFjcNA//Uiclpr76o0TJcsJb0qaIJ5WdAwK6D9gpHJwf4CzqUn6P0gRZeNpvRrFc
hevwZPvcZyZnDxhJU/wRFBVnPiaYdkeNU2u+9nDsJ6BgfCmQHtfQCh57Mab9KUPU
8i5aIx9jdZwGGF9gdGDmYCmwg7Vs6MV78jAX0BYNvx4emLly3xnCWzvRT9OR24dw
6/eFHX83XObuAN5TatEe1Sptx0Ko2sR52EzhyCGXCEkU/iBcMKOyui16eStwdTzS
R3FZNpUYQKK6immYKL1Jx5xBJiSrgZQT++GTIaOYrhmYUReo974NB8liLEK6DEGY
vlL30oH5sKBwqZgW+jjng2MaFyV/LXm/D2TN7cF4vWgdwBOqlRQ3LxL+YrQdzS81
cpwV30nAGm71B3V+0/AMRisPTdvTmxF/nOt5E7cIb9bJCDZwNWDcNUzR8G9lJBC+
3a1CX+NZnUYEV5yZ59O3wpNlBfj1FLn5VP22JvtRR027ibeFPCje034L5qNBGCJm
61pJRPBV7cnXmdhG/VTzFCJLTQ36qfuf9v0plY8hS1HuikYP90bMtHO67HGBT2Nm
tseZ/dLs4YpyuwnpvNAxEEYEtz6YfU9O85DbUPOH++ZzLVjP6GNRpJ2km/do95/S
RQ3g9q5fylgyeXf2xuhTQLYRC8m++Fwv+PaxGvyIkTzpayE3p0g=
=knui
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Cross-session Persistent Object?

2020-02-11 Thread M. Manna
If database is the answer, you could use memcache/redis to do this too. It
should be able to support multiple servers if you need.

Since it’s only persistent based on tomcat, I was thinking at the servlet
context level only. Provided that database read overhead is acceptable,
it’s a more persistent solution.

Thanks,

On Tue, 11 Feb 2020 at 20:56, Rouse, Ed  wrote:

>
>
> From: Jerry Malcolm 
> Sent: Tuesday, February 11, 2020 3:12 PM
> To: users@tomcat.apache.org
> Subject: Cross-session Persistent Object?
>
> [External email: Use caution! Do not open attachments or click on links
> from unknown senders or unexpected emails.]
> I need some advice.  I need to maintain a set of long-running threads.
> When a request comes in, I need to determine if I have a thread started
> for a particular id found in the request.  So I need to have a hashmap
> of threads keyed by the ids.  That part is simple enough.  But I'm
> struggling with where to keep that hashmap object so that it is
> available to all incoming requests (any session).  This object should
> persistently remain as long as Tomcat is active.  It must be scoped to
> the virtual host and only needs to be available in one webapp context
> within that host. Suggestions on how to proceed will be greatly
> appreciated.
>
> Thx.
>
> Jerry
>
> I would set up a database table to store the values and create a
> class/script depending on your
> environment that would be able to do crud processes on the table. Maybe
> set it up as a web service
> if that would allow easier access for the individual webapps.
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org users-unsubscr...@tomcat.apache.org>
> For additional commands, e-mail: users-h...@tomcat.apache.org users-h...@tomcat.apache.org>
>


RE: Cross-session Persistent Object?

2020-02-11 Thread Rouse, Ed


From: Jerry Malcolm 
Sent: Tuesday, February 11, 2020 3:12 PM
To: users@tomcat.apache.org
Subject: Cross-session Persistent Object?

[External email: Use caution! Do not open attachments or click on links from 
unknown senders or unexpected emails.]
I need some advice.  I need to maintain a set of long-running threads.
When a request comes in, I need to determine if I have a thread started
for a particular id found in the request.  So I need to have a hashmap
of threads keyed by the ids.  That part is simple enough.  But I'm
struggling with where to keep that hashmap object so that it is
available to all incoming requests (any session).  This object should
persistently remain as long as Tomcat is active.  It must be scoped to
the virtual host and only needs to be available in one webapp context
within that host. Suggestions on how to proceed will be greatly
appreciated.

Thx.

Jerry

I would set up a database table to store the values and create a class/script 
depending on your
environment that would be able to do crud processes on the table. Maybe set it 
up as a web service
if that would allow easier access for the individual webapps.
-
To unsubscribe, e-mail: 
users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: 
users-h...@tomcat.apache.org


Re: Cross-session Persistent Object?

2020-02-11 Thread M. Manna
Jerry,


On Tue, 11 Feb 2020 at 20:12, Jerry Malcolm  wrote:

> I need some advice.  I need to maintain a set of long-running threads.
> When a request comes in, I need to determine if I have a thread started
> for a particular id found in the request.  So I need to have a hashmap
> of threads keyed by the ids.  That part is simple enough.  But I'm
> struggling with where to keep that hashmap object so that it is
> available to all incoming requests (any session).  This object should
> persistently remain as long as Tomcat is active.  It must be scoped to
> the virtual host and only needs to be available in one webapp context
> within that host. Suggestions on how to proceed will be greatly
> appreciated.
>
> Thx.
>
> Jerry
>
>  Would setting your hashmap as attribute to the Servlet context work?

>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>