/** * Returns a {@link RolloutOptions} instance that will replace null attributes in options with * values from two tiers of fallbacks. First fallback to job then * {@link RolloutOptions#getDefault()}. */ static RolloutOptions rolloutOptionsWithFallback(final RolloutOptions options, final Job job) { return options.withFallback( job.getRolloutOptions() == null ? RolloutOptions.getDefault() : job.getRolloutOptions().withFallback(RolloutOptions.getDefault())); }
private boolean isRolloutTimedOut(final ZooKeeperClient client, final DeploymentGroup deploymentGroup) { final String groupName = deploymentGroup.getName(); final RolloutOptions defaultOptions = RolloutOptions.getDefault(); final long groupTimeoutSetting = deploymentGroup.getRolloutOptions() == null ? defaultOptions.getTimeout() : deploymentGroup.getRolloutOptions().withFallback(defaultOptions).getTimeout(); final long secondsSinceDeploy; try { final String statusPath = Paths.statusDeploymentGroupTasks(groupName); secondsSinceDeploy = MILLISECONDS.toSeconds( System.currentTimeMillis() - client.getNode(statusPath).getStat().getMtime()); } catch (KeeperException e) { // statusPath doesn't exist or some other ZK issue. probably this deployment group // was removed. log.warn("error determining deployment group modification time: name={}", groupName, e); return false; } if (secondsSinceDeploy > groupTimeoutSetting) { log.info("rolling-update on deployment-group name={} has timed out after " + "{} seconds (rolloutOptions.timeout={})", groupName, secondsSinceDeploy, groupTimeoutSetting); return true; } return false; }