lakshmi-manasa-g commented on a change in pull request #1442:
URL: https://github.com/apache/samza/pull/1442#discussion_r527293025
##########
File path:
samza-core/src/main/java/org/apache/samza/container/ContainerHeartbeatMonitor.java
##########
@@ -84,6 +113,38 @@ public void stop() {
}
}
+ private boolean checkAndEstablishConnectionWithNewAM() {
Review comment:
modular does sound good. but in this case, the smaller functions are
really small and dont accomplish much else than a single call to client or
store. Hence keeping this same. Also, doesnt have an advantage with testing.
##########
File path:
samza-core/src/test/java/org/apache/samza/container/TestContainerHeartbeatMonitor.java
##########
@@ -93,6 +103,31 @@ public void testDoesNotCallbackWhenHeartbeatAlive() throws
InterruptedException
verify(this.scheduler).shutdown();
}
+ @Test
+ public void testReestablishConnectionWithNewAM() throws InterruptedException
{
+ this.containerHeartbeatMonitor =
+ spy(new ContainerHeartbeatMonitor(this.onExpired,
this.containerHeartbeatClient, this.scheduler, COORDINATOR_URL,
+ "0", coordinatorStreamStore, true, 10));
+ CoordinatorStreamValueSerde serde = new
CoordinatorStreamValueSerde(SetConfig.TYPE);
+ byte[] newCoordinatorUrl =
serde.toBytes("http://some-host-2.prod.linkedin.com");
+ ContainerHeartbeatResponse response1 = new
ContainerHeartbeatResponse(false);
+ ContainerHeartbeatResponse response2 = new
ContainerHeartbeatResponse(true);
+
when(this.containerHeartbeatClient.requestHeartbeat()).thenReturn(response1).thenReturn(response2);
+
when(this.containerHeartbeatMonitor.getContainerHeartbeatClient()).thenReturn(this.containerHeartbeatClient);
Review comment:
the client's heartbeat response needs to be mocked and hence cant create
a new one.
updated to return mock when using the new url.
Also added failure scenario tests
----------------------------------------------------------------
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]