Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1049,12 +1049,24 @@ public ContainerBalancerStatusInfoResponseProto getContainerBalancerStatusInfo()

ContainerBalancerStatusInfoRequestProto request =
ContainerBalancerStatusInfoRequestProto.getDefaultInstance();
ContainerBalancerStatusInfoResponseProto response =
submitRequest(Type.GetContainerBalancerStatusInfo,
builder -> builder.setContainerBalancerStatusInfoRequest(request))
.getContainerBalancerStatusInfoResponse();
return response;

try {
ContainerBalancerStatusInfoResponseProto response =
submitRequest(Type.GetContainerBalancerStatusInfo,
builder -> builder.setContainerBalancerStatusInfoRequest(request))
.getContainerBalancerStatusInfoResponse();
Comment on lines +1053 to +1056
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please reduce indent of "line continuation" from 8 to 4 while already touching these lines.

return response;
} catch (IOException e) {
// HDDS-11120 - Added a rich rebalancing status info
// Backward compatibility fix - newer clients (2.0 >=) gracefully fallback to the old
// API when connecting to older servers (< 2.0) that don't support the new enum value.
if (e.getMessage() != null && e.getMessage().contains("missing required fields")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for the underlying InvalidProtocolBufferException instead? I'm not sure the text message will always be the same.

boolean isRunning = getContainerBalancerStatus();
return ContainerBalancerStatusInfoResponseProto.newBuilder()
.setIsRunning(isRunning)
.build();
}
throw e;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void execute(ScmClient scmClient) throws IOException {
ContainerBalancerStatusInfoResponseProto response = scmClient.getContainerBalancerStatusInfo();
boolean isRunning = response.getIsRunning();
ContainerBalancerStatusInfoProto balancerStatusInfo = response.getContainerBalancerStatusInfo();
if (isRunning) {
if (isRunning && balancerStatusInfo != null) {
Instant startedAtInstant = Instant.ofEpochSecond(balancerStatusInfo.getStartedAt());
LocalDateTime dateTime =
LocalDateTime.ofInstant(startedAtInstant, ZoneId.systemDefault());
Comment on lines +62 to 65
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Let's move these two statements inside isVerbose() (since values are only used there), and add balancerStatusInfo != null check in that if. Then we don't need a new outer else if and duplicate println.

Expand Down Expand Up @@ -101,6 +101,8 @@ public void execute(ScmClient scmClient) throws IOException {
}
}

} else if (isRunning) {
System.out.println("ContainerBalancer is Running.");
} else {
System.out.println("ContainerBalancer is Not Running.");
}
Expand Down
9 changes: 9 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/compatibility/read.robot
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,12 @@ Key Info File Flag Should Be Set Correctly

${dir_info} = Execute ozone sh key info ${dirpath}
Should Contain ${dir_info} \"file\" : false

Container Balancer Status Command Runs
# Container balancer command was introduced in version 1.2.0
# Skip test if either client or cluster doesn't support it
Pass Execution If '${CLIENT_VERSION}' < '${CONTAINERBALANCER_VERSION}' Client does not support container balancer
Pass Execution If '${CLUSTER_VERSION}' < '${CONTAINERBALANCER_VERSION}' Cluster does not support container balancer

${result} = Execute ozone admin containerbalancer status
Should Contain ${result} ContainerBalancer
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Resource ../ozone-lib/shell.robot
${EC_VERSION} 1.3.0
${FSO_VERSION} 1.3.0
${HSYNC_VERSION} 2.0.0
${CONTAINERBALANCER_VERSION} 1.2.0
${TESTFILE} ${TEST_DATA_DIR}/small