Skip to content

Commit

Permalink
DATAREDIS-762 - Polishing.
Browse files Browse the repository at this point in the history
Introduce marker interface RedisConfiguration along with several others providing access to specific setup scenarios like cluster and sentinel.

Original Pull Request: spring-projects#306
  • Loading branch information
christophstrobl committed Mar 20, 2018
1 parent bb990b1 commit 4a064c5
Show file tree
Hide file tree
Showing 12 changed files with 582 additions and 285 deletions.
1 change: 1 addition & 0 deletions src/main/asciidoc/reference/redis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class WriteToMasterReadFromSlaveConfiguration {
}
----

TIP: Use `RedisStaticMasterSlaveConfiguration` instead of `RedisStandaloneConfiguration` for environments reporting non public addresses via the `INFO` command (e.g. when using AWS).

[[redis:sentinel]]
== Redis Sentinel Support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.data.redis.connection.RedisConfiguration.ClusterConfiguration;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.NumberUtils;
Expand All @@ -41,7 +42,7 @@
* @author Mark Paluch
* @since 1.7
*/
public class RedisClusterConfiguration {
public class RedisClusterConfiguration implements RedisConfiguration, ClusterConfiguration {

private static final String REDIS_CLUSTER_NODES_CONFIG_PROPERTY = "spring.redis.cluster.nodes";
private static final String REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY = "spring.redis.cluster.max-redirects";
Expand Down Expand Up @@ -120,11 +121,11 @@ public void setClusterNodes(Iterable<RedisNode> nodes) {
}
}

/**
* Returns an {@link Collections#unmodifiableSet(Set)} of {@literal cluster nodes}.
*
* @return {@link Set} of nodes. Never {@literal null}.
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisConfiguration.ClusterConfiguration#getClusterNodes()
*/
@Override
public Set<RedisNode> getClusterNodes() {
return Collections.unmodifiableSet(clusterNodes);
}
Expand All @@ -149,9 +150,11 @@ public RedisClusterConfiguration clusterNode(RedisNode node) {
return this;
}

/**
* @return max number of redirects to follow or {@literal null} if not set.
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisConfiguration.ClusterConfiguration#getMaxRedirects()
*/
@Override
public Integer getMaxRedirects() {
return maxRedirects != null && maxRedirects > Integer.MIN_VALUE ? maxRedirects : null;
}
Expand Down Expand Up @@ -181,20 +184,20 @@ private void appendClusterNodes(Set<String> hostAndPorts) {
}
}

/**
* Get the {@link RedisPassword} defined.
*
* @return never {@literal null}.
* @since 2.0
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisConfiguration.WithPassword#getPassword()
*/
@Override
public RedisPassword getPassword() {
return password;
}

/**
* @param password must not be {@literal null}.
* @since 2.0
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisConfiguration.WithPassword#setPassword(org.springframework.data.redis.connection.RedisPassword)
*/
@Override
public void setPassword(RedisPassword password) {

Assert.notNull(password, "RedisPassword must not be null!");
Expand Down
Loading

0 comments on commit 4a064c5

Please sign in to comment.