Skip to content

Refactor Jedis and Lettuce RedisConnectionFactory to SmartLifecycle beans #2627

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

Closed
wants to merge 4 commits into from

Conversation

christophstrobl
Copy link
Member

Closes: #2503

Introduce ConnectionVerifier to avoid leaving connections/connection factories open for failing tests.
@@ -415,6 +460,8 @@ protected JedisCluster createCluster(RedisClusterConfiguration clusterConfig,

public void destroy() {

state.set(State.STOPPING);
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to call stop as we have quite some duplications?

Assert.state(this.initialized, "JedisConnectionFactory was not initialized through afterPropertiesSet()");
Assert.state(!this.destroyed, "JedisConnectionFactory was destroyed and cannot be used anymore");
Assert.state(State.STARTED.equals(state.get()), "JedisConnectionFactory was not initialized through afterPropertiesSet()");
Assert.state(!State.STOPPED.equals(state.get()), "JedisConnectionFactory was destroyed and cannot be used anymore");
Copy link
Member

Choose a reason for hiding this comment

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

We might want to reflect the lifecycle in the messages, as we want to allow starting after stopping, right?

resetConnection();
dispose(connectionProvider);
dispose(reactiveConnectionProvider);
this.client.close();
Copy link
Member

Choose a reason for hiding this comment

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

we should consider the shutdown timeout to prevent long shutdown times.

Duration timeout = clientConfiguration.getShutdownTimeout();
client.shutdown(quietPeriod.toMillis(), timeout.toMillis(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
try {
Copy link
Member

Choose a reason for hiding this comment

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

That code could go into stop and upon destroy it would be neat to reuse what stop does.

}
state.set(State.DESTROYED);
Copy link
Member

Choose a reason for hiding this comment

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

👍


Assert.state(State.STARTED.equals(state.get()),
"LettuceConnectionFactory was not initialized through afterPropertiesSet()");
Assert.state(!State.STOPPED.equals(state.get()),
Copy link
Member

Choose a reason for hiding this comment

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

We should reword the messages to reflect started/stopped state. Having a check for destroyed it good as well.

@mp911de mp911de self-assigned this Jul 10, 2023
@mp911de mp911de added the type: enhancement A general enhancement label Jul 10, 2023
@mp911de mp911de changed the title Implement SmartLifecycle for Jedis- and LettuceConnectionFactory Refactor Jedis and Lettuce RedisConnectionFactory to SmartLifecycle beans Jul 10, 2023
mp911de pushed a commit that referenced this pull request Jul 10, 2023
mp911de added a commit that referenced this pull request Jul 10, 2023
Reorder factory fields according to immutable configuration, mutable configuration and connection factory state. Reorder methods and switch Jedis references to its current GitHub repository.

Refine assertions. Update documentation.

See: #2503
Original pull request: #2627
@mp911de mp911de added this to the 3.2 M1 (2023.1.0) milestone Jul 10, 2023
@mp911de mp911de closed this Jul 10, 2023
@mp911de mp911de deleted the issue/2503 branch July 10, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate RedisConnectionFactory to Lifecycle beans
2 participants