On 20 Jun 2016, at 20:48, Brian Stansberry
On 6/20/16 5:04 AM, Kabir Khan wrote:
> Jeff and I were chatting about https://issues.jboss.org/browse/WFCORE-1157
There is currently a PR
) to allow
listening on the ControlledProcessState state changes. This is done via users registering
NotificationHandlers on the runtime-configuration-state.
> Since the notification handlers are executed asynchronously, there is no guarantee
that e.g. on a stop that the notification handler is triggered for the 'stopping'
and 'stopped' (the PR introduces this latter state) state changes since the server
may be down before this happens. The PR works around this by making the controller execute
the runtime-configuration-state handlers synchronously. However, this then means that the
standard notifications and the runtime-configuration-state notifications end up being in
separate streams, so that the 'stopping' handler may be invoked upon before the
standard/async notification handlers reflecting earlier changes.
> In fact looking at this a bit closer, the NonBlockingNotificationSupport class uses a
thread pool with several threads. This means that for the standard async notifications,
it is very likely that the handler for notification1 gets invoked before
notification2's handler, but is is _not_ guaranteed. If the thread processing
notification1 is paused for whatever reason, notification2 may end up being handled first.
Should we change the executor in NonBlockingNotificationSupport to be a single thread
I think it's guaranteed. All notifications go into a single queue and
then there is a lock that ensures only 1 thread at a time is processing
Ah yes, I missed that. I was speculating on the code according to my
memory from a few weeks ago!
You could skip the locking bit by using a single thread executor, but
that means creating a new executor, cleaning it up properly on shutdown,
and always having a thread in this pool, mostly doing nothing.
> Jeff also suggested, perhaps keeping the runtime-configuration-state notifications as
asynchronous, but to add some constructs to make sure that these always get executed
before server shutdown. This would keep the functionality from this PR where the
notifications are always invoked, and also make sure that the order is preserved.
> wildfly-dev mailing list
Senior Principal Software Engineer
JBoss by Red Hat
wildfly-dev mailing list