|
@@ -121,17 +121,23 @@ public class DiskBalancer {
|
|
*/
|
|
*/
|
|
public void shutdown() {
|
|
public void shutdown() {
|
|
lock.lock();
|
|
lock.lock();
|
|
|
|
+ boolean needShutdown = false;
|
|
try {
|
|
try {
|
|
this.isDiskBalancerEnabled = false;
|
|
this.isDiskBalancerEnabled = false;
|
|
this.currentResult = Result.NO_PLAN;
|
|
this.currentResult = Result.NO_PLAN;
|
|
if ((this.future != null) && (!this.future.isDone())) {
|
|
if ((this.future != null) && (!this.future.isDone())) {
|
|
this.currentResult = Result.PLAN_CANCELLED;
|
|
this.currentResult = Result.PLAN_CANCELLED;
|
|
this.blockMover.setExitFlag();
|
|
this.blockMover.setExitFlag();
|
|
- shutdownExecutor();
|
|
|
|
|
|
+ scheduler.shutdown();
|
|
|
|
+ needShutdown = true;
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
lock.unlock();
|
|
lock.unlock();
|
|
}
|
|
}
|
|
|
|
+ // no need to hold lock while shutting down executor.
|
|
|
|
+ if (needShutdown) {
|
|
|
|
+ shutdownExecutor();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -139,7 +145,6 @@ public class DiskBalancer {
|
|
*/
|
|
*/
|
|
private void shutdownExecutor() {
|
|
private void shutdownExecutor() {
|
|
final int secondsTowait = 10;
|
|
final int secondsTowait = 10;
|
|
- scheduler.shutdown();
|
|
|
|
try {
|
|
try {
|
|
if (!scheduler.awaitTermination(secondsTowait, TimeUnit.SECONDS)) {
|
|
if (!scheduler.awaitTermination(secondsTowait, TimeUnit.SECONDS)) {
|
|
scheduler.shutdownNow();
|
|
scheduler.shutdownNow();
|
|
@@ -228,6 +233,7 @@ public class DiskBalancer {
|
|
*/
|
|
*/
|
|
public void cancelPlan(String planID) throws DiskBalancerException {
|
|
public void cancelPlan(String planID) throws DiskBalancerException {
|
|
lock.lock();
|
|
lock.lock();
|
|
|
|
+ boolean needShutdown = false;
|
|
try {
|
|
try {
|
|
checkDiskBalancerEnabled();
|
|
checkDiskBalancerEnabled();
|
|
if (this.planID == null ||
|
|
if (this.planID == null ||
|
|
@@ -239,13 +245,18 @@ public class DiskBalancer {
|
|
DiskBalancerException.Result.NO_SUCH_PLAN);
|
|
DiskBalancerException.Result.NO_SUCH_PLAN);
|
|
}
|
|
}
|
|
if (!this.future.isDone()) {
|
|
if (!this.future.isDone()) {
|
|
- this.blockMover.setExitFlag();
|
|
|
|
- shutdownExecutor();
|
|
|
|
this.currentResult = Result.PLAN_CANCELLED;
|
|
this.currentResult = Result.PLAN_CANCELLED;
|
|
|
|
+ this.blockMover.setExitFlag();
|
|
|
|
+ scheduler.shutdown();
|
|
|
|
+ needShutdown = true;
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
lock.unlock();
|
|
lock.unlock();
|
|
}
|
|
}
|
|
|
|
+ // no need to hold lock while shutting down executor.
|
|
|
|
+ if (needShutdown) {
|
|
|
|
+ shutdownExecutor();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|