From 0b4f7c8ab06399f6b90e1626e8d5b9697cb33bb9 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Fri, 27 Sep 2024 03:29:57 +0000 Subject: [PATCH] feat: introduce `DowngradingLeader` --- c++/greptime/v1/meta/heartbeat.pb.cc | 21 ++++---- c++/greptime/v1/meta/heartbeat.pb.h | 3 +- go/greptime/v1/meta/heartbeat.pb.go | 48 +++++++++++-------- .../greptime/v1/meta/HeartbeatOuterClass.java | 39 +++++++++++---- proto/greptime/v1/meta/heartbeat.proto | 4 ++ 5 files changed, 75 insertions(+), 40 deletions(-) diff --git a/c++/greptime/v1/meta/heartbeat.pb.cc b/c++/greptime/v1/meta/heartbeat.pb.cc index b7e6607e..5f4c5e60 100644 --- a/c++/greptime/v1/meta/heartbeat.pb.cc +++ b/c++/greptime/v1/meta/heartbeat.pb.cc @@ -354,22 +354,22 @@ const char descriptor_table_protodef_greptime_2fv1_2fmeta_2fheartbeat_2eproto[] ".greptime.v1.meta.Peer\"|\n\016MailboxMessage" "\022\n\n\002id\030\001 \001(\004\022\017\n\007subject\030\002 \001(\t\022\014\n\004from\030\003 " "\001(\t\022\n\n\002to\030\004 \001(\t\022\030\n\020timestamp_millis\030\005 \001(" - "\003\022\016\n\004json\030\006 \001(\tH\000B\t\n\007payload*&\n\nRegionRo" - "le\022\n\n\006Leader\020\000\022\014\n\010Follower\020\0012\277\001\n\tHeartbe" - "at\022Z\n\tHeartbeat\022\".greptime.v1.meta.Heart" - "beatRequest\032#.greptime.v1.meta.Heartbeat" - "Response\"\000(\0010\001\022V\n\tAskLeader\022\".greptime.v" - "1.meta.AskLeaderRequest\032#.greptime.v1.me" - "ta.AskLeaderResponse\"\000B::min(), RegionRole_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::max() }; bool RegionRole_IsValid(int value); constexpr RegionRole RegionRole_MIN = Leader; -constexpr RegionRole RegionRole_MAX = Follower; +constexpr RegionRole RegionRole_MAX = DowngradingLeader; constexpr int RegionRole_ARRAYSIZE = RegionRole_MAX + 1; const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* RegionRole_descriptor(); diff --git a/go/greptime/v1/meta/heartbeat.pb.go b/go/greptime/v1/meta/heartbeat.pb.go index ade354bf..90f53502 100644 --- a/go/greptime/v1/meta/heartbeat.pb.go +++ b/go/greptime/v1/meta/heartbeat.pb.go @@ -41,6 +41,10 @@ const ( RegionRole_Leader RegionRole = 0 // Readonly region. RegionRole_Follower RegionRole = 1 + // A downgrading region, which is in the process of downgrading from Leader to Follower. + // + // This role is used to prevent the region from being written during the downgrade process. + RegionRole_DowngradingLeader RegionRole = 2 ) // Enum value maps for RegionRole. @@ -48,10 +52,12 @@ var ( RegionRole_name = map[int32]string{ 0: "Leader", 1: "Follower", + 2: "DowngradingLeader", } RegionRole_value = map[string]int32{ - "Leader": 0, - "Follower": 1, + "Leader": 0, + "Follower": 1, + "DowngradingLeader": 2, } ) @@ -882,26 +888,28 @@ var file_greptime_v1_meta_heartbeat_proto_rawDesc = []byte{ 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x12, 0x14, 0x0a, 0x04, 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6a, - 0x73, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x26, + 0x73, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x3d, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x6f, 0x6c, 0x6c, - 0x6f, 0x77, 0x65, 0x72, 0x10, 0x01, 0x32, 0xbf, 0x01, 0x0a, 0x09, 0x48, 0x65, 0x61, 0x72, 0x74, - 0x62, 0x65, 0x61, 0x74, 0x12, 0x5a, 0x0a, 0x09, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, - 0x74, 0x12, 0x22, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, - 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, - 0x12, 0x56, 0x0a, 0x09, 0x41, 0x73, 0x6b, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x22, 0x2e, - 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x6d, 0x65, 0x74, 0x61, - 0x2e, 0x41, 0x73, 0x6b, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x23, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x41, 0x73, 0x6b, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x47, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x54, - 0x65, 0x61, 0x6d, 0x2f, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2d, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, - 0x31, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x77, 0x65, 0x72, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x44, 0x6f, 0x77, 0x6e, 0x67, 0x72, + 0x61, 0x64, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x02, 0x32, 0xbf, 0x01, + 0x0a, 0x09, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x5a, 0x0a, 0x09, 0x48, + 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x22, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x48, 0x65, 0x61, 0x72, + 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x67, + 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, + 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x56, 0x0a, 0x09, 0x41, 0x73, 0x6b, 0x4c, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x12, 0x22, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x41, 0x73, 0x6b, 0x4c, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x41, 0x73, 0x6b, 0x4c, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x47, 0x72, + 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x2f, 0x67, 0x72, 0x65, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x72, 0x65, + 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/java/src/main/java/greptime/v1/meta/HeartbeatOuterClass.java b/java/src/main/java/greptime/v1/meta/HeartbeatOuterClass.java index 919330d8..47c736c9 100644 --- a/java/src/main/java/greptime/v1/meta/HeartbeatOuterClass.java +++ b/java/src/main/java/greptime/v1/meta/HeartbeatOuterClass.java @@ -35,6 +35,16 @@ public enum RegionRole * Follower = 1; */ Follower(1), + /** + *
+     * A downgrading region, which is in the process of downgrading from Leader to Follower.
+     * 
+     * This role is used to prevent the region from being written during the downgrade process.
+     * 
+ * + * DowngradingLeader = 2; + */ + DowngradingLeader(2), UNRECOGNIZED(-1), ; @@ -54,6 +64,16 @@ public enum RegionRole * Follower = 1; */ public static final int Follower_VALUE = 1; + /** + *
+     * A downgrading region, which is in the process of downgrading from Leader to Follower.
+     * 
+     * This role is used to prevent the region from being written during the downgrade process.
+     * 
+ * + * DowngradingLeader = 2; + */ + public static final int DowngradingLeader_VALUE = 2; public final int getNumber() { @@ -82,6 +102,7 @@ public static RegionRole forNumber(int value) { switch (value) { case 0: return Leader; case 1: return Follower; + case 2: return DowngradingLeader; default: return null; } } @@ -10391,15 +10412,15 @@ public greptime.v1.meta.HeartbeatOuterClass.MailboxMessage getDefaultInstanceFor ".greptime.v1.meta.Peer\"|\n\016MailboxMessage" + "\022\n\n\002id\030\001 \001(\004\022\017\n\007subject\030\002 \001(\t\022\014\n\004from\030\003 " + "\001(\t\022\n\n\002to\030\004 \001(\t\022\030\n\020timestamp_millis\030\005 \001(" + - "\003\022\016\n\004json\030\006 \001(\tH\000B\t\n\007payload*&\n\nRegionRo" + - "le\022\n\n\006Leader\020\000\022\014\n\010Follower\020\0012\277\001\n\tHeartbe" + - "at\022Z\n\tHeartbeat\022\".greptime.v1.meta.Heart" + - "beatRequest\032#.greptime.v1.meta.Heartbeat" + - "Response\"\000(\0010\001\022V\n\tAskLeader\022\".greptime.v" + - "1.meta.AskLeaderRequest\032#.greptime.v1.me" + - "ta.AskLeaderResponse\"\000B