Skip to content

Commit

Permalink
add LATENCY LATEST, LATENCY HISTORY and LATENCY RESET commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Lcarrot committed Feb 21, 2024
1 parent e3b8ffb commit 2373de1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -9287,13 +9287,13 @@ public Map<String, LatencyLatestInfo> latencyLatest() {
return BuilderFactory.LATENCY_LATEST_RESPONSE.build(connection.getOne());
}

public List<LatencyHistoryInfo> latencyHistory(EventKeyword event) {
public List<LatencyHistoryInfo> latencyHistory(LatencyEvent event) {
checkIsInMultiOrPipeline();
connection.sendCommand(new CommandArguments(LATENCY).add(HISTORY).add(event));
return BuilderFactory.LATENCY_HISTORY_RESPONSE.build(connection.getOne());
}

public long latencyReset(EventKeyword... events) {
public long latencyReset(LatencyEvent... events) {
checkIsInMultiOrPipeline();
CommandArguments arguments = new CommandArguments(LATENCY).add(Keyword.RESET);
Arrays.stream(events).forEach(arguments::add);
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,24 +371,4 @@ public byte[] getRaw() {
return raw;
}
}

public static enum EventKeyword implements Rawable {
ACTIVE_DEFRAG_CYCLE("active-defrag-cycle"), AOF_FSYNC_ALWAYS("aof-fsync-always"), AOF_STAT("aof-stat"),
AOF_REWRITE_DIFF_WRITE("aof-rewrite-diff-write"), AOF_RENAME("aof-rename"), AOF_WRITE("aof-write"),
AOF_WRITE_ACTIVE_CHILD("aof-write-active-child"), AOF_WRITE_ALONE("aof-write-alone"),
AOF_WRITE_PENDING_FSYNC("aof-write-pending-fsync"), COMMAND("command"), EXPIRE_CYCLE("expire-cycle"),
EVICTION_CYCLE("eviction-cycle"), EVICTION_DEL("eviction-del"), FAST_COMMAND("fast-command"),
FORK("fork"), RDB_UNLINK_TEMP_FILE("rdb-unlink-temp-file");

private final byte[] raw;

EventKeyword(String s) {
raw = SafeEncoder.encode(s);
}

@Override
public byte[] getRaw() {
return raw;
}
}
}
24 changes: 24 additions & 0 deletions src/main/java/redis/clients/jedis/args/LatencyEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package redis.clients.jedis.args;

import redis.clients.jedis.util.SafeEncoder;

public enum LatencyEvent implements Rawable {

ACTIVE_DEFRAG_CYCLE("active-defrag-cycle"), AOF_FSYNC_ALWAYS("aof-fsync-always"), AOF_STAT("aof-stat"),
AOF_REWRITE_DIFF_WRITE("aof-rewrite-diff-write"), AOF_RENAME("aof-rename"), AOF_WRITE("aof-write"),
AOF_WRITE_ACTIVE_CHILD("aof-write-active-child"), AOF_WRITE_ALONE("aof-write-alone"),
AOF_WRITE_PENDING_FSYNC("aof-write-pending-fsync"), COMMAND("command"), EXPIRE_CYCLE("expire-cycle"),
EVICTION_CYCLE("eviction-cycle"), EVICTION_DEL("eviction-del"), FAST_COMMAND("fast-command"),
FORK("fork"), RDB_UNLINK_TEMP_FILE("rdb-unlink-temp-file");

private final byte[] raw;

LatencyEvent(String s) {
raw = SafeEncoder.encode(s);
}

@Override
public byte[] getRaw() {
return raw;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package redis.clients.jedis.commands;

import redis.clients.jedis.Protocol;
import redis.clients.jedis.args.FlushMode;
import redis.clients.jedis.args.LatencyEvent;
import redis.clients.jedis.args.SaveMode;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.params.LolwutParams;
Expand Down Expand Up @@ -255,7 +255,7 @@ default void shutdown(SaveMode saveMode) throws JedisException {

Map<String, LatencyLatestInfo> latencyLatest();

List<LatencyHistoryInfo> latencyHistory(Protocol.EventKeyword events);
List<LatencyHistoryInfo> latencyHistory(LatencyEvent events);

long latencyReset(Protocol.EventKeyword... events);
long latencyReset(LatencyEvent... events);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import redis.clients.jedis.JedisMonitor;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.args.ClientPauseMode;
import redis.clients.jedis.args.LatencyEvent;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.HostAndPorts;
import redis.clients.jedis.params.CommandListFilterByParams;
Expand Down Expand Up @@ -450,7 +451,7 @@ public void latencyLatest() {

@Test
public void latencyHistoryFork() {
List<LatencyHistoryInfo> report = jedis.latencyHistory(Protocol.EventKeyword.FORK);
List<LatencyHistoryInfo> report = jedis.latencyHistory(LatencyEvent.FORK);
assertNotNull(report);
}

Expand Down

0 comments on commit 2373de1

Please sign in to comment.