@Test public void testThatWarningAlarmIsSentAndCeasedExternalRepair() { long daysSinceLastRepair = 2; long start = System.currentTimeMillis(); long lastRepaired = start - TimeUnit.DAYS.toMillis(daysSinceLastRepair); Map<String, Object> expectedData = new HashMap<>(); expectedData.put(RepairFaultReporter.FAULT_KEYSPACE, keyspaceName); expectedData.put(RepairFaultReporter.FAULT_TABLE, tableName); doReturn(lastRepaired).when(myRepairStateSnapshot).lastRepairedAt(); doReturn(true).when(myRepairStateSnapshot).canRepair(); myClock.setTime(start); assertThat(myRepairJob.runnable()).isTrue(); verify(myFaultReporter).raise(eq(RepairFaultReporter.FaultCode.REPAIR_WARNING), eq(expectedData)); lastRepaired = start; start = System.currentTimeMillis(); doReturn(lastRepaired).when(myRepairStateSnapshot).lastRepairedAt(); doReturn(false).when(myRepairStateSnapshot).canRepair(); myClock.setTime(start); assertThat(myRepairJob.runnable()).isFalse(); verify(myFaultReporter).cease(eq(RepairFaultReporter.FaultCode.REPAIR_WARNING), eq(expectedData)); }
@Override public boolean runnable() { if (super.runnable()) { try { myRepairState.update(); } catch (Exception e) { LOG.warn("Unable to check repair history, {}", this, e); } } RepairStateSnapshot repairStateSnapshot = myRepairState.getSnapshot(); long lastRepaired = repairStateSnapshot.lastRepairedAt(); if (lastRepaired != VnodeRepairState.UNREPAIRED) { sendOrCeaseAlarm(lastRepaired); } return repairStateSnapshot.canRepair() && super.runnable(); }
TableRepairJob extends ScheduledJob { @Override public boolean runnable() { if (super.runnable()) { try { myRepairState.update(); } catch (Exception e) { LOG.warn("Unable to check repair history, {}", this, e); } } RepairStateSnapshot repairStateSnapshot = myRepairState.getSnapshot(); long lastRepaired = repairStateSnapshot.lastRepairedAt(); if (lastRepaired != VnodeRepairState.UNREPAIRED) { sendOrCeaseAlarm(lastRepaired); } return repairStateSnapshot.canRepair() && super.runnable(); } }
TableRepairJob extends ScheduledJob { @Override public boolean runnable() { if (super.runnable()) { try { myRepairState.update(); } catch (Exception e) { LOG.warn("Unable to check repair history, {}", this, e); } } RepairStateSnapshot repairStateSnapshot = myRepairState.getSnapshot(); long lastRepaired = repairStateSnapshot.lastRepairedAt(); if (lastRepaired != VnodeRepairState.UNREPAIRED) { sendOrCeaseAlarm(lastRepaired); } return repairStateSnapshot.canRepair() && super.runnable(); } TableRepairJob(Builder builder); }
TableRepairJob extends ScheduledJob { @Override public boolean runnable() { if (super.runnable()) { try { myRepairState.update(); } catch (Exception e) { LOG.warn("Unable to check repair history, {}", this, e); } } RepairStateSnapshot repairStateSnapshot = myRepairState.getSnapshot(); long lastRepaired = repairStateSnapshot.lastRepairedAt(); if (lastRepaired != VnodeRepairState.UNREPAIRED) { sendOrCeaseAlarm(lastRepaired); } return repairStateSnapshot.canRepair() && super.runnable(); } TableRepairJob(Builder builder); TableReference getTableReference(); RepairConfiguration getRepairConfiguration(); @Override Iterator<ScheduledTask> iterator(); @Override void postExecute(boolean successful); @Override long getLastSuccessfulRun(); @Override boolean runnable(); @Override String toString(); }
TableRepairJob extends ScheduledJob { @Override public boolean runnable() { if (super.runnable()) { try { myRepairState.update(); } catch (Exception e) { LOG.warn("Unable to check repair history, {}", this, e); } } RepairStateSnapshot repairStateSnapshot = myRepairState.getSnapshot(); long lastRepaired = repairStateSnapshot.lastRepairedAt(); if (lastRepaired != VnodeRepairState.UNREPAIRED) { sendOrCeaseAlarm(lastRepaired); } return repairStateSnapshot.canRepair() && super.runnable(); } TableRepairJob(Builder builder); TableReference getTableReference(); RepairConfiguration getRepairConfiguration(); @Override Iterator<ScheduledTask> iterator(); @Override void postExecute(boolean successful); @Override long getLastSuccessfulRun(); @Override boolean runnable(); @Override String toString();  }