use of com.netflix.titus.api.jobmanager.model.job.Version in project titus-control-plane by Netflix.
the class JobReconciliationFrameworkFactory method validateTask.
private Optional<Task> validateTask(Task task) {
// Perform strict validation for reporting purposes
Set<ValidationError> strictViolations = strictEntitySanitizer.validate(task);
if (!strictViolations.isEmpty()) {
logger.error("No strictly consistent task record found: taskId={}, violations={}", task.getId(), EntitySanitizerUtil.toStringMap(strictViolations));
errorCollector.strictlyInvalidTask(task.getId());
}
// Required checks
Set<ValidationError> violations = permissiveEntitySanitizer.validate(task);
if (!violations.isEmpty()) {
logger.error("Bad task record found: taskId={}, violations={}", task.getId(), EntitySanitizerUtil.toStringMap(violations));
if (jobManagerConfiguration.isFailOnDataValidation()) {
return Optional.empty();
}
}
// If version is missing (old task objects) create one based on the current task state.
Task taskWithVersion = task;
if (task.getVersion() == null || task.getVersion().getTimestamp() < 0) {
Version newVersion = Version.newBuilder().withTimestamp(task.getStatus().getTimestamp()).build();
taskWithVersion = task.toBuilder().withVersion(newVersion).build();
}
return Optional.of(taskWithVersion);
}
use of com.netflix.titus.api.jobmanager.model.job.Version in project titus-control-plane by Netflix.
the class JobReconciliationFrameworkFactory method validateJob.
private Optional<Job> validateJob(Job job) {
// Perform strict validation for reporting purposes
Set<ValidationError> strictViolations = strictEntitySanitizer.validate(job);
if (!strictViolations.isEmpty()) {
logger.error("No strictly consistent job record found: jobId={}, violations={}", job.getId(), EntitySanitizerUtil.toStringMap(strictViolations));
errorCollector.strictlyInvalidJob(job.getId());
}
// Required checks
Set<ValidationError> violations = permissiveEntitySanitizer.validate(job);
if (!violations.isEmpty()) {
logger.error("Bad job record found: jobId={}, violations={}", job.getId(), EntitySanitizerUtil.toStringMap(violations));
if (jobManagerConfiguration.isFailOnDataValidation()) {
return Optional.empty();
}
}
// If version is missing (old job objects) create one based on the current job state.
Job jobWithVersion = job;
if (job.getVersion() == null || job.getVersion().getTimestamp() < 0) {
Version newVersion = Version.newBuilder().withTimestamp(job.getStatus().getTimestamp()).build();
jobWithVersion = job.toBuilder().withVersion(newVersion).build();
}
return Optional.of(jobWithVersion);
}
Aggregations