|
@@ -86,6 +86,7 @@ public class PredictPidContainer {
|
|
|
private void loadAndCalIfNeed(){
|
|
|
loadLambdaFile();
|
|
|
OSSObject dCpaFileOjb=client.getObject(bucketName,dThresholdFileName);
|
|
|
+ loadLatestThresholdCache(dCpaFileOjb);
|
|
|
if(cacheDate==null||dCpaFileOjb.getObjectMetadata().getLastModified().after(cacheDate)){
|
|
|
calNewLambda(dCpaFileOjb);
|
|
|
writeLambdaFileToOss();
|
|
@@ -115,6 +116,26 @@ public class PredictPidContainer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void loadLatestThresholdCache(OSSObject object) {
|
|
|
+ try {
|
|
|
+ InputStream is=object.getObjectContent();
|
|
|
+ InputStreamReader isr=new InputStreamReader(is);
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(isr);
|
|
|
+ String line = null;
|
|
|
+ while ((line = bufferedReader.readLine()) != null){
|
|
|
+ try {
|
|
|
+ String[] cols=line.split(",");
|
|
|
+ String group=cols[0].trim();
|
|
|
+ latestThresholdCache.put(group,Double.parseDouble(cols[4].trim()));
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("svc=calNewPredictLambda status=failed error={}", Arrays.toString(e.getStackTrace()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void writeLambdaFileToOss(){
|
|
|
//先不考虑各种更新失败及重复更新问题。
|
|
|
try {
|