Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use refresh state in incremental schedules #552

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,16 @@ public Iterator<ScheduledTask> iterator()
}

/**
* Decides if the job is runnable.
*
* @return true if enough time has passed and there is something to repair.
* Check if there's anything to repair, if not then just move the last run.
*/
@Override
public boolean runnable()
public void refreshState()
{
if (super.runnable())
boolean nothingToRepair = getProgress() >= 1.0;
if (nothingToRepair)
{
boolean nothingToRepair = getProgress() >= 1.0;
if (nothingToRepair)
{
myLastSuccessfulRun = System.currentTimeMillis();
return false;
}
return true;
myLastSuccessfulRun = System.currentTimeMillis();
}
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public void testRunnableNothingRepaired()
{
doReturn(0.0d).when(myCassandraMetrics).getPercentRepaired(myTableReference);
IncrementalRepairJob job = getIncrementalRepairJob();
job.refreshState();

assertThat(job).isNotNull();
assertThat(job.runnable()).isTrue();
Expand All @@ -228,6 +229,7 @@ public void testRunnableHalfRepaired()
{
doReturn(50.0d).when(myCassandraMetrics).getPercentRepaired(myTableReference);
IncrementalRepairJob job = getIncrementalRepairJob();
job.refreshState();

assertThat(job).isNotNull();
assertThat(job.runnable()).isTrue();
Expand All @@ -238,6 +240,7 @@ public void testRunnableEverythingRepaired()
{
doReturn(100.0d).when(myCassandraMetrics).getPercentRepaired(myTableReference);
IncrementalRepairJob job = getIncrementalRepairJob();
job.refreshState();

assertThat(job).isNotNull();
assertThat(job.runnable()).isFalse();
Expand All @@ -249,6 +252,7 @@ public void testRunnableIntervalNotYetPassed()
long lastRepairedAt = System.currentTimeMillis();
doReturn(lastRepairedAt).when(myCassandraMetrics).getMaxRepairedAt(myTableReference);
IncrementalRepairJob job = getIncrementalRepairJob();
job.refreshState();

assertThat(job).isNotNull();
assertThat(job.runnable()).isFalse();
Expand Down