Search in sources :

Example 21 with MapConfig

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

the class TestContainerProcessManager method testOnInitAMHighAvailability.

@Test
public void testOnInitAMHighAvailability() throws Exception {
    Map<String, String> configMap = new HashMap<>(configVals);
    configMap.put(JobConfig.YARN_AM_HIGH_AVAILABILITY_ENABLED, "true");
    Config conf = new MapConfig(configMap);
    SamzaApplicationState state = new SamzaApplicationState(getJobModelManager(2));
    state.runningProcessors.put("0", new SamzaResource(1, 1024, "host", "0"));
    MockClusterResourceManagerCallback callback = new MockClusterResourceManagerCallback();
    ClusterResourceManager clusterResourceManager = new MockClusterResourceManager(callback, state);
    ClusterManagerConfig clusterManagerConfig = spy(new ClusterManagerConfig(conf));
    ContainerManager containerManager = buildContainerManager(containerPlacementMetadataStore, state, clusterResourceManager, clusterManagerConfig.getHostAffinityEnabled(), false);
    ContainerProcessManager cpm = buildContainerProcessManager(clusterManagerConfig, state, clusterResourceManager, Optional.empty());
    MockContainerAllocatorWithoutHostAffinity allocator = new MockContainerAllocatorWithoutHostAffinity(clusterResourceManager, conf, state, containerManager);
    getPrivateFieldFromCpm("containerAllocator", cpm).set(cpm, allocator);
    CountDownLatch latch = new CountDownLatch(1);
    getPrivateFieldFromCpm("allocatorThread", cpm).set(cpm, new Thread() {

        public void run() {
            isRunning = true;
            latch.countDown();
        }
    });
    cpm.start();
    if (!latch.await(2, TimeUnit.SECONDS)) {
        Assert.fail("timed out waiting for the latch to expire");
    }
    // Verify Allocator thread has started running
    assertTrue(isRunning);
    // Verify only 1 was requested with allocator
    assertEquals(1, allocator.requestedContainers);
    assertTrue("Ensure no processors were forcefully restarted", callback.resourceStatuses.isEmpty());
    cpm.stop();
}
Also used : HashMap(java.util.HashMap) JobConfig(org.apache.samza.config.JobConfig) ClusterManagerConfig(org.apache.samza.config.ClusterManagerConfig) MapConfig(org.apache.samza.config.MapConfig) Config(org.apache.samza.config.Config) Matchers.anyString(org.mockito.Matchers.anyString) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterManagerConfig(org.apache.samza.config.ClusterManagerConfig) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 22 with MapConfig

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

the class TestPropertiesConfigLoader method testCanReadPropertiesConfigFiles.

@Test
public void testCanReadPropertiesConfigFiles() {
    ConfigLoader loader = new PropertiesConfigLoaderFactory().getLoader(new MapConfig(Collections.singletonMap("path", getClass().getResource("/test.properties").getPath())));
    Config config = loader.getConfig();
    assertEquals("bar", config.get("foo"));
}
Also used : ConfigLoader(org.apache.samza.config.ConfigLoader) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 23 with MapConfig

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

the class TestContainerHeartbeatMonitor method buildContainerHeartbeatMonitor.

private ContainerHeartbeatMonitor buildContainerHeartbeatMonitor(boolean enableAMHighAvailability) {
    Map<String, String> configMap = new HashMap<>();
    configMap.put(JobConfig.YARN_AM_HIGH_AVAILABILITY_ENABLED, String.valueOf(enableAMHighAvailability));
    configMap.put(JobConfig.YARN_CONTAINER_HEARTBEAT_RETRY_COUNT, "5");
    configMap.put(JobConfig.YARN_CONTAINER_HEARTBEAT_RETRY_SLEEP_DURATION_MS, "10");
    return new ContainerHeartbeatMonitor(this.onExpired, this.containerHeartbeatClient, this.scheduler, COORDINATOR_URL, CONTAINER_EXECUTION_ID, coordinatorStreamStore, new MapConfig(configMap));
}
Also used : HashMap(java.util.HashMap) MapConfig(org.apache.samza.config.MapConfig)

Example 24 with MapConfig

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

the class TestGroupBySystemStreamPartition method testBroadcastStreamGroupedCorrectly.

@Test
public void testBroadcastStreamGroupedCorrectly() {
    Config config = new MapConfig(ImmutableMap.of("task.broadcast.inputs", "SystemA.StreamA#0"));
    SystemStreamPartitionGrouper grouper = new GroupBySystemStreamPartition(config);
    Map<TaskName, Set<SystemStreamPartition>> result = grouper.group(ImmutableSet.of(aa0, aa1, aa2, ac0));
    Map<TaskName, Set<SystemStreamPartition>> expectedResult = ImmutableMap.<TaskName, Set<SystemStreamPartition>>builder().put(new TaskName(aa1.toString()), ImmutableSet.of(aa1, aa0)).put(new TaskName(aa2.toString()), ImmutableSet.of(aa2, aa0)).put(new TaskName(ac0.toString()), ImmutableSet.of(ac0, aa0)).build();
    assertEquals(expectedResult, result);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashSet(java.util.HashSet) TaskName(org.apache.samza.container.TaskName) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Example 25 with MapConfig

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

the class TestGroupBySystemStreamPartition method testLocalStreamGroupedCorrectly.

@Test
public void testLocalStreamGroupedCorrectly() {
    SystemStreamPartitionGrouper grouper = grouperFactory.getSystemStreamPartitionGrouper(new MapConfig());
    Map<TaskName, Set<SystemStreamPartition>> emptyResult = grouper.group(new HashSet<>());
    assertTrue(emptyResult.isEmpty());
    Map<TaskName, Set<SystemStreamPartition>> result = grouper.group(ImmutableSet.of(aa0, aa1, aa2, ac0));
    Map<TaskName, Set<SystemStreamPartition>> expectedResult = ImmutableMap.<TaskName, Set<SystemStreamPartition>>builder().put(new TaskName(aa0.toString()), ImmutableSet.of(aa0)).put(new TaskName(aa1.toString()), ImmutableSet.of(aa1)).put(new TaskName(aa2.toString()), ImmutableSet.of(aa2)).put(new TaskName(ac0.toString()), ImmutableSet.of(ac0)).build();
    assertEquals(expectedResult, result);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashSet(java.util.HashSet) TaskName(org.apache.samza.container.TaskName) MapConfig(org.apache.samza.config.MapConfig) SystemStreamPartition(org.apache.samza.system.SystemStreamPartition) Test(org.junit.Test)

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