This is an automated email from the ASF dual-hosted git repository. vaughn pushed a commit to branch feat_sailuo in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
commit 7ce809a35835ad199a0eb28ee2031d4ca7153fd9 Author: vaughn <[email protected]> AuthorDate: Tue Jul 29 22:38:06 2025 +0800 feat: add switch for role election --- .../src/main/java/org/apache/hugegraph/config/ServerOptions.java | 9 +++++++++ .../src/main/java/org/apache/hugegraph/core/GraphManager.java | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/config/ServerOptions.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/config/ServerOptions.java index f4b259cc4..2e933abf5 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/config/ServerOptions.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/config/ServerOptions.java @@ -73,6 +73,15 @@ public class ServerOptions extends OptionHolder { "master" ); + public static final ConfigOption<Boolean> ENABLE_SERVER_ROLE_ELECTION = + new ConfigOption<>( + "server.role_election", + "Whether to enable role election, if enabled, the server " + + "will elect a master node in the cluster.", + disallowEmpty(), + true + ); + public static final ConfigOption<Integer> MAX_WORKER_THREADS = new ConfigOption<>( "restserver.max_worker_threads", diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java index daae180a3..80b52e124 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java @@ -469,7 +469,8 @@ public final class GraphManager { NodeRole nodeRole = NodeRole.valueOf(role.toUpperCase()); boolean supportRoleElection = !nodeRole.computer() && - this.supportRoleElection(); + this.supportRoleElection() && + config.get(ServerOptions.ENABLE_SERVER_ROLE_ELECTION); if (supportRoleElection) { // Init any server as Worker role, then do role election nodeRole = NodeRole.WORKER;
