-
Notifications
You must be signed in to change notification settings - Fork 69
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
Bean subscription #426
Open
scottopell
wants to merge
49
commits into
master
Choose a base branch
from
feat/bean-listener
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Bean subscription #426
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
4fc47e2
Initial bean listening, adds attributes that match config
scottopell e104ed2
Moves bean subscription into dedicated thread
scottopell 9fee19d
Removes ConnectionListener
scottopell 0b996df
Adds test covering basic bean subscription functionality
scottopell 75a1bbc
Consolidate attribute matching and take 'ACTION' into account
scottopell 9e624cf
Utilize 'synchronized' keyword for simpler locking
scottopell 75d9296
Adds audit logging to bean refresh to catch any gaps in bean subscrip…
scottopell e4b2e6d
Shortens test timeframes for subscription to be processed
scottopell ff15967
Back to explicit locking
scottopell e0600d3
Removes un-necessary lockholder class
scottopell 64d8438
implements bean unsubscription
scottopell fe8c168
Merge branch 'master' into feat/bean-listener
scottopell 7f7c1a6
Adds extra logging instructions for misbehaving jmx server
scottopell 1bd15f0
Adds dedicated remote container bean subscription tests
scottopell 4fd1b09
Removes old mutex debugging code
scottopell 57f1970
Adds bean unsubscription test and (failing) bean subscription w/ netw…
scottopell 6670056
Adds JMX connection listener to mark instance as broken on connection…
scottopell d74319a
Removes un-needed bean subscriber thread
scottopell fe7705c
Clarifies bean-audit logging
scottopell c26e91b
Updates in-proc bean subscription tests with more attribute counting …
scottopell d746e40
Removes explicit locking in favor of 'synchronized'
scottopell 090f0dc
Adds owned thread to process mbean subscription events
scottopell c3fbfe6
Remove some unused logs and accidental regressions
scottopell addb80f
Addresses linting errors
scottopell 08cee1b
Renames ambiguous interface from BeanListener -> BeanTracker
scottopell 27dc057
Fixes bug where metricReached would display multiple times incorrectly
scottopell 642ee12
Corrects old name and var decl
scottopell 4d9ce86
Merge branch 'master' into feat/bean-listener
scottopell e8c2b68
Adds toggle to turn on bean subscription globally
scottopell d1bd7b8
Merge branch 'master' into feat/bean-listener
scottopell 79ce047
Adds env vars to enable subscription globally for validation
scottopell dcf963c
Updates TestBeanSubscription to use container IP directly similar to …
scottopell 781db37
Merge branch 'master' into feat/bean-listener
scottopell 905532a
Re-land changes from #481
scottopell bad14d0
Removes random idea for deployment validation
scottopell be3c9b4
Relands bean match ratio from #487
scottopell c118cc2
Fixes whoopsie
scottopell ea0bf5b
Fixes divide by zero bug introduced in previous commit
scottopell 82bbc94
Adds tlm for beans registered and unregistered
scottopell b40c5d6
Update tools/misbehaving-jmx-server/README.md
scottopell 34290a1
Fixes linting errors
scottopell 617f4f6
Merge branch 'master' into feat/bean-listener
scottopell 01e760c
Removes per-instance bean-subscription enablement in favor of applica…
scottopell 34ab16b
Merge branch 'master' into feat/bean-listener
scottopell 03eeff0
Merge branch 'master' into feat/bean-listener
scottopell 95820e9
Fixes linter warning
scottopell f916745
Fixes spy usage in bean sub tests
scottopell ff5e64f
Adds env var enablement for backwards compatibility during rollout
scottopell 5dfcd96
Merge branch 'master' into feat/bean-listener
scottopell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/org/datadog/jmxfetch/BeanNotificationListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.datadog.jmxfetch; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.concurrent.BlockingQueue; | ||
import java.util.concurrent.LinkedBlockingQueue; | ||
|
||
import javax.management.MBeanServerNotification; | ||
import javax.management.Notification; | ||
import javax.management.NotificationListener; | ||
import javax.management.ObjectName; | ||
|
||
|
||
@Slf4j | ||
class BeanNotificationListener implements NotificationListener { | ||
private final BlockingQueue<MBeanServerNotification> queue; | ||
private final BeanTracker beanTracker; | ||
|
||
public BeanNotificationListener(final BeanTracker bt) { | ||
this.beanTracker = bt; | ||
this.queue = new LinkedBlockingQueue<>(); | ||
new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
while (true) { | ||
try { | ||
MBeanServerNotification mbs = queue.take(); | ||
processMBeanServerNotification(mbs); | ||
} catch (InterruptedException e) { | ||
// ignore | ||
} | ||
} | ||
} | ||
}).start(); | ||
} | ||
|
||
@Override | ||
public void handleNotification(Notification notification, Object handback) { | ||
if (!(notification instanceof MBeanServerNotification)) { | ||
return; | ||
} | ||
MBeanServerNotification mbs = (MBeanServerNotification) notification; | ||
queue.offer(mbs); | ||
} | ||
|
||
private void processMBeanServerNotification(MBeanServerNotification notif) { | ||
log.debug("MBeanNotification: ts {} seqNum: {} msg: '{}'", | ||
notif.getTimeStamp(), | ||
notif.getSequenceNumber(), | ||
notif.getMessage()); | ||
ObjectName beanName = notif.getMBeanName(); | ||
if (notif.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION)) { | ||
beanTracker.trackBean(beanName); | ||
} else if (notif.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) { | ||
beanTracker.untrackBean(beanName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.datadog.jmxfetch; | ||
|
||
import javax.management.ObjectName; | ||
|
||
public interface BeanTracker { | ||
public void trackBean(ObjectName beanName); | ||
|
||
public void untrackBean(ObjectName beanName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to do anything here if we get
false
back? Maybe log/warn we couldn't add theMBeanServerNotification
?