-
Notifications
You must be signed in to change notification settings - Fork 621
HDDS-4926. Support start/stop for container balancer via command line #2278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
4ec7f55
f7cea16
8a26e33
5efb584
a96c1ba
fff764b
4526b6a
558c0fc
45e79e4
d913cf4
2879fb8
029cf09
c4f2fc4
3cd3fae
b575197
e50cfc4
11a93dd
040c4de
26a6e54
91e795c
a6260d4
b84dd23
5b483ae
993bc31
62f2b36
81a657d
6a04ed2
00e34f4
50029a7
0199f26
44aa8b1
e7abf32
e99c865
b69c5c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,8 @@ | |
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.RecommissionNodesResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ReplicationManagerStatusRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ReplicationManagerStatusResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerBalancerStatusRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerBalancerStatusResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMCloseContainerRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMDeleteContainerRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMListContainerRequestProto; | ||
|
|
@@ -69,6 +71,9 @@ | |
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartMaintenanceNodesResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartReplicationManagerRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StopReplicationManagerRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartContainerBalancerRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartContainerBalancerResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StopContainerBalancerRequestProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.Type; | ||
| import org.apache.hadoop.hdds.scm.DatanodeAdminError; | ||
| import org.apache.hadoop.hdds.scm.ScmInfo; | ||
|
|
@@ -712,6 +717,45 @@ public boolean getReplicationManagerStatus() throws IOException { | |
|
|
||
| } | ||
|
|
||
| @Override | ||
| public boolean startContainerBalancer(double threshold, int idleiterations, | ||
| int maxDatanodesToBalance, long maxSizeToMove) throws IOException { | ||
| StartContainerBalancerRequestProto request = | ||
| StartContainerBalancerRequestProto.newBuilder() | ||
| .setIdleiterations(idleiterations) | ||
| .setMaxDatanodesToBalance(maxDatanodesToBalance) | ||
| .setMaxSizeToMove(maxSizeToMove) | ||
| .setThreshold(threshold).build(); | ||
| StartContainerBalancerResponseProto response = | ||
| submitRequest(Type.StartContainerBalancer, | ||
| builder -> builder.setStartContainerBalancerRequest(request)) | ||
| .getStartContainerBalancerResponse(); | ||
| return response.getStart(); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopContainerBalancer() throws IOException { | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary blank line can be removed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks , will remove it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove these extra head and tail black line? |
||
| StopContainerBalancerRequestProto request = | ||
| StopContainerBalancerRequestProto.getDefaultInstance(); | ||
| submitRequest(Type.StopContainerBalancer, | ||
| builder -> builder.setStopContainerBalancerRequest(request)); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public boolean getContainerBalancerStatus() throws IOException { | ||
|
|
||
| ContainerBalancerStatusRequestProto request = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems i have already used 4 black space indent here |
||
| ContainerBalancerStatusRequestProto.getDefaultInstance(); | ||
| ContainerBalancerStatusResponseProto response = | ||
| submitRequest(Type.GetContainerBalancerStatus, | ||
| builder -> builder.setContainerBalancerStatusRequest(request)) | ||
| .getContainerBalancerStatusResponse(); | ||
| return response.getIsRunning(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Builds request for datanode usage information and receives response. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,9 @@ message ScmContainerLocationRequest { | |
| optional DatanodeUsageInfoRequestProto DatanodeUsageInfoRequest = 30; | ||
| optional GetExistContainerWithPipelinesInBatchRequestProto getExistContainerWithPipelinesInBatchRequest = 31; | ||
| optional GetContainerTokenRequestProto containerTokenRequest = 32; | ||
| optional StartContainerBalancerRequestProto startContainerBalancerRequest = 33; | ||
| optional StopContainerBalancerRequestProto stopContainerBalancerRequest = 34; | ||
| optional ContainerBalancerStatusRequestProto containerBalancerStatusRequest = 35; | ||
| } | ||
|
|
||
| message ScmContainerLocationResponse { | ||
|
|
@@ -109,6 +112,9 @@ message ScmContainerLocationResponse { | |
| optional DatanodeUsageInfoResponseProto DatanodeUsageInfoResponse = 30; | ||
| optional GetExistContainerWithPipelinesInBatchResponseProto getExistContainerWithPipelinesInBatchResponse = 31; | ||
| optional GetContainerTokenResponseProto containerTokenResponse = 32; | ||
| optional StartContainerBalancerResponseProto startContainerBalancerResponse = 33; | ||
| optional StopContainerBalancerResponseProto stopContainerBalancerResponse = 34; | ||
| optional ContainerBalancerStatusResponseProto containerBalancerStatusResponse = 35; | ||
|
|
||
| enum Status { | ||
| OK = 1; | ||
|
|
@@ -147,6 +153,9 @@ enum Type { | |
| DatanodeUsageInfo = 25; | ||
| GetExistContainerWithPipelinesInBatch = 26; | ||
| GetContainerToken = 27; | ||
| StartContainerBalancer = 28; | ||
| StopContainerBalancer = 29; | ||
| GetContainerBalancerStatus = 30; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -445,6 +454,33 @@ message GetContainerTokenResponseProto { | |
| required TokenProto token = 1; | ||
| } | ||
|
|
||
| message StartContainerBalancerRequestProto { | ||
| optional string traceID = 1; | ||
| required double threshold = 2; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we using KeyValue here if there will be more fields in future.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do all these required fileds have default values? If so, they are optional, insteal of required.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @ChenSammi for the reivew. there will not be default value, see this discuss
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @ChenSammi is pointing out that since all these fields do not have default values they should be optional. |
||
| required int32 idleiterations = 3; | ||
| required int32 maxDatanodesToBalance = 4; | ||
| required int64 maxSizeToMove = 5; | ||
| } | ||
|
|
||
| message StartContainerBalancerResponseProto { | ||
| required bool start = 1; | ||
| } | ||
|
|
||
| message StopContainerBalancerRequestProto { | ||
| optional string traceID = 1; | ||
| } | ||
|
|
||
| message StopContainerBalancerResponseProto { | ||
| } | ||
|
|
||
| message ContainerBalancerStatusRequestProto { | ||
| optional string traceID = 1; | ||
| } | ||
|
|
||
| message ContainerBalancerStatusResponseProto { | ||
| required bool isRunning = 1; | ||
| } | ||
|
|
||
| /** | ||
| * Protocol used from an HDFS node to StorageContainerManager. See the request | ||
| * and response messages for details of the RPC calls. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,11 @@ public final class ContainerBalancerConfiguration { | |
| "by Container Balancer.") | ||
| private long maxSizeToMove = 10 * OzoneConsts.GB; | ||
|
|
||
| @Config(key = "idle.iterations", type = ConfigType.INT, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on current implementation, I would suggest changing the "idle.iterations" to "max.iterations". As Lokesh said, we can do it in a seperate PR later to revisit all these configurations and namings.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, we could revisit it later |
||
| defaultValue = "10", tags = {ConfigTag.BALANCER}, | ||
| description = "The idle iteration count of Container Balancer") | ||
| private int idleIterations = 10; | ||
|
|
||
| /** | ||
| * Gets the threshold value for Container Balancer. | ||
| * | ||
|
|
@@ -78,6 +83,28 @@ public void setThreshold(double threshold) { | |
| this.threshold = String.valueOf(threshold); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the idle iteration value for Container Balancer. | ||
| * | ||
| * @return a idle iteration count larger than 0 | ||
| */ | ||
| public int getIdleIteration() { | ||
| return idleIterations; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the idle iteration value for Container Balancer. | ||
| * | ||
| * @param count a idle iteration count larger than 0 | ||
| */ | ||
| public void setIdleIteration(int count) { | ||
| if (count < 1) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't we also allowing |
||
| throw new IllegalArgumentException( | ||
| "Idle iteration count must be larger than 0."); | ||
| } | ||
| this.idleIterations = count; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the value of maximum number of datanodes that will be balanced by | ||
| * Container Balancer. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.