Source:
protected void waitForDependenciesStart(Instance instance) { List<Long> instancesIds = DataAccessor.fieldLongList(instance, DockerInstanceConstants.FIELD_VOLUMES_FROM); Long networkFromId = DataAccessor.fieldLong(instance, DockerInstanceConstants.FIELD_NETWORK_CONTAINER_ID); if (networkFromId != null) { instancesIds.add(networkFromId); } List<Instance> waitList = new ArrayList<>(); for (Long id : instancesIds) { Instance i = objectManager.loadResource(Instance.class, id); String type = networkFromId != null && networkFromId.equals(id) ? "networkFrom" : "volumeFrom"; if (REMOVED_STATES.contains(i.getState())) { throw new ExecutionException("Dependencies readiness error", type + " instance is removed", instance.getId()); } if (!isStartOnce(i) && !serviceDao.isServiceInstance(instance) && STOPPED_STATES.contains(i.getState())) { throw new ExecutionException("Dependencies readiness error", type + " instance is not running", instance.getId()); } waitList.add(i); } Long timeout = 120000L; for (Instance wait : waitList) { try { resourceMonitor.waitFor(wait, timeout, new ResourcePredicate<Instance>() { @Override public boolean evaluate(Instance obj) { InstanceHostMap ihm = objectManager.findAny(InstanceHostMap.class, INSTANCE_HOST_MAP.INSTANCE_ID, obj.getId(), INSTANCE_HOST_MAP.STATE, CommonStatesConstants.ACTIVE, INSTANCE_HOST_MAP.REMOVED, null); return ihm != null; } @Override public String getMessage() { return "running state"; } } ); } catch (TimeoutException e) { throw new ExecutionException("Dependencies readiness error", "instance is not running", instance.getId()); } } }

Target:
protected void waitForDependenciesStart(Instance instance) { List<Long> instancesIds = DataAccessor.fieldLongList(instance, DockerInstanceConstants.FIELD_VOLUMES_FROM); Long networkFromId = DataAccessor.fieldLong(instance, DockerInstanceConstants.FIELD_NETWORK_CONTAINER_ID); if (networkFromId != null) { instancesIds.add(networkFromId); } List<Instance> waitList = new ArrayList<>(); for (Long id : instancesIds) { Instance i = objectManager.loadResource(Instance.class, id); String type = networkFromId != null && networkFromId.equals(id) ? "networkFrom" : "volumeFrom"; if (REMOVED_STATES.contains(i.getState())) { throw new ExecutionException("Dependencies readiness error", type + " instance is removed", instance.getId()); } if (!isStartOnce(i) && !serviceDao.isServiceInstance(instance) && STOPPED_STATES.contains(i.getState())) { throw new ExecutionException("Dependencies readiness error", type + " instance is not running", instance.getId()); } waitList.add(i); } Long timeout = 120000L; for (Instance wait : waitList) { try { resourceMonitor.waitFor(wait, timeout, new ResourcePredicate<Instance>() { @Override public boolean evaluate(Instance obj) { if (isStartOnce(obj)) { return START_ONCE_STATES.contains(obj.getState()); } InstanceHostMap ihm = objectManager.findAny(InstanceHostMap.class, INSTANCE_HOST_MAP.INSTANCE_ID, obj.getId(), INSTANCE_HOST_MAP.STATE, CommonStatesConstants.ACTIVE, INSTANCE_HOST_MAP.REMOVED, null); return ihm != null; } @Override public String getMessage() { return "running state"; } } ); } catch (TimeoutException e) { throw new ExecutionException("Dependencies readiness error", "instance is not running", instance.getId()); } } }