Skip to content

Commit

Permalink
🐳 #277#280 偶现 BrokerClientType 为空
Browse files Browse the repository at this point in the history
  • Loading branch information
iohao committed May 10, 2024
1 parent 5a04384 commit d1642e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* ioGame
* ioGame
* Copyright (C) 2021 - present 渔民小镇 ([email protected][email protected]) . All Rights Reserved.
* # iohao.com . 渔民小镇
*
Expand Down Expand Up @@ -29,10 +29,7 @@
import lombok.experimental.FieldDefaults;
import org.jctools.maps.NonBlockingHashMap;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* 负载管理器
Expand Down Expand Up @@ -96,6 +93,10 @@ public void register(BrokerClientModuleMessage brokerClientModuleMessage) {
public BrokerClientProxy remove(String address) {
BrokerClientProxy brokerClientProxy = this.refMap.get(address);

if (Objects.isNull(brokerClientProxy)) {
return null;
}

BrokerClientType brokerClientType = brokerClientProxy.getBrokerClientType();
var loadBalanced = this.getRegionLoadBalanced(brokerClientType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,21 @@ public final class ConnectionCloseEventBrokerProcessor implements ConnectionEven

@Override
public void onEvent(String remoteAddress, Connection connection) {
if (IoGameGlobalConfig.openLog) {
log.info("Broker ConnectionEventType:【{}】 remoteAddress:【{}】,Connection:【{}】",
ConnectionEventType.CLOSE, remoteAddress, connection
);
}

Objects.requireNonNull(connection);

BalancedManager balancedManager = this.brokerServer.getBalancedManager();
// 当前下线的逻辑服
BrokerClientProxy brokerClientProxy = balancedManager.remove(remoteAddress);

extractedPrint(remoteAddress, brokerClientProxy);
BrokerPrintKit.print(this.brokerServer);

Optional.ofNullable(brokerClientProxy).ifPresent(proxy -> {
if (IoGameGlobalConfig.openLog) {
log.info("Broker ConnectionEventType:【{}】,remoteAddress:【{}】,brokerClientProxy:【{}】,Connection:【{}】",
ConnectionEventType.CLOSE, remoteAddress, brokerClientProxy, connection
);

BrokerPrintKit.print(this.brokerServer);
}

String id = proxy.getId();
BrokerClientModuleMessage moduleMessage = this.brokerClientModules.removeById(id);

Expand All @@ -83,12 +82,4 @@ public void onEvent(String remoteAddress, Connection connection) {
LineKit.offline(context);
});
}

private void extractedPrint(String remoteAddress, BrokerClientProxy brokerClientProxy) {
if (IoGameGlobalConfig.openLog) {
log.info("Broker ConnectionEventType:【{}】 remoteAddress:【{}】,brokerClientProxy:【{}】",
ConnectionEventType.CLOSE, remoteAddress, brokerClientProxy
);
}
}
}

0 comments on commit d1642e5

Please sign in to comment.