Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Require executor to be passed to lock refreshing timelock #2466

Closed
wants to merge 8 commits into from

Conversation

tpetracca
Copy link
Contributor

@tpetracca tpetracca commented Oct 10, 2017

Goals (and why): Make consumer of refreshing locks stuff responsible for executor

Implementation Description (bullets):

Concerns (what feedback would you like?): Moar breaking changes!

Where should we start reviewing?:

Priority (whenever / two weeks / yesterday):


This change is Reviewable

@tpetracca tpetracca changed the title Lock refresher executor 2 Require executor to be passed to lock refreshing timelock Oct 10, 2017
@@ -36,7 +36,8 @@
config.atlasDbConfig(),
resource -> { },
LockServiceImpl::create,
() -> config.atlasDbSupplier().getTimestampService());
() -> config.atlasDbSupplier().getTimestampService(),
null); //TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeremyk-91 @fsamuel-bs can someone help me figure out what to do here?

Copy link
Contributor

Choose a reason for hiding this comment

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

We will probably want to create a @Qualifier annotation for the refreshing scheduled executor and add that as a param to this method, and provide a default implementation

Copy link
Contributor

Choose a reason for hiding this comment

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

The cheap solution is to hardcode a default...

Better solution is to have a qualifier annotation for the refreshing scheduled executor as @schlosna mentions.

@@ -142,6 +143,8 @@ String derivedUserAgent() {
return userAgent().orElse(callingClass().map(UserAgents::fromClass).orElse(UserAgents.DEFAULT_USER_AGENT));
}

abstract ScheduledExecutorService executor();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably name this more specifically as scheduledExecutor or even lockRefreshingExecutor

Copy link
Contributor

Choose a reason for hiding this comment

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

If feels pretty random to just have this one executor passed in when we have many others that are just created internally. What's the reason for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there was a plan to shift towards a model where we pass executors around, so that internally at least we can control overall thread-pool sizes. Don't really have full context though!

.setNameFormat(TransactionManagersTest.class.getSimpleName() + "-%d")
.setDaemon(true)
.build());

Copy link
Contributor

Choose a reason for hiding this comment

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

Should make this a memorized supplier so we don’t create it on class load, and we would still need to shut it down if we create it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I guess this is a test class so it might not be as critical, but agree.)

@@ -36,7 +36,8 @@
config.atlasDbConfig(),
resource -> { },
LockServiceImpl::create,
() -> config.atlasDbSupplier().getTimestampService());
() -> config.atlasDbSupplier().getTimestampService(),
null); //TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

We will probably want to create a @Qualifier annotation for the refreshing scheduled executor and add that as a param to this method, and provide a default implementation

@nziebart
Copy link
Contributor

Is this needed for testability? If so what about just passing in a LockRefresher?

@hsaraogi
Copy link
Contributor

@tpetracca ping!

@tpetracca
Copy link
Contributor Author

@schlosna @nziebart do we actually want this? I abandoned it because I got what I needed from the previous PR and this was just an add-on so I could wire the executor up to my webserver's lifecycle manager but I'm not sure we actually need it?

@schlosna
Copy link
Contributor

I don't have super strong feelings, though ideally we would allow injection of all necessary executors so that we can ensure proper lifecycle management and instrumentation of resources.

@tpetracca tpetracca closed this Dec 11, 2017
@felixdesouza felixdesouza deleted the lock-refresher-executor-2 branch July 2, 2019 22:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants