Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinKirs committed Sep 4, 2024
1 parent aab1b64 commit e5e0257
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,38 @@
package org.apache.doris.fs;

import org.apache.doris.common.CacheFactory;
import org.apache.doris.common.Config;
import org.apache.doris.common.Pair;
import org.apache.doris.fs.remote.RemoteFileSystem;

import com.github.benmanes.caffeine.cache.LoadingCache;
import org.apache.hadoop.conf.Configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.OptionalLong;

public class FileSystemCache {

private static final Logger LOG = LogManager.getLogger(FileSystemCache.class);
private final LoadingCache<FileSystemCacheKey, RemoteFileSystem> fileSystemCache;

public FileSystemCache() {
// no need to set refreshAfterWrite, because the FileSystem is created once and never changed
CacheFactory fsCacheFactory = new CacheFactory(
//fixme just for test
OptionalLong.of(10L),
OptionalLong.of(1L),
OptionalLong.empty(),
Config.max_remote_file_system_cache_num,
1L,
false,
null);
fileSystemCache = fsCacheFactory.buildCache(this::loadFileSystem);
}

private RemoteFileSystem loadFileSystem(FileSystemCacheKey key) {
//fixme test
LOG.info("Create new file system: {}", key.getFsProperties());
return FileSystemFactory.getRemoteFileSystem(key.type, key.getFsProperties(), key.bindBrokerName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static void start() {
CustomThreadFactory threadFactory = new CustomThreadFactory("remote-fs-phantom-cleanup");
cleanupExecutor = Executors.newScheduledThreadPool(1, threadFactory);
cleanupExecutor.scheduleAtFixedRate(() -> {
System.gc();
Reference<? extends RemoteFileSystem> ref;
while ((ref = referenceQueue.poll()) != null) {
RemoteFileSystemPhantomReference phantomRef = (RemoteFileSystemPhantomReference) ref;
Expand All @@ -108,7 +109,7 @@ public static void start() {
}
}
}
}, 0, 20, TimeUnit.SECONDS);
}, 0, 1, TimeUnit.SECONDS);
}
}
}
Expand Down

0 comments on commit e5e0257

Please sign in to comment.