Search in sources :

Example 1 with QueueSpecificationGenerator

use of co.cask.cdap.app.queue.QueueSpecificationGenerator in project cdap by caskdata.

the class SimpleQueueSpecificationGeneratorTest method testQueueSpecificationGenWithWordCount.

@Test
public void testQueueSpecificationGenWithWordCount() throws Exception {
    ApplicationSpecification appSpec = Specifications.from(new WordCountApp());
    ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
    ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
    QueueSpecificationGenerator generator = new SimpleQueueSpecificationGenerator(NamespaceId.DEFAULT.app(newSpec.getName()));
    table = generator.create(newSpec.getFlows().values().iterator().next());
    Assert.assertEquals(get(FlowletConnection.Type.STREAM, "text", "StreamSource").iterator().next().getQueueName().toString(), String.format("stream:///%s/text", TEST_NAMESPACE_ID));
    Assert.assertEquals(get(FlowletConnection.Type.FLOWLET, "StreamSource", "Tokenizer").iterator().next().getQueueName().toString(), String.format("queue:///%s/WordCountApp/WordCountFlow/StreamSource/queue", Id.Namespace.DEFAULT.getId()));
    Assert.assertEquals(1, get(FlowletConnection.Type.FLOWLET, "Tokenizer", "CountByField").size());
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) QueueSpecificationGenerator(co.cask.cdap.app.queue.QueueSpecificationGenerator) ApplicationSpecificationAdapter(co.cask.cdap.internal.app.ApplicationSpecificationAdapter) WordCountApp(co.cask.cdap.WordCountApp) ReflectionSchemaGenerator(co.cask.cdap.internal.io.ReflectionSchemaGenerator) Test(org.junit.Test)

Example 2 with QueueSpecificationGenerator

use of co.cask.cdap.app.queue.QueueSpecificationGenerator in project cdap by caskdata.

the class SimpleQueueSpecificationGeneratorTest method testQueueSpecificationGenWithToyApp.

@Test
public void testQueueSpecificationGenWithToyApp() throws Exception {
    ApplicationSpecification appSpec = Specifications.from(new ToyApp());
    ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
    ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
    QueueSpecificationGenerator generator = new SimpleQueueSpecificationGenerator(NamespaceId.DEFAULT.app(newSpec.getName()));
    table = generator.create(newSpec.getFlows().values().iterator().next());
    dumpConnectionQueue(table);
    // Stream X
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.STREAM, "X", "A"), String.format("stream:///%s/X", TEST_NAMESPACE_ID)));
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.STREAM, "Y", "B"), String.format("stream:///%s/Y", TEST_NAMESPACE_ID)));
    // Node A
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "A", "E"), String.format("queue:///%s/ToyApp/ToyFlow/A/out1", Id.Namespace.DEFAULT.getId())));
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "A", "C"), String.format("queue:///%s/ToyApp/ToyFlow/A/queue", Id.Namespace.DEFAULT.getId())));
    // Node B
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "B", "E"), String.format("queue:///%s/ToyApp/ToyFlow/B/queue", Id.Namespace.DEFAULT.getId())));
    // Node C
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "C", "D"), String.format("queue:///%s/ToyApp/ToyFlow/C/c1", Id.Namespace.DEFAULT.getId())));
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "C", "F"), String.format("queue:///%s/ToyApp/ToyFlow/C/c2", Id.Namespace.DEFAULT.getId())));
    // Node D
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "D", "G"), String.format("queue:///%s/ToyApp/ToyFlow/D/d1", Id.Namespace.DEFAULT.getId())));
    // Node E
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "E", "G"), String.format("queue:///%s/ToyApp/ToyFlow/E/queue", Id.Namespace.DEFAULT.getId())));
    // Node F
    Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "F", "G"), String.format("queue:///%s/ToyApp/ToyFlow/F/f1", Id.Namespace.DEFAULT.getId())));
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) QueueSpecificationGenerator(co.cask.cdap.app.queue.QueueSpecificationGenerator) ApplicationSpecificationAdapter(co.cask.cdap.internal.app.ApplicationSpecificationAdapter) ToyApp(co.cask.cdap.ToyApp) ReflectionSchemaGenerator(co.cask.cdap.internal.io.ReflectionSchemaGenerator) Test(org.junit.Test)

Aggregations

ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)2 QueueSpecificationGenerator (co.cask.cdap.app.queue.QueueSpecificationGenerator)2 ApplicationSpecificationAdapter (co.cask.cdap.internal.app.ApplicationSpecificationAdapter)2 ReflectionSchemaGenerator (co.cask.cdap.internal.io.ReflectionSchemaGenerator)2 Test (org.junit.Test)2 ToyApp (co.cask.cdap.ToyApp)1 WordCountApp (co.cask.cdap.WordCountApp)1