Example #1
0
  public void destroyContainer(Container container, boolean force) {
    assertValid();
    String containerId = container.getId();
    LOGGER.info("Destroying container {}", containerId);
    boolean destroyed = false;
    try {
      ContainerProvider provider = getProvider(container, true);
      if (provider != null) {
        try {
          provider.stop(container);
        } catch (Exception ex) {
          // Ignore error while stopping and try to destroy.
        }
        provider.destroy(container);
        destroyed = true;
      }

    } finally {
      try {
        if (destroyed || force) {
          portService.get().unregisterPort(container);
          getDataStore().deleteContainer(container.getId());
        }
      } catch (Exception e) {
        LOGGER.warn(
            "Failed to cleanup container {} entries due to: {}. This will be ignored.",
            containerId,
            e.getMessage());
      }
    }
  }
Example #2
0
 public void stopContainer(Container container, boolean force) {
   assertValid();
   LOGGER.info("Stopping container {}", container.getId());
   ContainerProvider provider = getProvider(container);
   provider.stop(container);
 }