Parcourir la source

fix: 暂时注释tableStore启动检查

Marko552 il y a 4 ans
Parent
commit
d76af245e3

+ 1 - 3
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/runner/CheckTableStoreRunner.java

@@ -9,7 +9,6 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.annotation.Order;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
@@ -37,7 +36,6 @@ public class CheckTableStoreRunner implements ApplicationRunner {
 
     private static AtomicInteger retryTimes = new AtomicInteger(0);
     private static String RESOURCE_PATH = "classpath*:com/abi/qms/platform/dao/tablestore/entity/*.class";
-//    private static String RESOURCE_PATH = "classpath*:com/abi/task/common/tablestore/**/*.class";
 
 
     @Override
@@ -51,7 +49,7 @@ public class CheckTableStoreRunner implements ApplicationRunner {
                     long start = System.currentTimeMillis();
                     tableStoreUtils.createTable(tableInfo.tableName(),tableInfo.primaryKeyName());
                     log.info("表名{}创建成功,耗时{}ms",tableInfo.tableName(),(System.currentTimeMillis() -start));
-        });
+                });
     }
 
     private static Set<TableStore> getAllEntity(){

+ 0 - 64
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/runner/CustomApplicationRunner.java

@@ -1,27 +1,14 @@
 package com.abi.qms.platform.runner;
 
 import com.abi.qms.platform.infrastructure.util.RSAUtils;
-import com.abi.task.common.api.exception.BusinessException;
-import com.abi.task.common.tablestore.TableStoreUtils;
-import com.abi.task.common.tablestore.common.TableStore;
-import com.google.common.collect.Sets;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.ObjectUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.annotation.Order;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
-import org.springframework.core.type.classreading.MetadataReader;
 import org.springframework.stereotype.Component;
 
 import java.security.interfaces.RSAKey;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import static com.abi.qms.platform.infrastructure.constant.RsaKey.RSA_PRIVATE_KEY;
 import static com.abi.qms.platform.infrastructure.constant.RsaKey.RSA_PUBLIC_KEY;
@@ -38,12 +25,6 @@ import static com.abi.qms.platform.infrastructure.constant.RsaKey.RSA_PUBLIC_KEY
 @Slf4j
 public class CustomApplicationRunner implements ApplicationRunner {
 
-    @Autowired
-    private TableStoreUtils tableStoreUtils;
-
-    private static AtomicInteger retryTimes = new AtomicInteger(0);
-    private static String RESOURCE_PATH = "classpath*:com/abi/qms/platform/dao/tablestore/entity/*.class";
-
     public static ConcurrentHashMap<String, RSAKey> globalRsaKeyMap = new ConcurrentHashMap<>();
     /**
      * 项目启动时  加载公钥私钥到本地缓存
@@ -55,51 +36,6 @@ public class CustomApplicationRunner implements ApplicationRunner {
         Map<String, RSAKey> keyMap = RSAUtils.getKey();
         globalRsaKeyMap.put(RSA_PUBLIC_KEY,keyMap.get(RSA_PUBLIC_KEY));
         globalRsaKeyMap.put(RSA_PRIVATE_KEY,keyMap.get(RSA_PRIVATE_KEY));
-
-        Set<TableStore> tableNames = getAllEntity();
-        Map<String,String> existTableNames = tableStoreUtils.listTables();
-        tableNames.stream()
-                .filter(o->!existTableNames.containsKey(o.tableName()))
-                .forEach(tableInfo->{
-                    log.info("检查到表名{}不存在,开始执行创建",tableInfo.tableName());
-                    long start = System.currentTimeMillis();
-                    tableStoreUtils.createTable(tableInfo.tableName(),tableInfo.primaryKeyName());
-                    log.info("表名{}创建成功,耗时{}ms",tableInfo.tableName(),(System.currentTimeMillis() -start));
-                });
-
-
     }
 
-    private static Set<TableStore> getAllEntity(){
-        Set<TableStore> ret = Sets.newHashSet();
-        PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver();
-        CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory();
-        try {
-            Resource[] resources = pathMatchingResourcePatternResolver.getResources(RESOURCE_PATH);
-            ClassLoader loader = ClassLoader.getSystemClassLoader();
-            for (Resource resource : resources) {
-                MetadataReader reader = cachingMetadataReaderFactory.getMetadataReader(resource);
-                String className = reader.getClassMetadata().getClassName();
-                Class aClass = loader.loadClass(className);
-                TableStore annotation = (TableStore) aClass.getAnnotation(TableStore.class);
-                if (ObjectUtils.isNotEmpty(annotation)){
-                    ret.add(annotation);
-                }
-            }
-        } catch (Exception e) {
-            if (retryTimes.getAndIncrement()>2){
-                log.error("TableStore 初始化检查失败",e);
-                throw new BusinessException(500,"TableStore 初始化检查失败");
-            }
-            try {
-                Thread.sleep(retryTimes.get() * 1000);
-            } catch (InterruptedException interruptedException) {
-                // Do Nothing
-            }
-            //进行当前重试
-            log.info("当前开始重试,第{}次",retryTimes.get());
-            return getAllEntity();
-        }
-        return ret;
-    }
 }