yifan-c commented on code in PR #2546:
URL: https://github.com/apache/cassandra/pull/2546#discussion_r1302312376
##########
test/distributed/org/apache/cassandra/distributed/impl/INodeProvisionStrategy.java:
##########
@@ -18,97 +18,154 @@
package org.apache.cassandra.distributed.impl;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+import org.apache.cassandra.net.SocketUtils;
import org.apache.cassandra.utils.Shared;
import static org.apache.cassandra.utils.Shared.Recursive.INTERFACES;
@Shared(inner = INTERFACES)
public interface INodeProvisionStrategy
{
- public enum Strategy
+ enum Strategy
{
OneNetworkInterface
{
- INodeProvisionStrategy create(int subnet) {
+ @Override
+ INodeProvisionStrategy create(int subnet, @Nullable Map<String,
Integer> portMap)
+ {
+ String ipAdress = "127.0." + subnet + ".1";
return new INodeProvisionStrategy()
{
+ @Override
public String seedIp()
{
- return "127.0." + subnet + ".1";
+ return ipAdress;
}
+ @Override
public int seedPort()
{
- return 7012;
+ return storagePort(1);
}
+ @Override
public String ipAddress(int nodeNum)
{
- return "127.0." + subnet + ".1";
+ return ipAdress;
}
+ @Override
public int storagePort(int nodeNum)
{
+ if (portMap != null)
+ {
+ return portMap.computeIfAbsent("storagePort:" +
nodeNum, key -> SocketUtils.findAvailablePort(seedIp(), 7011 + nodeNum));
+ }
return 7011 + nodeNum;
}
+ @Override
public int nativeTransportPort(int nodeNum)
{
+ if (portMap != null)
+ {
+ return
portMap.computeIfAbsent("nativeTransportPort:" + nodeNum, key ->
SocketUtils.findAvailablePort(seedIp(), 9041 + nodeNum));
+ }
return 9041 + nodeNum;
}
+ @Override
public int jmxPort(int nodeNum)
{
+ if (portMap != null)
+ {
+ return portMap.computeIfAbsent("jmxPort:" +
nodeNum, key -> SocketUtils.findAvailablePort(seedIp(), 7199 + nodeNum));
+ }
return 7199 + nodeNum;
}
};
}
},
MultipleNetworkInterfaces
{
- INodeProvisionStrategy create(int subnet) {
- String ipPrefix = "127.0." + subnet + ".";
+ @Override
+ INodeProvisionStrategy create(int subnet, @Nullable Map<String,
Integer> portMap)
+ {
+ String ipPrefix = "127.0." + subnet + '.';
return new INodeProvisionStrategy()
{
+
+ @Override
public String seedIp()
{
- return ipPrefix + "1";
+ return ipPrefix + '1';
}
+ @Override
public int seedPort()
{
- return 7012;
+ return storagePort(1);
}
+ @Override
public String ipAddress(int nodeNum)
{
return ipPrefix + nodeNum;
}
+ @Override
public int storagePort(int nodeNum)
{
+ if (portMap != null)
+ {
+ return portMap.computeIfAbsent("storagePort" +
nodeNum, key -> SocketUtils.findAvailablePort(ipAddress(nodeNum), 7012));
Review Comment:
This key does not contain ":", while all the others contain ":".
Are the keys going to be printed. If so, we can go a bit for verbose to have
`node1` instead of `1` and probably `@` suits better than `:`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]