ibessonov commented on code in PR #1780:
URL: https://github.com/apache/ignite-3/pull/1780#discussion_r1142083882


##########
modules/network-api/src/main/java/org/apache/ignite/network/ChannelType.java:
##########
@@ -117,19 +92,16 @@ public static ChannelInfo defaultChannel() {
      * @return Register channel.
      * @throws ChannelTypeAlreadyExist In case when channel identifier already 
used.
      */
-    public static ChannelInfo register(short id, String name) throws 
ChannelTypeAlreadyExist {
-        lock.writeLock().lock();
-        try {
-            if (channels.get(id) == null) {
-                ChannelInfo result = new ChannelInfo(id, name);
-                channels.put(id, result);
-                return result;
-            }
-
+    public static ChannelType register(short id, String name) {
+        if (id == 0) {
             throw new ChannelTypeAlreadyExist(id, name);
-        } finally {
-            lock.writeLock().unlock();
         }

Review Comment:
   You don't need this check, it's already covered by the code below.
   Anyway, for the future, `0` had to be a private constant, probably, because 
it goes into the category of magic constants.



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeploymentManagerImpl.java:
##########
@@ -139,7 +139,7 @@ public DeploymentManagerImpl(ClusterService clusterService,
         this.metaStorage = metaStorage;
         this.configuration = configuration;
         this.cmgManager = cmgManager;
-        deploymentChannelInfo = ChannelInfo.generate("DeploymentUnits");
+        deploymentChannelType = ChannelType.register((short) 1, 
"DeploymentUnits");

Review Comment:
   I'm not trying to be rude, but how does it even work? As far as I remember, 
there's a static map inside of there.
   This means, that by starting 2 Ignite nodes, you'l try to register 2 channel 
types with identical ids. This will fail with exception, right?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to