Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ configuration is required for netty and the JDK in

We don’t have found a way yet to invoke default interface methods on
proxies without `MethodHandle`. Hence the `NodeSelection` API
(`masters()`, `all()` and others on `RedisAdvancedClusterCommands` and
(`primaries()`, `all()` and others on `RedisAdvancedClusterCommands` and
`RedisAdvancedClusterAsyncCommands`) do not work.

## Command execution reliability
Expand Down Expand Up @@ -2596,7 +2596,7 @@ means, if you execute a command twice, each resulting state is different
in comparison to the previous. Examples for non-idempotent Redis
commands are such as `LPUSH`, `PUBLISH` or `INCR`.

Note: When using master-replica replication, different rules apply to
Note: When using primary-replica replication, different rules apply to
*at-least-once* consistency. Replication between Redis nodes works
asynchronously. A command can be processed successfully from Lettuce’s
client perspective, but the result is not necessarily replicated to the
Expand Down Expand Up @@ -2659,14 +2659,14 @@ auto-replay of commands.
Lettuce sticks in clustered operations to the same rules as for
standalone operations but with one exception:

Command execution on master nodes, which is rejected by a `MOVED`
Command execution on primary nodes, which is rejected by a `MOVED`
response are tried to re-execute with the appropriate connection.
`MOVED` errors occur on master nodes when a slot’s responsibility is
`MOVED` errors occur on primary nodes when a slot’s responsibility is
moved from one cluster node to another node. Afterwards *at-least-once*
and *at-most-once* rules apply.

When the cluster topology changes, generally spoken, the cluster slots
or master/replica state is reconfigured, following rules apply:
or primary/replica state is reconfigured, following rules apply:

- **at-most-once** If the connection is disconnected, queued commands
are canceled and buffered commands, which were not sent, are executed
Expand All @@ -2679,4 +2679,3 @@ or master/replica state is reconfigured, following rules apply:
- If the connection is not disconnected, queued commands are finished
and buffered commands, which were not sent, are executed by using the
new cluster view

195 changes: 97 additions & 98 deletions docs/ha-sharding.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions docs/new-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
- Add support for [Redis
Streams](https://redis.io/topics/streams-intro).

- Asynchronous `connect()` for Master/Replica connections.
- Asynchronous `connect()` for Primary/Replica connections.

- [Asynchronous Connection Pooling](advanced-usage.md#asynchronous-connection-pooling)
through `AsyncConnectionPoolSupport` and `AsyncPool`.
Expand All @@ -166,7 +166,7 @@
- Reactive `ScanStream` to iterate over the keyspace using `SCAN`
commands.

- Transactions using Master/Replica connections are bound to the master
- Transactions using Primary/Replica connections are bound to the primary
node.

## What’s new in Lettuce 5.0
Expand Down Expand Up @@ -196,4 +196,3 @@

- HTML and PDF reference documentation along with a new project website:
<https://lettuce.io>.

3 changes: 1 addition & 2 deletions docs/redis-command-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public interface MixedCommands extends Commands {
to determine a command intent (whether a command is a read-only one).
Commands are resolved case-sensitive. Use lower-case command names in
`@Command` to resolve to an unknown command to e.g. enforce
master-routing.
primary-routing.

### CamelCase in method names

Expand Down Expand Up @@ -581,4 +581,3 @@ Errors are transported through `RedisFuture`. Synchronous commands don’t
receive any result/exception signal except if the batch is flushed
through a synchronous method call. Synchronous flushing throws
`BatchException` containing the failed commands.

8 changes: 4 additions & 4 deletions docs/user-guide/async-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ couple of `…​Either()` methods are available on a `CompletionStage<T>`,
see the [Java 8 API docs](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.html)
for the full reference. The either-or pattern consumes the value from
the first future that is completed. A good example might be two services
returning the same data, for instance, a Master-Replica scenario, but
returning the same data, for instance, a Primary-Replica scenario, but
you want to return the data as fast as possible:

``` java
RedisStringAsyncCommands<String, String> master = masterClient.connect().async();
RedisStringAsyncCommands<String, String> primary = primaryClient.connect().async();
RedisStringAsyncCommands<String, String> replica = replicaClient.connect().async();

RedisFuture<String> future = master.get("key");
RedisFuture<String> future = primary.get("key");
future.acceptEither(replica.get("key"), new Consumer<String>() {
@Override
public void accept(String value) {
Expand Down Expand Up @@ -568,4 +568,4 @@ Runnable listener = new Runnable() {
};

set.thenRun(listener);
```
```
8 changes: 4 additions & 4 deletions docs/user-guide/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ connection.addListener(new RedisClusterPubSubListener<String, String>() { ... })
connection.setNodeMessagePropagation(true);

RedisPubSubCommands<String, String> sync = connection.sync();
sync.masters().commands().subscribe("__keyspace@0__:*");
sync.primaries().commands().subscribe("__keyspace@0__:*");
```

There are two things to pay special attention to:

1. Replication: Keys replicated to replica nodes, especially
considering expiry, generate keyspace events on all nodes holding
the key. If a key expires and it is replicated, it will expire on
the master and all replicas. Each Redis server will emit keyspace
events. Subscribing to non-master nodes, therefore, will let your
the primary and all replicas. Each Redis server will emit keyspace
events. Subscribing to non-primary nodes, therefore, will let your
application see multiple events of the same type for the same key
because of Redis distributed nature.

2. Topology Changes: Subscriptions are issued either by using the
NodeSelection API or by calling `subscribe(…)` on the individual
cluster node connections. Subscription registrations are not
propagated to new nodes that are added on a topology change.
propagated to new nodes that are added on a topology change.
38 changes: 33 additions & 5 deletions src/main/java/io/lettuce/core/ReadFrom.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ public abstract class ReadFrom {

/**
* Setting to read from the upstream only.
*
* @deprecated since 7.3, use {@link #PRIMARY}.
*/
@Deprecated
public static final ReadFrom MASTER = new ReadFromImpl.ReadFromUpstream();

/**
* Setting to read preferred from the upstream and fall back to a replica if the master is not available.
* Setting to read preferred from the upstream and fall back to a replica if the primary is not available.
*
* @deprecated since 7.3, use {@link #PRIMARY_PREFERRED}.
*/
@Deprecated
public static final ReadFrom MASTER_PREFERRED = new ReadFromImpl.ReadFromUpstreamPreferred();

/**
Expand All @@ -61,6 +67,20 @@ public abstract class ReadFrom {
*/
public static final ReadFrom UPSTREAM_PREFERRED = new ReadFromImpl.ReadFromUpstreamPreferred();

/**
* Setting to read from the upstream only.
*
* @since 7.3
*/
public static final ReadFrom PRIMARY = UPSTREAM;

/**
* Setting to read preferred from the upstream and fall back to a replica if the upstream is not available.
*
* @since 7.3
*/
public static final ReadFrom PRIMARY_PREFERRED = UPSTREAM_PREFERRED;

/**
* Setting to read preferred from replica and fall back to upstream if no replica is available.
*
Expand Down Expand Up @@ -214,19 +234,27 @@ public static ReadFrom valueOf(String name) {
}
}

if (name.equalsIgnoreCase("master")) {
if (name.equalsIgnoreCase("upstream")) {
return UPSTREAM;
}

if (name.equalsIgnoreCase("masterPreferred")) {
if (name.equalsIgnoreCase("upstreamPreferred")) {
return UPSTREAM_PREFERRED;
}

if (name.equalsIgnoreCase("upstream")) {
if (name.equalsIgnoreCase("primary")) {
return PRIMARY;
}

if (name.equalsIgnoreCase("primaryPreferred")) {
return PRIMARY_PREFERRED;
}

if (name.equalsIgnoreCase("master")) {
return UPSTREAM;
}

if (name.equalsIgnoreCase("upstreamPreferred")) {
if (name.equalsIgnoreCase("masterPreferred")) {
return UPSTREAM_PREFERRED;
}

Expand Down
Loading
Loading