master
zhang chengzhi 2024-09-08 19:21:05 +08:00
parent 13287fba8f
commit 6801d81555
1 changed files with 16 additions and 1 deletions

View File

@ -6,10 +6,13 @@ import com.aliyun.oss.model.GetObjectRequest;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.ObjectListing;
import com.aliyun.oss.model.OSSObjectSummary;
import com.muyu.rule.server.service.RuleEngineVersionService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import redis.clients.jedis.timeseries.TSInfo;
import java.io.File;
import java.io.FileOutputStream;
@ -30,18 +33,24 @@ import java.io.IOException;
@Component
public class DownloadOssSynchronization implements ApplicationRunner {
private static final String endPoint = "oss-cn-beijing.aliyuncs.com";
private static final String accessKeyId = "LTAI5tRRrrYqiSXddVq7RvqW";
private static final String accessKeySecret = "GhEg1LlHTOx4q0rxs1S3pCaSQayCVL";
private static final String accessPre = "https://zcz-vfd-1000.oss-cn-beijing.aliyuncs.com/";
/**
*
*/
private static String serverClassPath = "home/lib/com/muyu/rule/common/engine/";
private static String bucketName = "zcz-vfd-1000";
@Autowired
private RuleEngineVersionService ruleEngineVersionService;
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("开始从Oss下载规则引擎");
@ -53,10 +62,16 @@ public class DownloadOssSynchronization implements ApplicationRunner {
for (OSSObjectSummary objectSummary : objectListing.getObjectSummaries()) {
String key = objectSummary.getKey();
downloadFile(ossClient, bucketName, key, serverClassPath);
ruleEngineVersionService.loadDateSetEngineClass(key);
}
// 关闭OSSClient
ossClient.shutdown();
//下载完成实现批量批量类加载
}
private void downloadFile(OSS ossClient, String bucketName, String key, String serverPath) {