NM Callback: NM reports stop of a container.
@param containerId ID of a container stopped.
198376
@Override
  public void onContainerStopped(final ContainerId containerId) {
    final boolean hasContainer = this.containers.hasContainer(containerId.toString());
    if (hasContainer) {
      this.reefEventHandlers.onResourceStatus(
          ResourceStatusEventImpl.newBuilder()
             .setIdentifier(containerId.toString())
             .setState(State.DONE)
             .build());
    }
  }
1165916
function (elementId, containerId) {
            var container = this.$containers[containerId];
            if (!container) {
                // TODO: remove this shit
                container = this.createContainer({'class': containerId + "-container"});
                this.$containers[containerId] = container;
                this.addChild(container);
                if (this.$containerOrder[containerId]) {
                    container.setChildIndex(this.$containerOrder[containerId]);
                }
            }

            var element = this.$elements[containerId + "_" + elementId];
            if (!element) {
                element = this.createContainer({});
                container.addChild(element);
            }

            return element.$el;
        }
804169
async def _handle_container_timeout(self, container_id, timeout):
        
        try:
            docker_stats = await self._docker_interface.get_stats(container_id)
            source = AsyncIteratorWrapper(docker_stats)
            nano_timeout = timeout * (10 ** 9)
            async for upd in source:
                if upd is None:
                    await self._kill_it_with_fire(container_id)
                self._logger.debug("%i", upd['cpu_stats']['cpu_usage']['total_usage'])
                if upd['cpu_stats']['cpu_usage']['total_usage'] > nano_timeout:
                    self._logger.info("Killing container %s as it used %i CPU seconds (max was %i)",
                                      container_id, int(upd['cpu_stats']['cpu_usage']['total_usage'] / (10 ** 9)), timeout)
                    await self._kill_it_with_fire(container_id)
                    return
        except asyncio.CancelledError:
            pass
        except:
            self._logger.exception("Exception in _handle_container_timeout")
117143
private void terminate()
    {
        if (this.container != null) {
            final Cache<String, Integer> cache = this.container
                            .<String, Integer>getCache(InfinispanCache.COUNTERCACHE);
            Integer count = cache.get(InfinispanCache.COUNTERCACHE);
            if (count == null || count < 2) {
                this.container.stop();
            } else {
                count = count - 1;
                cache.put(InfinispanCache.COUNTERCACHE, count);
            }
        }
    }
354870
@Override
    public void setContainerId(String containerId) {
        if (getId() == null) {
            super.setContainerId(containerId);
            JQMContext.attachAndEnhance(this);
        } else if (! containerId.equals(getId())) {
            throw new IllegalStateException("Attempt to change JQMPage with containerId '" + getId() + "' to '" + containerId + "' failed - once set, it cannot be changed.");
        }
    }
1156428
private void onContainerStatus(final ContainerStatus value) {

    final String containerId = value.getContainerId().toString();
    final boolean hasContainer = this.containers.hasContainer(containerId);

    if (hasContainer) {
      LOG.log(Level.FINE, "Received container status: {0}", containerId);

      final ResourceStatusEventImpl.Builder status =
          ResourceStatusEventImpl.newBuilder().setIdentifier(containerId);

      switch (value.getState()) {
      case COMPLETE:
        LOG.log(Level.FINE, "Container completed: status {0}", value.getExitStatus());
        switch (value.getExitStatus()) {
        case 0:
          status.setState(State.DONE);
          break;
        case 143:
          status.setState(State.KILLED);
          break;
        default:
          status.setState(State.FAILED);
        }
        status.setExitCode(value.getExitStatus());
        break;
      default:
        LOG.info("Container running");
        status.setState(State.RUNNING);
      }

      if (value.getDiagnostics() != null) {
        LOG.log(Level.FINE, "Container diagnostics: {0}", value.getDiagnostics());
        status.setDiagnostics(value.getDiagnostics());
      }

      // ResourceStatusHandler should close and release the Evaluator for us if the state is a terminal state.
      this.reefEventHandlers.onResourceStatus(status.build());
    }
  }
1184258
public DockerCLI createCliForContainer(String containerId) throws IOException, InterruptedException {
        LOG.trace("Creating cli for container {}.", containerId);
        final InspectContainerResponse inspect = getDockerCli().inspectContainerCmd(containerId).exec();
        return createCliForInspect(inspect);
    }
983034
synchronized Container removeAndGet(final String containerId) {
    final Container result = this.containers.remove(containerId);
    if (null == result) {
      throw new RuntimeException("Unknown container to remove: " + containerId);
    }
    return result;
  }
454599
def stop(name):
    
    container_name = get_container_name(name)
    client = docker.Client()
    try:
        client.stop(container_name)
    except docker.errors.NotFound:
        pass
    except docker.errors.APIError as error:
        die(error.explanation.decode())
515397
@Override
  public boolean restart(Integer containerId) {
    List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "restart"));
    if (containerId != null) {
      auroraCmd.add(String.format("%s/%d", jobSpec, containerId));
    } else {
      auroraCmd.add(jobSpec);
    }

    appendAuroraCommandOptions(auroraCmd, isVerbose);

    return runProcess(auroraCmd);
  }
932939
def remove_container(container_id, overlay_network, overlay_cidr)
      info "Remove container=#{container_id} from network=#{overlay_network} at cidr=#{overlay_cidr}"

      @ipam_client.release_address(overlay_network, overlay_cidr)
    rescue IpamError => error
      # Cleanup will take care of these later on
      warn "Failed to release container=#{container_id} from network=#{overlay_network} at cidr=#{overlay_cidr}: #{error}"
    end
51022
def container_exit_code(container_id: str) -> Optional[int]:
    
    container = docker_client.containers.get(container_id)
    return container.wait()["StatusCode"]
394774
async def _handle_container_hard_timeout(self, container_id, hard_timeout):
        
        if container_id in self._watching:
            self._logger.info("Killing container %s as it used its %i wall time seconds",
                              container_id, hard_timeout)
            await self._kill_it_with_fire(container_id)
374818
public void stop(int restartableId) {
        requested.remove((Integer) restartableId);
        Subscription subscription = restartableSubscriptions.get(restartableId);
        if (subscription != null)
            subscription.unsubscribe();
    }
146780
def stop(self):
        
        log.info("%r: Stopping %r clients", self.container_id, len(self.clients))
        self.stopped = True
        self._close_clients()
486854
async def stop_async(self):
        
        log.info("%r: Stopping %r clients", self.container_id, len(self.clients))
        self.stopped = True
        await self._close_clients_async()
429493
public void stopStartedContainers(boolean keepContainer,
                                      boolean removeVolumes,
                                      boolean removeCustomNetworks,
                                      GavLabel gavLabel)
        throws DockerAccessException, ExecException {
        Set<Network> networksToRemove = new HashSet<>();
        for (ContainerTracker.ContainerShutdownDescriptor descriptor : tracker.removeShutdownDescriptors(gavLabel)) {
            collectCustomNetworks(networksToRemove, descriptor, removeCustomNetworks);
            shutdown(descriptor, keepContainer, removeVolumes);
        }
        removeCustomNetworks(networksToRemove);
    }