From 9b4c3756ede585c001dc0dbba1135891afa3732c Mon Sep 17 00:00:00 2001 From: fjy Date: Sun, 15 Sep 2013 10:27:37 -0700 Subject: [PATCH] fix exception catching logic of moving segments --- .../server/master/DruidMasterBalancer.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/io/druid/server/master/DruidMasterBalancer.java b/server/src/main/java/io/druid/server/master/DruidMasterBalancer.java index 19452df4fad..28c966b4162 100644 --- a/server/src/main/java/io/druid/server/master/DruidMasterBalancer.java +++ b/server/src/main/java/io/druid/server/master/DruidMasterBalancer.java @@ -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 movingSegments = currentlyMovingSegments.get(toServer.getTier()); + if (movingSegments != null) { + movingSegments.remove(segmentName); + } + } + }; master.moveSegment( fromServerName, toServerName, segmentToMove.getIdentifier(), - new LoadPeonCallback() - { - @Override - protected void execute() - { - Map 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);