MINOR: Improve exception messages when state stores cannot be accessed. (#4383)

This commit is contained in:
Ewen Cheslack-Postava 2018-01-08 11:14:54 -08:00 committed by Guozhang Wang
parent d63f94797c
commit e1c407973f
1 changed files with 4 additions and 2 deletions

View File

@ -45,14 +45,16 @@ public class StreamThreadStateStoreProvider implements StateStoreProvider {
return Collections.emptyList(); return Collections.emptyList();
} }
if (!streamThread.isRunningAndNotRebalancing()) { if (!streamThread.isRunningAndNotRebalancing()) {
throw new InvalidStateStoreException("the state store, " + storeName + ", may have migrated to another instance."); throw new InvalidStateStoreException("Cannot get state store " + storeName + " because the stream thread is " +
streamThread.state() + ", not RUNNING");
} }
final List<T> stores = new ArrayList<>(); final List<T> stores = new ArrayList<>();
for (Task streamTask : streamThread.tasks().values()) { for (Task streamTask : streamThread.tasks().values()) {
final StateStore store = streamTask.getStore(storeName); final StateStore store = streamTask.getStore(storeName);
if (store != null && queryableStoreType.accepts(store)) { if (store != null && queryableStoreType.accepts(store)) {
if (!store.isOpen()) { if (!store.isOpen()) {
throw new InvalidStateStoreException("the state store, " + storeName + ", may have migrated to another instance."); throw new InvalidStateStoreException("Cannot get state store " + storeName + " for task " + streamTask +
" because the store is not open. The state store may have migrated to another instances.");
} }
stores.add((T) store); stores.add((T) store);
} }