Commit ed236e8c authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Implement command to read both static and dynamic clocks of a node

Just because we can. :P An automated client should never need to
call this.
parent 2208f1df
Pipeline #428262 failed with stages
in 21 minutes and 47 seconds
......@@ -63,6 +63,7 @@ struct cmdMapInit {
redis_cmd_map["lhget_with_fallback"] = {RedisCommand::LHGET_WITH_FALLBACK, CommandType::READ};
redis_cmd_map["raw_scan"] = {RedisCommand::RAW_SCAN, CommandType::READ};
redis_cmd_map["raw_get_all_versions"] = {RedisCommand::RAW_GET_ALL_VERSIONS, CommandType::READ};
redis_cmd_map["clock_get"] = {RedisCommand::CLOCK_GET, CommandType::READ};
redis_cmd_map["flushall"] = {RedisCommand::FLUSHALL, CommandType::WRITE};
redis_cmd_map["set"] = {RedisCommand::SET, CommandType::WRITE};
......
......@@ -98,6 +98,8 @@ enum class RedisCommand {
TX_READONLY,
TX_READWRITE,
CLOCK_GET,
CONFIG_GET,
CONFIG_SET,
CONFIG_GETALL,
......
......@@ -552,6 +552,21 @@ RedisEncodedResponse RedisDispatcher::dispatchRead(StagingArea &stagingArea, Red
return Formatter::vector(reply);
}
case RedisCommand::CLOCK_GET: {
if(request.size() != 1) return errArgs(request);
std::vector<std::string> reply;
ClockValue staticClock;
store.getClock(stagingArea, staticClock);
ClockValue dynamicClock = store.getDynamicClock();
reply.emplace_back(SSTR("STATIC-CLOCK: " << staticClock));
reply.emplace_back(SSTR("DYNAMIC-CLOCK: " << dynamicClock));
return Formatter::statusVector(reply);
}
default: {
return dispatchingError(request, 0);
}
......
......@@ -206,7 +206,7 @@ void StateMachine::hardSynchronizeDynamicClock() {
timeKeeper.synchronize(syncPoint);
}
ClockValue StateMachine::getDynamicTime() {
ClockValue StateMachine::getDynamicClock() {
return timeKeeper.getDynamicTime();
}
......
......@@ -202,7 +202,7 @@ public:
rocksdb::Status verifyChecksum();
RequestCounter& getRequestCounter() { return requestCounter; }
ClockValue getDynamicTime();
ClockValue getDynamicClock();
void hardSynchronizeDynamicClock();
private:
......
......@@ -408,6 +408,7 @@ TEST_F(Raft_e2e, test_many_redis_commands) {
futures.emplace_back(tunnel(leaderID)->exec("del", "myhash", "myset", "mystring"));
futures.emplace_back(tunnel(leaderID)->exec("exists", "mystring", "myset", "myhash", "adfa", "myhash"));
futures.emplace_back(tunnel(leaderID)->exec("del", "myhash", "myset"));
futures.emplace_back(tunnel(leaderID)->exec("clock-get"));
ASSERT_REPLY(futures[0], "OK");
ASSERT_REPLY(futures[1], make_vec("myhash", "myset", "mystring"));
......@@ -415,6 +416,7 @@ TEST_F(Raft_e2e, test_many_redis_commands) {
ASSERT_REPLY(futures[3], 3);
ASSERT_REPLY(futures[4], 0);
ASSERT_REPLY(futures[5], 0);
qdb_info(qclient::describeRedisReply(futures[6].get()));
futures.clear();
futures.emplace_back(tunnel(leaderID)->exec("set", "a", "aa"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment