Skip to content

Commit

Permalink
Merge branch 'ecchronos-4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
masokol committed Aug 25, 2023
2 parents 8b08051 + 4889e08 commit 06f1617
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@

### 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

## Version 4.0.6 (Not yet released)

### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557

## Version 4.0.5

### Merged from 1.0
Expand Down Expand Up @@ -83,6 +88,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 @@ -105,6 +111,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 @@ -229,6 +236,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 @@ -241,6 +249,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 @@ -280,6 +289,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 @@ -37,8 +37,11 @@ public final Map<Integer, FaultCode> getAlarms()
@Override
public final void raise(final FaultCode faultCode, final 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.getAlarms().size()).isEqualTo(1);
assertThat(loggingFaultReporter.getAlarms()).containsValue(RepairFaultReporter.FaultCode.REPAIR_WARNING);

loggingFaultReporter.raise(RepairFaultReporter.FaultCode.REPAIR_ERROR, data);
assertThat(loggingFaultReporter.getAlarms().size()).isEqualTo(1);
assertThat(loggingFaultReporter.getAlarms()).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.getAlarms().size()).isEqualTo(1);
assertThat(loggingFaultReporter.getAlarms()).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.getAlarms().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 06f1617

Please sign in to comment.