Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-315 Implement New Notifier API #4884

Merged
merged 42 commits into from
Sep 21, 2020
Merged

FISH-315 Implement New Notifier API #4884

merged 42 commits into from
Sep 21, 2020

Conversation

MattGill98
Copy link
Contributor

@MattGill98 MattGill98 commented Sep 11, 2020

Description

This is a major refactor of the notification service. The intention is to allow modules depending solely on the internal-api module to send notifications and implement custom notifiers without either having knowledge of the notification service itself. Extra functionality / modifications include:

  • PayaraExecutorService is now used across all notifiers, rather than each notifier implementing their own pooling.
  • It's possible to implement dynamic notifiers without domain.xml that are always enabled.
  • Implementing custom notifiers no longer requires implementations of: MessageImpl, MessageQueue, NotificationEvent, NotificationEventFactory, NotifierConfigurationExecutionOptions, NotifierConfigurationExecutionOptionsFactory, NotifierExecutionOptions, NotifierExecutionOptionsFactory.
  • New GlassFishStubBean allows copying ConfigBeanProxy objects to be referenced statically (respect commands run without the dynamic flag).

Important Info

Blockers

N/A

Testing

New tests

Testing Performed

Manual testing of CDI eventbus notifier with the health check and request tracing services.

Documentation

Not yet, TBD

Notes for Reviewers

The intention is for the notifiers left out of this update to be moved into a different repository by having them depend on an internal-api artifact. Reviewing should keep this in mind - if it's not properly decoupled and version independent it doesn't work.

This reverts commit 2a0b89b.

The reverted commit breaks a websocket TCK test. QACI-406 will endeavour
to fix this test without rolling back functionality.
A new notification module exists alongside the original notifier
project, which it was copied from. This module has then been modified to
incorporate the new API - which is implemented in a custom example
module as well as the new log notifier.

The notifiers can now be referenced by name rather than via a core enum.
This makes them more modular as services like the request tracing
service can discover the notifiers via HK2, and not through a centrally
registered enum.

Notifications can now be sent programmatically through HK2 topics.

Notifiers without any configuration can now be implemented, which
allows dynamic notifiers to be created by users. There is also now much
less boilerplate required to implement new services, as each notifier
listens for the same event type. No factories are required to be
implemented by the API user.

The notification get commands have also been improved to better discover
the notifier names, and to print better information when used from the
console.

Issues left to solve:
 - Some dynamic flags may not work
 - Notifier lifecycles aren't fully controlled (when are the initialize
methods called?
 - Performance hasn't been tested
 - No queues or thread pools are implemented for notifiers
 - Exceptions aren't handled in notifiers
 - Hasn't been tested in a clustered setup

Signed-off-by: Matthew Gill <[email protected]>
Redesigned the notification loop to use the PayaraExecutorService. This
prevents notifications with significant delay from running in the
notifying thread.

Signed-off-by: Matthew Gill <[email protected]>
The notifier bootstrap methods were failing if a configuration was
required as it wasn't being configured correctly.

Deleted unused classes.

Signed-off-by: Matthew Gill <[email protected]>
Fixed the notifier implementation so that the --dynamic flag
functionality is respected. This uses a new proxy bean that duplicates
the current configuration and can be referenced with a lower cost. This
can simply be recreated each time a dynamic configuration change is
made.

Signed-off-by: Matthew Gill <[email protected]>
Updated the request tracing service to use the new notifier API.

Signed-off-by: Matthew Gill <[email protected]>
Updated the health check service to use the new notifier API.

Signed-off-by: Matthew Gill <[email protected]>
Bugs were present, so due to time the lazy loading needs removing.

Signed-off-by: Matthew Gill <[email protected]>
An empty whitelist should count as no notifiers.

Signed-off-by: Matthew Gill <[email protected]>
Make sure HK2 Events are enabled in notification service constructor.

Signed-off-by: Matthew Gill <[email protected]>
Removed the old notification service and renamed the new notification
service. The current notifiers still need revamping.

Signed-off-by: Matthew Gill <[email protected]>
Updated the Audit service to use the new notifier API.

Signed-off-by: Matthew Gill <[email protected]>
Updated the JMX monitoring service to use the new notifier API

Signed-off-by: Matthew Gill <[email protected]>
The API depended on some core notification services packages which it
didn't use.

Signed-off-by: Matthew Gill <[email protected]>
The admin console was broken by the notifier changes, so this change
makes all the relevant updates to get it working again.

Signed-off-by: Matthew Gill <[email protected]>
The new Notifier implementation had strayed from the original API (so
the Payara API wouldn't work). This change returns the original
functionality.

Signed-off-by: Matthew Gill <[email protected]>
@MattGill98 MattGill98 self-assigned this Sep 11, 2020
@MeroRai MeroRai requested a review from dmatej September 14, 2020 08:11
Copy link
Contributor

@jbee jbee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big step in the right direction getting rid of a lot of ceremony while generalising and simplifying the concept and API of notifications. A lot of code could be deleted 👍 . Glad you also updated all the command names to follow the currently used naming conversions with get- and set-.

The configuration classes and commands around them to me seem the least mature which is due to the limitation HK2 style configurations. My hopes were that we could make the configuration even more generic so less code would need virtual duplication. I highlight how HK2 config is cause of ceremony and duplication as I think this is equally the case in many other areas of the server and improvements to this concept would greatly improve what can be done and reduce what needs to be written to do so.

Mostly general, API related comments...

  • Topic<PayaraNotification> to me should be extracted to an interface so the actual implementation via HK2 topics is hidden to the sender making him not depend on HK2 APIs directly
  • I hope PayaraNotificationFactory isn't really needed and that the builder and message could be created just using static methods, e.g. PayaraNotificationBuilder.newBuilder().set. ... .build().
  • Naming: not sure I am a big fan of prefixing the API classes with Payara, it is apparent from the package already but I guess it helps to not confuse old and new API
  • currently a sender will need to use the internal-api common artefact. It might be worth even extracting just the notifier API to a API module on its own. @Pandrex247 WDYT?

Currently the log notifier can be enabled repeatedly, meaning the
domain.xml fills up with log notifier blocks. This commit prevents
this by adding explicit checks to make sure the enabled notifier doesn't
already exist.

Signed-off-by: Matthew Gill <[email protected]>
It was unclear what the NotifierManager interface was for, so this
commit adds better commentary.

Signed-off-by: Matthew Gill <[email protected]>
This fixes 2 bugs:

- When the notification service is initialised, it would initialise all
notifiers regardless of whether they need initialising.
- When a notifier was disabled dynamically, the configuration of the
notifier wouldn't update so it wouldn't be destroyed

The isEnabled() method now reads the current notifier configuration
rather than the domain.xml, and destroying a bean will also cause a
config reload before it shuts down.

Signed-off-by: Matthew Gill <[email protected]>
@Cousjava
Copy link
Contributor

Fails to build, failing on test with:

[ERROR] Tests run: 23, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.453 s <<< FAILURE! - in fish.payara.nucleus.microprofile.config.spi.PayaraConfigTest
[ERROR] convertedValuesAreCached(fish.payara.nucleus.microprofile.config.spi.PayaraConfigTest)  Time elapsed: 0.1 s  <<< FAILURE!
java.lang.AssertionError: Run 8, value is not cached expected:<2> but was:<4>
	at fish.payara.nucleus.microprofile.config.spi.PayaraConfigTest.assertValue(PayaraConfigTest.java:252)
	at fish.payara.nucleus.microprofile.config.spi.PayaraConfigTest.assertCachedValue(PayaraConfigTest.java:243)
	at fish.payara.nucleus.microprofile.config.spi.PayaraConfigTest.convertedValuesAreCached(PayaraConfigTest.java:105)

When the notification service is disabled, none of the notifiers were
being shut down. They are now shutdown, and the destroy() method called
if any notifiers were available.

Signed-off-by: Matthew Gill <[email protected]>
@MattGill98
Copy link
Contributor Author

jenkins test please

@MattGill98 MattGill98 requested a review from jbee September 18, 2020 13:04
Copy link
Contributor

@jbee jbee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Have not run any testing as it is my understanding that you mostly wanted conceptual feedback. Correct me if I am wrong here.

protected void bootstrap() {
// Set the configuration before bootstrapping the notifier
if (config != null) {
PayaraConfiguredNotifier.class.cast(notifier).setConfiguration(config);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, would need to checkout the codebase and browse around this a little to get a better understanding of the relations involved. But as long as we are aware of this I think we could also just give it some time and at some point in the future a batter way becomes apparent to us - then we just have to also do the change :)

Copy link
Contributor

@Cousjava Cousjava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails for me, with error:

GRIZZLY0200: Service exception
java.lang.NullPointerException
        at java.util.Collections$UnmodifiableCollection.<init>(Collections.java:1028)
        at java.util.Collections$UnmodifiableList.<init>(Collections.java:1304)
        at java.util.Collections.unmodifiableList(Collections.java:1289)
        at fish.payara.internal.notification.PayaraNotification.<init>(PayaraNotification.java:77)
        at fish.payara.internal.notification.PayaraNotificationBuilder.build(PayaraNotificationBuilder.java:140)
        at fish.payara.nucleus.requesttracing.RequestTracingService.processTraceEnd(RequestTracingService.java:520)
        at fish.payara.nucleus.requesttracing.RequestTracingService.endTrace(RequestTracingService.java:463)

Which occurred by enabled notification, enabling request tracing with timeout of 300 milliseconds, including non-applications, and store longest traces; then click around in the admin console a couple of times.

The subject wasn't being printed in the messages.

Signed-off-by: Matthew Gill <[email protected]>
@MattGill98 MattGill98 requested a review from Cousjava September 18, 2020 15:55
@MattGill98
Copy link
Contributor Author

@Cousjava has reported that request tracing sends more notifications than before. We're both investigating

@jbee
Copy link
Contributor

jbee commented Sep 18, 2020

request tracing sends more notifications than before. We're both investigating

I would not be surprised if this is more correct than before - keep an open mind for this possibility ;)

Before this change, one thread ran for the notification service and
polled each notifier to handle one notification at a time, before
waiting 50ms. This may not keep up with the speed at which the
notification queue fills up, and notifiers may blocke each other.

After this change, each notifier has it's own thread, which will wait
indefinitely on the queue to fill up on the take() method, and then
reschedule itself every 5ms. This will be much more efficient in
handling notifications, with hopefully a minimal CPU impact.

Signed-off-by: Matthew Gill <[email protected]>
@MattGill98
Copy link
Contributor Author

jenkins test please

Copy link
Contributor

@Cousjava Cousjava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saving the status of notifiers in the admin console does not work.

@MattGill98
Copy link
Contributor Author

Nice spot 👍 Just modified the API to help reduce the risk of incorrect extension (as I did). Testing and will push ASAP.

The getNotifierProperties method was prone to incorrect extension, which
was causing admin console configuration issues to arise. This change
fixes these errors by removing the requirement to implement this method,
and fixes the remaining admin console issues.

Signed-off-by: Matthew Gill <[email protected]>
@MattGill98
Copy link
Contributor Author

jenkins test please

@MattGill98 MattGill98 requested a review from Cousjava September 21, 2020 12:34
@Cousjava
Copy link
Contributor

Fails to build:

[ERROR] Failed to execute goal on project notification-email: Could not resolve dependencies for project fish.payara.server.internal.packager:notification-email:distribution-fragment:5.2020.5-SNAPSHOT: Could not find artifact fish.payara.server.internal.payara-appserver-modules:notification-email-core:jar:5.2020.5-SNAPSHOT

@MattGill98
Copy link
Contributor Author

Which module is that in? I’ve built with BuildExtras and not come across that?

Moved the example notification module into nucleus, and removed the
remaining packager modules from the build lifecycle.

Signed-off-by: Matthew Gill <[email protected]>
@MattGill98
Copy link
Contributor Author

jenkins test please

Copy link
Contributor

@Cousjava Cousjava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All seems to work for me

@MattGill98
Copy link
Contributor Author

Thanks @jbee and @Cousjava!

@MattGill98 MattGill98 merged commit 35f2f2d into payara:master Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants