Skip to content

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

Merged
diemol merged 12 commits into
SeleniumHQ:trunkfrom
pujagani:expose-server-jmx
Dec 22, 2020
Merged

Expose server config, session queue and node as MBeans for JMX monitoring.#8838
diemol merged 12 commits into
SeleniumHQ:trunkfrom
pujagani:expose-server-jmx

Conversation

@pujagani

@pujagani pujagani commented Nov 4, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

@diemol diemol left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!


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

Copy link
Copy Markdown
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
Copy Markdown
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)

}

@ManagedAttribute(name = "URL")
public URL getExternalUrl() {

Copy link
Copy Markdown
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
Copy Markdown
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.

@diemol diemol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @pujagani!

@sonarqubecloud

Copy link
Copy Markdown

@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.

4 participants