Skip to content

Commit

Permalink
Merge branch 'ecchronos-1.2' into ecchronos-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
masokol committed Aug 25, 2023
2 parents 960356b + c070713 commit 7a88eb4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557
* Fix priority calculation for local queue - Issue #546
* Skip unnecessary reads from repair history - Issue #548
* Fix repair job priority - Issue #515
Expand Down Expand Up @@ -128,6 +129,7 @@

### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557
* Fix priority calculation for local queue - Issue #546
* Skip unnecessary reads from repair history - Issue #548
* Fix repair job priority - Issue #515
Expand All @@ -140,6 +142,7 @@

#### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557
* Fix priority calculation for local queue - Issue #546
* Skip unnecessary reads from repair history - Issue #548
* Fix repair job priority - Issue #515
Expand Down Expand Up @@ -179,6 +182,7 @@

## Version 1.0.8 (Not yet released)

* Fix logging fault reporter raising duplicate alarm - Issue #557
* Fix priority calculation for local queue - Issue #546
* Skip unnecessary reads from repair history - Issue #548
* Fix repair job priority - Issue #515
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public class LoggingFaultReporter implements RepairFaultReporter
@Override
public void raise(FaultCode faultCode, Map<String, Object> data)
{
alarms.put(data.hashCode(), faultCode);
LOG.error("Raising alarm: {} - {}", faultCode, data);
FaultCode oldCode = alarms.put(data.hashCode(), faultCode);
if (oldCode == null || (oldCode == FaultCode.REPAIR_WARNING && faultCode == FaultCode.REPAIR_ERROR))
{
LOG.error("Raising alarm: {} - {}", faultCode, data);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,38 @@ public class TestLoggingFaultReporter
{
LoggingFaultReporter loggingFaultReporter = new LoggingFaultReporter();

@Test
public void testAlarmIncreasingSeverity()
{
Map<String, Object> data = new HashMap<>();
data.put(RepairFaultReporter.FAULT_KEYSPACE, "keyspace");
data.put(RepairFaultReporter.FAULT_TABLE, "table");

loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_WARNING, data);
assertThat(loggingFaultReporter.alarms.size()).isEqualTo(1);
assertThat(loggingFaultReporter.alarms).containsValue(RepairFaultReporter.FaultCode.REPAIR_WARNING);

loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_ERROR, data);
assertThat(loggingFaultReporter.alarms.size()).isEqualTo(1);
assertThat(loggingFaultReporter.alarms).containsValue(RepairFaultReporter.FaultCode.REPAIR_ERROR);
}

@Test
public void testRaiseMultipleTimes()
{
Map<String, Object> data = new HashMap<>();
data.put(RepairFaultReporter.FAULT_KEYSPACE, "keyspace");
data.put(RepairFaultReporter.FAULT_TABLE, "table");

loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_WARNING, data);
loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_WARNING, data);
loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_WARNING, data);
loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_WARNING, data);
loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_WARNING, data);
assertThat(loggingFaultReporter.alarms.size()).isEqualTo(1);
assertThat(loggingFaultReporter.alarms).containsValue(RepairFaultReporter.FaultCode.REPAIR_WARNING);
}

@Test
public void testCeaseAlarms()
{
Expand Down Expand Up @@ -59,6 +91,4 @@ public void testCeaseMultipleAlarms()
loggingFaultReporter.cease(RepairFaultReporter.FaultCode.REPAIR_ERROR, data);
assertThat(loggingFaultReporter.alarms.size()).isEqualTo(0);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,19 @@ enum FaultCode
REPAIR_ERROR
}

/**
* This method might be called multiple times with the same parameters,
* implementations of this method should control whether the alarm should be raised.
* @param faultCode The fault code
* @param data The data containing keyspace and table
*/
void raise(FaultCode faultCode, Map<String, Object> data);

/**
* This method might be called multiple times with the same parameters,
* implementations of this method should control whether the alarm should be cleared.
* @param faultCode The fault code
* @param data The data containing keyspace and table
*/
void cease(FaultCode faultCode, Map<String, Object> data);
}

0 comments on commit 7a88eb4

Please sign in to comment.