Skip to content
Merged
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 @@ -76,4 +76,9 @@ public HddsProtos.DiskBalancerOpType getOpType() {
public DiskBalancerConfiguration getDiskBalancerConfiguration() {
return diskBalancerConfiguration;
}

@Override
public String toString() {
return getType() + ": opType=" + opType + ", configuration=" + diskBalancerConfiguration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public List<DatanodeAdminError> startDiskBalancer(
List<DatanodeAdminError> errors = new ArrayList<>();
for (DatanodeDetails dn : dns) {
try {
if (nodeManager.getNodeStatus(dn).isHealthy()) {
if (!nodeManager.getNodeStatus(dn).isHealthy()) {
errors.add(new DatanodeAdminError(dn.getHostName(),
"Datanode not in healthy state"));
continue;
Expand All @@ -169,6 +169,7 @@ public List<DatanodeAdminError> startDiskBalancer(
HddsProtos.DiskBalancerOpType.START, updateConf);
sendCommand(dn, command);
} catch (Exception e) {
LOG.info("Caught an error for {}", dn);
errors.add(new DatanodeAdminError(dn.getHostName(), e.getMessage()));
}
}
Expand Down Expand Up @@ -355,6 +356,7 @@ private void sendCommand(DatanodeDetails dn, DiskBalancerCommand command) {
" since not leader SCM.", dn.getUuidString());
return;
}
LOG.info("Sending {} to Datanode {}", command, dn);
scmNodeEventPublisher.fireEvent(SCMEvents.DATANODE_COMMAND,
new CommandForDatanode<>(dn.getUuid(), command));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,23 +1336,26 @@ public DatanodeDiskBalancerOpResponseProto getDatanodeDiskBalancerOp(
DatanodeDiskBalancerOpRequestProto request)
throws IOException {
List<DatanodeAdminError> errors;
HddsProtos.DiskBalancerConfigurationProto conf = request.getConf();
switch (request.getOpType()) {
case START:
errors = impl.startDiskBalancer(
Optional.of(request.getConf().getThreshold()),
Optional.of(request.getConf().getDiskBandwidthInMB()),
Optional.of(request.getConf().getParallelThread()),
Optional.of(request.getHostsList()));
conf.hasThreshold() ? Optional.of(conf.getThreshold()) : Optional.empty(),
conf.hasDiskBandwidthInMB() ? Optional.of(conf.getDiskBandwidthInMB()) : Optional.empty(),
conf.hasParallelThread() ? Optional.of(conf.getParallelThread()) : Optional.empty(),
request.getHostsList().isEmpty() ? Optional.empty() : Optional.of(request.getHostsList()));
break;
case UPDATE:

errors = impl.updateDiskBalancerConfiguration(
Optional.of(request.getConf().getThreshold()),
Optional.of(request.getConf().getDiskBandwidthInMB()),
Optional.of(request.getConf().getParallelThread()),
Optional.of(request.getHostsList()));
conf.hasThreshold() ? Optional.of(conf.getThreshold()) : Optional.empty(),
conf.hasDiskBandwidthInMB() ? Optional.of(conf.getDiskBandwidthInMB()) : Optional.empty(),
conf.hasParallelThread() ? Optional.of(conf.getParallelThread()) : Optional.empty(),
request.getHostsList().isEmpty() ? Optional.empty() : Optional.of(request.getHostsList()));
break;
case STOP:
errors = impl.stopDiskBalancer(Optional.of(request.getHostsList()));
errors = impl.stopDiskBalancer(
request.getHostsList().isEmpty() ? Optional.empty() : Optional.of(request.getHostsList()));
break;
default:
errors = new ArrayList<>();
Expand Down