diff --git a/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java b/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java index 9d4430ba1a..5e53833dc0 100644 --- a/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java +++ b/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java @@ -119,7 +119,7 @@ public void resetTargetStateCache(String clusterName, String instanceName) { */ public Map>> updateCacheWithNewCurrentStateAndGetDiff(String clusterName, Map>> newCurrentStateMap) { - return getOrCreateCache(clusterName).updateCacheWithNewCurrentStateAndGetDiff(newCurrentStateMap); + return getOrCreateCache(clusterName).updateCacheWithNewCurrentStateAndGetDiff(newCurrentStateMap); } public void updateCurrentState(String clusterName, String instanceName, String resourceId, String shardId, String toState) { diff --git a/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java b/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java index 3066dcc91e..0097f55f41 100644 --- a/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java +++ b/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java @@ -89,7 +89,7 @@ public void testE2E() throws Exception { for (int i = 0; i < START_NUM_NODE; i++) { csPaths.add(createTempFile(currentStatePath + i, ".txt", "")); targetPaths.add(createTempFile(targetStatePath + i, ".txt", "")); - String currentTime = String.valueOf(System.currentTimeMillis()); + String currentTime = String.valueOf(System.currentTimeMillis()/1000); String content = "{\"IsAlive\":" + true + ",\"LastUpdateTime\":" + currentTime + "}"; healthPaths.add(createTempFile("tmphealthCheck" + i, ".txt", content)); } @@ -158,15 +158,18 @@ public void testE2E() throws Exception { // check no pending messages for partitions verifyNoPendingMessages(List.of("instance0", "instance1", "instance2")); - // change health state to false on one instance - String currentTime = String.valueOf(System.currentTimeMillis()); - String content = "{\"IsAlive\":" + false + ",\"LastUpdateTime\":" + currentTime + "}"; + // change health state to false on two instances + String currentTime = String.valueOf(System.currentTimeMillis()/1000 - 100); + String content = "{\"IsAlive\":" + true + ",\"LastUpdateTime\":" + currentTime + "}"; Files.write(healthPaths.get(0), content.getBytes()); + String content2 = "{\"IsAlive\":" + false + ",\"LastUpdateTime\":" + currentTime + "}"; + Files.write(healthPaths.get(1), content2.getBytes()); + // check live instance for that instance is gone Assert.assertTrue(TestHelper.verify(() -> { List liveInstance = getLiveInstances(); - return !liveInstance.contains("instance0") && liveInstance.contains("instance1") && liveInstance.contains( + return !liveInstance.contains("instance0") && !liveInstance.contains("instance1") && liveInstance.contains( "instance2"); }, TestHelper.WAIT_DURATION));