Merge branch 'develop' into feature_enhance_interface

This commit is contained in:
pbting 2019-09-06 13:27:52 +08:00 committed by GitHub
commit 2431edae4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 44 additions and 29 deletions

View File

@ -62,5 +62,9 @@
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -23,7 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import com.google.common.base.Objects;
/**
* @author nkorange
@ -138,7 +138,7 @@ public abstract class AbstractHealthChecker implements Cloneable {
@Override
public int hashCode() {
return Objects.hash(path, headers, expectedResponseCode);
return Objects.hashCode(path, headers, expectedResponseCode);
}
@Override
@ -184,7 +184,7 @@ public abstract class AbstractHealthChecker implements Cloneable {
@Override
public int hashCode() {
return Objects.hash(TYPE);
return Objects.hashCode(TYPE);
}
@Override
@ -250,7 +250,7 @@ public abstract class AbstractHealthChecker implements Cloneable {
@Override
public int hashCode() {
return Objects.hash(user, pwd, cmd);
return Objects.hashCode(user, pwd, cmd);
}
@Override

View File

@ -435,7 +435,7 @@ public class ConfigController {
defaultValue = StringUtils.EMPTY) String tenant,
@RequestParam(value = "ids", required = false)List<Long> ids) {
ids.removeAll(Collections.singleton(null));
List<ConfigInfo> dataList = persistService.findAllConfigInfo4Export(dataId, group, tenant, appName, ids);
List<ConfigAllInfo> dataList = persistService.findAllConfigInfo4Export(dataId, group, tenant, appName, ids);
List<ZipUtils.ZipItem> zipItemList = new ArrayList<>();
StringBuilder metaData = null;
for(ConfigInfo ci : dataList){
@ -482,7 +482,7 @@ public class ConfigController {
return ResultBuilder.buildResult(ResultCodeEnum.NAMESPACE_NOT_EXIST, failedData);
}
}
List<ConfigInfo> configInfoList = null;
List<ConfigAllInfo> configInfoList = null;
try {
ZipUtils.UnZipResult unziped = ZipUtils.unzip(file.getBytes());
ZipUtils.ZipItem metaDataZipItem = unziped.getMetaDataItem();
@ -516,7 +516,7 @@ public class ConfigController {
+ "~" + tempDataId.substring(tempDataId.lastIndexOf(".") + 1);
}
String metaDataId = group + "." + tempDataId + ".app";
ConfigInfo ci = new ConfigInfo();
ConfigAllInfo ci = new ConfigAllInfo();
ci.setTenant(namespace);
ci.setGroup(group);
ci.setDataId(dataId);
@ -570,18 +570,19 @@ public class ConfigController {
}
ids.removeAll(Collections.singleton(null));
List<ConfigInfo> queryedDataList = persistService.findAllConfigInfo4Export(null,null, null, null, ids);
List<ConfigAllInfo> queryedDataList = persistService.findAllConfigInfo4Export(null,null, null, null, ids);
if(queryedDataList == null || queryedDataList.isEmpty()){
failedData.put("succCount", 0);
return ResultBuilder.buildResult(ResultCodeEnum.DATA_EMPTY, failedData);
}
List<ConfigInfo> configInfoList4Clone = new ArrayList<>(queryedDataList.size());
List<ConfigAllInfo> configInfoList4Clone = new ArrayList<>(queryedDataList.size());
for(ConfigInfo ci : queryedDataList){
ConfigInfo ci4save = new ConfigInfo();
for(ConfigAllInfo ci : queryedDataList){
ConfigAllInfo ci4save = new ConfigAllInfo();
ci4save.setTenant(namespace);
ci4save.setType(ci.getType());
ci4save.setGroup(ci.getGroup());
ci4save.setDataId(ci.getDataId());
ci4save.setContent(ci.getContent());

View File

@ -72,7 +72,7 @@ public class PersistService {
private DataSourceService dataSourceService;
private static final String SQL_FIND_ALL_CONFIG_INFO = "select data_id,group_id,tenant_id,app_name,content,type from config_info";
private static final String SQL_FIND_ALL_CONFIG_INFO = "select id,data_id,group_id,tenant_id,app_name,content,type,md5,gmt_create,gmt_modified,src_user,src_ip,c_desc,c_use,effect,c_schema from config_info";
private static final String SQL_TENANT_INFO_COUNT_BY_TENANT_ID = "select count(1) from tenant_info where tenant_id = ?";
@ -3419,7 +3419,7 @@ public class PersistService {
* @param group
* @return Collection of ConfigInfo objects
*/
public List<ConfigInfo> findAllConfigInfo4Export(final String dataId, final String group, final String tenant,
public List<ConfigAllInfo> findAllConfigInfo4Export(final String dataId, final String group, final String tenant,
final String appName, final List<Long> ids) {
String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
StringBuilder where = new StringBuilder(" where ");
@ -3451,7 +3451,7 @@ public class PersistService {
}
}
try {
return this.jt.query(SQL_FIND_ALL_CONFIG_INFO + where, paramList.toArray(), CONFIG_INFO_ROW_MAPPER);
return this.jt.query(SQL_FIND_ALL_CONFIG_INFO + where, paramList.toArray(), CONFIG_ALL_INFO_ROW_MAPPER);
} catch (CannotGetJdbcConnectionException e) {
fatalLog.error("[db-error] " + e.toString(), e);
throw e;
@ -3466,7 +3466,7 @@ public class PersistService {
* failData: import failed data (only with abort for the same configs)
* skipData: data skipped at import (only with skip for the same configs)
*/
public Map<String, Object> batchInsertOrUpdate(List<ConfigInfo> configInfoList, String srcUser, String srcIp,
public Map<String, Object> batchInsertOrUpdate(List<ConfigAllInfo> configInfoList, String srcUser, String srcIp,
Map<String, Object> configAdvanceInfo, Timestamp time, boolean notify, SameConfigPolicy policy) throws NacosException {
int succCount = 0;
int skipCount = 0;
@ -3474,7 +3474,7 @@ public class PersistService {
List<Map<String, String>> skipData = null;
for (int i = 0; i < configInfoList.size(); i++) {
ConfigInfo configInfo = configInfoList.get(i);
ConfigAllInfo configInfo = configInfoList.get(i);
try {
ParamUtils.checkParam(configInfo.getDataId(), configInfo.getGroup(), "datumId", configInfo.getContent());
} catch (NacosException e) {
@ -3484,14 +3484,16 @@ public class PersistService {
ConfigInfo configInfo2Save = new ConfigInfo(configInfo.getDataId(), configInfo.getGroup(),
configInfo.getTenant(), configInfo.getAppName(), configInfo.getContent());
// simple judgment of file type based on suffix
String type = null;
if (configInfo.getDataId().contains(SPOT)) {
String extName = configInfo.getDataId().substring(configInfo.getDataId().lastIndexOf(SPOT) + 1).toLowerCase();
try {
type = FileTypeEnum.valueOf(extName).getFileType();
} catch (Exception ex) {
type = FileTypeEnum.TEXT.getFileType();
String type = configInfo.getType();
if (StringUtils.isBlank(type)) {
// simple judgment of file type based on suffix
if (configInfo.getDataId().contains(SPOT)) {
String extName = configInfo.getDataId().substring(configInfo.getDataId().lastIndexOf(SPOT) + 1).toUpperCase();
try {
type = FileTypeEnum.valueOf(extName).getFileType();
} catch (Exception ex) {
type = FileTypeEnum.TEXT.getFileType();
}
}
}
if (configAdvanceInfo == null) {

View File

@ -50,7 +50,7 @@ public class HealthCheckProcessorDelegate implements HealthCheckProcessor {
String type = task.getCluster().getHealthChecker().getType();
HealthCheckProcessor processor = healthCheckProcessorMap.get(type);
if(processor == null){
processor = healthCheckProcessorMap.get("none");
processor = healthCheckProcessorMap.get(NoneHealthCheckProcessor.TYPE);
}
processor.process(task);

View File

@ -47,6 +47,8 @@ import static com.alibaba.nacos.naming.misc.Loggers.SRV_LOG;
@Component
public class HttpHealthCheckProcessor implements HealthCheckProcessor {
public static final String TYPE = "HTTP";
@Autowired
private SwitchDomain switchDomain;
@ -79,7 +81,7 @@ public class HttpHealthCheckProcessor implements HealthCheckProcessor {
@Override
public String getType() {
return "HTTP";
return TYPE;
}
@Override

View File

@ -45,6 +45,8 @@ import static com.alibaba.nacos.naming.misc.Loggers.SRV_LOG;
@Component
public class MysqlHealthCheckProcessor implements HealthCheckProcessor {
public static final String TYPE = "MYSQL";
@Autowired
private HealthCheckCommon healthCheckCommon;
@ -83,7 +85,7 @@ public class MysqlHealthCheckProcessor implements HealthCheckProcessor {
@Override
public String getType() {
return "MYSQL";
return TYPE;
}
@Override

View File

@ -26,12 +26,14 @@ import org.springframework.stereotype.Component;
@Component
public class NoneHealthCheckProcessor implements HealthCheckProcessor {
public static final String TYPE = "NONE";
@Override
public void process(HealthCheckTask task) {
}
@Override
public String getType() {
return "NONE";
return TYPE;
}
}

View File

@ -43,6 +43,8 @@ import static com.alibaba.nacos.naming.misc.Loggers.SRV_LOG;
@Component
public class TcpSuperSenseProcessor implements HealthCheckProcessor, Runnable {
public static final String TYPE = "TCP";
@Autowired
private HealthCheckCommon healthCheckCommon;
@ -420,6 +422,6 @@ public class TcpSuperSenseProcessor implements HealthCheckProcessor, Runnable {
@Override
public String getType() {
return "TCP";
return TYPE;
}
}