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 Sep 12, 2023
2 parents b45bbb0 + d22287d commit 91f0b41
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 2 deletions.
17 changes: 17 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
* Support configuring backoff for failed jobs - Issue #475
* Dropping keyspaces does not clean up schedules - Issue #469

### Merged from 1.2

* Fix calculation of tokens per repair - Issue #570

### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557
Expand All @@ -27,6 +31,10 @@

## Version 4.0.6 (Not yet released)

### Merged from 1.2

* Fix calculation of tokens per repair - Issue #570

### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557
Expand Down Expand Up @@ -88,6 +96,10 @@

## Version 3.0.1 (Not yet released)

### Merged from 1.2

* Fix calculation of tokens per repair - Issue #570

### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557
Expand All @@ -111,6 +123,10 @@

## Version 2.0.7 (Not yet released)

### Merged from 1.2

* Fix calculation of tokens per repair - Issue #570

### Merged from 1.0

* Fix logging fault reporter raising duplicate alarm - Issue #557
Expand Down Expand Up @@ -234,6 +250,7 @@

## Version 1.2.0 (Not yet released)

* Fix calculation of tokens per repair - Issue #570
* Repairs not scheduled when statistics disabled - Issue #175

### Merged from 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,11 @@ private BigInteger getTokensPerRepair(final VnodeRepairStates vnodeRepairStates)
BigInteger targetSizeInBytes = BigInteger.valueOf(
getRepairConfiguration().getTargetRepairSizeInBytes());

BigInteger targetRepairs = tableSizeInBytes.divide(targetSizeInBytes);
tokensPerRepair = fullRangeSize.divide(targetRepairs);
if (tableSizeInBytes.compareTo(targetSizeInBytes) > 0)
{
BigInteger targetRepairs = tableSizeInBytes.divide(targetSizeInBytes);
tokensPerRepair = fullRangeSize.divide(targetRepairs);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class TestTableRepairJob
private static final long RUN_INTERVAL_IN_DAYS = 1;
private static final long GC_GRACE_DAYS = 10;

private static final long ONE_MB_IN_BYTES = 1 * 1024 * 1024;
private static final long HUNDRED_MB_IN_BYTES = 100 * 1024 * 1024;
private static final long THOUSAND_MB_IN_BYTES = 1000 * 1024 * 1024;

Expand Down Expand Up @@ -385,6 +386,108 @@ public void testIteratorWithTargetSize()
}
}

@Test
public void testIteratorWithTargetSizeBiggerThanTableSize()
{
LongTokenRange tokenRange1 = new LongTokenRange(0, 10);
LongTokenRange tokenRange2 = new LongTokenRange(10, 20);
LongTokenRange tokenRange3 = new LongTokenRange(20, 30);
List<LongTokenRange> expectedTokenRanges = Arrays.asList(
tokenRange1,
tokenRange2,
tokenRange3
);
ImmutableSet<DriverNode> replicas = ImmutableSet.of(mock(DriverNode.class), mock(DriverNode.class));
ImmutableList<LongTokenRange> vnodes = ImmutableList.of(tokenRange1, tokenRange2, tokenRange3);

VnodeRepairStates vnodeRepairStates = VnodeRepairStatesImpl.newBuilder(
ImmutableList.of(
new VnodeRepairState(tokenRange1, replicas, 1234L),
new VnodeRepairState(tokenRange2, replicas, 1234L),
new VnodeRepairState(tokenRange3, replicas, 1234L))).build();
ReplicaRepairGroup replicaRepairGroup = new ReplicaRepairGroup(replicas, vnodes, System.currentTimeMillis());

RepairStateSnapshot repairStateSnapshot = RepairStateSnapshot.newBuilder()
.withReplicaRepairGroups(Collections.singletonList(replicaRepairGroup))
.withLastCompletedAt(1234L)
.withVnodeRepairStates(vnodeRepairStates)
.build();
when(myRepairState.getSnapshot()).thenReturn(repairStateSnapshot);
// 100 MB target size, 1 MB in table
when(myTableStorageStates.getDataSize(eq(myTableReference))).thenReturn(ONE_MB_IN_BYTES);

Iterator<ScheduledTask> iterator = myRepairJob.iterator();

ScheduledTask task = iterator.next();
assertThat(task).isInstanceOf(RepairGroup.class);
Collection<RepairTask> repairTasks = ((RepairGroup) task).getRepairTasks();

assertThat(repairTasks).hasSize(expectedTokenRanges.size());

Iterator<RepairTask> repairTaskIterator = repairTasks.iterator();
for (LongTokenRange expectedRange : expectedTokenRanges)
{
assertThat(repairTaskIterator.hasNext()).isTrue();
VnodeRepairTask repairTask = (VnodeRepairTask) repairTaskIterator.next();
assertThat(repairTask.getReplicas()).containsExactlyInAnyOrderElementsOf(replicas);
assertThat(repairTask.getRepairConfiguration()).isEqualTo(myRepairConfiguration);
assertThat(repairTask.getTableReference()).isEqualTo(myTableReference);

assertThat(repairTask.getTokenRanges()).containsExactly(expectedRange);
}
}

@Test
public void testIteratorWithTargetSizeSameAsTableSize()
{
LongTokenRange tokenRange1 = new LongTokenRange(0, 10);
LongTokenRange tokenRange2 = new LongTokenRange(10, 20);
LongTokenRange tokenRange3 = new LongTokenRange(20, 30);
List<LongTokenRange> expectedTokenRanges = Arrays.asList(
tokenRange1,
tokenRange2,
tokenRange3
);
ImmutableSet<DriverNode> replicas = ImmutableSet.of(mock(DriverNode.class), mock(DriverNode.class));
ImmutableList<LongTokenRange> vnodes = ImmutableList.of(tokenRange1, tokenRange2, tokenRange3);

VnodeRepairStates vnodeRepairStates = VnodeRepairStatesImpl.newBuilder(
ImmutableList.of(
new VnodeRepairState(tokenRange1, replicas, 1234L),
new VnodeRepairState(tokenRange2, replicas, 1234L),
new VnodeRepairState(tokenRange3, replicas, 1234L))).build();
ReplicaRepairGroup replicaRepairGroup = new ReplicaRepairGroup(replicas, vnodes, System.currentTimeMillis());

RepairStateSnapshot repairStateSnapshot = RepairStateSnapshot.newBuilder()
.withReplicaRepairGroups(Collections.singletonList(replicaRepairGroup))
.withLastCompletedAt(1234L)
.withVnodeRepairStates(vnodeRepairStates)
.build();
when(myRepairState.getSnapshot()).thenReturn(repairStateSnapshot);
// 100 MB target size, 100 MB in table
when(myTableStorageStates.getDataSize(eq(myTableReference))).thenReturn(HUNDRED_MB_IN_BYTES);

Iterator<ScheduledTask> iterator = myRepairJob.iterator();

ScheduledTask task = iterator.next();
assertThat(task).isInstanceOf(RepairGroup.class);
Collection<RepairTask> repairTasks = ((RepairGroup) task).getRepairTasks();

assertThat(repairTasks).hasSize(expectedTokenRanges.size());

Iterator<RepairTask> repairTaskIterator = repairTasks.iterator();
for (LongTokenRange expectedRange : expectedTokenRanges)
{
assertThat(repairTaskIterator.hasNext()).isTrue();
VnodeRepairTask repairTask = (VnodeRepairTask) repairTaskIterator.next();
assertThat(repairTask.getReplicas()).containsExactlyInAnyOrderElementsOf(replicas);
assertThat(repairTask.getRepairConfiguration()).isEqualTo(myRepairConfiguration);
assertThat(repairTask.getTableReference()).isEqualTo(myTableReference);

assertThat(repairTask.getTokenRanges()).containsExactly(expectedRange);
}
}

@Test
public void testStatusCompleted()
{
Expand Down

0 comments on commit 91f0b41

Please sign in to comment.