Skip to content
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

Added JavaDoc for basic JedisCluster constructors #3304

Merged
merged 11 commits into from
Sep 22, 2024
63 changes: 63 additions & 0 deletions src/main/java/redis/clients/jedis/JedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,37 @@ public class JedisCluster extends UnifiedJedis {
* Default timeout in milliseconds.
*/
public static final int DEFAULT_TIMEOUT = 2000;
/**
* Default amount of attemps for connecting.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Default amount of attemps for connecting.
* Default amount of attempts for executing a command.

sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
*/
public static final int DEFAULT_MAX_ATTEMPTS = 5;

/**
* Creates a Jedis-Cluster Instance where only a single Host is being used as a "Cluster".<br>
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
* Here, the default Timeout of {@value #DEFAULT_TIMEOUT} ms is being used with {@value #DEFAULT_MAX_ATTEMPTS} maximum attempts.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Creates a Jedis-Cluster Instance where only a single Host is being used as a "Cluster".<br>
* Here, the default Timeout of {@value #DEFAULT_TIMEOUT} ms is being used with {@value #DEFAULT_MAX_ATTEMPTS} maximum attempts.
* Creates a JedisCluster instance where only a single node is used for cluster recongnition.
* <p>
* Here, the default timeout of {@link JedisCluster#DEFAULT_TIMEOUT} ms is being used with {@link JedisCluster#DEFAULT_MAX_ATTEMPTS} maximum attempts.

Copy link
Contributor Author

@thxrben thxrben Sep 22, 2024

Choose a reason for hiding this comment

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

Is there a reason you prefer to use a p here instead of a br?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We've history of javadoc plugins having issues with <br>. Using <br /> resolved those but were giving different issues.

<p> have been without issues (or less issues).

* @param node Host to connect to.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @param node Host to connect to.
* @param node address to first connect to.

*/
public JedisCluster(HostAndPort node) {
this(Collections.singleton(node));
}

/**
* Creates a Jedis-Cluster Instance where only a single Host is being used as a "Cluster".<br>
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
* Here, the default of {@value #DEFAULT_MAX_ATTEMPTS} maximum attempts is being used.
* @param node Host to connect to.
* @param timeout Timeout in milliseconds.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @param timeout Timeout in milliseconds.
* @param timeout connection and socket timeout in milliseconds.

*/
public JedisCluster(HostAndPort node, int timeout) {
this(Collections.singleton(node), timeout);
}

/**
* Creates a Jedis-Cluster Instance where only a single Host is being used as a "Cluster".<br>
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
* You can specify the timeout and the maximum attempts.
* @param node Host to connect to.
* @param timeout Timeout in milliseconds.
* @param maxAttempts Maximum Attempts to use.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @param maxAttempts Maximum Attempts to use.
* @param maxAttempts maximum attempts for executing a command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Capitilization

*/
public JedisCluster(HostAndPort node, int timeout, int maxAttempts) {
this(Collections.singleton(node), timeout, maxAttempts);
}
Expand Down Expand Up @@ -83,14 +104,32 @@ public JedisCluster(HostAndPort node, final JedisClientConfig clientConfig, int
this(Collections.singleton(node), clientConfig, maxAttempts, poolConfig);
}

/**
* Creates a Jedis-Cluster with multiple Nodes/Instances.
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
* Here, the default Timeout of {@value #DEFAULT_TIMEOUT} ms is being used with {@value #DEFAULT_MAX_ATTEMPTS} maximum attempts.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Creates a Jedis-Cluster with multiple Nodes/Instances.
* Here, the default Timeout of {@value #DEFAULT_TIMEOUT} ms is being used with {@value #DEFAULT_MAX_ATTEMPTS} maximum attempts.
* Creates a JedisCluster with multiple entry points.
* <p>
* Here, the default timeout of {@link JedisCluster#DEFAULT_TIMEOUT} ms is being used with {@link JedisCluster#DEFAULT_MAX_ATTEMPTS} maximum attempts.

* @param nodes Hosts to connect to.
*/
public JedisCluster(Set<HostAndPort> nodes) {
this(nodes, DEFAULT_TIMEOUT);
}

/**
* Creates a Jedis-Cluster with multiple Nodes/Instances.
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
* Here, the default of {@value #DEFAULT_MAX_ATTEMPTS} maximum attempts is being used.
* @param nodes Hosts to connect to.
* @param timeout Timeout in milliseconds.
*/
public JedisCluster(Set<HostAndPort> nodes, int timeout) {
this(nodes, DefaultJedisClientConfig.builder().timeoutMillis(timeout).build());
}

/**
* Creates a Jedis-Cluster with multiple Nodes/Instances. <br>
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
* You can specify the timeout and the maximum attempts.
* @param nodes Hosts to connect to.
* @param timeout Timeout in milliseconds.
* @param maxAttempts Maximum Attempts to use.
*/
public JedisCluster(Set<HostAndPort> nodes, int timeout, int maxAttempts) {
this(nodes, DefaultJedisClientConfig.builder().timeoutMillis(timeout).build(), maxAttempts);
}
Expand Down Expand Up @@ -187,6 +226,18 @@ public JedisCluster(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfi
super(clusterNodes, clientConfig, maxAttempts);
}

/**
* Creates a Jedis-Cluster with multiple Nodes/Instances. <br>
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
* You can specify the timeout and the maximum attempts. <br><br>
*
* Additionally, you are free to provide a {@link JedisClientConfig} instance. <br>
* You can use the {@link DefaultJedisClientConfig#builder()} Builder-Pattern to customize your configuration, includings socketTimeouts, Username & Passwords aswell as SSL and hostnames.
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
*
* @param clusterNodes Hosts to connect to.
* @param clientConfig Timeout in milliseconds.
* @param maxAttempts Maximum Attempts to use.
* @param maxTotalRetriesDuration Maximum time used for reconnecting.
*/
public JedisCluster(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig, int maxAttempts,
Duration maxTotalRetriesDuration) {
super(clusterNodes, clientConfig, maxAttempts, maxTotalRetriesDuration);
Expand All @@ -197,10 +248,22 @@ public JedisCluster(ClusterConnectionProvider provider, int maxAttempts,
super(provider, maxAttempts, maxTotalRetriesDuration);
}

/**
* Returns all nodes that were configured to connect to in a KEY-VALUE pair (Map).
* Key is the HOST:PORT and the value is the connection.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Returns all nodes that were configured to connect to in a KEY-VALUE pair (Map).
* Key is the HOST:PORT and the value is the connection.
* Returns all nodes that were configured to connect to in a key-value pairs (@link Map).
* Key is the HOST:PORT and the value is the connection pool.

* @return the map of all connections.
*/
public Map<String, ConnectionPool> getClusterNodes() {
return ((ClusterConnectionProvider) provider).getNodes();
}

/**
* Returns the connection for one of the 16,384 slots.<br><br>
* If there is no connection for the given slot, either cause the node died or didn't connect, it may not return the correct node.
* It will try to resolve connection-based issues using reconnection.
thxrben marked this conversation as resolved.
Show resolved Hide resolved
* @param slot the slot to retrieve the connection for.
* @return connection of the provided slot. {@code close()} of this connection must be called after use.
*/
public Connection getConnectionFromSlot(int slot) {
return ((ClusterConnectionProvider) provider).getConnectionFromSlot(slot);
}
Expand Down