use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestExecutionPlanner method testCalculateInStreamPartitionsBehindTablesWithSideInputs.
@Test
public void testCalculateInStreamPartitionsBehindTablesWithSideInputs() {
ExecutionPlanner planner = new ExecutionPlanner(config, streamManager);
StreamApplicationDescriptorImpl graphSpec = createStreamGraphWithStreamTableJoinWithSideInputs();
JobGraph jobGraph = (JobGraph) planner.plan(graphSpec);
// Partitions should be the same as input1
jobGraph.getIntermediateStreams().forEach(edge -> {
assertEquals(64, edge.getPartitionCount());
});
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestExecutionPlanner method testCalculateOrderSensitiveJoinInputPartitions.
@Test
public void testCalculateOrderSensitiveJoinInputPartitions() {
// This test ensures that the ExecutionPlanner can handle groups of joined stream edges
// in the correct order. It creates an example stream-stream join application that has
// the following sets of joined streams (notice the order):
//
// a. e1 (16), e2` (?)
// b. e3` (?), e4` (?)
// c. e2` (?), e3` (?)
//
// If processed in the above order, the ExecutionPlanner will fail to assign the partitions
// correctly.
ExecutionPlanner planner = new ExecutionPlanner(config, streamManager);
StreamApplicationDescriptorImpl graphSpec = createStreamGraphWithComplexStreamStreamJoin();
JobGraph jobGraph = (JobGraph) planner.plan(graphSpec);
// Partitions should be the same as input1
jobGraph.getIntermediateStreams().forEach(edge -> {
assertEquals(64, edge.getPartitionCount());
});
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestExecutionPlanner method createStreamGraphWithInvalidStreamTableJoinWithSideInputs.
private StreamApplicationDescriptorImpl createStreamGraphWithInvalidStreamTableJoinWithSideInputs() {
/**
* Example stream-table join that is invalid due to disagreement in partition count between the
* stream behind table t and another joined stream. Table t is configured with input2 (16) as
* side-input stream.
*
* join-table t -> output1 (8)
* |
* input1 (64) —————————
*/
return new StreamApplicationDescriptorImpl(appDesc -> {
MessageStream<KV<Object, Object>> messageStream1 = appDesc.getInputStream(input1Descriptor);
OutputStream<KV<Object, Object>> output1 = appDesc.getOutputStream(output1Descriptor);
TableDescriptor tableDescriptor = new TestLocalTableDescriptor.MockLocalTableDescriptor("table-id", new KVSerde(new StringSerde(), new StringSerde())).withSideInputs(Arrays.asList("input2")).withSideInputsProcessor(mock(SideInputsProcessor.class));
Table table = appDesc.getTable(tableDescriptor);
messageStream1.join(table, mock(StreamTableJoinFunction.class)).sendTo(output1);
}, config);
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestJobNodeConfigurationGenerator method testConfigRewriter.
@Test
public void testConfigRewriter() {
Map<String, String> configs = new HashMap<>(mockConfig);
String streamCfgToOverride = String.format("streams.%s.samza.system", intermediateInputDescriptor.getStreamId());
configs.put(String.format(JobConfig.CONFIG_REWRITER_CLASS, "mock"), MockConfigRewriter.class.getName());
configs.put(JobConfig.CONFIG_REWRITERS, "mock");
configs.put(String.format("job.config.rewriter.mock.%s", streamCfgToOverride), "rewritten-system");
mockConfig = spy(new MapConfig(configs));
mockStreamAppDesc = new StreamApplicationDescriptorImpl(getRepartitionJoinStreamApplication(), mockConfig);
configureJobNode(mockStreamAppDesc);
JobNodeConfigurationGenerator configureGenerator = new JobNodeConfigurationGenerator();
JobConfig jobConfig = configureGenerator.generateJobConfig(mockJobNode, "testJobGraphJson");
Config expectedConfig = getExpectedJobConfig(mockConfig, mockJobNode.getInEdges());
validateJobConfig(expectedConfig, jobConfig);
assertEquals("rewritten-system", jobConfig.get(streamCfgToOverride));
}
use of org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl in project samza by apache.
the class TestJobNodeConfigurationGenerator method testConfigureSerdesForRepartitionWithNoDefaultSystem.
@Test
public void testConfigureSerdesForRepartitionWithNoDefaultSystem() {
// set the application to RepartitionOnlyStreamApplication
mockStreamAppDesc = new StreamApplicationDescriptorImpl(getRepartitionOnlyStreamApplication(), 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);
Map<String, Serde> deserializedSerdes = validateAndGetDeserializedSerdes(jobConfig, 2);
validateStreamConfigures(jobConfig, null);
String partitionByKeySerde = jobConfig.get("streams.jobName-jobId-partition_by-p1.samza.key.serde");
String partitionByMsgSerde = jobConfig.get("streams.jobName-jobId-partition_by-p1.samza.msg.serde");
assertTrue("Serialized serdes should not contain intermediate stream key serde", !deserializedSerdes.containsKey(partitionByKeySerde));
assertTrue("Serialized serdes should not contain intermediate stream msg serde", !deserializedSerdes.containsKey(partitionByMsgSerde));
}
Aggregations