mcvsubbu commented on a change in pull request #3633: Use
ZkCacheBaseDataAccessor to cache instance configs in PinotHelixResourceManager
URL: https://github.com/apache/incubator-pinot/pull/3633#discussion_r245437412
##########
File path:
pinot-controller/src/test/java/com/linkedin/pinot/controller/helix/core/PinotHelixResourceManagerTest.java
##########
@@ -78,6 +88,94 @@ public void testGetInstanceEndpoints() throws
InvalidConfigException {
}
}
+ @Test
+ public void testGetInstanceConfigs() throws Exception {
+ Set<String> servers =
_helixResourceManager.getAllInstancesForServerTenant(SERVER_TENANT_NAME);
+ for (String server : servers) {
+ InstanceConfig cachedInstanceConfig =
_helixResourceManager.getHelixInstanceConfig(server);
+ InstanceConfig realInstanceConfig =
_helixAdmin.getInstanceConfig(_helixClusterName, server);
+ Assert.assertEquals(cachedInstanceConfig, realInstanceConfig);
+ }
+
+ ZkClient zkClient = new ZkClient(_helixResourceManager.getHelixZkURL(),
10_000, 10_000, new ZNRecordSerializer());
+
+ modifyExistingInstanceConfig(zkClient);
+ addAndRemoveNewInstanceConfig(zkClient);
+
+ zkClient.close();
+ }
+
+ private void modifyExistingInstanceConfig(ZkClient zkClient) throws
InterruptedException {
+ String instanceName = "Server_localhost_" + new
Random().nextInt(NUM_INSTANCES);
+ String instanceConfigPath =
PropertyPathBuilder.instanceConfig(_helixClusterName, instanceName);
+ Assert.assertTrue(zkClient.exists(instanceConfigPath));
+ ZNRecord znRecord = zkClient.readData(instanceConfigPath, null);
+
+ InstanceConfig cachedInstanceConfig =
_helixResourceManager.getHelixInstanceConfig(instanceName);
+ String originalPort = cachedInstanceConfig.getPort();
+ Assert.assertNotNull(originalPort);
+ String newPort = Long.toString(System.currentTimeMillis());
+ Assert.assertTrue(!newPort.equals(originalPort));
+
+ // Set new port to this instance config.
+
znRecord.setSimpleField(InstanceConfig.InstanceConfigProperty.HELIX_PORT.toString(),
newPort);
+ zkClient.writeData(instanceConfigPath, znRecord);
+
+ long start = System.currentTimeMillis();
+ int retry = 0;
+ InstanceConfig latestCachedInstanceConfig
=_helixResourceManager.getHelixInstanceConfig(instanceName);
+ String latestPort = latestCachedInstanceConfig.getPort();
+ while (!newPort.equals(latestPort) && retry < 10) {
Review comment:
Turn this into a time-based loop instead of count-based. you can sleep 100ms
between any two iterations.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]