Skip to content

WIP: Support RedisBacked Distributor#8403

Closed
raju249 wants to merge 23 commits intoSeleniumHQ:trunkfrom
raju249:distributor-state-redis
Closed

WIP: Support RedisBacked Distributor#8403
raju249 wants to merge 23 commits intoSeleniumHQ:trunkfrom
raju249:distributor-state-redis

Conversation

@raju249
Copy link
Member

@raju249 raju249 commented Jun 9, 2020

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Adds support for Distributor backed with redis for storing info about the nodes in the grid.

Motivation and Context

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.

@raju249 raju249 force-pushed the distributor-state-redis branch 3 times, most recently from 55d51e8 to 2497654 Compare June 11, 2020 10:46
String clazz = config.get(DISTRIBUTOR_SECTION, "implementation").orElse(DEFAULT_DISTRIBUTOR_SERVER);
LOG.info("Creating distributor server: " + clazz);
try {
Class<?> busClazz = Class.forName(clazz);
Copy link
Member

Choose a reason for hiding this comment

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

bus? Your copy-and-paste is showing :)

@raju249 raju249 force-pushed the distributor-state-redis branch from 5e79877 to 463d67e Compare June 12, 2020 14:12
@raju249 raju249 force-pushed the distributor-state-redis branch from 1eec14c to e4816dd Compare June 16, 2020 06:33
Copy link
Member

@shs96c shs96c left a comment

Choose a reason for hiding this comment

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

It's a good start. Don't be afraid to create a new package if you need to for the bits that are shared between multiple redis-backed implementations.

"//java/server/test/org/openqa/selenium/grid:__subpackages__",
],
exports = [
"//java/server/src/org/openqa/selenium/grid",
Copy link
Member

Choose a reason for hiding this comment

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

Technically this should also be in deps. I'm mildly surprised this compiles (if it does!)

@Override
public CreateSessionResponse newSession(HttpRequest request)
throws SessionNotCreatedException {
return null;
Copy link
Member

Choose a reason for hiding this comment

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

Very much a WIP :)

Require.nonNull("Node to add", node);

RedisCommands<String, String> commands = connection.sync();
commands.mset(
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the intermediate commands variable? Or just chain the method calls? Probably fine either way....

Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking to keep it the same 😅

private String nodeUriKey(UUID id) {
Require.nonNull("Node UUID", id);

return "node:" + id.toString() + ":uri";
Copy link
Member

Choose a reason for hiding this comment

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

id will be coerced to a string anyway, so the call to toString() can be omitted.

private final Config config;

public RedisDistributorOptions(Config config) {
this.config = config;
Copy link
Member

Choose a reason for hiding this comment

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

Check that it's not null

@diemol diemol closed this Jul 12, 2020
@diemol diemol reopened this Jul 12, 2020
@diemol diemol changed the base branch from master to trunk July 12, 2020 19:43
@AutomatedTester AutomatedTester linked an issue Jul 21, 2020 that may be closed by this pull request
@raju249 raju249 force-pushed the distributor-state-redis branch from b1d2200 to 84901b3 Compare August 18, 2020 06:55
@barancev barancev added the B-grid Everything grid and server related label Jan 24, 2021
@pujagani
Copy link
Contributor

pujagani commented Jun 11, 2021

Thank you @raju249 for your contribution! Appreciate the work. It has definitely helped as a boilerplate to get started. However, since the last contribution to this branch, the Distributor and Grid, in general, has gone through a bunch of enhancements ever since. Based on the changes made here, Redis Distributor is introduced as part of 192aed6 (other commits are also involved but the above mentioned is the crux).

@pujagani pujagani closed this Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-grid Everything grid and server related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Grid] Distributor should store state

5 participants