-
Notifications
You must be signed in to change notification settings - Fork 616
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 30 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; | ||
|
|
@@ -91,6 +96,7 @@ | |
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.function.Consumer; | ||
| import static org.apache.hadoop.ozone.ClientVersions.CURRENT_VERSION; | ||
|
|
||
|
|
@@ -712,6 +718,73 @@ public boolean getReplicationManagerStatus() throws IOException { | |
|
|
||
| } | ||
|
|
||
| @Override | ||
| public boolean startContainerBalancer(Optional<Double> threshold, | ||
| Optional<Integer> idleiterations, | ||
| Optional<Integer> maxDatanodesToBalance, | ||
| Optional<Long> maxSizeToMoveInGB) throws IOException{ | ||
| StartContainerBalancerRequestProto.Builder builder = | ||
| StartContainerBalancerRequestProto.newBuilder(); | ||
| builder.setTraceID(TracingUtil.exportCurrentSpan()); | ||
|
|
||
| //make balancer configuration optional | ||
| if (threshold.isPresent()) { | ||
| double tsd = threshold.get(); | ||
| Preconditions.checkState(tsd >= 0.0D && tsd < 1.0D, | ||
| "threshold should to be specified in range [0.0, 1.0)."); | ||
| builder.setThreshold(tsd); | ||
| } | ||
| if (maxSizeToMoveInGB.isPresent()) { | ||
| long mstm = maxSizeToMoveInGB.get(); | ||
| Preconditions.checkState(mstm > 0, | ||
| "maxSizeToMoveInGB must be positive."); | ||
| builder.setMaxSizeToMoveInGB(mstm); | ||
| } | ||
| if (maxDatanodesToBalance.isPresent()) { | ||
| int mdtb = maxDatanodesToBalance.get(); | ||
| Preconditions.checkState(mdtb > 0, | ||
| "maxDatanodesToBalance must be positive."); | ||
| builder.setMaxDatanodesToBalance(mdtb); | ||
| } | ||
| if (idleiterations.isPresent()) { | ||
| int idi = idleiterations.get(); | ||
| Preconditions.checkState(idi > 0 || idi == -1, | ||
| "maxDatanodesToBalance must be positive or" + | ||
| " -1(infinitly run container balancer)."); | ||
| builder.setIdleiterations(idi); | ||
| } | ||
|
|
||
| StartContainerBalancerRequestProto request = builder.build(); | ||
| StartContainerBalancerResponseProto response = | ||
| submitRequest(Type.StartContainerBalancer, | ||
| builder1 -> builder1.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. | ||
| * | ||
|
|
||
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.
Did you mean: