HeartSaVioR commented on a change in pull request #2996: STORM-3376: Set Server
callback before opening Netty socket, so we do…
URL: https://github.com/apache/storm/pull/2996#discussion_r281022603
##########
File path: storm-client/src/jvm/org/apache/storm/messaging/local/Context.java
##########
@@ -37,62 +38,53 @@
public class Context implements IContext {
private static final Logger LOG = LoggerFactory.getLogger(Context.class);
- private static ConcurrentHashMap<String, LocalServer> _registry = new
ConcurrentHashMap<>();
-
- private static LocalServer getLocalServer(String nodeId, int port) {
- String key = nodeId + "-" + port;
- LocalServer ret = _registry.get(key);
- if (ret == null) {
- ret = new LocalServer(port);
- LocalServer tmp = _registry.putIfAbsent(key, ret);
- if (tmp != null) {
- ret = tmp;
- }
+ private final ConcurrentHashMap<String, LocalServer> _registry = new
ConcurrentHashMap<>();
+
+ private static String getNodeKey(String nodeId, int port) {
+ return nodeId + "-" + port;
+ }
+
+ private LocalServer createLocalServer(String nodeId, int port,
IConnectionCallback cb) {
+ String key = getNodeKey(nodeId, port);
+ LocalServer ret = new LocalServer(port, cb);
Review comment:
That sounds much better. Thanks for explaining!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services