Skip to content

Commit

Permalink
Update last message in repair run with info about failing to connect …
Browse files Browse the repository at this point in the history
…to a host
  • Loading branch information
Bj0rnen committed Feb 23, 2015
1 parent 5d278bf commit edba6f5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/java/com/spotify/reaper/service/SegmentRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void runRepair(Collection<String> 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;
}
Expand Down Expand Up @@ -152,8 +152,8 @@ private void runRepair(Collection<String> potentialCoordinators, long timeoutMil
}
}

boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator)
throws ReaperException {
boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator,
RepairRun repairRun) {
Collection<String> allHosts =
coordinator.tokenRangeToEndpoint(keyspace, segment.getTokenRange());
for (String hostName : allHosts) {
Expand All @@ -166,19 +166,23 @@ 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;
}
if (hostProxy.isRepairRunning()) {
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 '{}'",
Expand Down

0 comments on commit edba6f5

Please sign in to comment.