Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Attaching a globally-unique Job object to a user session's "Progress View"
Attaching a globally-unique Job object to a user session's "Progress View" [message #103241] Wed, 27 August 2008 19:48 Go to next message
Eclipse UserFriend
Originally posted by: akarypid.yahoo.gr

Hi,

I am a new user of RAP (by the way, congratulations to the project team
for this cool stuff!) and need guidance implementing the following scenario:

My application performs a periodic house-keeping task. It is launched
using a standard java.util.concurrent.ScheduledExecutorService which is
static (unique within the application) and is instantiated in the
plug-in's activator.

In order to be able to display the task's project, I use the Eclipse
jobs API (org.eclipse.core.runtime.jobs.Job) and the Runnable() launched
periodically simply calls "myStaticJob.schedule()" to run the job.

However, when I open a client session to my application using a web
browser and reveal the standard eclipse progress view (id:
org.eclipse.ui.views.ProgressView), the GUI is not updated. The job's
progress (reported through its IProgressMonitor) is not shown (even
though the job is running and I can see its "debug" output printed on
the console).

After careful consideration, I believe that the reason for this is that
in RAP, each user has an HTTP session and the progress view only shows
jobs from that session. To test this, I added an Action to create and
launch a non-static instance of my job: indeed, the progress view was
updated with the job's progress (from the IProgressMonitor) in that case.

Now, I can get a reference to the Job instance (since it is a static
object) when the user opens the RAP session. Is there a way to "attach"
this Job to the user's progress view so that the user GUI is updated
when the job runs? I would like any "logged-in" user to be able to see
that the job is running...
Re: Attaching a globally-unique Job object to a user session's "Progress View" [message #104340 is a reply to message #103241] Mon, 08 September 2008 09:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Alexandros,

as far as I understand, your observations are right. RAP currently
does not list 'static' jobs in the ProgressView. Only those jobs
created within the session are visible in the sessions' ProgressView.
We are aware that there are valid use cases for this and aim to
provide a solution, but it is unlikely to happen in the near future.

To work around this, you could write a session-scoped job, that
propagates the progress of the house-keeping job to the UI using
e.g. a producer-consumer pattern.
Please be aware that you need to clean up properly when sessions
terminate to avoid memory leaks.

HTH
Rüdiger

Alexandros Karypidis wrote:
> Hi,
>
> I am a new user of RAP (by the way, congratulations to the project team
> for this cool stuff!) and need guidance implementing the following
> scenario:
>
> My application performs a periodic house-keeping task. It is launched
> using a standard java.util.concurrent.ScheduledExecutorService which is
> static (unique within the application) and is instantiated in the
> plug-in's activator.
>
> In order to be able to display the task's project, I use the Eclipse
> jobs API (org.eclipse.core.runtime.jobs.Job) and the Runnable() launched
> periodically simply calls "myStaticJob.schedule()" to run the job.
>
> However, when I open a client session to my application using a web
> browser and reveal the standard eclipse progress view (id:
> org.eclipse.ui.views.ProgressView), the GUI is not updated. The job's
> progress (reported through its IProgressMonitor) is not shown (even
> though the job is running and I can see its "debug" output printed on
> the console).
>
> After careful consideration, I believe that the reason for this is that
> in RAP, each user has an HTTP session and the progress view only shows
> jobs from that session. To test this, I added an Action to create and
> launch a non-static instance of my job: indeed, the progress view was
> updated with the job's progress (from the IProgressMonitor) in that case.
>
> Now, I can get a reference to the Job instance (since it is a static
> object) when the user opens the RAP session. Is there a way to "attach"
> this Job to the user's progress view so that the user GUI is updated
> when the job runs? I would like any "logged-in" user to be able to see
> that the job is running...
Re: Attaching a globally-unique Job object to a user session's "Progress View" [message #104379 is a reply to message #104340] Mon, 08 September 2008 19:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: akarypid.yahoo.gr

Hello Rüdiger,

Thank you very much for your reply. I have in fact managed to get this
working since I posted. I do exactly what you suggest, but now have
another problem: in order to receive updates to the client GUI from the
server side, I am forced to use UICallback.activate(). When a RAP client
disappears (e.g. because the user closes the browser program), I have
stale "proxy jobs" left on the server that need to be cleaned-up.

I have summarized my problem in these posts:

The problem:
http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg04224.html
My understanding of how callbacks work:
http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg04181.html

Unfortunately so far there's been no feedback. I would appreciate it if
you gave me some general direction to look towards (I'm not lazy, I just
need some overall direction). What I need is a way to detect that a
UICallback.activate() has been "broken" in order to perform some cleanup
(remove instances of a class called ProxyJob -- see the following for
details).

To give some context, the outline of my solution follows (btw, if
anybody is interested and the moderator of this newsgroup has no
objection, I can post the code here. it's ~200 lines):

------------------------

1) I have defined a class called ForwarderMonitor that implements
IProgressMonitor. This class wraps an "underlying" IProgressMonitor and
has a list of "registered listener" IProgressMonitors. Whenever a method
is called [worked(), beginTask(), etc] on the Forwarder monitor, it
calls the respective method on the "underlying monitor", as well as for
all "registered listener" monitors.

2) I have an abstract class called MultiMonitorJob which implements the
run() method and provides an abstract "dorun(ForwarderMonitor m)" method
for the end-developer to put the actual code. therefore, the actual job
implementation reports progress to a number of monitors (all those that
are registered to the ForwarderMonitor given as a parameter). Each
MultiMonitorJob has a ForwarderMonitor private member. When a
MultiMonitorJob is scheduled, its run() method calls dorun() with that
ForwarderMonitor.

3) I then created another class called "ProxyJob". MultiMonitorJob has a
"createProxyJob()" method that creates an instance. When the RAP client
logs in, I call this method to create a "proxy job" for that RAP client.
The list of proxy jobs is maintained in the actual job (MultiMonitorJob)
and when the job's run() is called, it calls schedule() on all the
ProxyJob instances that exist. ProxyJob simply registers its
IProgressMonitor with the ForwarderMonitor of the MultiMonitorJob from
which it was created and then calls join() to wait for the actual job to
complete. As the job is running, progress is relayed by the forwarder
progress monitor of MultiMonitorJob to the IProgressMonitor of each
ProxyJob and ultimately to all RAP clients.

Rüdiger Herrmann wrote:

> Hi Alexandros,
>
> as far as I understand, your observations are right. RAP currently does
> not list 'static' jobs in the ProgressView. Only those jobs created
> within the session are visible in the sessions' ProgressView.
> We are aware that there are valid use cases for this and aim to provide
> a solution, but it is unlikely to happen in the near future.
>
> To work around this, you could write a session-scoped job, that
> propagates the progress of the house-keeping job to the UI using e.g. a
> producer-consumer pattern.
> Please be aware that you need to clean up properly when sessions
> terminate to avoid memory leaks.
>
> HTH
> Rüdiger
>
> Alexandros Karypidis wrote:
>> Hi,
>>
>> I am a new user of RAP (by the way, congratulations to the project
>> team for this cool stuff!) and need guidance implementing the
>> following scenario:
>>
>> My application performs a periodic house-keeping task. It is launched
>> using a standard java.util.concurrent.ScheduledExecutorService which
>> is static (unique within the application) and is instantiated in the
>> plug-in's activator.
>>
>> In order to be able to display the task's project, I use the Eclipse
>> jobs API (org.eclipse.core.runtime.jobs.Job) and the Runnable()
>> launched periodically simply calls "myStaticJob.schedule()" to run the
>> job.
>>
>> However, when I open a client session to my application using a web
>> browser and reveal the standard eclipse progress view (id:
>> org.eclipse.ui.views.ProgressView), the GUI is not updated. The job's
>> progress (reported through its IProgressMonitor) is not shown (even
>> though the job is running and I can see its "debug" output printed on
>> the console).
>>
>> After careful consideration, I believe that the reason for this is
>> that in RAP, each user has an HTTP session and the progress view only
>> shows jobs from that session. To test this, I added an Action to
>> create and launch a non-static instance of my job: indeed, the
>> progress view was updated with the job's progress (from the
>> IProgressMonitor) in that case.
>>
>> Now, I can get a reference to the Job instance (since it is a static
>> object) when the user opens the RAP session. Is there a way to
>> "attach" this Job to the user's progress view so that the user GUI is
>> updated when the job runs? I would like any "logged-in" user to be
>> able to see that the job is running...
Re: Attaching a globally-unique Job object to a user session's "Progress View" [message #104471 is a reply to message #104379] Tue, 09 September 2008 10:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Alexandros,

from what I understand you would need to clean up the ProxyJob
(interrupt its Thread) when the session it belongs to ends.

Not sure if you already do so. If not, there is an ISessionStore
(returned by RWT#getSessionStore) that allows you to register
SessionStoreListeners that are notified when a session terminates.

In case that doesn't solve the problem, could you please send some
(preferably self-contained) code that demonstrates what you described?

If you would like to share the ForwarderMonitor, ProxyJob etc
classes, you are welcome to do so in any case.

Cheers,
Rüdiger


Alexandros Karypidis wrote:
> Hello Rüdiger,
>
> Thank you very much for your reply. I have in fact managed to get this
> working since I posted. I do exactly what you suggest, but now have
> another problem: in order to receive updates to the client GUI from the
> server side, I am forced to use UICallback.activate(). When a RAP client
> disappears (e.g. because the user closes the browser program), I have
> stale "proxy jobs" left on the server that need to be cleaned-up.
>
> I have summarized my problem in these posts:
>
> The problem:
> http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg04224.html
> My understanding of how callbacks work:
> http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg04181.html
>
> Unfortunately so far there's been no feedback. I would appreciate it if
> you gave me some general direction to look towards (I'm not lazy, I just
> need some overall direction). What I need is a way to detect that a
> UICallback.activate() has been "broken" in order to perform some cleanup
> (remove instances of a class called ProxyJob -- see the following for
> details).
>
> To give some context, the outline of my solution follows (btw, if
> anybody is interested and the moderator of this newsgroup has no
> objection, I can post the code here. it's ~200 lines):
>
> ------------------------
>
> 1) I have defined a class called ForwarderMonitor that implements
> IProgressMonitor. This class wraps an "underlying" IProgressMonitor and
> has a list of "registered listener" IProgressMonitors. Whenever a method
> is called [worked(), beginTask(), etc] on the Forwarder monitor, it
> calls the respective method on the "underlying monitor", as well as for
> all "registered listener" monitors.
>
> 2) I have an abstract class called MultiMonitorJob which implements the
> run() method and provides an abstract "dorun(ForwarderMonitor m)" method
> for the end-developer to put the actual code. therefore, the actual job
> implementation reports progress to a number of monitors (all those that
> are registered to the ForwarderMonitor given as a parameter). Each
> MultiMonitorJob has a ForwarderMonitor private member. When a
> MultiMonitorJob is scheduled, its run() method calls dorun() with that
> ForwarderMonitor.
>
> 3) I then created another class called "ProxyJob". MultiMonitorJob has a
> "createProxyJob()" method that creates an instance. When the RAP client
> logs in, I call this method to create a "proxy job" for that RAP client.
> The list of proxy jobs is maintained in the actual job (MultiMonitorJob)
> and when the job's run() is called, it calls schedule() on all the
> ProxyJob instances that exist. ProxyJob simply registers its
> IProgressMonitor with the ForwarderMonitor of the MultiMonitorJob from
> which it was created and then calls join() to wait for the actual job to
> complete. As the job is running, progress is relayed by the forwarder
> progress monitor of MultiMonitorJob to the IProgressMonitor of each
> ProxyJob and ultimately to all RAP clients.
>
> Rüdiger Herrmann wrote:
>
>> Hi Alexandros,
>>
>> as far as I understand, your observations are right. RAP currently
>> does not list 'static' jobs in the ProgressView. Only those jobs
>> created within the session are visible in the sessions' ProgressView.
>> We are aware that there are valid use cases for this and aim to
>> provide a solution, but it is unlikely to happen in the near future.
>>
>> To work around this, you could write a session-scoped job, that
>> propagates the progress of the house-keeping job to the UI using e.g.
>> a producer-consumer pattern.
>> Please be aware that you need to clean up properly when sessions
>> terminate to avoid memory leaks.
>>
>> HTH
>> Rüdiger
>>
>> Alexandros Karypidis wrote:
>>> Hi,
>>>
>>> I am a new user of RAP (by the way, congratulations to the project
>>> team for this cool stuff!) and need guidance implementing the
>>> following scenario:
>>>
>>> My application performs a periodic house-keeping task. It is launched
>>> using a standard java.util.concurrent.ScheduledExecutorService which
>>> is static (unique within the application) and is instantiated in the
>>> plug-in's activator.
>>>
>>> In order to be able to display the task's project, I use the Eclipse
>>> jobs API (org.eclipse.core.runtime.jobs.Job) and the Runnable()
>>> launched periodically simply calls "myStaticJob.schedule()" to run
>>> the job.
>>>
>>> However, when I open a client session to my application using a web
>>> browser and reveal the standard eclipse progress view (id:
>>> org.eclipse.ui.views.ProgressView), the GUI is not updated. The job's
>>> progress (reported through its IProgressMonitor) is not shown (even
>>> though the job is running and I can see its "debug" output printed on
>>> the console).
>>>
>>> After careful consideration, I believe that the reason for this is
>>> that in RAP, each user has an HTTP session and the progress view only
>>> shows jobs from that session. To test this, I added an Action to
>>> create and launch a non-static instance of my job: indeed, the
>>> progress view was updated with the job's progress (from the
>>> IProgressMonitor) in that case.
>>>
>>> Now, I can get a reference to the Job instance (since it is a static
>>> object) when the user opens the RAP session. Is there a way to
>>> "attach" this Job to the user's progress view so that the user GUI is
>>> updated when the job runs? I would like any "logged-in" user to be
>>> able to see that the job is running...
Re: Attaching a globally-unique Job object to a user session's "Progress View" [message #104563 is a reply to message #104471] Tue, 09 September 2008 16:40 Go to previous message
Eclipse UserFriend
Originally posted by: akarypid.yahoo.gr

This is a multi-part message in MIME format.
--------------000608080209010401010309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

The zip file contains a plug-in that provides the functionality and
another one that provides demo application. The demo creates a job in
the activator (global singleton) and the workbench window advisor calls
createProxy() to attach the client UI to the server job (i.e. creates a
ProxyJob).

Regarding your question, the proxy job does not really get stuck. The
problem is that it is created when a client connects and must cease to
exist when a client leaves. I had two ideas but lacked the knowledge to
implement them (though now you have given me an answer for approach #2):

1) My understanding is that UICallback.activate() maintains an open HTTP
connection among the server and the client. If so, RWT would know when
this connection is broken. Is there a way for my code to be notified of
this? I would then respond by removing the ProxyJob instance for the client.

2) At the very least, is there a way to retrieve the list of active HTTP
session ids (i.e. list of clients running the RAP application). I would
then be able to remove all stale proxies if the session id in the proxy
is no longer listed in "active sessions".

I will now look at SessionStoreListeners. From what I understand I
should be able to create a listener that removes the proxy when the
client's HTTP session is destroyed. This would ensure that all proxies
are destroyed at the very latest when the sessions expire.

Thank you for your help and patience in resolving this.

R
Previous Topic:size of a StandaloneView
Next Topic:Profiling RAP applications with TPTP?
Goto Forum:
  


Current Time: Fri Apr 26 06:41:26 GMT 2024

Powered by FUDForum. Page generated in 0.02603 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top