@Override public void onDeleteJob(URI deletedJobURI, String deletedJobVersion) { super.onDeleteJob(deletedJobURI, deletedJobVersion); try { JobSpec.Builder jobSpecBuilder = JobSpec.builder(deletedJobURI); Properties props = new Properties(); jobSpecBuilder.withVersion(deletedJobVersion).withConfigAsProperties(props); _jobSpecQueue.put(new ImmutablePair<SpecExecutor.Verb, Spec>(SpecExecutor.Verb.DELETE, jobSpecBuilder.build())); _metrics.jobSpecEnqCount.incrementAndGet(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
/** Creates a builder for the JobSpec based on values in a job properties config. */ public static Builder builder(URI catalogURI, Properties jobProps) { String name = JobState.getJobNameFromProps(jobProps); String group = JobState.getJobGroupFromProps(jobProps); if (null == group) { group = "default"; } try { URI jobURI = new URI(catalogURI.getScheme(), catalogURI.getAuthority(), "/" + group + "/" + name, null); Builder builder = new Builder(jobURI).withConfigAsProperties(jobProps); String descr = JobState.getJobDescriptionFromProps(jobProps); if (null != descr) { builder.withDescription(descr); } return builder; } catch (URISyntaxException e) { throw new RuntimeException("Unable to create a JobSpec URI: " + e, e); } }
props.putAll(record.getProperties()); jobSpecBuilder.withJobCatalogURI(record.getUri()).withVersion(record.getVersion()) .withDescription(record.getDescription()).withConfigAsProperties(props);
props.putAll(record.getProperties()); jobSpecBuilder.withJobCatalogURI(record.getUri()).withVersion(record.getVersion()) .withDescription(record.getDescription()).withConfigAsProperties(props);
/** * Creates {@link JobSpec} from the {@link AvroJobSpec} record. * @param record the record as an {@link AvroJobSpec} * @return a {@link JobSpec} 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).withMetadata(record.getMetadata()); if (!record.getTemplateUri().isEmpty()) { try { jobSpecBuilder.withTemplate(new URI(record.getTemplateUri())); } catch (URISyntaxException e) { log.error("could not parse template URI " + record.getTemplateUri()); } } JobSpec jobSpec = jobSpecBuilder.build(); log.info("Parsed job spec " + jobSpec.toString()); return Lists.newArrayList(Either.<JobSpec, URI>left(jobSpec)); }
/** Creates a builder for the JobSpec based on values in a job properties config. */ public static Builder builder(URI catalogURI, Properties jobProps) { String name = JobState.getJobNameFromProps(jobProps); String group = JobState.getJobGroupFromProps(jobProps); if (null == group) { group = "default"; } try { URI jobURI = new URI(catalogURI.getScheme(), catalogURI.getAuthority(), "/" + group + "/" + name, null); Builder builder = new Builder(jobURI).withConfigAsProperties(jobProps); String descr = JobState.getJobDescriptionFromProps(jobProps); if (null != descr) { builder.withDescription(descr); } return builder; } catch (URISyntaxException e) { throw new RuntimeException("Unable to create a JobSpec URI: " + e, e); } }
@Override public void onDeleteJob(URI deletedJobURI, String deletedJobVersion) { super.onDeleteJob(deletedJobURI, deletedJobVersion); try { JobSpec.Builder jobSpecBuilder = JobSpec.builder(deletedJobURI); Properties props = new Properties(); jobSpecBuilder.withVersion(deletedJobVersion).withConfigAsProperties(props); _jobSpecQueue.put(new ImmutablePair<SpecExecutor.Verb, Spec>(SpecExecutor.Verb.DELETE, jobSpecBuilder.build())); _metrics.jobSpecEnqCount.incrementAndGet(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
.withVersion("2") .withDescription("A test job") .withConfigAsProperties(props);
properties.setProperty(JOB_NAME_KEY, "jobname"); JobSpec js1 = JobSpec.builder("gobblin:/testAwaitForDone/job1") .withConfigAsProperties(properties) .build(); JobExecution je1 = JobExecutionUpdatable.createFromJobSpec(js1);
.withVersion("2") .withDescription("A test job") .withConfigAsProperties(props);
/** * Creates {@link JobSpec} from the {@link AvroJobSpec} record. * @param record the record as an {@link AvroJobSpec} * @return a {@link JobSpec} 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).withMetadata(record.getMetadata()); if (!record.getTemplateUri().isEmpty()) { try { jobSpecBuilder.withTemplate(new URI(record.getTemplateUri())); } catch (URISyntaxException e) { log.error("could not parse template URI " + record.getTemplateUri()); } } JobSpec jobSpec = jobSpecBuilder.build(); log.info("Parsed job spec " + jobSpec.toString()); return Lists.newArrayList(Either.<JobSpec, URI>left(jobSpec)); }