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 @@ -155,9 +155,11 @@ public boolean start(ContainerBalancerConfiguration balancerConfiguration) {
return false;
}

balancerRunning = true;
this.config = balancerConfiguration;
validateConfiguration(config);
if (!validateConfiguration(config)) {
return false;
}
balancerRunning = true;
LOG.info("Starting Container Balancer...{}", this);

//we should start a new balancer thread async
Expand Down Expand Up @@ -766,7 +768,7 @@ public void stop() {
LOG.info("Container Balancer stopped successfully.");
}

private void validateConfiguration(ContainerBalancerConfiguration conf) {
private boolean validateConfiguration(ContainerBalancerConfiguration conf) {
// maxSizeEnteringTarget and maxSizeLeavingSource should by default be
// greater than container size
long size = (long) ozoneConfiguration.getStorageSize(
Expand All @@ -776,10 +778,12 @@ private void validateConfiguration(ContainerBalancerConfiguration conf) {
if (conf.getMaxSizeEnteringTarget() <= size) {
LOG.info("MaxSizeEnteringTarget should be larger than " +
"ozone.scm.container.size");
return false;
}
if (conf.getMaxSizeLeavingSource() <= size) {
LOG.info("MaxSizeLeavingSource should be larger than " +
"ozone.scm.container.size");
return false;
}

// balancing interval should be greater than DUFactory refresh period
Expand All @@ -788,7 +792,9 @@ private void validateConfiguration(ContainerBalancerConfiguration conf) {
if (conf.getBalancingInterval().toMillis() <= balancingInterval) {
LOG.info("balancing.iteration.interval should be larger than " +
"hdds.datanode.du.refresh.period.");
return false;
}
return true;
}

public void setNodeManager(NodeManager nodeManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void setup() throws SCMException, NodeNotFoundException {
balancerConfiguration.setIdleIteration(1);
balancerConfiguration.setMaxDatanodesRatioToInvolvePerIteration(1.0d);
balancerConfiguration.setMaxSizeToMovePerIteration(50 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(5 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(50 * OzoneConsts.GB);
conf.setFromObject(balancerConfiguration);
GenericTestUtils.setLogLevel(ContainerBalancer.LOG, Level.DEBUG);

Expand Down Expand Up @@ -390,7 +390,7 @@ public void targetDatanodeShouldBeInServiceHealthy()
balancerConfiguration.setThreshold(0.1);
balancerConfiguration.setMaxDatanodesRatioToInvolvePerIteration(1.0d);
balancerConfiguration.setMaxSizeToMovePerIteration(50 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(5 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(50 * OzoneConsts.GB);
containerBalancer.start(balancerConfiguration);

// waiting for balance completed.
Expand All @@ -417,7 +417,7 @@ public void selectedContainerShouldNotAlreadyHaveBeenSelected() {
balancerConfiguration.setThreshold(0.1);
balancerConfiguration.setMaxDatanodesRatioToInvolvePerIteration(1.0d);
balancerConfiguration.setMaxSizeToMovePerIteration(50 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(5 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(50 * OzoneConsts.GB);

containerBalancer.start(balancerConfiguration);

Expand All @@ -443,7 +443,7 @@ public void balancerShouldNotSelectConfiguredExcludeContainers() {
balancerConfiguration.setThreshold(0.1);
balancerConfiguration.setMaxDatanodesRatioToInvolvePerIteration(1.0d);
balancerConfiguration.setMaxSizeToMovePerIteration(50 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(5 * OzoneConsts.GB);
balancerConfiguration.setMaxSizeEnteringTarget(50 * OzoneConsts.GB);
balancerConfiguration.setExcludeContainers("1, 4, 5");

containerBalancer.start(balancerConfiguration);
Expand Down Expand Up @@ -473,20 +473,9 @@ public void balancerShouldObeyMaxSizeEnteringTargetLimit() {

// no containers should be selected when the limit is zero
balancerConfiguration.setMaxSizeEnteringTarget(0);
containerBalancer.start(balancerConfiguration);
boolean startResult = containerBalancer.start(balancerConfiguration);

// waiting for balance completed.
// TODO: this is a temporary implementation for now
// modify this after balancer is fully completed
try {
Thread.sleep(500);
} catch (InterruptedException e) {}

containerBalancer.stop();
// balancer should have identified unbalanced nodes
Assert.assertFalse(containerBalancer.getUnBalancedNodes().isEmpty());
// no container should have been selected
Assert.assertTrue(containerBalancer.getSourceToTargetMap().isEmpty());
Assert.assertFalse(startResult);

// some containers should be selected when using default values
OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
Expand Down