fix exception catching logic of moving segments

This commit is contained in:
fjy 2013-09-15 10:27:37 -07:00
parent 8b480e55db
commit 9b4c3756ed
1 changed files with 18 additions and 12 deletions

View File

@ -156,27 +156,33 @@ public class DruidMasterBalancer implements DruidMasterHelper
(toServer.getSegment(segmentName) == null) &&
new ServerHolder(toServer, toPeon).getAvailableSize() > segmentToMove.getSize()) {
log.info("Moving [%s] from [%s] to [%s]", segmentName, fromServerName, toServerName);
LoadPeonCallback callback = null;
try {
currentlyMovingSegments.get(toServer.getTier()).put(segmentName, segment);
callback = new LoadPeonCallback()
{
@Override
protected void execute()
{
Map<String, BalancerSegmentHolder> movingSegments = currentlyMovingSegments.get(toServer.getTier());
if (movingSegments != null) {
movingSegments.remove(segmentName);
}
}
};
master.moveSegment(
fromServerName,
toServerName,
segmentToMove.getIdentifier(),
new LoadPeonCallback()
{
@Override
protected void execute()
{
Map<String, BalancerSegmentHolder> movingSegments = currentlyMovingSegments.get(toServer.getTier());
if (movingSegments != null) {
movingSegments.remove(segmentName);
}
}
}
callback
);
currentlyMovingSegments.get(toServer.getTier()).put(segmentName, segment);
}
catch (Exception e) {
log.makeAlert(e, String.format("[%s] : Moving exception", segmentName)).emit();
if (callback != null) {
callback.execute();
}
}
} else {
currentlyMovingSegments.get(toServer.getTier()).remove(segmentName);