|
25 | 25 | #include "server/server_family.h"
|
26 | 26 | #include "server/server_state.h"
|
27 | 27 |
|
28 |
| -ABSL_FLAG(std::string, cluster_announce_ip, "", "ip that cluster commands announce to the client"); |
| 28 | +ABSL_FLAG(std::string, cluster_announce_ip, "", "DEPRECATED: use --announce_ip"); |
| 29 | + |
29 | 30 | ABSL_FLAG(std::string, cluster_node_id, "",
|
30 | 31 | "ID within a cluster, used for slot assignment. MUST be unique. If empty, uses master "
|
31 | 32 | "replication ID (random string)");
|
32 | 33 |
|
33 | 34 | ABSL_DECLARE_FLAG(int32_t, port);
|
| 35 | +ABSL_DECLARE_FLAG(std::string, announce_ip); |
| 36 | +ABSL_DECLARE_FLAG(uint16_t, announce_port); |
34 | 37 |
|
35 | 38 | namespace dfly {
|
36 | 39 | namespace acl {
|
@@ -66,6 +69,16 @@ ClusterFamily::ClusterFamily(ServerFamily* server_family) : server_family_(serve
|
66 | 69 |
|
67 | 70 | InitializeCluster();
|
68 | 71 |
|
| 72 | + // TODO: Remove flag cluster_announce_ip in v1.23+ |
| 73 | + if (!absl::GetFlag(FLAGS_cluster_announce_ip).empty()) { |
| 74 | + CHECK(absl::GetFlag(FLAGS_announce_ip).empty()) |
| 75 | + << "Can't use both --cluster_announce_ip and --announce_ip"; |
| 76 | + |
| 77 | + LOG(WARNING) << "WARNING: Flag --cluster_announce_ip is deprecated in favor of --announce_ip. " |
| 78 | + "Use the latter, as the former will be removed in a future release."; |
| 79 | + absl::SetFlag(&FLAGS_announce_ip, absl::GetFlag(FLAGS_cluster_announce_ip)); |
| 80 | + } |
| 81 | + |
69 | 82 | id_ = absl::GetFlag(FLAGS_cluster_node_id);
|
70 | 83 | if (id_.empty()) {
|
71 | 84 | id_ = server_family_->master_replid();
|
@@ -104,13 +117,15 @@ ClusterShardInfo ClusterFamily::GetEmulatedShardInfo(ConnectionContext* cntx) co
|
104 | 117 | ServerState& etl = *ServerState::tlocal();
|
105 | 118 | if (!replication_info.has_value()) {
|
106 | 119 | DCHECK(etl.is_master);
|
107 |
| - std::string cluster_announce_ip = absl::GetFlag(FLAGS_cluster_announce_ip); |
| 120 | + std::string cluster_announce_ip = absl::GetFlag(FLAGS_announce_ip); |
108 | 121 | std::string preferred_endpoint =
|
109 | 122 | cluster_announce_ip.empty() ? cntx->conn()->LocalBindAddress() : cluster_announce_ip;
|
| 123 | + uint16_t cluster_announce_port = absl::GetFlag(FLAGS_announce_port); |
| 124 | + uint16_t preferred_port = cluster_announce_port == 0 |
| 125 | + ? static_cast<uint16_t>(absl::GetFlag(FLAGS_port)) |
| 126 | + : cluster_announce_port; |
110 | 127 |
|
111 |
| - info.master = {.id = id_, |
112 |
| - .ip = preferred_endpoint, |
113 |
| - .port = static_cast<uint16_t>(absl::GetFlag(FLAGS_port))}; |
| 128 | + info.master = {.id = id_, .ip = preferred_endpoint, .port = preferred_port}; |
114 | 129 |
|
115 | 130 | for (const auto& replica : server_family_->GetDflyCmd()->GetReplicasRoleInfo()) {
|
116 | 131 | info.replicas.push_back({.id = replica.id,
|
|
0 commit comments