use of org.apache.gobblin.runtime.api.SpecExecutor.Verb in project incubator-gobblin by apache.
the class AvroJobSpecKafkaJobMonitor method parseJobSpec.
/**
* Creates a {@link JobSpec} or {@link URI} from the {@link AvroJobSpec} record.
* @param record the record as an {@link AvroJobSpec}
* @return a {@link JobSpec} or {@link URI} wrapped in a {@link Collection} of {@link Either}
*/
@Override
public Collection<Either<JobSpec, URI>> parseJobSpec(AvroJobSpec record) {
JobSpec.Builder jobSpecBuilder = JobSpec.builder(record.getUri());
Properties props = new Properties();
props.putAll(record.getProperties());
jobSpecBuilder.withJobCatalogURI(record.getUri()).withVersion(record.getVersion()).withDescription(record.getDescription()).withConfigAsProperties(props);
if (!record.getTemplateUri().isEmpty()) {
try {
jobSpecBuilder.withTemplate(new URI(record.getTemplateUri()));
} catch (URISyntaxException e) {
log.error("could not parse template URI " + record.getTemplateUri());
}
}
String verbName = record.getMetadata().get(VERB_KEY);
Verb verb = Verb.valueOf(verbName);
JobSpec jobSpec = jobSpecBuilder.build();
log.info("Parsed job spec " + jobSpec.toString());
if (verb == Verb.ADD || verb == Verb.UPDATE) {
return Lists.newArrayList(Either.<JobSpec, URI>left(jobSpec));
} else {
return Lists.newArrayList(Either.<JobSpec, URI>right(jobSpec.getUri()));
}
}
Aggregations