Search in sources :

Example 96 with MapConfig

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());
}
Also used : SystemFactory(org.apache.samza.system.SystemFactory) MetricsRegistry(org.apache.samza.metrics.MetricsRegistry) DiagnosticsManager(org.apache.samza.diagnostics.DiagnosticsManager) MetricsConfig(org.apache.samza.config.MetricsConfig) JobConfig(org.apache.samza.config.JobConfig) SystemConfig(org.apache.samza.config.SystemConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) SystemProducer(org.apache.samza.system.SystemProducer) JobModel(org.apache.samza.job.model.JobModel) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 97 with MapConfig

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));
}
Also used : HashMap(java.util.HashMap) JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 98 with MapConfig

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);
}
Also used : MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 99 with MapConfig

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));
}
Also used : HashMap(java.util.HashMap) MapConfig(org.apache.samza.config.MapConfig)

Example 100 with MapConfig

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");
                });
            }
        }
    });
}
Also used : ConfigUtil(org.apache.samza.util.ConfigUtil) TableDescriptor(org.apache.samza.table.descriptors.TableDescriptor) LoggerFactory(org.slf4j.LoggerFactory) JobConfig(org.apache.samza.config.JobConfig) HashMap(java.util.HashMap) JoinOperatorSpec(org.apache.samza.operators.spec.JoinOperatorSpec) Serde(org.apache.samza.serializers.Serde) LocalTableDescriptor(org.apache.samza.table.descriptors.LocalTableDescriptor) StringUtils(org.apache.commons.lang3.StringUtils) StreamConfig(org.apache.samza.config.StreamConfig) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OperatorSpec(org.apache.samza.operators.spec.OperatorSpec) Map(java.util.Map) ApplicationConfig(org.apache.samza.config.ApplicationConfig) StreamUtil(org.apache.samza.util.StreamUtil) MapConfig(org.apache.samza.config.MapConfig) KV(org.apache.samza.operators.KV) NoOpSerde(org.apache.samza.serializers.NoOpSerde) SerializableSerde(org.apache.samza.serializers.SerializableSerde) StorageConfig(org.apache.samza.config.StorageConfig) Logger(org.slf4j.Logger) SerializerConfig(org.apache.samza.config.SerializerConfig) TaskConfig(org.apache.samza.config.TaskConfig) Collection(java.util.Collection) Set(java.util.Set) WindowOperatorSpec(org.apache.samza.operators.spec.WindowOperatorSpec) UUID(java.util.UUID) JavaTableConfig(org.apache.samza.config.JavaTableConfig) Collectors(java.util.stream.Collectors) SamzaException(org.apache.samza.SamzaException) StoreDescriptor(org.apache.samza.operators.spec.StoreDescriptor) Objects(java.util.Objects) Base64(java.util.Base64) List(java.util.List) StatefulOperatorSpec(org.apache.samza.operators.spec.StatefulOperatorSpec) Config(org.apache.samza.config.Config) MathUtil(org.apache.samza.util.MathUtil) TableConfigGenerator(org.apache.samza.table.TableConfigGenerator) Joiner(com.google.common.base.Joiner) LocalTableDescriptor(org.apache.samza.table.descriptors.LocalTableDescriptor) ArrayList(java.util.ArrayList) MapConfig(org.apache.samza.config.MapConfig)

Aggregations

MapConfig (org.apache.samza.config.MapConfig)496 Test (org.junit.Test)402 Config (org.apache.samza.config.Config)294 HashMap (java.util.HashMap)216 SamzaSqlTestConfig (org.apache.samza.sql.util.SamzaSqlTestConfig)98 SamzaSqlApplicationConfig (org.apache.samza.sql.runner.SamzaSqlApplicationConfig)97 JobConfig (org.apache.samza.config.JobConfig)91 Map (java.util.Map)75 ApplicationConfig (org.apache.samza.config.ApplicationConfig)65 SystemStreamPartition (org.apache.samza.system.SystemStreamPartition)57 SamzaSqlValidator (org.apache.samza.sql.planner.SamzaSqlValidator)55 TaskName (org.apache.samza.container.TaskName)52 HashSet (java.util.HashSet)51 List (java.util.List)51 Set (java.util.Set)49 Partition (org.apache.samza.Partition)49 ArrayList (java.util.ArrayList)48 StreamApplicationDescriptorImpl (org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl)48 TaskConfig (org.apache.samza.config.TaskConfig)45 StreamConfig (org.apache.samza.config.StreamConfig)43