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