use of com.hubspot.singularity.SingularityPendingTaskId in project Singularity by HubSpot.
the class SingularityPendingTaskIdMigration method createFrom.
public SingularityPendingTaskId createFrom(String string, long createdAt) {
if (Character.isDigit(string.charAt(string.length() - 1))) {
LOG.warn("Not migrating {} - it appears to be migrated already", string);
return SingularityPendingTaskId.valueOf(string);
}
String[] splits = null;
try {
splits = JavaUtils.reverseSplit(string, 5, "-");
} catch (IllegalStateException ise) {
throw new InvalidSingularityTaskIdException(String.format("PendingTaskId %s was invalid (%s)", string, ise.getMessage()));
}
try {
final String requestId = splits[0];
final String deployId = splits[1];
final long nextRunAt = Long.parseLong(splits[2]);
final int instanceNo = Integer.parseInt(splits[3]);
final PendingType pendingType = PendingType.valueOf(splits[4]);
return new SingularityPendingTaskId(requestId, deployId, nextRunAt, instanceNo, pendingType, createdAt);
} catch (IllegalArgumentException e) {
throw new InvalidSingularityTaskIdException(String.format("PendingTaskId %s had an invalid parameter (%s)", string, e.getMessage()));
}
}
Aggregations