symious commented on a change in pull request #2550:
URL: https://github.com/apache/ozone/pull/2550#discussion_r691037186
##########
File path:
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -700,6 +701,9 @@ public void bootstrapOzoneManager(String omNodeId) throws
Exception {
while (true) {
try {
basePort = 10000 + RANDOM.nextInt(1000) * 4;
+ if (!isPortAvailable(basePort)) {
Review comment:
@sodonnel Thanks for review.
Yeah, I was checking the same page, too.
Normally we don't use ports under 1000, but in docker it should be fine?
Another case is if the port returned is larger than 65531, it will exceed
the port range?
##########
File path:
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -700,6 +701,9 @@ public void bootstrapOzoneManager(String omNodeId) throws
Exception {
while (true) {
try {
basePort = 10000 + RANDOM.nextInt(1000) * 4;
+ if (!isPortAvailable(basePort)) {
Review comment:
Sure.
Do we need to call the method 4 times, or add a restriction that basePort is
under 65532?
##########
File path:
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -966,4 +970,31 @@ public StorageContainerManager
getStorageContainerManager() {
return getStorageContainerManagers().get(0);
}
+ private int getFreePort() {
+ ServerSocket ss = null;
+ try {
+ ss = new ServerSocket(0);
+ return ss.getLocalPort();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (ss != null) {
+ try {
+ ss.close();
+ } catch (IOException e) {
+ LOG.error("Got exception while closing ServerSocket: " +
+ e.getMessage());
+ }
+ }
+ }
+ return -1;
+ }
+
+ private Set<Integer> getFreePortSet(int size) {
+ Set<Integer> portSet = new HashSet<>();
+ while (portSet.size() < size) {
+ portSet.add(getFreePort());
Review comment:
Sure, updated to use `SCMTestUtils.getReusableAddress()`.
--
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]