Adding initialized boolean to record work state
Due to the long startup time of workers it's helpful to find out if they are ready for work.
This commit is contained in:
parent
0a91e6faa5
commit
7daae980c0
1 changed files with 10 additions and 2 deletions
|
|
@ -94,6 +94,8 @@ public class Worker implements Runnable {
|
|||
private volatile long shutdownStartTimeMillis;
|
||||
private volatile boolean shutdownComplete = false;
|
||||
|
||||
private volatile boolean initialized = false;
|
||||
|
||||
// Holds consumers for shards the worker is currently tracking. Key is shard
|
||||
// info, value is ShardConsumer.
|
||||
private ConcurrentMap<ShardInfo, ShardConsumer> shardInfoShardConsumerMap =
|
||||
|
|
@ -457,6 +459,7 @@ public class Worker implements Runnable {
|
|||
if (!isDone) {
|
||||
throw new RuntimeException(lastException);
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -580,6 +583,10 @@ public class Worker implements Runnable {
|
|||
return shutdownComplete;
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
ConcurrentMap<ShardInfo, ShardConsumer> getShardInfoShardConsumerMap() {
|
||||
return shardInfoShardConsumerMap;
|
||||
}
|
||||
|
|
@ -630,6 +637,7 @@ public class Worker implements Runnable {
|
|||
if (metricsFactory instanceof WorkerCWMetricsFactory) {
|
||||
((CWMetricsFactory) metricsFactory).shutdown();
|
||||
}
|
||||
initialized = false;
|
||||
shutdownComplete = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue