From a1da8c121ec1f47bdd0ade3790be777e8a2fb4fa Mon Sep 17 00:00:00 2001 From: "Yangkai.Shen" <237497819@qq.com> Date: Fri, 23 Aug 2019 14:06:27 +0800 Subject: [PATCH 1/7] :bug: remove server.contextPath --- console/src/main/resources/application.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/console/src/main/resources/application.properties b/console/src/main/resources/application.properties index 64c42676e..7e6495697 100644 --- a/console/src/main/resources/application.properties +++ b/console/src/main/resources/application.properties @@ -1,6 +1,5 @@ # spring -server.contextPath=/nacos server.servlet.contextPath=/nacos server.port=8848 From bbad9d69b08f0b7acfc2a5d7b4a0110a92283dd5 Mon Sep 17 00:00:00 2001 From: Beldon <1047325205@qq.com> Date: Sun, 25 Aug 2019 20:23:05 +0800 Subject: [PATCH 2/7] fix #1764. --- .../nacos/naming/healthcheck/HealthCheckProcessorDelegate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java index 1de6acb09..8f4ad5c0a 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java @@ -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("NONE"); } processor.process(task); From 1fd5ee360e97c395f29c5eb727c47ec0d56b9632 Mon Sep 17 00:00:00 2001 From: ly <641921791@qq.com> Date: Thu, 29 Aug 2019 01:23:12 +0800 Subject: [PATCH 3/7] [Issue] #1769 Solve the bug of the clone configuration function --- config/pom.xml | 4 + .../server/controller/ConfigController.java | 25 +++--- .../config/server/model/ConfigAllInfo.java | 9 --- .../nacos/config/server/model/ConfigInfo.java | 12 ++- .../config/server/service/PersistService.java | 78 +++++++++++++++++-- 5 files changed, 98 insertions(+), 30 deletions(-) diff --git a/config/pom.xml b/config/pom.xml index 68141b6b9..67915429d 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -46,6 +46,10 @@ ${project.groupId} nacos-core + + com.alibaba + fastjson + com.google.guava guava diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java index 3ca85fb80..d45166b9a 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java @@ -50,6 +50,7 @@ import java.io.IOException; import java.net.URLDecoder; import java.sql.Timestamp; import java.util.*; +import java.util.stream.Collectors; import static com.alibaba.nacos.core.utils.SystemUtils.LOCAL_IP; @@ -570,26 +571,26 @@ public class ConfigController { } ids.removeAll(Collections.singleton(null)); - List queryedDataList = persistService.findAllConfigInfo4Export(null,null, null, null, ids); + List queryedDataList = persistService.findConfigAllInfoByIds(ids); if(queryedDataList == null || queryedDataList.isEmpty()){ failedData.put("succCount", 0); return ResultBuilder.buildResult(ResultCodeEnum.DATA_EMPTY, failedData); } - List configInfoList4Clone = new ArrayList<>(queryedDataList.size()); - - for(ConfigInfo ci : queryedDataList){ + String tenant = namespace; + List configInfoList4Clone = queryedDataList.stream().map(configAllInfo -> { ConfigInfo ci4save = new ConfigInfo(); - ci4save.setTenant(namespace); - ci4save.setGroup(ci.getGroup()); - ci4save.setDataId(ci.getDataId()); - ci4save.setContent(ci.getContent()); - if(StringUtils.isNotBlank(ci.getAppName())){ - ci4save.setAppName(ci.getAppName()); + ci4save.setTenant(tenant); + ci4save.setGroup(configAllInfo.getGroup()); + ci4save.setDataId(configAllInfo.getDataId()); + ci4save.setContent(configAllInfo.getContent()); + if(StringUtils.isNotBlank(configAllInfo.getAppName())){ + ci4save.setAppName(configAllInfo.getAppName()); } - configInfoList4Clone.add(ci4save); - } + ci4save.setType(configAllInfo.getType()); + return ci4save; + }).collect(Collectors.toList()); if (configInfoList4Clone.isEmpty()) { failedData.put("succCount", 0); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java index 218d263a2..71ccf117f 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java @@ -34,7 +34,6 @@ public class ConfigAllInfo extends ConfigInfo { private String desc; private String use; private String effect; - private String type; private String schema; private String configTags; @@ -97,14 +96,6 @@ public class ConfigAllInfo extends ConfigInfo { this.effect = effect; } - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - public String getSchema() { return schema; } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java index be0d2de0d..4073da20c 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java @@ -28,6 +28,8 @@ public class ConfigInfo extends ConfigInfoBase { private String appName; + private String type; + public ConfigInfo() { } @@ -63,6 +65,14 @@ public class ConfigInfo extends ConfigInfoBase { this.appName = appName; } + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + @Override public int hashCode() { return super.hashCode(); @@ -77,7 +87,7 @@ public class ConfigInfo extends ConfigInfoBase { public String toString() { return "ConfigInfo{" + "id=" + getId() + ", dataId='" + getDataId() + '\'' + ", group='" + getGroup() + '\'' + ", tenant='" + tenant + '\'' + ", appName='" + appName + '\'' + ", content='" + getContent() + '\'' - + ", md5='" + getMd5() + '\'' + '}'; + + ", md5='" + getMd5() + '\'' + ", type='" + type + '\'' + '}'; } } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java index ba64208a0..fc1b2353b 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java @@ -52,6 +52,7 @@ import java.io.IOException; import java.sql.*; import java.util.*; import java.util.Map.Entry; +import java.util.stream.Collectors; import static com.alibaba.nacos.config.server.utils.LogUtil.defaultLog; import static com.alibaba.nacos.config.server.utils.LogUtil.fatalLog; @@ -3040,6 +3041,34 @@ public class PersistService { } } + /** + * Find ConfigAllInfo by ids + * + * @param ids ids + * @return ConfigAllInfo + */ + public List findConfigAllInfoByIds(final List ids) { + if(CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + + String[] array = new String[ids.size()]; + Arrays.fill(array, "?"); + + String sql = "SELECT ID,data_id,group_id,tenant_id,app_name,content,md5,gmt_create,gmt_modified,src_user,src_ip,c_desc,c_use,effect,type,c_schema FROM config_info " + + "WHERE id IN (" + String.join(",", array) + ")"; + + try { + List> maps = this.jt.queryForList(sql, ids.toArray()); + return maps.stream().map(this::convertConfigAllInfo).collect(Collectors.toList()); + } catch (EmptyResultDataAccessException e) { // 表明数据不存在, 返回null + return Collections.emptyList(); + } catch (CannotGetJdbcConnectionException e) { + fatalLog.error("[db-error] " + e.toString(), e); + throw e; + } + } + /** * 更新变更记录;数据库原子操作,最小sql动作,无业务封装 * @@ -3296,6 +3325,37 @@ public class PersistService { return configs; } + private ConfigAllInfo convertConfigAllInfo(Map map) { + if (map == null) { + return null; + } + ConfigAllInfo configAllInfo = new ConfigAllInfo(); + configAllInfo.setId((long) map.get("id")); + configAllInfo.setDataId((String) map.get("data_id")); + configAllInfo.setGroup((String) map.get("group_id")); + configAllInfo.setTenant((String) map.get("tenant_id")); + configAllInfo.setAppName((String) map.get("app_name")); + configAllInfo.setContent((String) map.get("content")); + configAllInfo.setMd5((String) map.get("md5")); + configAllInfo.setCreateTime(((Timestamp) map.get("gmt_create")).getTime()); + configAllInfo.setModifyTime(((Timestamp) map.get("gmt_modified")).getTime()); + configAllInfo.setCreateUser((String) map.get("src_user")); + configAllInfo.setCreateIp((String) map.get("src_ip")); + configAllInfo.setDesc((String) map.get("c_desc")); + configAllInfo.setUse((String) map.get("c_use")); + configAllInfo.setEffect((String) map.get("effect")); + configAllInfo.setType((String) map.get("type")); + configAllInfo.setSchema((String) map.get("c_schema")); + + List configTagList = this.selectTagByConfig(configAllInfo.getDataId(), configAllInfo.getGroup(), + configAllInfo.getTenant()); + + if (!CollectionUtils.isEmpty(configTagList)) { + configAllInfo.setConfigTags(String.join(",", configTagList.toArray(new String[0]))); + } + return configAllInfo; + } + /** * 获取所有的配置的Md5值,通过分页方式获取。 * @@ -3484,14 +3544,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).toLowerCase(); + try { + type = FileTypeEnum.valueOf(extName).getFileType(); + } catch (Exception ex) { + type = FileTypeEnum.TEXT.getFileType(); + } } } if (configAdvanceInfo == null) { From 4459dc73b9fdc6b82ce8903dbdb06dc36d41d0b3 Mon Sep 17 00:00:00 2001 From: nkorange Date: Fri, 30 Aug 2019 10:15:38 +0800 Subject: [PATCH 4/7] Fix #1764 --- .../naming/healthcheck/HealthCheckProcessorDelegate.java | 2 +- .../nacos/naming/healthcheck/HttpHealthCheckProcessor.java | 4 +++- .../nacos/naming/healthcheck/MysqlHealthCheckProcessor.java | 4 +++- .../nacos/naming/healthcheck/NoneHealthCheckProcessor.java | 4 +++- .../nacos/naming/healthcheck/TcpSuperSenseProcessor.java | 4 +++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java index 1de6acb09..e85af4a69 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessorDelegate.java @@ -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); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java index 064de1e12..b03f7e359 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java @@ -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 diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java index 756d7fcba..1ce59f46c 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java @@ -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 diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java index c7bf4a84d..221e6770d 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/NoneHealthCheckProcessor.java @@ -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; } } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java index 4d6cb676c..117a231e2 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java @@ -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; } } From 59a36f91e4ea33927d5618488aba555c8f616e68 Mon Sep 17 00:00:00 2001 From: ly <641921791@qq.com> Date: Fri, 30 Aug 2019 21:31:40 +0800 Subject: [PATCH 5/7] [Issue] #1769 Solve the bug of the clone configuration function --- config/pom.xml | 4 -- .../server/controller/ConfigController.java | 28 ++++---- .../config/server/model/ConfigAllInfo.java | 11 +++ .../config/server/service/PersistService.java | 68 ++----------------- 4 files changed, 29 insertions(+), 82 deletions(-) diff --git a/config/pom.xml b/config/pom.xml index 67915429d..68141b6b9 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -46,10 +46,6 @@ ${project.groupId} nacos-core - - com.alibaba - fastjson - com.google.guava guava diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java index d45166b9a..cf0a7b9f4 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java @@ -50,7 +50,6 @@ import java.io.IOException; import java.net.URLDecoder; import java.sql.Timestamp; import java.util.*; -import java.util.stream.Collectors; import static com.alibaba.nacos.core.utils.SystemUtils.LOCAL_IP; @@ -436,7 +435,7 @@ public class ConfigController { defaultValue = StringUtils.EMPTY) String tenant, @RequestParam(value = "ids", required = false)List ids) { ids.removeAll(Collections.singleton(null)); - List dataList = persistService.findAllConfigInfo4Export(dataId, group, tenant, appName, ids); + List dataList = persistService.findAllConfigInfo4Export(dataId, group, tenant, appName, ids); List zipItemList = new ArrayList<>(); StringBuilder metaData = null; for(ConfigInfo ci : dataList){ @@ -571,26 +570,27 @@ public class ConfigController { } ids.removeAll(Collections.singleton(null)); - List queryedDataList = persistService.findConfigAllInfoByIds(ids); + List queryedDataList = persistService.findAllConfigInfo4Export(null,null, null, null, ids); if(queryedDataList == null || queryedDataList.isEmpty()){ failedData.put("succCount", 0); return ResultBuilder.buildResult(ResultCodeEnum.DATA_EMPTY, failedData); } - String tenant = namespace; - List configInfoList4Clone = queryedDataList.stream().map(configAllInfo -> { + List configInfoList4Clone = new ArrayList<>(queryedDataList.size()); + + for(ConfigInfo ci : queryedDataList){ ConfigInfo ci4save = new ConfigInfo(); - ci4save.setTenant(tenant); - ci4save.setGroup(configAllInfo.getGroup()); - ci4save.setDataId(configAllInfo.getDataId()); - ci4save.setContent(configAllInfo.getContent()); - if(StringUtils.isNotBlank(configAllInfo.getAppName())){ - ci4save.setAppName(configAllInfo.getAppName()); + ci4save.setTenant(namespace); + ci4save.setType(ci.getType()); + ci4save.setGroup(ci.getGroup()); + ci4save.setDataId(ci.getDataId()); + ci4save.setContent(ci.getContent()); + if(StringUtils.isNotBlank(ci.getAppName())){ + ci4save.setAppName(ci.getAppName()); } - ci4save.setType(configAllInfo.getType()); - return ci4save; - }).collect(Collectors.toList()); + configInfoList4Clone.add(ci4save); + } if (configInfoList4Clone.isEmpty()) { failedData.put("succCount", 0); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java index 71ccf117f..2c0505765 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java @@ -34,6 +34,7 @@ public class ConfigAllInfo extends ConfigInfo { private String desc; private String use; private String effect; + private String type; private String schema; private String configTags; @@ -96,6 +97,16 @@ public class ConfigAllInfo extends ConfigInfo { this.effect = effect; } + @Override + public String getType() { + return type; + } + + @Override + public void setType(String type) { + this.type = type; + } + public String getSchema() { return schema; } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java index fc1b2353b..d3f626b63 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java @@ -52,7 +52,6 @@ import java.io.IOException; import java.sql.*; import java.util.*; import java.util.Map.Entry; -import java.util.stream.Collectors; import static com.alibaba.nacos.config.server.utils.LogUtil.defaultLog; import static com.alibaba.nacos.config.server.utils.LogUtil.fatalLog; @@ -73,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 = ?"; @@ -3041,34 +3040,6 @@ public class PersistService { } } - /** - * Find ConfigAllInfo by ids - * - * @param ids ids - * @return ConfigAllInfo - */ - public List findConfigAllInfoByIds(final List ids) { - if(CollectionUtils.isEmpty(ids)) { - return Collections.emptyList(); - } - - String[] array = new String[ids.size()]; - Arrays.fill(array, "?"); - - String sql = "SELECT ID,data_id,group_id,tenant_id,app_name,content,md5,gmt_create,gmt_modified,src_user,src_ip,c_desc,c_use,effect,type,c_schema FROM config_info " + - "WHERE id IN (" + String.join(",", array) + ")"; - - try { - List> maps = this.jt.queryForList(sql, ids.toArray()); - return maps.stream().map(this::convertConfigAllInfo).collect(Collectors.toList()); - } catch (EmptyResultDataAccessException e) { // 表明数据不存在, 返回null - return Collections.emptyList(); - } catch (CannotGetJdbcConnectionException e) { - fatalLog.error("[db-error] " + e.toString(), e); - throw e; - } - } - /** * 更新变更记录;数据库原子操作,最小sql动作,无业务封装 * @@ -3325,37 +3296,6 @@ public class PersistService { return configs; } - private ConfigAllInfo convertConfigAllInfo(Map map) { - if (map == null) { - return null; - } - ConfigAllInfo configAllInfo = new ConfigAllInfo(); - configAllInfo.setId((long) map.get("id")); - configAllInfo.setDataId((String) map.get("data_id")); - configAllInfo.setGroup((String) map.get("group_id")); - configAllInfo.setTenant((String) map.get("tenant_id")); - configAllInfo.setAppName((String) map.get("app_name")); - configAllInfo.setContent((String) map.get("content")); - configAllInfo.setMd5((String) map.get("md5")); - configAllInfo.setCreateTime(((Timestamp) map.get("gmt_create")).getTime()); - configAllInfo.setModifyTime(((Timestamp) map.get("gmt_modified")).getTime()); - configAllInfo.setCreateUser((String) map.get("src_user")); - configAllInfo.setCreateIp((String) map.get("src_ip")); - configAllInfo.setDesc((String) map.get("c_desc")); - configAllInfo.setUse((String) map.get("c_use")); - configAllInfo.setEffect((String) map.get("effect")); - configAllInfo.setType((String) map.get("type")); - configAllInfo.setSchema((String) map.get("c_schema")); - - List configTagList = this.selectTagByConfig(configAllInfo.getDataId(), configAllInfo.getGroup(), - configAllInfo.getTenant()); - - if (!CollectionUtils.isEmpty(configTagList)) { - configAllInfo.setConfigTags(String.join(",", configTagList.toArray(new String[0]))); - } - return configAllInfo; - } - /** * 获取所有的配置的Md5值,通过分页方式获取。 * @@ -3479,7 +3419,7 @@ public class PersistService { * @param group * @return Collection of ConfigInfo objects */ - public List findAllConfigInfo4Export(final String dataId, final String group, final String tenant, + public List findAllConfigInfo4Export(final String dataId, final String group, final String tenant, final String appName, final List ids) { String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant; StringBuilder where = new StringBuilder(" where "); @@ -3511,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; @@ -3548,7 +3488,7 @@ public class PersistService { 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).toLowerCase(); + String extName = configInfo.getDataId().substring(configInfo.getDataId().lastIndexOf(SPOT) + 1).toUpperCase(); try { type = FileTypeEnum.valueOf(extName).getFileType(); } catch (Exception ex) { From 40be568c0115e4be0afad2f44e138a4d0d30e009 Mon Sep 17 00:00:00 2001 From: ly <641921791@qq.com> Date: Sat, 31 Aug 2019 10:39:42 +0800 Subject: [PATCH 6/7] [Issue] #1769 Solve the bug of the clone configuration function --- .../config/server/controller/ConfigController.java | 10 +++++----- .../nacos/config/server/model/ConfigAllInfo.java | 2 -- .../nacos/config/server/model/ConfigInfo.java | 12 +----------- .../nacos/config/server/service/PersistService.java | 4 ++-- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java index cf0a7b9f4..668097b61 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java @@ -482,7 +482,7 @@ public class ConfigController { return ResultBuilder.buildResult(ResultCodeEnum.NAMESPACE_NOT_EXIST, failedData); } } - List configInfoList = null; + List 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); @@ -577,10 +577,10 @@ public class ConfigController { return ResultBuilder.buildResult(ResultCodeEnum.DATA_EMPTY, failedData); } - List configInfoList4Clone = new ArrayList<>(queryedDataList.size()); + List 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()); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java index 2c0505765..218d263a2 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigAllInfo.java @@ -97,12 +97,10 @@ public class ConfigAllInfo extends ConfigInfo { this.effect = effect; } - @Override public String getType() { return type; } - @Override public void setType(String type) { this.type = type; } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java index 4073da20c..be0d2de0d 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/model/ConfigInfo.java @@ -28,8 +28,6 @@ public class ConfigInfo extends ConfigInfoBase { private String appName; - private String type; - public ConfigInfo() { } @@ -65,14 +63,6 @@ public class ConfigInfo extends ConfigInfoBase { this.appName = appName; } - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - @Override public int hashCode() { return super.hashCode(); @@ -87,7 +77,7 @@ public class ConfigInfo extends ConfigInfoBase { public String toString() { return "ConfigInfo{" + "id=" + getId() + ", dataId='" + getDataId() + '\'' + ", group='" + getGroup() + '\'' + ", tenant='" + tenant + '\'' + ", appName='" + appName + '\'' + ", content='" + getContent() + '\'' - + ", md5='" + getMd5() + '\'' + ", type='" + type + '\'' + '}'; + + ", md5='" + getMd5() + '\'' + '}'; } } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java index d3f626b63..5fb623921 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/PersistService.java @@ -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 batchInsertOrUpdate(List configInfoList, String srcUser, String srcIp, + public Map batchInsertOrUpdate(List configInfoList, String srcUser, String srcIp, Map configAdvanceInfo, Timestamp time, boolean notify, SameConfigPolicy policy) throws NacosException { int succCount = 0; int skipCount = 0; @@ -3474,7 +3474,7 @@ public class PersistService { List> 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) { From 95b92b06e90087c05dc04a326369b8ad24f00cff Mon Sep 17 00:00:00 2001 From: nkorange Date: Fri, 6 Sep 2019 12:53:31 +0800 Subject: [PATCH 7/7] Fix #1621 --- api/pom.xml | 4 ++++ .../nacos/api/naming/pojo/AbstractHealthChecker.java | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index cc3b7e063..ee6d89d24 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -62,5 +62,9 @@ spring-test test + + com.google.guava + guava + diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/AbstractHealthChecker.java b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/AbstractHealthChecker.java index 8f09604a5..97259572b 100644 --- a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/AbstractHealthChecker.java +++ b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/AbstractHealthChecker.java @@ -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