You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@oodt.apache.org by Jordan Padams <jo...@gmail.com> on 2013/11/08 02:31:58 UTC

PushPull DaemonLauncher

Hello all,

I am trying to develop a pretty simple wrapper for the PushPull where I
call the DaemonLauncher to run through the daemons in my config once and
then shut down altogether.  We currently don't have a need to have the
software running at intervals.

On that note, here are a few of the methods I've tried but haven't worked:

1. DaemonLauncher.main() - The software hangs because of the wait() waiting
for a notify().
2. DaemonLauncher.viewDaemonWaitingList() - I've tried monitoring the
daemon waiting list, and quit() the DaemonLauncher once it gets to 0, but
then it misses the last daemon in my config.

Is there a way for me to wait on the DaemonLauncher until all daemons have
completed, then quit?

I've implemented a quick workaround by creating the following method so I
can see if daemons are still running:

    public boolean hasRunningDaemons() {

        return this.dm.hasRunningDaemons();

    }
I don't have a lot of experience with daemon processes so this may just be
something I'm blatantly missing.  Appreciate the help.

Thanks,
Jordan

-- 
Jordan Padams
Software Engineer
NASA Jet Propulsion Laboratory

Re: PushPull DaemonLauncher

Posted by Bruce Barkstrom <br...@gmail.com>.
You could take a look at the design philosophy in

Burns, A. and Wellings, A, 2007: Concurrent and Real-Time
Programming in Ada, Cambridge Press

or

McCormick, J. W., Singhoff, F., and Hugues, J., 2011:
Building Parallel, Embedded, and Real-Time Applications
with Ada, Cambridge Press

Bruce R. Barkstrom


On Thu, Nov 7, 2013 at 8:31 PM, Jordan Padams <jo...@gmail.com>wrote:

> Hello all,
>
> I am trying to develop a pretty simple wrapper for the PushPull where I
> call the DaemonLauncher to run through the daemons in my config once and
> then shut down altogether.  We currently don't have a need to have the
> software running at intervals.
>
> On that note, here are a few of the methods I've tried but haven't worked:
>
> 1. DaemonLauncher.main() - The software hangs because of the wait() waiting
> for a notify().
> 2. DaemonLauncher.viewDaemonWaitingList() - I've tried monitoring the
> daemon waiting list, and quit() the DaemonLauncher once it gets to 0, but
> then it misses the last daemon in my config.
>
> Is there a way for me to wait on the DaemonLauncher until all daemons have
> completed, then quit?
>
> I've implemented a quick workaround by creating the following method so I
> can see if daemons are still running:
>
>     public boolean hasRunningDaemons() {
>
>         return this.dm.hasRunningDaemons();
>
>     }
> I don't have a lot of experience with daemon processes so this may just be
> something I'm blatantly missing.  Appreciate the help.
>
> Thanks,
> Jordan
>
> --
> Jordan Padams
> Software Engineer
> NASA Jet Propulsion Laboratory
>

Re: PushPull DaemonLauncher

Posted by Cameron Goodale <si...@gmail.com>.
Hey Brian,

Thanks for looking into this for me.  Here is an excerpt from the logs
after I turned them up to FINE (trying to see anything I might be missing)
and I also added in some of my own log statements to track the Daemon
unregister method.  I added in a 3 star (***) prefix to note the log
messages I added.

One thing to note is after my log messages the process should have shutdown
but it would just hang there, so I think something outside the startDaemon
method is keeping the process alive.  Perhaps the missing notify() method
you mentioned can resolve it.


FINE: Should close connection in response to directive: close
Dec 3, 2013 9:46:13 AM org.apache.commons.httpclient.HttpConnection
releaseConnection
FINE: Releasing connection back to connection manager.
Dec 3, 2013 9:46:13 AM
org.apache.oodt.cas.pushpull.retrievalsystem.FileRetrievalSystem
addToDownloadQueue
WARNING: Skipping file {parent = 'null', path =
'/allData/1/MOD09GA/Recent/MOD09GA.A2013336.h25v05.005.NRT.hdf', isDir =
'false'} because it is already in staging area
Dec 3, 2013 9:46:16 AM
org.apache.oodt.cas.pushpull.protocol.ProtocolHandler disconnect
INFO: Disconnecting protocol
org.apache.oodt.cas.protocol.ftp.CommonsNetFtpProtocol
Dec 3, 2013 9:46:16 AM org.apache.oodt.cas.pushpull.daemon.Daemon$1 run
INFO: Daemon with ID = 90111 on RMI registry port 9011 is shutting down
***Dec 3, 2013 9:46:16 AM org.apache.oodt.cas.pushpull.daemon.Daemon
unregister
***INFO: Unregistered the MBean
***Dec 3, 2013 9:46:16 AM org.apache.oodt.cas.pushpull.daemon.Daemon
unregister
***INFO: UnicastRemoteObject undone
***Dec 3, 2013 9:46:16 AM org.apache.oodt.cas.pushpull.daemon.Daemon
unregister
***INFO: After daemonListener
***Dec 3, 2013 9:46:16 AM org.apache.oodt.cas.pushpull.daemon.Daemon$1 run
***INFO: Unregistration Completed

To be complete, here is a Patch of where I added in the Log messages (just
in case I added them incorrectly):

Index: Daemon.java
===================================================================
--- Daemon.java (revision 1546755)
+++ Daemon.java (working copy)
@@ -239,6 +239,8 @@
                         + Daemon.this.getDaemonID() + " on RMI registry
port "
                         + Daemon.this.rmiRegPort + " is shutting down");
                 Daemon.this.unregister();
+                LOG.log(Level.INFO, "Unregistration Completed");
+
             }
         }).start();
     }
@@ -251,8 +253,11 @@
             this.mbs.unregisterMBean(new ObjectName(
                     "org.apache.oodt.cas.pushpull.daemon:type=Daemon"
                             + this.getDaemonID()));
+            LOG.log(Level.INFO, "Unregistered the MBean");
             UnicastRemoteObject.unexportObject(this, true);
+            LOG.log(Level.INFO, "UnicastRemoteObject undone");
             this.daemonListener.wasUnregisteredWith(this);
+            LOG.log(Level.INFO, "After daemonListener");
         } catch (Exception e) {
             e.printStackTrace();
         }

-Cameron


On Tue, Dec 3, 2013 at 11:41 AM, Brian Foster <ho...@me.com> wrote:

> Hey Cameron,
>
> can you attach the logs when you come across another case where the
> pushpull gets stuck?
>
> i was doing a quick pass through the code... it looks like the
> DaemonController stays up all the time... wait() is called on it... i
> thought there was a notify() call when daemon queue became empty, which
> would cause the DaemonController to wake up and terminate, but i don't see
> it... i will see if i can get a fix in for that sometime this week.
>
> -Brian
>
>
> On Nov 30, 2013, at 03:08 PM, Cameron Goodale <si...@gmail.com> wrote:
>
> Hey Brian and Jordan,
>
> I have a similar issue with trying to run pushpull within a cron because
> for some reason (i need to sort out) my pushpull daemon will just hang
> after running and sleeping successfully using
> the org.apache.oodt.cas.protocol.ftp.CommonsNetFtpProtocol. I haven't
> taken the time to find out how many sleep/wake cycles it takes to
> eventually hang, but I have seen it happen several times now.
>
> I looked into the code and it seems like updating the runInfo tag so
> period="" should short circuit the code from re-running, but when I have
> done this in testing I get a message like this:
>
> Nov 30, 2013 10:07:32 AM
> org.apache.oodt.cas.pushpull.protocol.ProtocolHandler disconnect
> INFO: Disconnecting protocol
> org.apache.oodt.cas.protocol.ftp.CommonsNetFtpProtocol
> Nov 30, 2013 10:07:32 AM org.apache.oodt.cas.pushpull.daemon.Daemon$1 run
> INFO: Daemon with ID = 90111 on RMI registry port 9011 is shutting down
>
> but the process doesn't actually stop. Looking at Daemon.java I see that:
> Daemon.this.unregister(); is called right after that log message, but it
> doesn't seem to quit the process. That command is run within a Java Thread
> object, but nothing seems to stop the Thread, so the daemon will never
> exit.
>
> If you guys have made any progress on this I would love to hear about it.
> I am also not an expert on Java Threads, so I could have missed something
> in the code, but it seems like the Thread is started and never terminated.
>
> Thanks for reading,
>
>
>
> Cameron
>
>
> On Thu, Nov 21, 2013 at 1:43 PM, Brian Foster <ho...@me.com> wrote:
>
> Hey Jordan,
>
> Try not specifying the <runInfo> element for your daemons in
>
> RemoteSpecs.xml file. It should just run once through for those sites. I
>
> believe the pushpull shuts down automatically when all deamons have
>
> terminated, so after you run one pass it should just terminate. It's been
>
> a while since i've worked with push-pull code, if that doesn't work i'll
>
> have to dig further into the code.
>
> if you looking to do just a on off download a given file, then you might
>
> consider just using cas-protocol directly. Take a look at:
>
>
> https://svn.apache.org/repos/asf/oodt/trunk/protocol/api/src/main/resources/policy/cmd-line-actions.xml
> .
>
> You can run cas-protocol via this bin script:
>
>
> https://svn.apache.org/repos/asf/oodt/trunk/protocol/api/src/main/bin/protocol
> .
>
> Just build and deploy like all other cas products and that script will end
>
> up in the bin directory. If you would like to add custom action to
>
> cas-protocol there is documentation for this at:
>
> https://svn.apache.org/repos/asf/oodt/trunk/cli/README.txt
>
> -Brian
>
> On Nov 07, 2013, at 05:31 PM, Jordan Padams <jo...@gmail.com>
>
> wrote:
>
> Hello all,
>
> I am trying to develop a pretty simple wrapper for the PushPull where I
>
> call the DaemonLauncher to run through the daemons in my config once and
>
> then shut down altogether. We currently don't have a need to have the
>
> software running at intervals.
>
> On that note, here are a few of the methods I've tried but haven't worked:
>
> 1. DaemonLauncher.main() - The software hangs because of the wait() waiting
>
> for a notify().
>
> 2. DaemonLauncher.viewDaemonWaitingList() - I've tried monitoring the
>
> daemon waiting list, and quit() the DaemonLauncher once it gets to 0, but
>
> then it misses the last daemon in my config.
>
> Is there a way for me to wait on the DaemonLauncher until all daemons have
>
> completed, then quit?
>
> I've implemented a quick workaround by creating the following method so I
>
> can see if daemons are still running:
>
> public boolean hasRunningDaemons() {
>
> return this.dm.hasRunningDaemons();
>
> }
>
> I don't have a lot of experience with daemon processes so this may just be
>
> something I'm blatantly missing. Appreciate the help.
>
> Thanks,
>
> Jordan
>
> --
>
> Jordan Padams
>
> Software Engineer
>
> NASA Jet Propulsion Laboratory
>
>
>
> --
>
> Sent from a Tin Can attached to a String
>
>


-- 

Sent from a Tin Can attached to a String

Re: PushPull DaemonLauncher

Posted by Cameron Goodale <si...@gmail.com>.
Hey Brian and Jordan,

I have a similar issue with trying to run pushpull within a cron because
for some reason (i need to sort out) my pushpull daemon will just hang
after running and sleeping successfully using
the org.apache.oodt.cas.protocol.ftp.CommonsNetFtpProtocol.  I haven't
taken the time to find out how many sleep/wake cycles it takes to
eventually hang, but I have seen it happen several times now.

I looked into the code and it seems like updating the runInfo tag so
period="" should short circuit the code from re-running, but when I have
done this in testing I get a message like this:

Nov 30, 2013 10:07:32 AM
org.apache.oodt.cas.pushpull.protocol.ProtocolHandler disconnect
INFO: Disconnecting protocol
org.apache.oodt.cas.protocol.ftp.CommonsNetFtpProtocol
Nov 30, 2013 10:07:32 AM org.apache.oodt.cas.pushpull.daemon.Daemon$1 run
INFO: Daemon with ID = 90111 on RMI registry port 9011 is shutting down

but the process doesn't actually stop.  Looking at Daemon.java I see that:
  Daemon.this.unregister();  is called right after that log message, but it
doesn't seem to quit the process.  That command is run within a Java Thread
object, but nothing seems to stop the Thread, so the daemon will never exit.

If you guys have made any progress on this I would love to hear about it.
 I am also not an expert on Java Threads, so I could have missed something
in the code, but it seems like the Thread is started and never terminated.

Thanks for reading,



Cameron


On Thu, Nov 21, 2013 at 1:43 PM, Brian Foster <ho...@me.com> wrote:

> Hey Jordan,
>
> Try not specifying the <runInfo> element for your daemons in
> RemoteSpecs.xml file.  It should just run once through for those sites.  I
> believe the pushpull shuts down automatically when all deamons have
> terminated, so after you run one pass it should just terminate.  It's been
> a while since i've worked with push-pull code, if that doesn't work i'll
> have to dig further into the code.
>
> if you looking to do just a on off download a given file, then you might
> consider just using cas-protocol directly.  Take a look at:
> https://svn.apache.org/repos/asf/oodt/trunk/protocol/api/src/main/resources/policy/cmd-line-actions.xml.
>  You can run cas-protocol via this bin script:
> https://svn.apache.org/repos/asf/oodt/trunk/protocol/api/src/main/bin/protocol.
>  Just build and deploy like all other cas products and that script will end
> up in the bin directory.  If you would like to add custom action to
> cas-protocol there is documentation for this at:
> https://svn.apache.org/repos/asf/oodt/trunk/cli/README.txt
>
> -Brian
>
> On Nov 07, 2013, at 05:31 PM, Jordan Padams <jo...@gmail.com>
> wrote:
>
> Hello all,
>
> I am trying to develop a pretty simple wrapper for the PushPull where I
> call the DaemonLauncher to run through the daemons in my config once and
> then shut down altogether. We currently don't have a need to have the
> software running at intervals.
>
> On that note, here are a few of the methods I've tried but haven't worked:
>
> 1. DaemonLauncher.main() - The software hangs because of the wait() waiting
> for a notify().
> 2. DaemonLauncher.viewDaemonWaitingList() - I've tried monitoring the
> daemon waiting list, and quit() the DaemonLauncher once it gets to 0, but
> then it misses the last daemon in my config.
>
> Is there a way for me to wait on the DaemonLauncher until all daemons have
> completed, then quit?
>
> I've implemented a quick workaround by creating the following method so I
> can see if daemons are still running:
>
> public boolean hasRunningDaemons() {
>
> return this.dm.hasRunningDaemons();
>
> }
> I don't have a lot of experience with daemon processes so this may just be
> something I'm blatantly missing. Appreciate the help.
>
> Thanks,
> Jordan
>
> --
> Jordan Padams
> Software Engineer
> NASA Jet Propulsion Laboratory
>
>


-- 

Sent from a Tin Can attached to a String