Skip to content

Commit

Permalink
[SCB-2056]print a verbose log when client pool not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
liubao68 committed Aug 3, 2020
1 parent 05eda5c commit 70756fe
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -105,6 +105,7 @@ protected CLIENT_POOL findByContext(Context targetContext) {
// 2.vertx worker thread
// 3.other vertx thread
// select a existing context
assertPoolsInitialized();
int idx = reactiveNextIndex.getAndIncrement() % pools.size();
if (idx < 0) {
idx = -idx;
Expand All @@ -113,7 +114,15 @@ protected CLIENT_POOL findByContext(Context targetContext) {
}

public CLIENT_POOL findThreadBindClientPool() {
assertPoolsInitialized();
int idx = (int) (Thread.currentThread().getId() % pools.size());
return pools.get(idx);
}

private void assertPoolsInitialized() {
if (pools.size() == 0) {
throw new IllegalStateException("client pool not initialized successfully when making calls."
+ "Please check if system boot up is ready or some errors happened when startup.");
}
}
}

0 comments on commit 70756fe

Please sign in to comment.