Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/protocol/ProcessQueueInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class ProcessQueueInfo {
virtual ~ProcessQueueInfo() {}

public:
const uint64 getCommitOffset() const { return commitOffset; }
const int64 getCommitOffset() const { return commitOffset; }

void setCommitOffset(uint64 input_commitOffset) { commitOffset = input_commitOffset; }
void setCommitOffset(int64 input_commitOffset) { commitOffset = input_commitOffset; }

void setLocked(bool in_locked) { locked = in_locked; }

Expand All @@ -56,7 +56,7 @@ class ProcessQueueInfo {

Json::Value toJson() const {
Json::Value outJson;
outJson["commitOffset"] = (UtilAll::to_string(commitOffset)).c_str();
outJson["commitOffset"] = (Json::Int64)commitOffset;
outJson["cachedMsgMinOffset"] = (UtilAll::to_string(cachedMsgMinOffset)).c_str();
outJson["cachedMsgMaxOffset"] = (UtilAll::to_string(cachedMsgMaxOffset)).c_str();
outJson["cachedMsgCount"] = (int)(cachedMsgCount);
Expand All @@ -74,7 +74,7 @@ class ProcessQueueInfo {
}

public:
uint64 commitOffset;
int64 commitOffset;
uint64 cachedMsgMinOffset;
uint64 cachedMsgMaxOffset;
int cachedMsgCount;
Expand Down
13 changes: 12 additions & 1 deletion test/src/protocol/ProcessQueueInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ TEST(processQueueInfo, init) {

Json::Value outJson = processQueueInfo.toJson();

EXPECT_EQ(outJson["commitOffset"], "456");
EXPECT_TRUE(outJson["commitOffset"].isInt64());
EXPECT_EQ(outJson["commitOffset"].asInt64(), 456);
EXPECT_EQ(outJson["cachedMsgMinOffset"], "0");
EXPECT_EQ(outJson["cachedMsgMaxOffset"], "0");
EXPECT_EQ(outJson["cachedMsgCount"].asInt(), 0);
Expand All @@ -67,6 +68,16 @@ TEST(processQueueInfo, init) {
EXPECT_EQ(outJson["droped"].asBool(), true);
EXPECT_EQ(outJson["lastPullTimestamp"], "0");
EXPECT_EQ(outJson["lastConsumeTimestamp"], "0");

processQueueInfo.setCommitOffset(-1);
Json::Value sentinelJson = processQueueInfo.toJson();
EXPECT_TRUE(sentinelJson["commitOffset"].isInt64());
EXPECT_EQ(sentinelJson["commitOffset"].asInt64(), -1);

processQueueInfo.setCommitOffset(-2);
Json::Value exceptionalJson = processQueueInfo.toJson();
EXPECT_TRUE(exceptionalJson["commitOffset"].isInt64());
EXPECT_EQ(exceptionalJson["commitOffset"].asInt64(), -2);
}

int main(int argc, char* argv[]) {
Expand Down