private Set<String> validateJobVersion(final String jobIdVersion, final JobId recomputedId) { final Set<String> errors = Sets.newHashSet(); if (isNullOrEmpty(jobIdVersion)) { errors.add(format("Job version was not specified in job id [%s].", recomputedId)); return errors; } if (!NAME_VERSION_PATTERN.matcher(jobIdVersion).matches()) { // Check that the job version contains only allowed characters errors.add(format("Job version may only contain [0-9a-zA-Z-_.] in job version [%s].", recomputedId.getVersion())); } // Check that the job version is correct if (!recomputedId.getVersion().equals(jobIdVersion)) { errors.add(format("Id version mismatch: %s != %s", jobIdVersion, recomputedId.getVersion())); } return errors; }
public static String configJobRefShort(final JobId id) { return CONFIG_JOBREFS.path(id.getName() + ":" + id.getVersion()); }
/** * Validate the Job's JobId by checking name, version, and hash are * not null or empty, don't contain invalid characters. * * @param job The Job to check. * * @return A set of error Strings */ private Set<String> validateJobId(final Job job) { final Set<String> errors = Sets.newHashSet(); final JobId jobId = job.getId(); if (jobId == null) { errors.add("Job id was not specified."); return errors; } final String jobIdVersion = jobId.getVersion(); final String jobIdHash = jobId.getHash(); final JobId recomputedId = job.toBuilder().build().getId(); errors.addAll(validateJobName(jobId, recomputedId)); errors.addAll(validateJobVersion(jobIdVersion, recomputedId)); if (this.shouldValidateJobHash) { errors.addAll(validateJobHash(jobIdHash, recomputedId)); } return errors; }
final String env = Joiner.on(" ").withKeyValueSeparator("=").join(job.getEnv()); final JobStatus status = jobStatuses.get(jobId); table.row(full ? jobId : jobId.toShortString(), jobId.getName(), jobId.getVersion(), status != null ? status.getDeployments().keySet().size() : 0, command, env);
assertEquals(version, job.getId().getVersion()); assertEquals(ports, job.getPorts()); assertEquals(env, job.getEnv());
.setVersion(expected.getId().getVersion() + "-cloned") .build(); final JobId clonedJobId = JobId.parse(CharMatcher.whitespace().trimFrom(
.setVersion(id.getVersion());
public static String configJobRefShort(final JobId id) { return CONFIG_JOBREFS.path(id.getName() + ":" + id.getVersion()); }
private void outputDeployedMessage(final String host, final String containerId) { final StrSubstitutor subst = new StrSubstitutor(new ImmutableMap.Builder<String, Object>() .put("host", host) .put("name", job.getId().getName()) .put("version", job.getId().getVersion()) .put("hash", job.getId().getHash()) .put("job", job.toString()) .put("containerId", containerId) .build() ); log.info("{}", subst.replace(jobDeployedMessageFormat)); } }
final String env = Joiner.on(" ").withKeyValueSeparator("=").join(job.getEnv()); final JobStatus status = futures.get(jobId).get(); table.row(full ? jobId : jobId.toShortString(), jobId.getName(), jobId.getVersion(), status != null ? status.getDeployments().keySet().size() : 0, command, env);