use of org.apache.gobblin.runtime.api.JobSpec in project incubator-gobblin by apache.
the class StreamingJobConfigurationManager method fetchJobSpecs.
private void fetchJobSpecs() throws ExecutionException, InterruptedException {
List<Pair<SpecExecutor.Verb, Spec>> changesSpecs = (List<Pair<SpecExecutor.Verb, Spec>>) this.specConsumer.changedSpecs().get();
// propagate thread interruption so that caller will exit from loop
if (Thread.interrupted()) {
throw new InterruptedException();
}
for (Pair<SpecExecutor.Verb, Spec> entry : changesSpecs) {
SpecExecutor.Verb verb = entry.getKey();
if (verb.equals(SpecExecutor.Verb.ADD)) {
// Handle addition
JobSpec jobSpec = (JobSpec) entry.getValue();
postNewJobConfigArrival(jobSpec.getUri().toString(), jobSpec.getConfigAsProperties());
} else if (verb.equals(SpecExecutor.Verb.UPDATE)) {
// Handle update
JobSpec jobSpec = (JobSpec) entry.getValue();
postUpdateJobConfigArrival(jobSpec.getUri().toString(), jobSpec.getConfigAsProperties());
} else if (verb.equals(SpecExecutor.Verb.DELETE)) {
// Handle delete
Spec anonymousSpec = (Spec) entry.getValue();
postDeleteJobConfigArrival(anonymousSpec.getUri().toString(), new Properties());
}
}
}
use of org.apache.gobblin.runtime.api.JobSpec in project incubator-gobblin by apache.
the class AzkabanProjectConfigTest method testProjectNameDefault.
@Test
public void testProjectNameDefault() throws Exception {
String expectedProjectName = "GobblinService__uri";
Properties properties = new Properties();
JobSpec jobSpec = new JobSpec(new URI("uri"), "0.0", "test job spec", ConfigUtils.propertiesToConfig(properties), properties, Optional.absent());
AzkabanProjectConfig azkabanProjectConfig = new AzkabanProjectConfig(jobSpec);
String actualProjectName = azkabanProjectConfig.getAzkabanProjectName();
Assert.assertEquals(actualProjectName, expectedProjectName);
}
use of org.apache.gobblin.runtime.api.JobSpec in project incubator-gobblin by apache.
the class AzkabanProjectConfigTest method testProjectZipFileName.
@Test
public void testProjectZipFileName() throws Exception {
String expectedZipFileName = "randomPrefix_http___localhost_8000_context.zip";
Properties properties = new Properties();
properties.setProperty("gobblin.service.azkaban.project.namePrefix", "randomPrefix");
JobSpec jobSpec = new JobSpec(new URI("http://localhost:8000/context"), "0.0", "test job spec", ConfigUtils.propertiesToConfig(properties), properties, Optional.absent());
AzkabanProjectConfig azkabanProjectConfig = new AzkabanProjectConfig(jobSpec);
String actualZipFileName = azkabanProjectConfig.getAzkabanProjectZipFilename();
Assert.assertEquals(actualZipFileName, expectedZipFileName);
}
use of org.apache.gobblin.runtime.api.JobSpec in project incubator-gobblin by apache.
the class AzkabanProjectConfigTest method testProjectZipFileNameForLongName.
@Test
public void testProjectZipFileNameForLongName() throws Exception {
String expectedZipFileName = "randomPrefixWithReallyLongName_http___localhost_8000__55490420.zip";
Properties properties = new Properties();
properties.setProperty("gobblin.service.azkaban.project.namePrefix", "randomPrefixWithReallyLongName");
JobSpec jobSpec = new JobSpec(new URI("http://localhost:8000/context/that-keeps-expanding-and-explanding"), "0.0", "test job spec", ConfigUtils.propertiesToConfig(properties), properties, Optional.absent());
AzkabanProjectConfig azkabanProjectConfig = new AzkabanProjectConfig(jobSpec);
String actualZipFileName = azkabanProjectConfig.getAzkabanProjectZipFilename();
Assert.assertEquals(actualZipFileName, expectedZipFileName);
}
use of org.apache.gobblin.runtime.api.JobSpec in project incubator-gobblin by apache.
the class StreamingKafkaSpecExecutorTest method testAddSpec.
@Test
public void testAddSpec() throws Exception {
_closer = Closer.create();
_properties = new Properties();
// Properties for Producer
_properties.setProperty(KafkaWriterConfigurationKeys.KAFKA_TOPIC, TOPIC);
_properties.setProperty(KafkaWriterConfigurationKeys.KAFKA_PRODUCER_CONFIG_PREFIX + "bootstrap.servers", _kafkaBrokers);
_properties.setProperty(KafkaWriterConfigurationKeys.KAFKA_PRODUCER_CONFIG_PREFIX + "value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
// Properties for Consumer
_properties.setProperty("jobSpecMonitor.kafka.zookeeper.connect", zkConnect);
_properties.setProperty(SimpleKafkaSpecExecutor.SPEC_KAFKA_TOPICS_KEY, TOPIC);
_properties.setProperty("gobblin.cluster.jobconf.fullyQualifiedPath", _JOBS_DIR_PATH);
Config config = ConfigUtils.propertiesToConfig(_properties);
// SEI Producer
_seip = _closer.register(new SimpleKafkaSpecProducer(config));
String addedSpecUriString = "/foo/bar/addedSpec";
Spec spec = initJobSpec(addedSpecUriString);
WriteResponse writeResponse = (WriteResponse) _seip.addSpec(spec).get();
log.info("WriteResponse: " + writeResponse);
_jobCatalog = new NonObservingFSJobCatalog(config.getConfig("gobblin.cluster"));
_jobCatalog.startAsync().awaitRunning();
// SEI Consumer
_seic = _closer.register(new StreamingKafkaSpecConsumer(config, _jobCatalog));
_seic.startAsync().awaitRunning();
List<Pair<SpecExecutor.Verb, Spec>> consumedEvent = _seic.changedSpecs().get();
Assert.assertTrue(consumedEvent.size() == 1, "Consumption did not match production");
Map.Entry<SpecExecutor.Verb, Spec> consumedSpecAction = consumedEvent.get(0);
Assert.assertTrue(consumedSpecAction.getKey().equals(SpecExecutor.Verb.ADD), "Verb did not match");
Assert.assertTrue(consumedSpecAction.getValue().getUri().toString().equals(addedSpecUriString), "Expected URI did not match");
Assert.assertTrue(consumedSpecAction.getValue() instanceof JobSpec, "Expected JobSpec");
}
Aggregations