Fire internal listeners before external stream ones

By separating the internal listeners from the external stream event
listeners, this fixes two problems with the previous design. First, it
causes events from other primaries to only be sent to the external
stream event listeners instead of the internal listeners. This ensures
that any internal event processing (such as posting a comment on a
cherry-picked change) only happens once per cluster instead of once per
primary as it would previously. Second, since all new events resulting
from internal dispatching will have been dispatched before sending
events to stream listeners, no new events will be dispatched while
sending to stream listeners, and this avoids a sending loop which could
previously happen in these situations.

Also include some minor cleanups such a removing an unneeded volatile,
and ordering variable definitions.

Change-Id: Id95cbfef48d8b5c9bc3179dabb37949aed514227
2 files changed