Skip to content

Commit

Permalink
Merge branch 'ecchronos-1.1' into ecchronos-1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
masokol committed Aug 18, 2023
2 parents 0b83f7f + 495e6b8 commit 693781b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Merged from 1.0

* Fix priority calculation for local queue - Issue #546
* Skip unnecessary reads from repair history - Issue #548
* Fix repair job priority - Issue #515
* Fix malformed IPv6 for JMX - Issue #306
Expand All @@ -17,6 +18,7 @@

#### Merged from 1.0

* Fix priority calculation for local queue - Issue #546
* Skip unnecessary reads from repair history - Issue #548
* Fix repair job priority - Issue #515
* Fix malformed IPv6 for JMX - Issue #306
Expand Down Expand Up @@ -55,6 +57,7 @@

## Version 1.0.8 (Not yet released)

* Fix priority calculation for local queue - Issue #546
* Skip unnecessary reads from repair history - Issue #548
* Fix repair job priority - Issue #515
* Fix malformed IPv6 for JMX - Issue #306
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ private TableRepairJob getRepairJob(TableReference tableReference, RepairConfigu
.withTableStorageStates(myTableStorageStates)
.withRepairPolices(myRepairPolicies)
.build();

job.runnable();
job.refreshState();

return job;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public Iterator<ScheduledTask> iterator()

for (ReplicaRepairGroup replicaRepairGroup : repairStateSnapshot.getRepairGroups())
{
taskList.add(new RepairGroup(getRealPriority(), myTableReference, myRepairConfiguration,
taskList.add(new RepairGroup(getRealPriority(replicaRepairGroup.getLastCompletedAt()),
myTableReference, myRepairConfiguration,
replicaRepairGroup, myJmxProxyFactory, myTableRepairMetrics,
myRepairLockType.getLockFactory(),
new RepairLockFactoryImpl(),
Expand Down Expand Up @@ -194,14 +195,6 @@ else if (msSinceLastRepair >= myRepairConfiguration.getRepairWarningTimeInMs())
@Override
public boolean runnable()
{
try
{
myRepairState.update();
} catch (Exception e)
{
LOG.warn("Unable to check repair history, {}", this, e);
}

RepairStateSnapshot repairStateSnapshot = myRepairState.getSnapshot();

long lastRepaired = repairStateSnapshot.lastRepairedAt();
Expand All @@ -214,6 +207,19 @@ public boolean runnable()
return repairStateSnapshot.canRepair() && super.runnable();
}

@Override
public void refreshState()
{
try
{
myRepairState.update();
}
catch (Exception e)
{
LOG.warn("Unable to check repair history, {}", this, e);
}
}

/**
* Calculate real priority based on available tasks.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ protected void postExecute(boolean successful)
}
}

/**
* This method is called every time the scheduler creates a list of jobs to run.
* Use this if you need to do some updates before priority is calculated.
* Default is noop.
*/
protected void refreshState()
{
// NOOP by default
}

/**
* Set the job to be runnable again after the given delay has elapsed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ int size()
@Override
public synchronized Iterator<ScheduledJob> iterator()
{
myJobQueues.values().forEach(q -> q.forEach(ScheduledJob::refreshState));
Iterator<ScheduledJob> baseIterator = new ManyToOneIterator<>(myJobQueues.values(), myComparator);

return new RunnableJobIterator(baseIterator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ public void testPrevalidateNotRepairable()

assertThat(myRepairJob.runnable()).isFalse();

verify(myRepairState, times(1)).update();
verify(myRepairStateSnapshot, times(1)).canRepair();
}

Expand All @@ -196,7 +195,6 @@ public void testPrevalidateNeedRepair()
mockRepairGroup(0L);
assertThat(myRepairJob.runnable()).isTrue();

verify(myRepairState, times(1)).update();
verify(myRepairStateSnapshot, times(2)).canRepair();
}

Expand All @@ -209,7 +207,6 @@ public void testPrevalidateNotRepairableThenRepairable()
assertThat(myRepairJob.runnable()).isFalse();
assertThat(myRepairJob.runnable()).isTrue();

verify(myRepairState, times(2)).update();
verify(myRepairStateSnapshot, times(3)).canRepair();
}

Expand Down

0 comments on commit 693781b

Please sign in to comment.