use of org.apache.samza.table.descriptors.BaseTableDescriptor 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.table.descriptors.BaseTableDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetTable.
@Test
public void testGetTable() throws Exception {
Config mockConfig = getConfig();
String tableId = "t1";
BaseTableDescriptor mockTableDescriptor = mock(BaseTableDescriptor.class);
when(mockTableDescriptor.getTableId()).thenReturn(tableId);
AtomicReference<TableImpl> table = new AtomicReference<>();
StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(appDesc -> {
table.set((TableImpl) appDesc.getTable(mockTableDescriptor));
}, mockConfig);
assertEquals(tableId, table.get().getTableId());
}
use of org.apache.samza.table.descriptors.BaseTableDescriptor in project samza by apache.
the class TestStreamApplicationDescriptorImpl method testGetTableWithBadId.
@Test(expected = IllegalStateException.class)
public void testGetTableWithBadId() {
Config mockConfig = getConfig();
new StreamApplicationDescriptorImpl(appDesc -> {
BaseTableDescriptor mockTableDescriptor = mock(BaseTableDescriptor.class);
when(mockTableDescriptor.getTableId()).thenReturn("my.table");
appDesc.getTable(mockTableDescriptor);
}, mockConfig);
}
use of org.apache.samza.table.descriptors.BaseTableDescriptor in project samza by apache.
the class TestCachingTable method createDummyTableDescriptor.
private TableDescriptor createDummyTableDescriptor(String tableId) {
BaseTableDescriptor tableDescriptor = mock(BaseTableDescriptor.class);
when(tableDescriptor.getTableId()).thenReturn(tableId);
return tableDescriptor;
}
use of org.apache.samza.table.descriptors.BaseTableDescriptor in project samza by apache.
the class TestJobNodeConfigurationGenerator method testTaskApplicationWithTableAndSideInput.
@Test
public void testTaskApplicationWithTableAndSideInput() {
// 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");
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));
// set the application to TaskApplication, which still wire up all input/output/intermediate streams
TaskApplicationDescriptorImpl taskAppDesc = new TaskApplicationDescriptorImpl(getTaskApplication(), mockConfig);
// add table to the task application
taskAppDesc.withTable(mockTableDescriptor);
taskAppDesc.withInputStream(inputSystemDescriptor.getInputDescriptor("sideInput1", defaultSerde));
configureJobNode(taskAppDesc);
// 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, deserializedSerdes);
validateTableConfigure(jobConfig, deserializedSerdes, mockTableDescriptor);
}
Aggregations