|
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
public class PidLambdaContainer {
|
|
|
private final static Logger log = LoggerFactory.getLogger(PidLambdaContainer.class);
|
|
|
|
|
|
- private static final int SCHEDULE_PERIOD = 1;
|
|
|
+ private static final int SCHEDULE_PERIOD = 10;
|
|
|
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
|
|
@Value("${model.oss.internal.endpoint:oss-cn-hangzhou.aliyuncs.com}")
|
|
|
String endpoint = "";
|
|
@@ -115,12 +115,17 @@ public class PidLambdaContainer {
|
|
|
|
|
|
private void writeLambdaFileToOss(){
|
|
|
//先不考虑各种更新失败及重复更新问题。
|
|
|
- String tempFile=lambdaFileName+"_temp";
|
|
|
- String content= JSONObject.toJSONString(lambdaCache);
|
|
|
- PutObjectResult putObjectResult=client.putObject(bucketName,tempFile,new ByteArrayInputStream(content.getBytes()));
|
|
|
- CopyObjectResult copyObjectResult=client.copyObject(bucketName, tempFile, bucketName, lambdaFileName);
|
|
|
- this.cacheDate= copyObjectResult.getLastModified();
|
|
|
- client.deleteObject(bucketName, tempFile);
|
|
|
+ try {
|
|
|
+ String tempFile=lambdaFileName+"_temp";
|
|
|
+ String content= JSONObject.toJSONString(lambdaCache);
|
|
|
+ PutObjectResult putObjectResult=client.putObject(bucketName,tempFile,new ByteArrayInputStream(content.getBytes()));
|
|
|
+ CopyObjectResult copyObjectResult=client.copyObject(bucketName, tempFile, bucketName, lambdaFileName);
|
|
|
+ this.cacheDate= copyObjectResult.getLastModified();
|
|
|
+ client.deleteObject(bucketName, tempFile);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("svc=writeLambdaFileToOss status=failed error={}", Arrays.toString(e.getStackTrace()));
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void loadLambdaFile(){
|
|
@@ -140,6 +145,7 @@ public class PidLambdaContainer {
|
|
|
lambdaCache=JSONObject.parseObject(builder.toString(),new TypeReference<ConcurrentHashMap<Long,Double>>(){});
|
|
|
this.cacheDate=object.getObjectMetadata().getLastModified();
|
|
|
}catch (Exception e){
|
|
|
+ log.error("svc=loadLambdaFile status=failed error={}", Arrays.toString(e.getStackTrace()));
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|