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

Expose server config, session queue and node as MBeans for JMX monitoring. #8838

Merged
merged 12 commits into from
Dec 22, 2020

Conversation

pujagani
Copy link
Contributor

@pujagani pujagani commented Nov 4, 2020

Description

Changes are related to #7761.

Motivation and Context

Old Grid exposed MBeans for JMX monitoring. The changes include exposing MBeans and attributes for monitoring the new Grid. This includes:

  1. Exposing BaseServerConfig and related attributes.
  2. Exposing Node and related attributes.
  3. NewSessionQueue and related attributes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

try {
return getExternalUri().toURL();
} catch (MalformedURLException e) {
throw new ConfigException("Cannot convert URI to URL" + e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

nit: We probably want a space after URL

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

👋 @pujagani, I went through it and I added a comment besides the one already exists.

Also, it seems tests for this PR are not passing, and a couple are still to be written. Could you please have a look? I'll happily review right after.

@ManagedAttribute(name = "NewSessionQueueSize")
public int getQueueSize() {
Lock writeLock = lock.writeLock();
writeLock.lock();
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to lock to read the queue size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it uses ConcurrentLinkedDeque, the size() requires a traversal and value may not be accurate if it is being modified when size is calculated. Hence the lock. But for exposing values if we don't need that kind of accuracy, then we can get rid of the lock. @diemol What would you suggest?

@pujagani
Copy link
Contributor Author

@diemol I updated and added the tests and they all pass now. The test was picking up previously registered MBeans and hence failing for different cases. Please help review. Thank you!

@@ -80,6 +88,17 @@ public boolean isReady() {
return bus.isReady();
}

@ManagedAttribute(name = "NewSessionQueueSize")
public int getQueueSize() {
Lock writeLock = lock.writeLock();
Copy link
Member

Choose a reason for hiding this comment

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

This need only be a read lock

}

@ManagedAttribute(name = "RemoteNodeUri")
public URI getExternalURI() {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: getExternalUri We try and AVOID SHOUTING in Selenium (which is why we have HttpMethod, and so on)

@@ -101,6 +111,15 @@ public URI getExternalUri() {
}
}

@ManagedAttribute(name = "URL")
public URL getExternalUrl() {
Copy link
Member

Choose a reason for hiding this comment

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

Daft question, but why don't we just return the URI?


String retryInterval = (String) beanServer.getAttribute(name, "RetryIntervalSeconds");
assertThat(Long.parseLong(retryInterval)).isEqualTo(queueOptions.getRetryIntervalSeconds());
} catch (InstanceNotFoundException | IntrospectionException | ReflectionException
Copy link
Member

Choose a reason for hiding this comment

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

It's fine to just let the test fail because the exception was thrown. That'll give you more information that just calling fail in these catch blocks.

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

Thank you, @pujagani!

@sonarcloud
Copy link

sonarcloud bot commented Dec 22, 2020

@diemol diemol merged commit b4b7674 into SeleniumHQ:trunk Dec 22, 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.

None yet

4 participants