|
@@ -7,7 +7,6 @@ import com.aliyun.oss.model.ListObjectsRequest;
|
|
import com.aliyun.oss.model.OSSObject;
|
|
import com.aliyun.oss.model.OSSObject;
|
|
import com.aliyun.oss.model.OSSObjectSummary;
|
|
import com.aliyun.oss.model.OSSObjectSummary;
|
|
import com.aliyun.oss.model.ObjectListing;
|
|
import com.aliyun.oss.model.ObjectListing;
|
|
-import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
|
import lombok.Getter;
|
|
import lombok.Getter;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -21,7 +20,6 @@ import java.io.InputStreamReader;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
-import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -59,10 +57,10 @@ public class DnnCidDataHelper {
|
|
// 更新CID集合的方法
|
|
// 更新CID集合的方法
|
|
private synchronized void updateCidSet() {
|
|
private synchronized void updateCidSet() {
|
|
try {
|
|
try {
|
|
- log.info("开始初始化CID数据...");
|
|
|
|
|
|
+ log.info("start init cid data");
|
|
String modelVersion = readCsvPathFromOss();
|
|
String modelVersion = readCsvPathFromOss();
|
|
if (StringUtils.isEmpty(modelVersion)) {
|
|
if (StringUtils.isEmpty(modelVersion)) {
|
|
- log.error("modelVersion 获取为空");
|
|
|
|
|
|
+ log.error("modelVersion is null");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
String csvPath = cidPath + modelVersion;
|
|
String csvPath = cidPath + modelVersion;
|
|
@@ -85,7 +83,7 @@ public class DnnCidDataHelper {
|
|
}
|
|
}
|
|
if (filePath.toLowerCase().endsWith(".csv")) {
|
|
if (filePath.toLowerCase().endsWith(".csv")) {
|
|
firstCsvFilePath = filePath;
|
|
firstCsvFilePath = filePath;
|
|
- log.info("找到CSV文件: {}", firstCsvFilePath);
|
|
|
|
|
|
+ log.info("find csv file: {}", firstCsvFilePath);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -103,15 +101,15 @@ public class DnnCidDataHelper {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- log.info("成功读取CSV文件,共{}行数据", newCidSet.size());
|
|
|
|
|
|
+ log.info("success get csv file size = {}", newCidSet.size());
|
|
} else {
|
|
} else {
|
|
- log.error("指定文件夹下没有找到CSV文件!");
|
|
|
|
|
|
+ log.error("not found csv file");
|
|
}
|
|
}
|
|
// 使用volatile保证可见性,一次性替换整个集合
|
|
// 使用volatile保证可见性,一次性替换整个集合
|
|
cidSet = Collections.unmodifiableSet(newCidSet);
|
|
cidSet = Collections.unmodifiableSet(newCidSet);
|
|
- log.info("CID数据初始化完成,共{}条记录", cidSet.size());
|
|
|
|
|
|
+ log.info("cid set init success size={}", cidSet.size());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("更新CID数据失败", e);
|
|
|
|
|
|
+ log.error("update cid error", e);
|
|
// 发生异常时保持原数据不变
|
|
// 发生异常时保持原数据不变
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -123,7 +121,7 @@ public class DnnCidDataHelper {
|
|
try {
|
|
try {
|
|
// 检查配置文件是否存在
|
|
// 检查配置文件是否存在
|
|
if (!ossClient.doesObjectExist(BUCKET_NAME, modelVersionPath)) {
|
|
if (!ossClient.doesObjectExist(BUCKET_NAME, modelVersionPath)) {
|
|
- log.error("OSS配置文件不存在: {}", modelVersionPath);
|
|
|
|
|
|
+ log.error("modelVersionPath not exist: {}", modelVersionPath);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
// 获取配置文件内容
|
|
// 获取配置文件内容
|
|
@@ -144,7 +142,7 @@ public class DnnCidDataHelper {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("从OSS读取配置文件失败", e);
|
|
|
|
|
|
+ log.error("get modelVersionPath error", e);
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|