@Test public void isContainerRecycledError () { Container container = mock(Container.class); assertFalse(cloudFoundryContainerPlatform.isContainerRecycled(container)); }
@Override public boolean isContainerRecycled (Container container) { log.debug("Recycling container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); if (!(container instanceof CloudFoundryContainer)) { log.warn("Was passed another Platform's container"); return false; } CloudFoundryContainer cloudFoundryContainer = (CloudFoundryContainer) container; Instant timeInState = getTimeInState(cloudFoundryContainer); ContainerHealth containerHealth = checkHealth(cloudFoundryContainer.getApplicationId(), cloudFoundryContainer.getInstance()); Instant experimentStartTime = cloudFoundryContainer.getExperimentStartTime(); boolean isContainerRecycled = timeInState != null && timeInState.isAfter(experimentStartTime) && ContainerHealth.NORMAL .equals(containerHealth); log.debug("Evaluating if the container is recycled. {} {} {}", kv("Container Health", containerHealth), kv("Container Start Time", timeInState), kv("Experiment Start Time", experimentStartTime)); return isContainerRecycled; }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public boolean isContainerRecycled (Container container) { log.debug("Recycling container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); if (!(container instanceof CloudFoundryContainer)) { log.warn("Was passed another Platform's container"); return false; } CloudFoundryContainer cloudFoundryContainer = (CloudFoundryContainer) container; Instant timeInState = getTimeInState(cloudFoundryContainer); ContainerHealth containerHealth = checkHealth(cloudFoundryContainer.getApplicationId(), cloudFoundryContainer.getInstance()); Instant experimentStartTime = cloudFoundryContainer.getExperimentStartTime(); boolean isContainerRecycled = timeInState != null && timeInState.isAfter(experimentStartTime) && ContainerHealth.NORMAL .equals(containerHealth); log.debug("Evaluating if the container is recycled. {} {} {}", kv("Container Health", containerHealth), kv("Container Start Time", timeInState), kv("Experiment Start Time", experimentStartTime)); return isContainerRecycled; } }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public boolean isContainerRecycled (Container container) { log.debug("Recycling container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); if (!(container instanceof CloudFoundryContainer)) { log.warn("Was passed another Platform's container"); return false; } CloudFoundryContainer cloudFoundryContainer = (CloudFoundryContainer) container; Instant timeInState = getTimeInState(cloudFoundryContainer); ContainerHealth containerHealth = checkHealth(cloudFoundryContainer.getApplicationId(), cloudFoundryContainer.getInstance()); Instant experimentStartTime = cloudFoundryContainer.getExperimentStartTime(); boolean isContainerRecycled = timeInState != null && timeInState.isAfter(experimentStartTime) && ContainerHealth.NORMAL .equals(containerHealth); log.debug("Evaluating if the container is recycled. {} {} {}", kv("Container Health", containerHealth), kv("Container Start Time", timeInState), kv("Experiment Start Time", experimentStartTime)); return isContainerRecycled; } @Autowired  CloudFoundryContainerPlatform(); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public boolean isContainerRecycled (Container container) { log.debug("Recycling container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); if (!(container instanceof CloudFoundryContainer)) { log.warn("Was passed another Platform's container"); return false; } CloudFoundryContainer cloudFoundryContainer = (CloudFoundryContainer) container; Instant timeInState = getTimeInState(cloudFoundryContainer); ContainerHealth containerHealth = checkHealth(cloudFoundryContainer.getApplicationId(), cloudFoundryContainer.getInstance()); Instant experimentStartTime = cloudFoundryContainer.getExperimentStartTime(); boolean isContainerRecycled = timeInState != null && timeInState.isAfter(experimentStartTime) && ContainerHealth.NORMAL .equals(containerHealth); log.debug("Evaluating if the container is recycled. {} {} {}", kv("Container Health", containerHealth), kv("Container Start Time", timeInState), kv("Experiment Start Time", experimentStartTime)); return isContainerRecycled; } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public boolean isContainerRecycled (Container container) { log.debug("Recycling container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); if (!(container instanceof CloudFoundryContainer)) { log.warn("Was passed another Platform's container"); return false; } CloudFoundryContainer cloudFoundryContainer = (CloudFoundryContainer) container; Instant timeInState = getTimeInState(cloudFoundryContainer); ContainerHealth containerHealth = checkHealth(cloudFoundryContainer.getApplicationId(), cloudFoundryContainer.getInstance()); Instant experimentStartTime = cloudFoundryContainer.getExperimentStartTime(); boolean isContainerRecycled = timeInState != null && timeInState.isAfter(experimentStartTime) && ContainerHealth.NORMAL .equals(containerHealth); log.debug("Evaluating if the container is recycled. {} {} {}", kv("Container Health", containerHealth), kv("Container Start Time", timeInState), kv("Experiment Start Time", experimentStartTime)); return isContainerRecycled; } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container);  }