-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add CONFIG REWRITE
and CONFIG RESETSTAT
.
#95
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.commands; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Server Management Commands interface for both standalone and cluster clients. | ||
* | ||
* @see <a href="https://redis.io/commands/?group=server">Server Management Commands</a> | ||
*/ | ||
public interface ServerManagementBaseCommands { | ||
|
||
/** | ||
* Rewrites the configuration file with the current configuration. | ||
* | ||
* @see <a href="https://redis.io/commands/config-rewrite/">redis.io</a> for details. | ||
* @return <code>OK</code> when the configuration was rewritten properly, otherwise an error is | ||
* raised. | ||
* @example | ||
* <pre> | ||
* String response = client.configRewrite().get(); | ||
* assert response.equals("OK") | ||
* </pre> | ||
*/ | ||
CompletableFuture<String> configRewrite(); | ||
|
||
/** | ||
* Resets the statistics reported by Redis using the <a | ||
* href="https://redis.io/commands/info/">INFO</a> and <a | ||
* href="https://redis.io/commands/latency-histogram/">LATENCY HISTOGRAM</a> commands. | ||
* | ||
* @see <a href="https://redis.io/commands/config-resetstat/">redis.io</a> for details. | ||
* @return <code>OK</code> to confirm that the statistics were successfully reset. | ||
* @example | ||
* <pre> | ||
* String response = client.configResetStat().get(); | ||
* assert response.equals("OK") | ||
* </pre> | ||
*/ | ||
CompletableFuture<String> configResetStat(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Server Management Commands interface. | ||
* Server Management Commands interface for cluster client. | ||
* | ||
* @see <a href="https://redis.io/commands/?group=server">Server Management Commands</a> | ||
*/ | ||
|
@@ -71,4 +71,68 @@ public interface ServerManagementClusterCommands { | |
* value is the information of the sections requested for the node. | ||
*/ | ||
CompletableFuture<ClusterValue<String>> info(InfoOptions options, Route route); | ||
|
||
/** | ||
* Rewrites the configuration file with the current configuration.<br> | ||
* The command will be routed automatically to all nodes. | ||
* | ||
* @see <a href="https://redis.io/commands/config-rewrite/">redis.io</a> for details. | ||
* @return <code>OK</code> when the configuration was rewritten properly, otherwise an error is | ||
* raised. | ||
* @example | ||
* <pre> | ||
* String response = client.configRewrite().get(); | ||
* assert response.equals("OK") | ||
* </pre> | ||
*/ | ||
CompletableFuture<String> configRewrite(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are only saving lines of documentation by extending the base commands, which adds complexity to the code. I don't recommend doing this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reverted |
||
|
||
/** | ||
* Rewrites the configuration file with the current configuration. | ||
* | ||
* @see <a href="https://redis.io/commands/config-rewrite/">redis.io</a> for details. | ||
* @param route Routing configuration for the command. Client will route the command to the nodes | ||
* defined. | ||
* @return <code>OK</code> when the configuration was rewritten properly, otherwise an error is | ||
* raised. | ||
* @example | ||
* <pre> | ||
* String response = client.configRewrite(ALL_PRIMARIES).get(); | ||
* assert response.equals("OK") | ||
* </pre> | ||
*/ | ||
CompletableFuture<String> configRewrite(Route route); | ||
|
||
/** | ||
* Resets the statistics reported by Redis using the <a | ||
* href="https://redis.io/commands/info/">INFO</a> and <a | ||
* href="https://redis.io/commands/latency-histogram/">LATENCY HISTOGRAM </a> commands.<br> | ||
* The command will be routed automatically to all nodes. | ||
* | ||
* @see <a href="https://redis.io/commands/config-resetstat/">redis.io</a> for details. | ||
* @return <code>OK</code> to confirm that the statistics were successfully reset. | ||
* @example | ||
* <pre> | ||
* String response = client.configResetStat().get(); | ||
* assert response.equals("OK") | ||
* </pre> | ||
*/ | ||
CompletableFuture<String> configResetStat(); | ||
|
||
/** | ||
* Resets the statistics reported by Redis using the <a | ||
* href="https://redis.io/commands/info/">INFO</a> and <a | ||
* href="https://redis.io/commands/latency-histogram/">LATENCY HISTOGRAM </a> commands. | ||
* | ||
* @see <a href="https://redis.io/commands/config-resetstat/">redis.io</a> for details. | ||
* @param route Routing configuration for the command. Client will route the command to the nodes | ||
* defined. | ||
* @return <code>OK</code> to confirm that the statistics were successfully reset. | ||
* @example | ||
* <pre> | ||
* String response = client.configResetStat(ALL_PRIMARIES).get(); | ||
* assert response.equals("OK") | ||
* </pre> | ||
*/ | ||
CompletableFuture<String> configResetStat(Route route); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static redis_request.RedisRequestOuterClass.RequestType.ConfigResetStat; | ||
import static redis_request.RedisRequestOuterClass.RequestType.ConfigRewrite; | ||
import static redis_request.RedisRequestOuterClass.RequestType.CustomCommand; | ||
import static redis_request.RedisRequestOuterClass.RequestType.Decr; | ||
import static redis_request.RedisRequestOuterClass.RequestType.DecrBy; | ||
|
@@ -328,11 +330,6 @@ public void mset_returns_success() { | |
|
||
// exercise | ||
CompletableFuture<String> response = service.mset(keyValueMap); | ||
String payload = response.get(); | ||
|
||
// verify | ||
assertEquals(testResponse, response); | ||
assertEquals(OK, payload); | ||
} | ||
|
||
@SneakyThrows | ||
|
@@ -622,4 +619,40 @@ public void scard_returns_success() { | |
assertEquals(testResponse, response); | ||
assertEquals(value, payload); | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
public void configRewrite_returns_success() { | ||
// setup | ||
CompletableFuture<String> testResponse = mock(CompletableFuture.class); | ||
when(testResponse.get()).thenReturn(OK); | ||
when(commandManager.<String>submitNewCommand(eq(ConfigRewrite), eq(new String[0]), any())) | ||
.thenReturn(testResponse); | ||
|
||
// exercise | ||
CompletableFuture<String> response = service.configRewrite(); | ||
String payload = response.get(); | ||
|
||
// verify | ||
assertEquals(testResponse, response); | ||
assertEquals(OK, payload); | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
public void configResetStat_returns_success() { | ||
// setup | ||
CompletableFuture<String> testResponse = mock(CompletableFuture.class); | ||
when(testResponse.get()).thenReturn(OK); | ||
when(commandManager.<String>submitNewCommand(eq(ConfigResetStat), eq(new String[0]), any())) | ||
.thenReturn(testResponse); | ||
|
||
// exercise | ||
CompletableFuture<String> response = service.configResetStat(); | ||
String payload = response.get(); | ||
|
||
// verify | ||
assertEquals(testResponse, response); | ||
assertEquals(OK, payload); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Info and ping return strings rather than OK, but this is a minor detail and maybe not worth worrying about if we're able to remove some code duplication here like you've shown There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reverted this and added new tests |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't ClusterClient extend baseClient why do you need to call it like this? We don't have the other commands such as incr etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do it to redefine (extend) the javadoc. The function signature (= API) is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing. I would strongly suggest that we only extend one interface with the signature, otherwise it's confusing to developers which documentation applies here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted