diff --git a/CHANGES.md b/CHANGES.md index 46537b713..e21bee275 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ ### Merged from 1.0 +* Fix priority calculation for local queue - Issue #546 * Skip unnecessary reads from repair history - Issue #548 ## Version 4.0.4 @@ -58,6 +59,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 @@ -79,6 +81,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 @@ -202,6 +205,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 @@ -213,6 +217,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 @@ -251,6 +256,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 diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairSchedulerImpl.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairSchedulerImpl.java index eed585120..365639ab9 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairSchedulerImpl.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairSchedulerImpl.java @@ -221,8 +221,7 @@ private TableRepairJob getRepairJob(final TableReference tableReference, .withRepairPolices(myRepairPolicies) .withRepairHistory(myRepairHistory) .build(); - - job.runnable(); + job.refreshState(); return job; } diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TableRepairJob.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TableRepairJob.java index 830f3b386..7f852487e 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TableRepairJob.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TableRepairJob.java @@ -202,7 +202,7 @@ public Iterator iterator() .withRepairHistory(myRepairHistory) .withJobId(getId()); - taskList.add(builder.build(getRealPriority())); + taskList.add(builder.build(getRealPriority(replicaRepairGroup.getLastCompletedAt()))); } return taskList.iterator(); @@ -265,6 +265,15 @@ public long getRunOffset() */ @Override public boolean runnable() + { + return myRepairState.getSnapshot().canRepair() && super.runnable(); + } + + /** + * Refresh the repair state. + */ + @Override + public void refreshState() { try { @@ -274,8 +283,6 @@ public boolean runnable() { LOG.warn("Unable to check repair history, {}", this, e); } - - return myRepairState.getSnapshot().canRepair() && super.runnable(); } /** diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJob.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJob.java index c84f15a4b..f989f3b3d 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJob.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJob.java @@ -78,6 +78,16 @@ protected void finishJob() // Do nothing } + /** + * 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. * diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJobQueue.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJobQueue.java index 2f311e377..2186f3ee3 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJobQueue.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/scheduling/ScheduledJobQueue.java @@ -118,6 +118,7 @@ final int size() @Override public final synchronized Iterator iterator() { + myJobQueues.values().forEach(q -> q.forEach(ScheduledJob::refreshState)); Iterator baseIterator = new ManyToOneIterator<>(myJobQueues.values(), myComparator); return new RunnableJobIterator(baseIterator); diff --git a/core/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TestTableRepairJob.java b/core/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TestTableRepairJob.java index 89e0afcae..3914e24e0 100644 --- a/core/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TestTableRepairJob.java +++ b/core/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/repair/TestTableRepairJob.java @@ -161,7 +161,6 @@ public void testPrevalidateNotRepairable() assertThat(myRepairJob.runnable()).isFalse(); - verify(myRepairState, times(1)).update(); verify(myRepairStateSnapshot, times(1)).canRepair(); } @@ -173,7 +172,6 @@ public void testPrevalidateNeedRepair() mockRepairGroup(0L); assertThat(myRepairJob.runnable()).isTrue(); - verify(myRepairState, times(1)).update(); verify(myRepairStateSnapshot, times(2)).canRepair(); } @@ -186,7 +184,6 @@ public void testPrevalidateNotRepairableThenRepairable() assertThat(myRepairJob.runnable()).isFalse(); assertThat(myRepairJob.runnable()).isTrue(); - verify(myRepairState, times(2)).update(); verify(myRepairStateSnapshot, times(3)).canRepair(); }