adoroszlai commented on code in PR #10158:
URL: https://github.com/apache/ozone/pull/10158#discussion_r3166431087
##########
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:
Should we create `CacheMetrics` for this instance, too?
(If so, this should be moved to the constructor so we can keep reference to
the cache metrics instance, to be unregistered in `close()`).
##########
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:
Only if the patch is updated for other purpose (e.g. cache metrics):
assertion about original datanode and pipeline being unchanged would be nice.
--
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]