use of org.apache.samza.config.MapConfig in project samza by apache.
the class TestDiagnosticsUtil method testBuildDiagnosticsManager.
@Test
public void testBuildDiagnosticsManager() {
Config config = new MapConfig(buildTestConfigs());
JobModel mockJobModel = mock(JobModel.class);
SystemFactory systemFactory = mock(SystemFactory.class);
SystemProducer mockProducer = mock(SystemProducer.class);
when(systemFactory.getProducer(anyString(), any(Config.class), any(MetricsRegistry.class), anyString())).thenReturn(mockProducer);
PowerMockito.mockStatic(ReflectionUtil.class);
when(ReflectionUtil.getObj(SYSTEM_FACTORY, SystemFactory.class)).thenReturn(systemFactory);
Optional<DiagnosticsManager> diagnosticsManager = DiagnosticsUtil.buildDiagnosticsManager(JOB_NAME, JOB_ID, mockJobModel, CONTAINER_ID, Optional.of(ENV_ID), Optional.of(SAMZA_EPOCH_ID), config);
Assert.assertTrue(diagnosticsManager.isPresent());
}
use of org.apache.samza.config.MapConfig in project samza by apache.
the class TestDefaultCoordinatorStreamConfigFactory method testBuildCoordinatorStreamConfigWithJobName.
@Test
public void testBuildCoordinatorStreamConfigWithJobName() {
Map<String, String> mapConfig = new HashMap<>();
mapConfig.put("job.name", "testName");
mapConfig.put("job.id", "testId");
mapConfig.put("job.coordinator.system", "testSamza");
mapConfig.put("test.only", "nothing");
mapConfig.put("systems.testSamza.test", "test");
Config config = factory.buildCoordinatorStreamConfig(new MapConfig(mapConfig));
Map<String, String> expectedMap = new HashMap<>();
expectedMap.put("job.name", "testName");
expectedMap.put("job.id", "testId");
expectedMap.put("systems.testSamza.test", "test");
expectedMap.put(JobConfig.JOB_COORDINATOR_SYSTEM, "testSamza");
expectedMap.put(JobConfig.MONITOR_PARTITION_CHANGE_FREQUENCY_MS, "300000");
assertEquals(config, new MapConfig(expectedMap));
}
use of org.apache.samza.config.MapConfig in project samza by apache.
the class TestConfigUtil method testApplyRewriterNoClassForConfigRewriterName.
@Test(expected = SamzaException.class)
public void testApplyRewriterNoClassForConfigRewriterName() {
Map<String, String> fullConfig = ImmutableMap.of(CONFIG_KEY, CONFIG_VALUE);
ConfigUtil.applyRewriter(new MapConfig(fullConfig), REWRITER_NAME);
}
use of org.apache.samza.config.MapConfig in project samza by apache.
the class JobNodeConfigurationGenerator method mergeConfig.
static Config mergeConfig(Map<String, String> originalConfig, Map<String, String> generatedConfig) {
validateJobConfigs(originalConfig, generatedConfig);
Map<String, String> mergedConfig = new HashMap<>(generatedConfig);
originalConfig.forEach((k, v) -> {
if (generatedConfig.containsKey(k) && !Objects.equals(generatedConfig.get(k), v)) {
LOG.info("Replacing generated config for key: {} value: {} with original config value: {}", k, generatedConfig.get(k), v);
}
mergedConfig.put(k, v);
});
return ConfigUtil.rewriteConfig(new MapConfig(mergedConfig));
}
use of org.apache.samza.config.MapConfig in project samza by apache.
the class JobNodeConfigurationGenerator method configureTables.
private void configureTables(Map<String, String> generatedConfig, Config originalConfig, Map<String, TableDescriptor> tables, Set<String> inputs) {
generatedConfig.putAll(TableConfigGenerator.generate(new MapConfig(generatedConfig), new ArrayList<>(tables.values())));
// Add side inputs to the inputs and mark the stream as bootstrap
tables.values().forEach(tableDescriptor -> {
if (tableDescriptor instanceof LocalTableDescriptor) {
LocalTableDescriptor localTableDescriptor = (LocalTableDescriptor) tableDescriptor;
List<String> sideInputs = localTableDescriptor.getSideInputs();
if (sideInputs != null && !sideInputs.isEmpty()) {
sideInputs.stream().map(sideInput -> StreamUtil.getSystemStreamFromNameOrId(originalConfig, sideInput)).forEach(systemStream -> {
inputs.add(StreamUtil.getNameFromSystemStream(systemStream));
generatedConfig.put(String.format(StreamConfig.STREAM_PREFIX + StreamConfig.BOOTSTRAP, systemStream.getSystem(), systemStream.getStream()), "true");
});
}
}
});
}
Aggregations