From 03d746174594566e54d785e72c7af71f3c3ae388 Mon Sep 17 00:00:00 2001 From: mchimang Date: Tue, 29 Jul 2025 04:18:36 +0530 Subject: [PATCH] feat: add fields - raftAppliedIndex , errorsList, dbSizeInUse and isLearner in StatusResponse Signed-off-by: mchimang --- .../jetcd/maintenance/StatusResponse.java | 38 +++++++++++++++++++ jetcd-core/src/main/proto/rpc.proto | 8 ++++ .../io/etcd/jetcd/impl/MaintenanceTest.java | 9 +++++ jetcd-grpc/src/main/proto/rpc.proto | 8 ++++ 4 files changed, 63 insertions(+) diff --git a/jetcd-core/src/main/java/io/etcd/jetcd/maintenance/StatusResponse.java b/jetcd-core/src/main/java/io/etcd/jetcd/maintenance/StatusResponse.java index 93cadc16..28ee8432 100644 --- a/jetcd-core/src/main/java/io/etcd/jetcd/maintenance/StatusResponse.java +++ b/jetcd-core/src/main/java/io/etcd/jetcd/maintenance/StatusResponse.java @@ -16,6 +16,8 @@ package io.etcd.jetcd.maintenance; +import java.util.List; + import io.etcd.jetcd.Maintenance; import io.etcd.jetcd.impl.AbstractResponse; @@ -73,4 +75,40 @@ public long getRaftIndex() { public long getRaftTerm() { return getResponse().getRaftTerm(); } + + /** + * Returns the current raft applied index of the responding member. + * + * @return the raft applied index. + */ + public long getRaftAppliedIndex() { + return getResponse().getRaftAppliedIndex(); + } + + /** + * Return the information corresponding to the alarms, health and status. + * + * @return the list of errors + */ + public List getErrorList() { + return getResponse().getErrorsList(); + } + + /** + * Returns the size of the backend database logically in use, in bytes, of the responding member. + * + * @return dbSizeInUse + */ + public long getDbSizeInUse() { + return getResponse().getDbSizeInUse(); + } + + /** + * Returns if the member is a raft learner. + * + * @return if the member is a raft learner + */ + public boolean isLearner() { + return getResponse().getIsLearner(); + } } diff --git a/jetcd-core/src/main/proto/rpc.proto b/jetcd-core/src/main/proto/rpc.proto index 6a67e600..637abf6e 100644 --- a/jetcd-core/src/main/proto/rpc.proto +++ b/jetcd-core/src/main/proto/rpc.proto @@ -725,6 +725,14 @@ message StatusResponse { uint64 raftIndex = 5; // raftTerm is the current raft term of the responding member. uint64 raftTerm = 6; + // raftAppliedIndex is the current raft applied index of the responding member. + uint64 raftAppliedIndex = 7; + // errors contains alarm/health information and status. + repeated string errors = 8; + // dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member. + int64 dbSizeInUse = 9; + // isLearner indicates if the member is raft learner. + bool isLearner = 10; } message AuthEnableRequest { diff --git a/jetcd-core/src/test/java/io/etcd/jetcd/impl/MaintenanceTest.java b/jetcd-core/src/test/java/io/etcd/jetcd/impl/MaintenanceTest.java index 6e517d6b..e8f32a89 100644 --- a/jetcd-core/src/test/java/io/etcd/jetcd/impl/MaintenanceTest.java +++ b/jetcd-core/src/test/java/io/etcd/jetcd/impl/MaintenanceTest.java @@ -72,6 +72,15 @@ public void setUp() { public void testStatusMember() throws ExecutionException, InterruptedException { StatusResponse statusResponse = maintenance.statusMember(endpoints.get(0)).get(); assertThat(statusResponse.getDbSize()).isGreaterThan(0); + assertThat(statusResponse.getRaftIndex()).isGreaterThan(0); + assertThat(statusResponse.getRaftAppliedIndex()) + .isGreaterThan(0) + .isLessThanOrEqualTo(statusResponse.getRaftIndex()); + assertThat(statusResponse.getDbSizeInUse()) + .isGreaterThan(0) + .isLessThanOrEqualTo(statusResponse.getDbSize()); + assertThat(statusResponse.isLearner()).isFalse(); + assertThat(statusResponse.getErrorList().size()).isEqualTo(0); } @Test diff --git a/jetcd-grpc/src/main/proto/rpc.proto b/jetcd-grpc/src/main/proto/rpc.proto index bf67359f..07330a78 100644 --- a/jetcd-grpc/src/main/proto/rpc.proto +++ b/jetcd-grpc/src/main/proto/rpc.proto @@ -725,6 +725,14 @@ message StatusResponse { uint64 raftIndex = 5; // raftTerm is the current raft term of the responding member. uint64 raftTerm = 6; + // raftAppliedIndex is the current raft applied index of the responding member. + uint64 raftAppliedIndex = 7; + // errors contains alarm/health information and status. + repeated string errors = 8; + // dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member. + int64 dbSizeInUse = 9; + // isLearner indicates if the member is raft learner. + bool isLearner = 10; } message AuthEnableRequest {