This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch branch-4.7
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.7 by this push:
new 8334542 OrderedScheduler#chooseThread(key) handle null key
8334542 is described below
commit 8334542d1753c04a451ff7c45a43058d1f9d8502
Author: Sijie Guo <[email protected]>
AuthorDate: Mon Apr 30 16:29:08 2018 -0700
OrderedScheduler#chooseThread(key) handle null key
Descriptions of the changes in this PR:
*Motivation*
It is more convenient if OrderedScheduler#chooseThread(key) can handle null
key. so the applications who is using #chooseThread don't need to worry which
method to choose - `chooseThread()` vs `chooseThread(key)`.
*Solution*
in `chooseThread(key)`, fallback to randomly pickup a thread if key is null.
Author: Sijie Guo <[email protected]>
Reviewers: Enrico Olivelli <[email protected]>, Jia Zhai <None>
This closes #1372 from sijie/order_scheduler_null_key
(cherry picked from commit 1f0f92c0c0cfc0cafe0cab976d8c5fbdf34c10d3)
Signed-off-by: Sijie Guo <[email protected]>
---
.../java/org/apache/bookkeeper/common/util/OrderedExecutor.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
index 0f634d0..6a86141 100644
---
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
+++
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
@@ -348,7 +348,11 @@ public class OrderedExecutor implements ExecutorService {
return threads[0];
}
- return threads[MathUtils.signSafeMod(orderingKey.hashCode(),
threads.length)];
+ if (null == orderingKey) {
+ return threads[rand.nextInt(threads.length)];
+ } else {
+ return threads[MathUtils.signSafeMod(orderingKey.hashCode(),
threads.length)];
+ }
}
/**
--
To stop receiving notification emails like this one, please contact
[email protected].