Sanil15 commented on a change in pull request #1170: Samza-2330: Handle expired
resource request for Container allocator when host affinity is disabled
URL: https://github.com/apache/samza/pull/1170#discussion_r331206220
##########
File path:
samza-core/src/test/java/org/apache/samza/clustermanager/TestContainerAllocatorWithoutHostAffinity.java
##########
@@ -290,4 +292,53 @@ public void testRequestAllocationWithRunStreamProcessor()
throws Exception {
assertTrue(state.preferredHostRequests.get() == 0);
spyAllocator.stop();
}
+
+ @Test
+ public void testExpiredRequestAllocationOnAnyHost() throws Exception {
+ MockClusterResourceManager spyManager = spy(new
MockClusterResourceManager(callback, state));
+ spyAllocator = Mockito.spy(
+ new ContainerAllocator(spyManager, config, state, false,
Optional.empty()));
+
+ // Request Resources
+ spyAllocator.requestResources(new HashMap<String, String>() {
+ {
+ put("0", "abc");
+ put("1", "def");
+ }
+ });
+
+ spyThread = new Thread(spyAllocator);
+ // Start the container allocator thread periodic assignment
+ spyThread.start();
+
+ // Let the request expire, expiration timeout is 3 ms
+ Thread.sleep(20);
+
+ // Verify that all the request that were created as ANY_HOST host
+ // and all created requests expired
+ assertEquals(state.preferredHostRequests.get(), 0);
+ // Atleast 2 requests should expire & 2 ANY_HOST requests should be
generated
+ assertTrue(state.anyHostRequests.get() >= 2);
Review comment:
Good catch, you are right!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services