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();
}
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"));
}
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));
}
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);
}
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);
}
Aggregations