You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Mark Womack <mw...@apache.org> on 2004/11/28 08:05:29 UTC
PluginRegistry Review
Attempting to get my head wrapped around this stuff before starting on the watchdog design and implementation.
1) You guys beat me to it. I was going to make the change from a static, separate PluginRegistry to a per-LoggerRepository instance. Good move. That really simplified the implementation, of which there was serious need. Thanks.
2) startPlugin was changed to addPlugin and it appears that the activateOptions() method is no longer called in startPlugin. Why? Right after the plugin is added to the registry, we call firePluginStarted(), which isn't true anymore; the registry has no idea when the plugin will be started. Just wondering if this is an oversight or if there was a reason. Is there ever a case where you would want to add a plugin to the registry but not start it immediately?
3) All of the isEquivalent checking has been removed. The reason this was here before was related to the upcoming watchdog stuff. Let's say you have a receiver configured in your xml configuration. That xml configuration changes, the watchdog see this, and initiates the reconfiguration. Now, the same reciever is still configured in the xml file, no differences. If you shutdown the existing receiver, create and start a new receiver (all with the same settings), there will be a period of time where logging events will not be received and will be lost; the time in which the receiver is not there. The isEquivalent was a way to get around this. If it appears that the plugin is equivalent to an existing one, then let the existing one remain, thus having no "down time". I'd like to do this "is equivalent" check more elegantly; it places a burden on the plugin developer to implement correctly. Or maybe the above scenario does not warrant this feature?
4) Does it bother anyone that plugins can be started/stopped independently of the PluginRegistry? I'm not sure how to enforce all plugin actions done through the registry. Maybe it is not that big of a deal.
-Mark
Re: PluginRegistry Review
Posted by Ceki Gülcü <ce...@qos.ch>.
At 09:44 PM 11/28/2004, Mark Womack wrote:
>Ceki,
>
>I guess I am missing the context here since we are successfully
>configuring plugins today with the old XML configurator.
>
>And looking at the code, the o.a.l.spi.LoggerRepository interface has new
>methods to get/return the PR associated with it. The Hierarchy class
>implements them, so there is a reference to the PR. You added these at
>the time you made PR per-instance instead of a single static. Is there
>anything more that needs to be done? Are you suggesting that we do away
>with the PR and move relevant methods into the LoggerRepository?
Yesterday when I wrote
One additional point, a PR knows about its owning LoggingRepository
but the inverse is not true. The owning LoggingRepository does not
know its PR. This of course makes configuring plugins through a
config file impossible.
I looked but somehow did not see that LoggingRepository.getPluginRegistry
method. Just ignore the above paragraph.
>-Mark
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: PluginRegistry Review
Posted by Mark Womack <mw...@apache.org>.
Ceki,
I guess I am missing the context here since we are successfully configuring
plugins today with the old XML configurator.
And looking at the code, the o.a.l.spi.LoggerRepository interface has new
methods to get/return the PR associated with it. The Hierarchy class
implements them, so there is a reference to the PR. You added these at the
time you made PR per-instance instead of a single static. Is there anything
more that needs to be done? Are you suggesting that we do away with the PR
and move relevant methods into the LoggerRepository?
-Mark
----- Original Message -----
From: "Ceki Gülcü" <ce...@qos.ch>
To: "Log4J Developers List" <lo...@logging.apache.org>
Sent: Sunday, November 28, 2004 11:09 AM
Subject: Re: PluginRegistry Review
Mark,
One additional point, a PR knows about its owning LoggingRepository but the
inverse is not true. The owning LoggingRepository does not know its PR.
This of course makes configuring plugins through a config file impossible.
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: PluginRegistry Review
Posted by Ceki Gülcü <ce...@qos.ch>.
Mark,
One additional point, a PR knows about its owning LoggingRepository but the
inverse is not true. The owning LoggingRepository does not know its PR.
This of course makes configuring plugins through a config file impossible.
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: PluginRegistry Review
Posted by Ceki Gülcü <ce...@qos.ch>.
At 09:37 PM 11/28/2004, Mark Womack wrote:
>OK. Then we should change the name of the event to firePluginAdded
>instead of firePluginStarted, and we should find a different way to report
>that a plugin has been started, if it is important.
No because I doubt anyone would be interested in the fact that the plugin
was added to the PR. The firePluginStarted method should be called after
the activating the plugin and adding it to PR. However, firePluginStarted
could be renamed to firePluginActivated.
>>Mark, keep in mind that the current impossibility for us to stop the
>>watchdog thread at LoggingRepository shutdown, constitutes a very
>>serious bug. We MUST be able to cleanly stop the watchdog thread at
>>LoggingRepository shutdown, otherwise application servers like Tomcat
>>cannot cleanly recycle the application. (I cannot over emphasize the
>>importance of this problem.)
>
>Yeah, it is serious. Using the plugin architecture for watchdogs will
>solve this issue since plugins are shutdown properly when the repository
>is shutdown.
Real test cases proving this would be nice. I just realized that DBReceiver
would not be closed on LogManager.shutdown. (Another case of acute
do-as-i-say-not-as-i-doitis.)
>Darn reformat/reinstall. How's this message?
Just perfect. :-)
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: PluginRegistry Review
Posted by Mark Womack <mw...@apache.org>.
Ceki,
> It's a separation of concerns' issue. The PluginRegistry is just a
> bag containing plugins, plus keeps track of listeners.
>
> Also keep in mind that we already have a model for configuring log4j
> components. It is as follows:
>
> 1) Create a new instance of the desired class, call this instance X.
> 2) Name the instance x.
> 3) Configure sub-components of X, if any such sub-components exist
> 4) invoke x.activateOptions
>
> Once point 4 is completed, we have a configured component. Whether the
> component gets attached somewhere, for example to a logger in the case
> of an Appender, is not important. x.activateOptions is always called
> before attaching the component.
>
> If you consider that activateOption methods can throw exceptions
> (caugt by the Configurator), then it should become clear that calling
> activateOptions within the PluginRegistry add method is wrong.
>
> One can always call firePluginStarted *after* adding a Plugin to
> PluginRegistry.
OK. Then we should change the name of the event to firePluginAdded instead
of firePluginStarted, and we should find a different way to report that a
plugin has been started, if it is important.
>> 3) All of the isEquivalent checking has been removed. The reason this
>> was here before was related to the upcoming watchdog stuff. Let's say
>> ...
>> isEquivalent was a way to get around this. If it appears that the
>> plugin is equivalent to an existing one, then let the existing one
>> remain, thus having no "down time". I'd like to do this "is
>> equivalent" check more elegantly, it places a burden on the plugin
>> developer to implement correctly. Or maybe the above scenario does
>> not warrant this feature?
>
> As long as log4j components, including Plugins are named entities,
> then one can keep track of them through their names.
OK. We can start with just that and see where it goes.
> Mark, keep in mind that the current impossibility for us to stop the
> watchdog thread at LoggingRepository shutdown, constitutes a very
> serious bug. We MUST be able to cleanly stop the watchdog thread at
> LoggingRepository shutdown, otherwise application servers like Tomcat
> cannot cleanly recycle the application. (I cannot over emphasize the
> importance of this problem.)
Yeah, it is serious. Using the plugin architecture for watchdogs will solve
this issue since plugins are shutdown properly when the repository is
shutdown.
> To solve it, I wrote the o.a.log4j.scheduler package. Each
> LoggerRepository comes with a scheduler which is lazily
> intialized. When the LoggerRepository is shutdown so is its Scheduler
> (if it has been initialized).
>
> A Watchdog then simply becomes a recurrent Job registered with the
> Scheduler.
Yep. I noticed the new scheduler stuff during my review, and I plan to use
it in the watchdog implementation.
> ps. If you can, please post simple text messages, with no HTML.
Darn reformat/reinstall. How's this message?
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: PluginRegistry Review
Posted by Ceki Gülcü <ce...@qos.ch>.
Mark,
Paul
At 08:05 AM 11/28/2004, Mark Womack wrote:
> 2) startPlugin was changed to addPlugin and it appears that the
> activateOptions() method is no longer called in startPlugin. Why?
> Right after the plugin is added to the registry, we call
> firePluginStarted(), which isn't true anymore, the registry has no
> idea when the plugin will be started. Just wondering if this is an
> oversight or if there was a reason. Is there ever a case where you
> would want to add a plugin to the registry but not start it
> immediately?
It's a separation of concerns' issue. The PluginRegistry is just a
bag containing plugins, plus keeps track of listeners.
Also keep in mind that we already have a model for configuring log4j
components. It is as follows:
1) Create a new instance of the desired class, call this instance X.
2) Name the instance x.
3) Configure sub-components of X, if any such sub-components exist
4) invoke x.activateOptions
Once point 4 is completed, we have a configured component. Whether the
component gets attached somewhere, for example to a logger in the case
of an Appender, is not important. x.activateOptions is always called
before attaching the component.
If you consider that activateOption methods can throw exceptions
(caugt by the Configurator), then it should become clear that calling
activateOptions within the PluginRegistry add method is wrong.
One can always call firePluginStarted *after* adding a Plugin to
PluginRegistry.
> 3) All of the isEquivalent checking has been removed. The reason this
> was here before was related to the upcoming watchdog stuff. Let's say
> you have a receiver configured in your xml configuration. That xml
> configuration changes, the watchdog see this, and initiates the
> reconfiguration. Now, the same reciever is still configured in the
> xml file, no differences. If you shutdown the existing receiver,
> create and start a new receiver (all with the same settings), there
> will be a period of time where logging events will not be received and
> will be lost, the time in which the receiver is not there. The
> isEquivalent was a way to get around this. If it appears that the
> plugin is equivalent to an existing one, then let the existing one
> remain, thus having no "down time". I'd like to do this "is
> equivalent" check more elegantly, it places a burden on the plugin
> developer to implement correctly. Or maybe the above scenario does
> not warrant this feature?
As long as log4j components, including Plugins are named entities,
then one can keep track of them through their names.
> 4) Does it bother anyone that plugins can be started/stopped
> independently of the PluginRegistry? I'm not sure how to enforce all
> plugin actions done through the registry. Maybe it is not that big of
> a deal.
If you view the PR as a bag, then the starting and stopping of a Plugin
is naturally independent of the PR.
Mark, keep in mind that the current impossibility for us to stop the
watchdog thread at LoggingRepository shutdown, constitutes a very
serious bug. We MUST be able to cleanly stop the watchdog thread at
LoggingRepository shutdown, otherwise application servers like Tomcat
cannot cleanly recycle the application. (I cannot over emphasize the
importance of this problem.)
To solve it, I wrote the o.a.log4j.scheduler package. Each
LoggerRepository comes with a scheduler which is lazily
intialized. When the LoggerRepository is shutdown so is its Scheduler
(if it has been initialized).
A Watchdog then simply becomes a recurrent Job registered with the
Scheduler.
ps. If you can, please post simple text messages, with no HTML.
>-Mark
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org