ivandika3 commented on code in PR #10158:
URL: https://github.com/apache/ozone/pull/10158#discussion_r3166670298


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ScmClient.java:
##########
@@ -73,6 +78,14 @@ static LoadingCache<Long, Pipeline> 
createContainerLocationCache(
     long ttl = configuration.getTimeDuration(
         OZONE_OM_CONTAINER_LOCATION_CACHE_TTL,
         OZONE_OM_CONTAINER_LOCATION_CACHE_TTL_DEFAULT.getDuration(), unit);
+    int datanodeCacheMaxSize = configuration.getInt(
+        OZONE_OM_CONTAINER_LOCATION_DATANODE_CACHE_SIZE,
+        OZONE_OM_CONTAINER_LOCATION_DATANODE_CACHE_SIZE_DEFAULT);
+
+    final Cache<DatanodeID, DatanodeDetails> datanodeDetailsCache =
+        CacheBuilder.newBuilder()
+            .maximumSize(datanodeCacheMaxSize)
+            .build();

Review Comment:
   Good idea, updated.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestScmClient.java:
##########
@@ -166,13 +173,37 @@ public void testGetContainerLocationsWithScmFailures() 
throws IOException {
     assertEquals(runtimeException, actualRt.getCause());
   }
 
-  ContainerWithPipeline createPipeline(long containerId) {
+  @Test
+  public void testDatanodeDetailsCacheUpdatesIpAddressChange() {
+    Cache<DatanodeID, DatanodeDetails> datanodeDetailsCache =
+        CacheBuilder.newBuilder().build();
+    DatanodeDetails original = randomDatanode();
+    DatanodeDetails updated = DatanodeDetails.newBuilder()
+        .setDatanodeDetails(original)
+        .setIpAddress("updated-ip")
+        .build();
+
+    ScmClient.newPipelineWithDNCache(
+        createPipeline(1L, asList(original)).getPipeline(),
+        datanodeDetailsCache);
+    Pipeline refreshed = ScmClient.newPipelineWithDNCache(
+        createPipeline(2L, asList(updated)).getPipeline(),
+        datanodeDetailsCache);
+
+    DatanodeDetails refreshedNode = refreshed.getNodes().get(0);
+    assertSame(updated, refreshedNode);
+    assertEquals("updated-ip", refreshedNode.getIpAddress());
+    assertSame(updated, datanodeDetailsCache.getIfPresent(original.getID()));

Review Comment:
   Updated with some more assertions.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to