use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestJobNodeConfigurationGenerator method testStreamApplicationWithTableAndSideInput.
@Test
public void testStreamApplicationWithTableAndSideInput() {
mockStreamAppDesc = new StreamApplicationDescriptorImpl(getRepartitionJoinStreamApplication(), mockConfig);
// add table to the RepartitionJoinStreamApplication
GenericInputDescriptor<KV<String, Object>> sideInput1 = inputSystemDescriptor.getInputDescriptor("sideInput1", defaultSerde);
BaseTableDescriptor mockTableDescriptor = new MockLocalTableDescriptor("testTable", defaultSerde).withSideInputs(Arrays.asList(sideInput1.getStreamId())).withSideInputsProcessor(mock(SideInputsProcessor.class, withSettings().serializable())).withConfig("mock.table.provider.config", "mock.config.value");
// add side input and terminate at table in the appplication
mockStreamAppDesc.getInputStream(sideInput1).sendTo(mockStreamAppDesc.getTable(mockTableDescriptor));
StreamEdge sideInputEdge = new StreamEdge(new StreamSpec(sideInput1.getStreamId(), "sideInput1", inputSystemDescriptor.getSystemName()), false, false, mockConfig);
// need to put the sideInput related stream configuration to the original config
// TODO: this is confusing since part of the system and stream related configuration is generated outside the JobGraphConfigureGenerator
// It would be nice if all system and stream related configuration is generated in one place and only intermediate stream
// configuration is generated by JobGraphConfigureGenerator
Map<String, String> configs = new HashMap<>(mockConfig);
configs.putAll(sideInputEdge.generateConfig());
mockConfig = spy(new MapConfig(configs));
configureJobNode(mockStreamAppDesc);
// create the JobGraphConfigureGenerator and generate the jobConfig for the jobNode
JobNodeConfigurationGenerator configureGenerator = new JobNodeConfigurationGenerator();
JobConfig jobConfig = configureGenerator.generateJobConfig(mockJobNode, "testJobGraphJson");
Config expectedJobConfig = getExpectedJobConfig(mockConfig, mockJobNode.getInEdges());
validateJobConfig(expectedJobConfig, jobConfig);
Map<String, Serde> deserializedSerdes = validateAndGetDeserializedSerdes(jobConfig, 5);
validateTableConfigure(jobConfig, deserializedSerdes, mockTableDescriptor);
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class ExecutionPlannerTestBase method setUp.
@Before
public void setUp() {
defaultSerde = KVSerde.of(new StringSerde(), new JsonSerdeV2<>());
inputSystemDescriptor = new GenericSystemDescriptor("input-system", "mockSystemFactoryClassName");
outputSystemDescriptor = new GenericSystemDescriptor("output-system", "mockSystemFactoryClassName");
intermediateSystemDescriptor = new GenericSystemDescriptor("intermediate-system", "mockSystemFactoryClassName");
input1Descriptor = inputSystemDescriptor.getInputDescriptor("input1", defaultSerde);
input2Descriptor = inputSystemDescriptor.getInputDescriptor("input2", defaultSerde);
outputDescriptor = outputSystemDescriptor.getOutputDescriptor("output", defaultSerde);
intermediateInputDescriptor = intermediateSystemDescriptor.getInputDescriptor("jobName-jobId-partition_by-p1", defaultSerde).withPhysicalName("jobName-jobId-partition_by-p1");
intermediateOutputDescriptor = intermediateSystemDescriptor.getOutputDescriptor("jobName-jobId-partition_by-p1", defaultSerde).withPhysicalName("jobName-jobId-partition_by-p1");
broadcastInputDesriptor = intermediateSystemDescriptor.getInputDescriptor("jobName-jobId-broadcast-b1", defaultSerde).withPhysicalName("jobName-jobId-broadcast-b1");
Map<String, String> configs = new HashMap<>();
configs.put(JobConfig.JOB_NAME, "jobName");
configs.put(JobConfig.JOB_ID, "jobId");
configs.putAll(input1Descriptor.toConfig());
configs.putAll(input2Descriptor.toConfig());
configs.putAll(outputDescriptor.toConfig());
configs.putAll(inputSystemDescriptor.toConfig());
configs.putAll(outputSystemDescriptor.toConfig());
configs.putAll(intermediateSystemDescriptor.toConfig());
configs.put(JobConfig.JOB_DEFAULT_SYSTEM, intermediateSystemDescriptor.getSystemName());
mockConfig = spy(new MapConfig(configs));
mockStreamAppDesc = new StreamApplicationDescriptorImpl(getRepartitionJoinStreamApplication(), mockConfig);
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestJobGraph method createGraph4.
/**
* graph4 is a graph of single-loop node
* 1<->1
*/
private void createGraph4() {
StreamApplicationDescriptorImpl appDesc = mock(StreamApplicationDescriptorImpl.class);
graph4 = new JobGraph(new MapConfig(), appDesc);
JobNode n1 = graph4.getOrCreateJobNode("1", "1");
graph4.addInputStream(genStream(), n1);
graph4.addIntermediateStream(genStream(), n1, n1);
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestJobGraph method testAddSink.
@Test
public void testAddSink() {
/**
* 1 -> s1
* 2 -> s2
* 2 -> s3
*/
StreamApplicationDescriptorImpl appDesc = mock(StreamApplicationDescriptorImpl.class);
JobGraph graph = new JobGraph(new MapConfig(), appDesc);
JobNode n1 = graph.getOrCreateJobNode("1", "1");
JobNode n2 = graph.getOrCreateJobNode("2", "1");
StreamSpec s1 = genStream();
StreamSpec s2 = genStream();
StreamSpec s3 = genStream();
graph.addOutputStream(s1, n1);
graph.addOutputStream(s2, n2);
graph.addOutputStream(s3, n2);
assertTrue(graph.getOutputStreams().size() == 3);
assertTrue(graph.getOrCreateJobNode("1", "1").getOutEdges().size() == 1);
assertTrue(graph.getOrCreateJobNode("2", "1").getOutEdges().size() == 2);
assertTrue(graph.getOrCreateStreamEdge(s1).getSourceNodes().size() == 1);
assertTrue(graph.getOrCreateStreamEdge(s1).getTargetNodes().size() == 0);
assertTrue(graph.getOrCreateStreamEdge(s2).getSourceNodes().size() == 1);
assertTrue(graph.getOrCreateStreamEdge(s2).getTargetNodes().size() == 0);
assertTrue(graph.getOrCreateStreamEdge(s3).getSourceNodes().size() == 1);
assertTrue(graph.getOrCreateStreamEdge(s3).getTargetNodes().size() == 0);
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestJobNodeConfigurationGenerator method testConfigureSerdesWithRepartitionJoinApplication.
@Test
public void testConfigureSerdesWithRepartitionJoinApplication() {
mockStreamAppDesc = new StreamApplicationDescriptorImpl(getRepartitionJoinStreamApplication(), mockConfig);
configureJobNode(mockStreamAppDesc);
// create the JobGraphConfigureGenerator and generate the jobConfig for the jobNode
JobNodeConfigurationGenerator configureGenerator = new JobNodeConfigurationGenerator();
JobConfig jobConfig = configureGenerator.generateJobConfig(mockJobNode, "testJobGraphJson");
// Verify the results
Config expectedJobConfig = getExpectedJobConfig(mockConfig, mockJobNode.getInEdges());
validateJobConfig(expectedJobConfig, jobConfig);
// additional, check the computed window.ms for join
assertEquals("3600000", jobConfig.get(TaskConfig.WINDOW_MS));
Map<String, Serde> deserializedSerdes = validateAndGetDeserializedSerdes(jobConfig, 5);
validateStreamConfigures(jobConfig, deserializedSerdes);
validateJoinStoreConfigures(jobConfig, deserializedSerdes);
}
Aggregations