luchunliang commented on code in PR #4938:
URL: https://github.com/apache/inlong/pull/4938#discussion_r922800129
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/repository/DataProxyConfigRepository.java:
##########
@@ -163,53 +175,108 @@ private Map<String, List<InLongIdObject>>
reloadInlongId() {
if (groupId == null) {
continue;
}
- // choose topic
- String groupTopic = groupIdObj.getTopic();
- String streamTopic = streamIdObj.getTopic();
- String finalTopic = null;
- if (StringUtils.isEmpty(groupTopic)) {
- // both empty then ignore
- if (StringUtils.isEmpty(streamTopic)) {
- continue;
- } else {
- finalTopic = streamTopic;
- }
+ Map<String, String> groupParams =
this.getExtParams(groupIdObj.getExtParams());
+ Map<String, String> streamParams =
this.getExtParams(streamIdObj.getExtParams());
+ this.parseFirstTopic(groupIdObj, streamIdObj, groupParams,
streamParams, inlongIdMap);
+ this.parseSecondTopic(groupIdObj, streamIdObj, groupParams,
streamParams, inlongIdMap);
+ }
+ return inlongIdMap;
+ }
+
+ /**
+ * getExtParams
+ */
+ @SuppressWarnings("unchecked")
+ private Map<String, String> getExtParams(String extParams) {
+ // parse extparams
+ if (!StringUtils.isEmpty(extParams)) {
+ try {
+ Map<String, String> groupParams = gson.fromJson(extParams,
HashMap.class);
+ return groupParams;
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage(), e);
Review Comment:
fix it
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/repository/DataProxyConfigRepository.java:
##########
@@ -313,4 +380,60 @@ public String getProxyMd5(String clusterName) {
public String getProxyConfigJson(String clusterName) {
return this.proxyConfigJson.get(clusterName);
}
+
+ /**
+ * changeClusterTag
+ */
+ public String changeClusterTag(String inlongGroupId, String clusterTag,
+ String topic) {
+ // select
+ InlongGroupEntity oldGroup =
inlongGroupMapper.selectByGroupId(inlongGroupId);
+ if (oldGroup == null) {
+ throw new BusinessException(ErrorCodeEnum.GROUP_NOT_FOUND);
+ }
+ // parse ext_params
+ String extParams = oldGroup.getExtParams();
+ if (StringUtils.isEmpty(extParams)) {
+ extParams = "{}";
+ }
+ // parse json
+ Gson gson = new Gson();
+ JsonObject extParamsObj = gson.fromJson(extParams, JsonObject.class);
+ // change cluster tag
+ extParamsObj.addProperty(KEY_SECOND_CLUSTER_TAG,
oldGroup.getInlongClusterTag());
+ extParamsObj.addProperty(KEY_SECOND_TOPIC, oldGroup.getMqResource());
+ oldGroup.setInlongClusterTag(clusterTag);
+ oldGroup.setMqResource(topic);
+ String newExtParams = extParamsObj.toString();
+ oldGroup.setExtParams(newExtParams);
+ // update
+ inlongGroupMapper.updateByIdentifierSelective(oldGroup);
+ return inlongGroupId;
+ }
+
+ /**
+ * removeSecondClusterTag
+ */
+ public String removeSecondClusterTag(String inlongGroupId) {
Review Comment:
add UT code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]