-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support issuing Latency commands (#3729)
* add LATENCY LATEST, LATENCY HISTORY and LATENCY RESET commands * add LatencyEvent class
- Loading branch information
Showing
8 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
private LatencyEvent(String s) { | ||
raw = SafeEncoder.encode(s); | ||
} | ||
|
||
@Override | ||
public byte[] getRaw() { | ||
return raw; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/redis/clients/jedis/resps/LatencyHistoryInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package redis.clients.jedis.resps; | ||
|
||
import redis.clients.jedis.Builder; | ||
|
||
import java.util.List; | ||
|
||
import static redis.clients.jedis.BuilderFactory.LONG; | ||
|
||
public class LatencyHistoryInfo { | ||
|
||
private final long timestamp; | ||
private final long latency; | ||
|
||
public LatencyHistoryInfo(long timestamp, long latency) { | ||
this.timestamp = timestamp; | ||
this.latency = latency; | ||
} | ||
|
||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public long getLatency() { | ||
return latency; | ||
} | ||
|
||
public static final Builder<LatencyHistoryInfo> LATENCY_HISTORY_BUILDER = new Builder<LatencyHistoryInfo>() { | ||
@Override | ||
public LatencyHistoryInfo build(Object data) { | ||
List<Object> commandData = (List<Object>) data; | ||
|
||
long timestamp = LONG.build(commandData.get(0)); | ||
long latency = LONG.build(commandData.get(1)); | ||
|
||
return new LatencyHistoryInfo(timestamp, latency); | ||
} | ||
}; | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/redis/clients/jedis/resps/LatencyLatestInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package redis.clients.jedis.resps; | ||
|
||
import redis.clients.jedis.Builder; | ||
|
||
import java.util.List; | ||
|
||
import static redis.clients.jedis.BuilderFactory.LONG; | ||
import static redis.clients.jedis.BuilderFactory.STRING; | ||
|
||
public class LatencyLatestInfo { | ||
|
||
private final String command; | ||
private final long timestamp; | ||
private final long lastEventLatency; | ||
private final long maxEventLatency; | ||
|
||
public LatencyLatestInfo(String command, long timestamp, long lastEventLatency, long maxEventLatency) { | ||
this.command = command; | ||
this.timestamp = timestamp; | ||
this.lastEventLatency = lastEventLatency; | ||
this.maxEventLatency = maxEventLatency; | ||
} | ||
|
||
public String getCommand() { | ||
return command; | ||
} | ||
|
||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public long getLastEventLatency() { | ||
return lastEventLatency; | ||
} | ||
|
||
public long getMaxEventLatency() { | ||
return maxEventLatency; | ||
} | ||
|
||
public static final Builder<LatencyLatestInfo> LATENCY_LATEST_BUILDER = new Builder<LatencyLatestInfo>() { | ||
@Override | ||
public LatencyLatestInfo build(Object data) { | ||
List<Object> commandData = (List<Object>) data; | ||
|
||
String command = STRING.build(commandData.get(0)); | ||
long timestamp = LONG.build(commandData.get(1)); | ||
long lastEventLatency = LONG.build(commandData.get(2)); | ||
long maxEventLatency = LONG.build(commandData.get(3)); | ||
|
||
return new LatencyLatestInfo(command, timestamp, lastEventLatency, maxEventLatency); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters