From edba6f52d21c36dc761e5b262b51ee72e370f324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Hegerfors?= Date: Mon, 23 Feb 2015 12:24:10 +0100 Subject: [PATCH] Update last message in repair run with info about failing to connect to a host --- .../spotify/reaper/service/SegmentRunner.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/spotify/reaper/service/SegmentRunner.java b/src/main/java/com/spotify/reaper/service/SegmentRunner.java index cddf895ff..67db9ccfb 100644 --- a/src/main/java/com/spotify/reaper/service/SegmentRunner.java +++ b/src/main/java/com/spotify/reaper/service/SegmentRunner.java @@ -102,7 +102,7 @@ private void runRepair(Collection potentialCoordinators, long timeoutMil RepairUnit repairUnit = context.storage.getRepairUnit(segment.getRepairUnitId()).get(); String keyspace = repairUnit.getKeyspaceName(); - if (!canRepair(segment, keyspace, coordinator)) { + if (!canRepair(segment, keyspace, coordinator, repairRun)) { postpone(segment); return; } @@ -152,8 +152,8 @@ private void runRepair(Collection potentialCoordinators, long timeoutMil } } - boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator) - throws ReaperException { + boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator, + RepairRun repairRun) { Collection allHosts = coordinator.tokenRangeToEndpoint(keyspace, segment.getTokenRange()); for (String hostName : allHosts) { @@ -166,8 +166,7 @@ boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator) + "compactions (> {}) on host \"{}\"", segmentId, MAX_PENDING_COMPACTIONS, hostProxy.getHost()); String msg = String.format("Postponed due to pending compactions (%d)", - pendingCompactions); - RepairRun repairRun = context.storage.getRepairRun(segment.getRunId()).get(); + pendingCompactions); context.storage.updateRepairRun(repairRun.with().lastEvent(msg).build(repairRun.getId())); return false; } @@ -175,10 +174,15 @@ boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator) LOG.warn("SegmentRunner declined to repair segment {} because one of the hosts ({}) was " + "already involved in a repair", segmentId, hostProxy.getHost()); String msg = String.format("Postponed due to affected hosts already doing repairs"); - RepairRun repairRun = context.storage.getRepairRun(segment.getRunId()).get(); context.storage.updateRepairRun(repairRun.with().lastEvent(msg).build(repairRun.getId())); return false; } + } catch (ReaperException e) { + LOG.warn("SegmentRunner declined to repair segment {} because one of the hosts ({}) could " + + "not be connected with", segmentId, hostName); + String msg = String.format("Postponed due to inability to connect host %s", hostName); + context.storage.updateRepairRun(repairRun.with().lastEvent(msg).build(repairRun.getId())); + return false; } } LOG.info("It is ok to repair segment '{}' om repair run with id '{}'",