/** * Parse a job id string. * * <p>This parsing method can be used when input is not know to be correct. I.e. when parsing a * job id supplied by the user in the cli or when parsing a request in the master rest * interface. * * @param id A string representation of the job ID. * * @return The JobId object. * * @throws JobIdParseException If the ID cannot be parsed. * @see #fromString(String) */ public static JobId parse(final String id) throws JobIdParseException { final String[] parts = id.split(":"); switch (parts.length) { case 1: return new JobId(parts[0], true); case 2: return new JobId(parts[0], parts[1]); case 3: return new JobId(parts[0], parts[1], parts[2]); default: throw new JobIdParseException("Invalid Job id: " + id); } }
public Job buildWithoutHash() { final JobId id = new JobId(pm.name, pm.version); return new Job(id, pm); }
public Job build() { final String configHash; try { configHash = hex(Json.sha1digest(pm.withoutMetaParameters())); } catch (IOException e) { throw new RuntimeException(e); } final String hash; if (!Strings.isNullOrEmpty(this.hash)) { hash = this.hash; } else { if (pm.name != null && pm.version != null) { final String input = String.format("%s:%s:%s", pm.name, pm.version, configHash); hash = hex(sha1digest(input.getBytes(UTF_8))); } else { hash = null; } } final JobId id = new JobId(pm.name, pm.version, hash); return new Job(id, pm); }