HBASE-23556: Minor ChoreService Cleanup (#927)
This commit is contained in:
parent
c39339c004
commit
72ab1c1193
|
@ -173,9 +173,7 @@ public class ChoreService implements ChoreServicer {
|
|||
* @param chore The Chore to be rescheduled. If the chore is not scheduled with this ChoreService
|
||||
* yet then this call is equivalent to a call to scheduleChore.
|
||||
*/
|
||||
private synchronized void rescheduleChore(ScheduledChore chore) {
|
||||
if (chore == null) return;
|
||||
|
||||
private void rescheduleChore(ScheduledChore chore) {
|
||||
if (scheduledChores.containsKey(chore)) {
|
||||
ScheduledFuture<?> future = scheduledChores.get(chore);
|
||||
future.cancel(false);
|
||||
|
@ -216,12 +214,11 @@ public class ChoreService implements ChoreServicer {
|
|||
@InterfaceAudience.Private
|
||||
@Override
|
||||
public synchronized boolean triggerNow(ScheduledChore chore) {
|
||||
if (chore == null) {
|
||||
return false;
|
||||
} else {
|
||||
if (chore != null) {
|
||||
rescheduleChore(chore);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,17 +349,14 @@ public class ChoreService implements ChoreServicer {
|
|||
}
|
||||
|
||||
private void cancelAllChores(final boolean mayInterruptIfRunning) {
|
||||
ArrayList<ScheduledChore> choresToCancel = new ArrayList<>(scheduledChores.keySet().size());
|
||||
// Build list of chores to cancel so we can iterate through a set that won't change
|
||||
// as chores are cancelled. If we tried to cancel each chore while iterating through
|
||||
// keySet the results would be undefined because the keySet would be changing
|
||||
for (ScheduledChore chore : scheduledChores.keySet()) {
|
||||
choresToCancel.add(chore);
|
||||
}
|
||||
ArrayList<ScheduledChore> choresToCancel = new ArrayList<>(scheduledChores.keySet());
|
||||
|
||||
for (ScheduledChore chore : choresToCancel) {
|
||||
cancelChore(chore, mayInterruptIfRunning);
|
||||
}
|
||||
choresToCancel.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue