Search in sources :

Example 1 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class ClusterBasedJobCoordinator method main.

/**
   * The entry point for the {@link ClusterBasedJobCoordinator}
   * @param args args
   */
public static void main(String[] args) {
    Config coordinatorSystemConfig = null;
    final String coordinatorSystemEnv = System.getenv(ShellCommandConfig.ENV_COORDINATOR_SYSTEM_CONFIG());
    try {
        //Read and parse the coordinator system config.
        log.info("Parsing coordinator system config {}", coordinatorSystemEnv);
        coordinatorSystemConfig = new MapConfig(SamzaObjectMapper.getObjectMapper().readValue(coordinatorSystemEnv, Config.class));
    } catch (IOException e) {
        log.error("Exception while reading coordinator stream config {}", e);
        throw new SamzaException(e);
    }
    ClusterBasedJobCoordinator jc = new ClusterBasedJobCoordinator(coordinatorSystemConfig);
    jc.run();
}
Also used : ClusterManagerConfig(org.apache.samza.config.ClusterManagerConfig) ShellCommandConfig(org.apache.samza.config.ShellCommandConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) IOException(java.io.IOException) SamzaException(org.apache.samza.SamzaException)

Example 2 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class TestExecutionPlanner method testTriggerIntervalWithInvalidWindowMs.

@Test
public void testTriggerIntervalWithInvalidWindowMs() throws Exception {
    Map<String, String> map = new HashMap<>(config);
    map.put(TaskConfig.WINDOW_MS(), "-1");
    map.put(JobConfig.JOB_INTERMEDIATE_STREAM_PARTITIONS(), String.valueOf(DEFAULT_PARTITIONS));
    Config cfg = new MapConfig(map);
    ExecutionPlanner planner = new ExecutionPlanner(cfg, streamManager);
    StreamGraphImpl streamGraph = createStreamGraphWithJoinAndWindow();
    ExecutionPlan plan = planner.plan(streamGraph);
    List<JobConfig> jobConfigs = plan.getJobConfigs();
    assertEquals(jobConfigs.size(), 1);
    // GCD of 8, 16, 1600 and 252 is 4
    assertEquals(jobConfigs.get(0).get(TaskConfig.WINDOW_MS()), "4");
}
Also used : HashMap(java.util.HashMap) JobConfig(org.apache.samza.config.JobConfig) MapConfig(org.apache.samza.config.MapConfig) TaskConfig(org.apache.samza.config.TaskConfig) Config(org.apache.samza.config.Config) StreamGraphImpl(org.apache.samza.operators.StreamGraphImpl) MapConfig(org.apache.samza.config.MapConfig) JobConfig(org.apache.samza.config.JobConfig) Test(org.junit.Test)

Example 3 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class TestContainerProcessManager method testAppMasterWithFwk.

@Test
public void testAppMasterWithFwk() {
    ContainerProcessManager taskManager = new ContainerProcessManager(new MapConfig(config), state, new MetricsRegistryMap(), manager);
    taskManager.start();
    SamzaResource container2 = new SamzaResource(1, 1024, "", "id0");
    assertFalse(taskManager.shouldShutdown());
    taskManager.onResourceAllocated(container2);
    configVals.put(JobConfig.SAMZA_FWK_PATH(), "/export/content/whatever");
    Config config1 = new MapConfig(configVals);
    ContainerProcessManager taskManager1 = new ContainerProcessManager(new MapConfig(config), state, new MetricsRegistryMap(), manager);
    taskManager1.start();
    taskManager1.onResourceAllocated(container2);
}
Also used : JobConfig(org.apache.samza.config.JobConfig) MapConfig(org.apache.samza.config.MapConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) Test(org.junit.Test)

Example 4 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class TestContainerProcessManager method testTaskManagerShouldStopWhenContainersFinish.

/**
   * Test Task Manager should stop when all containers finish
   */
@Test
public void testTaskManagerShouldStopWhenContainersFinish() {
    Config conf = getConfig();
    ContainerProcessManager taskManager = new ContainerProcessManager(new MapConfig(conf), state, new MetricsRegistryMap(), manager);
    taskManager.start();
    assertFalse(taskManager.shouldShutdown());
    taskManager.onResourceCompleted(new SamzaResourceStatus("123", "diagnostics", SamzaResourceStatus.SUCCESS));
    assertTrue(taskManager.shouldShutdown());
}
Also used : JobConfig(org.apache.samza.config.JobConfig) MapConfig(org.apache.samza.config.MapConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) Test(org.junit.Test)

Example 5 with MapConfig

use of org.apache.samza.config.MapConfig in project samza by apache.

the class TestContainerAllocator method getConfig.

private static Config getConfig() {
    Config config = new MapConfig(new HashMap<String, String>() {

        {
            put("yarn.container.count", "1");
            put("systems.test-system.samza.factory", "org.apache.samza.job.yarn.MockSystemFactory");
            put("yarn.container.memory.mb", "512");
            put("yarn.package.path", "/foo");
            put("task.inputs", "test-system.test-stream");
            put("systems.test-system.samza.key.serde", "org.apache.samza.serializers.JsonSerde");
            put("systems.test-system.samza.msg.serde", "org.apache.samza.serializers.JsonSerde");
            put("yarn.container.retry.count", "1");
            put("yarn.container.retry.window.ms", "1999999999");
            put("yarn.allocator.sleep.ms", "10");
        }
    });
    Map<String, String> map = new HashMap<>();
    map.putAll(config);
    return new MapConfig(map);
}
Also used : HashMap(java.util.HashMap) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) 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