This is an automated email from the ASF dual-hosted git repository.
stack pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new d6eec74 HBASE-23556: Minor ChoreService Cleanup (#927)
d6eec74 is described below
commit d6eec74273a4cee9edce548e726af75734096a19
Author: belugabehr <[email protected]>
AuthorDate: Tue Dec 10 17:20:11 2019 -0500
HBASE-23556: Minor ChoreService Cleanup (#927)
---
.../main/java/org/apache/hadoop/hbase/ChoreService.java | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git
a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
index 0ad52b2..9dbb307 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
@@ -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();
}
/**