|
@@ -1,22 +1,13 @@
|
|
package com.abi.qms.platform.runner;
|
|
package com.abi.qms.platform.runner;
|
|
|
|
|
|
import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
-import com.abi.task.common.api.exception.BusinessException;
|
|
|
|
import com.abi.task.common.tablestore.TableStoreUtils;
|
|
import com.abi.task.common.tablestore.TableStoreUtils;
|
|
import com.abi.task.common.tablestore.common.TableStore;
|
|
import com.abi.task.common.tablestore.common.TableStore;
|
|
import com.google.common.collect.Sets;
|
|
import com.google.common.collect.Sets;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.ApplicationArguments;
|
|
import org.springframework.boot.ApplicationArguments;
|
|
import org.springframework.boot.ApplicationRunner;
|
|
import org.springframework.boot.ApplicationRunner;
|
|
-import org.springframework.boot.actuate.beans.BeansEndpoint;
|
|
|
|
-import org.springframework.context.ApplicationContext;
|
|
|
|
-import org.springframework.context.ApplicationContextAware;
|
|
|
|
-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 org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -38,15 +29,13 @@ public class CheckTableStoreRunner implements ApplicationRunner {
|
|
@Autowired
|
|
@Autowired
|
|
private TableStoreUtils tableStoreUtils;
|
|
private TableStoreUtils tableStoreUtils;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private ApplicationContextAware applicationContextAware;
|
|
|
|
|
|
|
|
private static AtomicInteger retryTimes = new AtomicInteger(0);
|
|
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/qms/platform/dao/tablestore/entity/*.class";
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void run(ApplicationArguments args) throws Exception {
|
|
|
|
|
|
+ public void run(ApplicationArguments args){
|
|
Set<TableStore> tableNames = getAllEntity();
|
|
Set<TableStore> tableNames = getAllEntity();
|
|
Map<String,String> existTableNames = tableStoreUtils.listTables();
|
|
Map<String,String> existTableNames = tableStoreUtils.listTables();
|
|
tableNames.stream()
|
|
tableNames.stream()
|
|
@@ -62,34 +51,6 @@ public class CheckTableStoreRunner implements ApplicationRunner {
|
|
private static Set<TableStore> getAllEntity(){
|
|
private static Set<TableStore> getAllEntity(){
|
|
Set<TableStore> ret = Sets.newHashSet();
|
|
Set<TableStore> ret = Sets.newHashSet();
|
|
ret.add(QrCode.class.getAnnotation(TableStore.class));
|
|
ret.add(QrCode.class.getAnnotation(TableStore.class));
|
|
-// 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;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|