use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StartContainerBalancerRequestProto in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method startContainerBalancer.
@Override
public boolean startContainerBalancer(Optional<Double> threshold, Optional<Integer> iterations, Optional<Integer> maxDatanodesPercentageToInvolvePerIteration, Optional<Long> maxSizeToMovePerIterationInGB, Optional<Long> maxSizeEnteringTargetInGB, Optional<Long> maxSizeLeavingSourceInGB) 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 < 100D, "threshold should be specified in range [0.0, 100.0).");
builder.setThreshold(tsd);
}
if (maxSizeToMovePerIterationInGB.isPresent()) {
long mstm = maxSizeToMovePerIterationInGB.get();
Preconditions.checkState(mstm > 0, "maxSizeToMovePerIterationInGB must be positive.");
builder.setMaxSizeToMovePerIterationInGB(mstm);
}
if (maxDatanodesPercentageToInvolvePerIteration.isPresent()) {
int mdti = maxDatanodesPercentageToInvolvePerIteration.get();
Preconditions.checkState(mdti >= 0, "maxDatanodesPercentageToInvolvePerIteration must be " + "greater than equal to zero.");
Preconditions.checkState(mdti <= 100, "maxDatanodesPercentageToInvolvePerIteration must be " + "lesser than equal to hundred.");
builder.setMaxDatanodesPercentageToInvolvePerIteration(mdti);
}
if (iterations.isPresent()) {
int i = iterations.get();
Preconditions.checkState(i > 0 || i == -1, "number of iterations must be positive or" + " -1 (for running container balancer infinitely).");
builder.setIterations(i);
}
if (maxSizeEnteringTargetInGB.isPresent()) {
long mset = maxSizeEnteringTargetInGB.get();
Preconditions.checkState(mset > 0, "maxSizeEnteringTargetInGB must be positive.");
builder.setMaxSizeEnteringTargetInGB(mset);
}
if (maxSizeLeavingSourceInGB.isPresent()) {
long msls = maxSizeLeavingSourceInGB.get();
Preconditions.checkState(msls > 0, "maxSizeLeavingSourceInGB must be positive.");
builder.setMaxSizeLeavingSourceInGB(msls);
}
StartContainerBalancerRequestProto request = builder.build();
StartContainerBalancerResponseProto response = submitRequest(Type.StartContainerBalancer, builder1 -> builder1.setStartContainerBalancerRequest(request)).getStartContainerBalancerResponse();
return response.getStart();
}
Aggregations