You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Querna <pa...@querna.org> on 2009/03/29 21:37:51 UTC

mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

On Sun, Mar 29, 2009 at 9:17 PM,  <mt...@apache.org> wrote:
> Author: mturk
> Date: Sun Mar 29 19:17:30 2009
> New Revision: 759751
>
> URL: http://svn.apache.org/viewvc?rev=759751&view=rev
> Log:
> Use child singleton watchdog for running the heartbeat module
>
> Modified:
>    httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

I'm looking at the API exposed by mod_watchdog.h, and its not quite
feeling right.

If we want this to be an API used easily, I think we should just make
them proper timers (ie, run function X in singleton in 10 seconds),
and when the timer finishes, it can re-register -- this is far more
flexiable, and in the long term the API could be taken over by MPMs
that can better support it.

WDYT?

Thanks,

Paul

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Graham Leggett <mi...@sharp.fm>.
Paul Querna wrote:

> I'm looking at the API exposed by mod_watchdog.h, and its not quite
> feeling right.
> 
> If we want this to be an API used easily, I think we should just make
> them proper timers (ie, run function X in singleton in 10 seconds),
> and when the timer finishes, it can re-register -- this is far more
> flexiable, and in the long term the API could be taken over by MPMs
> that can better support it.
> 
> WDYT?

+1.

The Eclipse Jobs API works in a similar way. You register a job to run 
in X seconds, if you want to run the job again, you reregister the job 
just before you finish.

Regards,
Graham
--

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Mladen Turk <mt...@apache.org>.
Jim Jagielski wrote:
> 
>>
>> fine, disagree with that, but what are your thoughts on switching to
>> the provider API?
>>
> 
> +1 to provider... it's one of the best parts of httpd
> 

But it uses the provider already :)

Regards
-- 
^(TM)

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Mar 30, 2009, at 5:22 AM, Paul Querna wrote:

> On Mon, Mar 30, 2009 at 10:48 AM, Mladen Turk <mt...@apache.org>  
> wrote:
>> Paul Querna wrote:
>>>
>>> On Sun, Mar 29, 2009 at 10:44 PM, Paul Querna <pa...@querna.org>  
>>> wrote:
>>>
>>> Inside a MPM that does it natively, just use the registered list of
>>> providers, and implement the same behavoirs as the module.
>>>
>>
>> The problem with mpm is that (IIRC the proposal) it uses
>> the current free resource. However if busy there will be no
>> resources available. So the solution is to dedicate a
>> separate resource for watchdog thread(s). Now, that's a
>> plain duplicate of mod_watchdog copied across the mpms.
>
> fine, disagree with that, but what are your thoughts on switching to
> the provider API?
>

+1 to provider... it's one of the best parts of httpd


Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Mladen Turk <mt...@apache.org>.
Paul Querna wrote:
> On Mon, Mar 30, 2009 at 10:48 AM, Mladen Turk <mt...@apache.org> wrote:
>> Paul Querna wrote:
>>> On Sun, Mar 29, 2009 at 10:44 PM, Paul Querna <pa...@querna.org> wrote:
>>>
>>> Inside a MPM that does it natively, just use the registered list of
>>> providers, and implement the same behavoirs as the module.
>>>
>> The problem with mpm is that (IIRC the proposal) it uses
>> the current free resource. However if busy there will be no
>> resources available. So the solution is to dedicate a
>> separate resource for watchdog thread(s). Now, that's a
>> plain duplicate of mod_watchdog copied across the mpms.
> 
> fine, disagree with that, but what are your thoughts on switching to
> the provider API?
> 
> I'd like to just implement it, but I don't want to do it and then get
> yelled at......
> 

Well if it'll allow multiple watchdog threads and parent
for non-forked mpm's, I have no problem with any API
you'll end up with :)

IMO all you need is to  split the single callback to
multiple one's. I don't think it's worth the effort,
but you're welcome.

Regards
-- 
^(TM)

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Paul Querna <pa...@querna.org>.
On Mon, Mar 30, 2009 at 10:48 AM, Mladen Turk <mt...@apache.org> wrote:
> Paul Querna wrote:
>>
>> On Sun, Mar 29, 2009 at 10:44 PM, Paul Querna <pa...@querna.org> wrote:
>>
>> Inside a MPM that does it natively, just use the registered list of
>> providers, and implement the same behavoirs as the module.
>>
>
> The problem with mpm is that (IIRC the proposal) it uses
> the current free resource. However if busy there will be no
> resources available. So the solution is to dedicate a
> separate resource for watchdog thread(s). Now, that's a
> plain duplicate of mod_watchdog copied across the mpms.

fine, disagree with that, but what are your thoughts on switching to
the provider API?

I'd like to just implement it, but I don't want to do it and then get
yelled at......

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Mladen Turk <mt...@apache.org>.
Paul Querna wrote:
> On Sun, Mar 29, 2009 at 10:44 PM, Paul Querna <pa...@querna.org> wrote:
> 
> Inside a MPM that does it natively, just use the registered list of
> providers, and implement the same behavoirs as the module.
> 

The problem with mpm is that (IIRC the proposal) it uses
the current free resource. However if busy there will be no
resources available. So the solution is to dedicate a
separate resource for watchdog thread(s). Now, that's a
plain duplicate of mod_watchdog copied across the mpms.


Regards
-- 
^(TM)

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Paul Querna <pa...@querna.org>.
On Sun, Mar 29, 2009 at 10:44 PM, Paul Querna <pa...@querna.org> wrote:
> On Sun, Mar 29, 2009 at 10:25 PM, Mladen Turk <mt...@apache.org> wrote:
>> Paul Querna wrote:
>>>
>>> On Sun, Mar 29, 2009 at 9:17 PM,  <mt...@apache.org> wrote:
>>>>
>>>> Author: mturk
>>>> Date: Sun Mar 29 19:17:30 2009
>>>> New Revision: 759751
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=759751&view=rev
>>>> Log:
>>>> Use child singleton watchdog for running the heartbeat module
>>>>
>>>> Modified:
>>>>   httpd/httpd/trunk/modules/cluster/mod_heartbeat.c
>>>
>>> I'm looking at the API exposed by mod_watchdog.h, and its not quite
>>> feeling right.
>>>
>>> If we want this to be an API used easily, I think we should just make
>>> them proper timers (ie, run function X in singleton in 10 seconds),
>>> and when the timer finishes, it can re-register -- this is far more
>>> flexiable, and in the long term the API could be taken over by MPMs
>>> that can better support it.
>>>
>>> WDYT?
>>>
>>
>> There are actually two API's
>> The one I implemented for heartbeat is the simple one,
>> cause the heartbeat functionality is simple.
>
> And actually the 'simple' API is the one I don't like.
>
> Specifically, the watchdog_need hook. Using the parent/singleton
> parameters and toggling them back and forth is what I don't like.
>
> I think the whole hook section could be replaced with a single
> provider, with a structure like this:
>
> typedef struct ap_watchdog_provider_t ap_watchdog_provider_t;
> struct ap_watchdog_provider_t {
>    const char *name;
>    apr_time_t interval;
>    apr_uint32_t flags;
>    void *baton;
>
>    apr_status_t (*watchdog_init)(void *baton, apr_pool_t *pool);
>    apr_status_t (*watchdog_step)(void *baton, apr_pool_t *pool);
>    apr_status_t (*watchdog_exit)(void *baton, apr_pool_t *pool);
> };
>
> This would expose the ability to set it as parent or singleton via
> flags, and as long as the interval was re-inspected after every step
> call, you could change the interval.
>
> With something like this, I'm not even sure you need the other API --
> i'd prefer to provide one good API that works easily for everyone,
> than 2 or more.
>
>> The second one is where you create a watchdog instance
>> with some interval and then it calls the provided
>> callback. If the callback return != 0 it's not
>> called any more. If you need a different interval,
>> change it by API call.
>
> hm.  I'm think I'd like to restructure the internals so that it could
> be powered by an MPM (ie Simple or Event), or if the MPM isn't
> available it would fallback to the modules functions.

To clarify this, if we used the providers like I suggested above, the
watchdog module could do an MPM Query to see if the MPM supports
watchdog, and if it does, the module just turns off, it gets more
complicated if the mod_watchdog is exposing symbols and hooks that
other modules expect to always be in the ABI, the providers would
provide a separation of implementation from the ABI.

Inside a MPM that does it natively, just use the registered list of
providers, and implement the same behavoirs as the module.

Thanks,

Paul

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Paul Querna <pa...@querna.org>.
On Sun, Mar 29, 2009 at 10:25 PM, Mladen Turk <mt...@apache.org> wrote:
> Paul Querna wrote:
>>
>> On Sun, Mar 29, 2009 at 9:17 PM,  <mt...@apache.org> wrote:
>>>
>>> Author: mturk
>>> Date: Sun Mar 29 19:17:30 2009
>>> New Revision: 759751
>>>
>>> URL: http://svn.apache.org/viewvc?rev=759751&view=rev
>>> Log:
>>> Use child singleton watchdog for running the heartbeat module
>>>
>>> Modified:
>>>   httpd/httpd/trunk/modules/cluster/mod_heartbeat.c
>>
>> I'm looking at the API exposed by mod_watchdog.h, and its not quite
>> feeling right.
>>
>> If we want this to be an API used easily, I think we should just make
>> them proper timers (ie, run function X in singleton in 10 seconds),
>> and when the timer finishes, it can re-register -- this is far more
>> flexiable, and in the long term the API could be taken over by MPMs
>> that can better support it.
>>
>> WDYT?
>>
>
> There are actually two API's
> The one I implemented for heartbeat is the simple one,
> cause the heartbeat functionality is simple.

And actually the 'simple' API is the one I don't like.

Specifically, the watchdog_need hook. Using the parent/singleton
parameters and toggling them back and forth is what I don't like.

I think the whole hook section could be replaced with a single
provider, with a structure like this:

typedef struct ap_watchdog_provider_t ap_watchdog_provider_t;
struct ap_watchdog_provider_t {
    const char *name;
    apr_time_t interval;
    apr_uint32_t flags;
    void *baton;

    apr_status_t (*watchdog_init)(void *baton, apr_pool_t *pool);
    apr_status_t (*watchdog_step)(void *baton, apr_pool_t *pool);
    apr_status_t (*watchdog_exit)(void *baton, apr_pool_t *pool);
};

This would expose the ability to set it as parent or singleton via
flags, and as long as the interval was re-inspected after every step
call, you could change the interval.

With something like this, I'm not even sure you need the other API --
i'd prefer to provide one good API that works easily for everyone,
than 2 or more.

> The second one is where you create a watchdog instance
> with some interval and then it calls the provided
> callback. If the callback return != 0 it's not
> called any more. If you need a different interval,
> change it by API call.

hm.  I'm think I'd like to restructure the internals so that it could
be powered by an MPM (ie Simple or Event), or if the MPM isn't
available it would fallback to the modules functions.

> IMO having separate watchdogs is much better then
> having one that will call multiple callbacks with
> different timeouts because if one job blocks, others
> will not execute.
>
> BTW, we had this discussion few months back.

Yes, but I suck and completely failed to emailize my thoughts, sorry :)

Paul

Re: mod_watchdog API, was Re: svn commit: r759751 - /httpd/httpd/trunk/modules/cluster/mod_heartbeat.c

Posted by Mladen Turk <mt...@apache.org>.
Paul Querna wrote:
> On Sun, Mar 29, 2009 at 9:17 PM,  <mt...@apache.org> wrote:
>> Author: mturk
>> Date: Sun Mar 29 19:17:30 2009
>> New Revision: 759751
>>
>> URL: http://svn.apache.org/viewvc?rev=759751&view=rev
>> Log:
>> Use child singleton watchdog for running the heartbeat module
>>
>> Modified:
>>    httpd/httpd/trunk/modules/cluster/mod_heartbeat.c
> 
> I'm looking at the API exposed by mod_watchdog.h, and its not quite
> feeling right.
> 
> If we want this to be an API used easily, I think we should just make
> them proper timers (ie, run function X in singleton in 10 seconds),
> and when the timer finishes, it can re-register -- this is far more
> flexiable, and in the long term the API could be taken over by MPMs
> that can better support it.
> 
> WDYT?
> 

There are actually two API's
The one I implemented for heartbeat is the simple one,
cause the heartbeat functionality is simple.

The second one is where you create a watchdog instance
with some interval and then it calls the provided
callback. If the callback return != 0 it's not
called any more. If you need a different interval,
change it by API call.

IMO having separate watchdogs is much better then
having one that will call multiple callbacks with
different timeouts because if one job blocks, others
will not execute.

BTW, we had this discussion few months back.

Regards
-- 
^(TM)