@Test public void removeParentAndChildren() throws Exception { String topParent = manager.startContainer(busyboxImageName, Constants.CONTAINER_TYPE_SYSTEM, null, sleepCommand); assertNotNull(topParent); services.add(topParent); String child1 = manager.startContainer(busyboxImageName, Constants.CONTAINER_TYPE_SYSTEM, topParent, sleepCommand); assertNotNull(child1); services.add(child1); String subParent = manager.startContainer(busyboxImageName, Constants.CONTAINER_TYPE_SYSTEM, topParent, sleepCommand); assertNotNull(subParent); services.add(subParent); String subchild = manager.startContainer(busyboxImageName, Constants.CONTAINER_TYPE_SYSTEM, subParent, sleepCommand); assertNotNull(subchild); services.add(subchild); String unrelatedParent = manager.startContainer(busyboxImageName, Constants.CONTAINER_TYPE_SYSTEM, null, sleepCommand); assertNotNull(unrelatedParent); services.add(unrelatedParent); String unrelatedChild = manager.startContainer(busyboxImageName, Constants.CONTAINER_TYPE_SYSTEM, unrelatedParent, sleepCommand); assertNotNull(unrelatedChild); services.add(unrelatedChild); assertContainerIsRunning("Top parent container", topParent); assertContainerIsRunning("Child 1 container", child1); assertContainerIsRunning("Sub parent container", subParent); assertContainerIsRunning("Sub child container", subchild); assertContainerIsRunning("Unrelated parent container", unrelatedParent); assertContainerIsRunning("Unrelated child container", unrelatedChild); manager.removeParentAndChildren(topParent); assertContainerIsNotRunning("Top parent container", topParent); services.remove(topParent); assertContainerIsNotRunning("Child 1 container", child1); services.remove(child1); assertContainerIsNotRunning("Sub parent container", subParent); services.remove(subParent); assertContainerIsNotRunning("Sub child container", subchild); services.remove(subchild); assertContainerIsRunning("Unrelated parent container", unrelatedParent); assertContainerIsRunning("Unrelated child container", unrelatedChild); }
@Override public void removeParentAndChildren(String parent) { removeContainer(parent); try { List<Service> services = dockerClient.listServices(Service.Criteria.builder().labels(ImmutableMap.of(LABEL_PARENT, parent)).build()); for (Service c : services) { if (c != null) { removeParentAndChildren(c.spec().name()); } } } catch (Exception e) { LOGGER.error("Error while removing containers: " + e.toString()); } }
ContainerManagerImpl implements ContainerManager { @Override public void removeParentAndChildren(String parent) { removeContainer(parent); try { List<Service> services = dockerClient.listServices(Service.Criteria.builder().labels(ImmutableMap.of(LABEL_PARENT, parent)).build()); for (Service c : services) { if (c != null) { removeParentAndChildren(c.spec().name()); } } } catch (Exception e) { LOGGER.error("Error while removing containers: " + e.toString()); } } }
ContainerManagerImpl implements ContainerManager { @Override public void removeParentAndChildren(String parent) { removeContainer(parent); try { List<Service> services = dockerClient.listServices(Service.Criteria.builder().labels(ImmutableMap.of(LABEL_PARENT, parent)).build()); for (Service c : services) { if (c != null) { removeParentAndChildren(c.spec().name()); } } } catch (Exception e) { LOGGER.error("Error while removing containers: " + e.toString()); } } ContainerManagerImpl(); }
ContainerManagerImpl implements ContainerManager { @Override public void removeParentAndChildren(String parent) { removeContainer(parent); try { List<Service> services = dockerClient.listServices(Service.Criteria.builder().labels(ImmutableMap.of(LABEL_PARENT, parent)).build()); for (Service c : services) { if (c != null) { removeParentAndChildren(c.spec().name()); } } } catch (Exception e) { LOGGER.error("Error while removing containers: " + e.toString()); } } ContainerManagerImpl(); void pullImage(String imageName); @Deprecated String startContainer(String imageName); @Deprecated String startContainer(String imageName, String[] command); String startContainer(String imageName, String type, String parent); @Override String startContainer(String imageName, String containerType, String parentId, String[] command); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] command); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
    String[] netAliases, String[] command); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] command, boolean pullImage); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] netAliases, String[] command, boolean pullImage); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] netAliases, String[] command, String experimentId); @Override void removeContainer(String serviceName); @Deprecated @Override void stopContainer(String containerId); @Deprecated @Override void stopParentAndChildren(String parentId); @Override void removeParentAndChildren(String parent); @Override Service getContainerInfo(String serviceName); @Override List<Service> getContainers(Service.Criteria criteria); @Override Integer getContainerExitCode(String serviceName); @Deprecated @Override String getContainerId(String name); @Deprecated @Override String getContainerName(String containerId); @Override void addContainerObserver(ContainerStateObserver containerObserver); static boolean containsVersionTag(String imageName); @Override ContainerStats getStats(String containerId); }
ContainerManagerImpl implements ContainerManager { @Override public void removeParentAndChildren(String parent) { removeContainer(parent); try { List<Service> services = dockerClient.listServices(Service.Criteria.builder().labels(ImmutableMap.of(LABEL_PARENT, parent)).build()); for (Service c : services) { if (c != null) { removeParentAndChildren(c.spec().name()); } } } catch (Exception e) { LOGGER.error("Error while removing containers: " + e.toString()); } } ContainerManagerImpl(); void pullImage(String imageName); @Deprecated String startContainer(String imageName); @Deprecated String startContainer(String imageName, String[] command); String startContainer(String imageName, String type, String parent); @Override String startContainer(String imageName, String containerType, String parentId, String[] command); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] command); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
    String[] netAliases, String[] command); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] command, boolean pullImage); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] netAliases, String[] command, boolean pullImage); @Override String startContainer(String imageName, String containerType, String parentId, String[] env,
            String[] netAliases, String[] command, String experimentId); @Override void removeContainer(String serviceName); @Deprecated @Override void stopContainer(String containerId); @Deprecated @Override void stopParentAndChildren(String parentId); @Override void removeParentAndChildren(String parent); @Override Service getContainerInfo(String serviceName); @Override List<Service> getContainers(Service.Criteria criteria); @Override Integer getContainerExitCode(String serviceName); @Deprecated @Override String getContainerId(String name); @Deprecated @Override String getContainerName(String containerId); @Override void addContainerObserver(ContainerStateObserver containerObserver); static boolean containsVersionTag(String imageName); @Override ContainerStats getStats(String containerId); static final String DEPLOY_ENV_KEY; static final String DOCKER_AUTOPULL_ENV_KEY; static final String LOGGING_GELF_ADDRESS_KEY; static final String USER_NAME_KEY; static final String USER_EMAIL_KEY; static final String USER_PASSWORD_KEY; static final String REGISTRY_URL_KEY; static final String HOBBIT_DOCKER_NETWORK; static final String LOGGING_TAG; static final Set<String> NEW_TASKS_STATES; static final Set<String> UNFINISHED_TASK_STATES; }