Skip to content

Commit

Permalink
🎨 node权重
Browse files Browse the repository at this point in the history
  • Loading branch information
adlered committed Dec 20, 2024
1 parent 94a62c1 commit 9eebd92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ public void getNode(final RequestContext context) {
JSONObject node = new JSONObject();
node.put("node", entry.getKey());
node.put("name", NodeUtil.nodeNickNames.get(entry.getKey()));
node.put("weight", NodeUtil.nodeWeight.get(entry.getKey()));
node.put("online", entry.getValue());
data.put(node);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/b3log/symphony/util/NodeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class NodeUtil {

public static HashMap<String, String> nodeNickNames = new HashMap<>();

public static HashMap<String, String> nodeWeight = new HashMap<>();

public static void init() {
LOGGER.log(Level.INFO, "Loading nodes");
for (WebSocket i : wsNodes) {
Expand All @@ -73,9 +75,11 @@ public static void init() {
wsNodes = new ArrayList<>();
uriNodes = new ArrayList<>();
nodeNickNames.clear();
nodeWeight.clear();
String[] nodes = Symphonys.get("chatroom.node.url").split(";");
for (String i : nodes) {
nodeNickNames.put(i.split(",")[0], i.split(",")[1]);
nodeWeight.put(i.split(",")[0], i.split(",")[2]);
i = i.split(",")[0];
String serverUri = i + "?apiKey=" + Symphonys.get("chatroom.node.adminKey");
try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/symphony.properties
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,6 @@ pay.wechat.mch_id=
pay.wechat.key=

# Rhyus
chatroom.node.url=ws://127.0.0.1:10831,\u6cb3\u5317\u4e00\u533a
chatroom.node.url=ws://127.0.0.1:10831,\u6cb3\u5317\u4e00\u533a,1
#ws://121.62.31.42:10831
chatroom.node.adminKey=123456

0 comments on commit 9eebd92

Please sign in to comment.