xuchenhao commented on code in PR #59065:
URL: https://github.com/apache/doris/pull/59065#discussion_r2702992854
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/FileCacheAdmissionManager.java:
##########
@@ -615,83 +634,56 @@ public void loadRules(String filePath) {
}
public void loadRules() {
- if (Config.file_cache_admission_control_json_file_path == null
- ||
Config.file_cache_admission_control_json_file_path.isEmpty()) {
- LOG.warn("File cache admission JSON file path is not configured,
admission control will be disabled.");
+ if (Config.file_cache_admission_control_json_dir == null
+ || Config.file_cache_admission_control_json_dir.isEmpty())
{
+ LOG.warn("File cache admission JSON directory is not configured,
admission control will be disabled.");
return;
}
try {
- File ruleFile = new
File(Config.file_cache_admission_control_json_file_path);
+ File ruleDir = new
File(Config.file_cache_admission_control_json_dir);
- if (!ruleFile.exists()) {
- LOG.warn("File cache admission JSON file does not exist: {}",
- Config.file_cache_admission_control_json_file_path);
+ if (!ruleDir.exists()) {
+ LOG.warn("File cache admission JSON directory does not exist:
{}",
+ Config.file_cache_admission_control_json_dir);
return;
}
- long lastModified = ruleFile.lastModified();
- if (lastModified <= lastLoadedTime) {
- LOG.info("File cache admission rules file has not been
modified since last load, skip loading.");
+ if (!ruleDir.isDirectory()) {
+ LOG.error("File cache admission JSON directory is not a
directory: {}",
+ Config.file_cache_admission_control_json_dir);
return;
}
- List<AdmissionRule> loadedRules = RuleLoader.loadRulesFromFile(
- Config.file_cache_admission_control_json_file_path);
- LOG.info("{} rules loaded successfully from file: {}",
loadedRules.size(),
- Config.file_cache_admission_control_json_file_path);
+ File[] jsonFiles = ruleDir.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".json");
+ }
+ });
+
+ LOG.info("Found {} JSON files in admission rule directory: {}",
+ jsonFiles.length,
Config.file_cache_admission_control_json_dir);
+
+ List<AdmissionRule> allRules = new ArrayList<>();
+
+ for (File jsonFile : jsonFiles) {
+ List<AdmissionRule> loadedRules =
RuleLoader.loadRulesFromFile(jsonFile.getPath());
Review Comment:
已增加注释
--
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]