use of com.aws.greengrass.config.WhatHappened in project aws-greengrass-nucleus by aws-greengrass.
the class GreengrassService method waitForDependersToExit.
private void waitForDependersToExit() throws InterruptedException {
List<GreengrassService> dependers = getHardDependers();
Subscriber dependerExitWatcher = (WhatHappened what, Topic t) -> {
synchronized (dependersExitedLock) {
if (dependersExited(dependers)) {
dependersExitedLock.notifyAll();
}
}
};
// subscribing to depender state changes
dependers.forEach(dependerGreengrassService -> dependerGreengrassService.addStateSubscriber(dependerExitWatcher));
synchronized (dependersExitedLock) {
while (!dependersExited(dependers)) {
logger.atDebug("service-waiting-for-depender-to-finish").log();
dependersExitedLock.wait();
}
}
// removing state change watchers
dependers.forEach(dependerGreengrassService -> dependerGreengrassService.removeStateSubscriber(dependerExitWatcher));
}
Aggregations