hudeqi commented on code in PR #14243: URL: https://github.com/apache/kafka/pull/14243#discussion_r1310123945
########## storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java: ########## @@ -125,12 +126,37 @@ public RemoteIndexCache(RemoteStorageManager remoteStorageManager, String logDir * @param remoteStorageManager RemoteStorageManager instance, to be used in fetching indexes. * @param logDir log directory */ - public RemoteIndexCache(int maxSize, RemoteStorageManager remoteStorageManager, String logDir) throws IOException { + public RemoteIndexCache(long maxSize, RemoteStorageManager remoteStorageManager, String logDir) throws IOException { this.remoteStorageManager = remoteStorageManager; cacheDir = new File(logDir, DIR_NAME); - internalCache = Caffeine.newBuilder() - .maximumSize(maxSize) + internalCache = initEmptyCache(maxSize); + init(); + + // Start cleaner thread that will clean the expired entries. + cleanerThread = createCleanerThread(); + cleanerThread.start(); + } + + public void resizeCacheSize(long remoteLogIndexFileCacheSize) { + lock.writeLock().lock(); + try { + Cache<Uuid, Entry> newCache = initEmptyCache(remoteLogIndexFileCacheSize); + for (Map.Entry<Uuid, Entry> entry : internalCache.asMap().entrySet()) { + newCache.put(entry.getKey(), entry.getValue()); + } + internalCache = newCache; Review Comment: updated ########## storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java: ########## @@ -437,7 +457,7 @@ public void close() { // Note that internal cache does not require explicit cleaning/closing. We don't want to invalidate or cleanup // the cache as both would lead to triggering of removal listener. - + internalCache.cleanUp(); Review Comment: updated -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org