private long getAllowedMillis(SingularityDeploy deploy) { long seconds = deploy.getDeployHealthTimeoutSeconds().or(configuration.getDeployHealthyBySeconds()); if (deploy.getHealthcheck().isPresent() && !deploy.getSkipHealthchecksOnDeploy().or(false)) { seconds += deployHealthHelper.getMaxHealthcheckTimeoutSeconds(deploy.getHealthcheck().get()); } else { seconds += deploy.getConsiderHealthyAfterRunningForSeconds().or(configuration.getConsiderTaskHealthyAfterRunningForSeconds()); } return TimeUnit.SECONDS.toMillis(seconds); }
private boolean isRunningTaskHealthy(final Optional<SingularityDeploy> deploy, Collection<SingularityTaskHistoryUpdate> updates, SingularityTaskId taskId) { long runningThreshold = configuration.getConsiderTaskHealthyAfterRunningForSeconds(); if (deploy.isPresent()) { runningThreshold = deploy.get().getConsiderHealthyAfterRunningForSeconds().or(runningThreshold); } if (runningThreshold < 1) { return true; } Optional<SingularityTaskHistoryUpdate> runningUpdate = SingularityTaskHistoryUpdate.getUpdate(updates, ExtendedTaskState.TASK_RUNNING); long taskDuration = System.currentTimeMillis() - runningUpdate.get().getTimestamp(); long runningThresholdMillis = TimeUnit.SECONDS.toMillis(runningThreshold); if (taskDuration < runningThresholdMillis) { LOG.debug("Task {} has been running for {}, has not yet reached running threshold of {}", taskId, JavaUtils.durationFromMillis(taskDuration), JavaUtils.durationFromMillis(runningThresholdMillis)); return false; } return true; }
private boolean isRunningTaskHealthy(final Optional<SingularityDeploy> deploy, Collection<SingularityTaskHistoryUpdate> updates, SingularityTaskId taskId) { long runningThreshold = configuration.getConsiderTaskHealthyAfterRunningForSeconds(); if (deploy.isPresent()) { runningThreshold = deploy.get().getConsiderHealthyAfterRunningForSeconds().or(runningThreshold); } if (runningThreshold < 1) { return true; } Optional<SingularityTaskHistoryUpdate> runningUpdate = SingularityTaskHistoryUpdate.getUpdate(updates, ExtendedTaskState.TASK_RUNNING); long taskDuration = System.currentTimeMillis() - runningUpdate.get().getTimestamp(); long runningThresholdMillis = TimeUnit.SECONDS.toMillis(runningThreshold); if (taskDuration < runningThresholdMillis) { LOG.debug("Task {} has been running for {}, has not yet reached running threshold of {}", taskId, JavaUtils.durationFromMillis(taskDuration), JavaUtils.durationFromMillis(runningThresholdMillis)); return false; } return true; }
private long getAllowedMillis(SingularityDeploy deploy) { long seconds = deploy.getDeployHealthTimeoutSeconds().or(configuration.getDeployHealthyBySeconds()); if (deploy.getHealthcheck().isPresent() && !deploy.getSkipHealthchecksOnDeploy().or(false)) { seconds += deployHealthHelper.getMaxHealthcheckTimeoutSeconds(deploy.getHealthcheck().get()); } else { seconds += deploy.getConsiderHealthyAfterRunningForSeconds().or(configuration.getConsiderTaskHealthyAfterRunningForSeconds()); } return TimeUnit.SECONDS.toMillis(seconds); }