You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/05/18 06:39:03 UTC

[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4200: [INLONG-4177][Manager] Refactor getClusterConfig interface

healchow commented on code in PR #4200:
URL: https://github.com/apache/incubator-inlong/pull/4200#discussion_r875517977


##########
inlong-manager/manager-dao/src/main/resources/mappers/SortClusterMapper.xml:
##########
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.inlong.manager.dao.mapper.SortClusterMapper">
+    <resultMap id="SortTaskDTO" type="org.apache.inlong.manager.dao.entity.SortTaskDTO">
+        <result column="inlong_cluster_name" jdbcType="VARCHAR" property="sortClusterName"/>
+        <result column="sort_task_name" jdbcType="VARCHAR" property="sortTaskName"/>
+        <result column="sort_consumer_group" jdbcType="VARCHAR" property="sortConsumerGroup"/>
+        <result column="sink_type" jdbcType="VARCHAR" property="sinkType"/>
+        <result column="data_node_name" jdbcType="VARCHAR" property="dataNodeName"/>
+    </resultMap>
+    <resultMap id="SortSinkParamsDTO" type="org.apache.inlong.manager.dao.entity.SortSinkParamsDTO">
+        <result column="sort_task_name" jdbcType="VARCHAR" property="sortTaskName"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="type" jdbcType="VARCHAR" property="type"/>
+        <result column="ext_params" jdbcType="VARCHAR" property="extParams"/>
+    </resultMap>
+    <resultMap id="SortIdParamsDTO" type="org.apache.inlong.manager.dao.entity.SortIdParamsDTO">
+        <result column="sort_task_name" jdbcType="VARCHAR" property="sortTaskName"/>
+        <result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId"/>
+        <result column="inlong_stream_id" jdbcType="VARCHAR" property="inlongStreamId"/>
+        <result column="ext_params" jdbcType="VARCHAR" property="extParams"/>
+    </resultMap>
+
+    <select id="selectAllTasks" resultMap="SortTaskDTO">
+        select
+            inlong_cluster_name, sort_task_name, sort_consumer_group, sink_type, data_node_name
+        from stream_sink
+        <where>
+            is_deleted = 0
+        </where>
+        group by
+            inlong_cluster_name, sort_task_name, sort_consumer_group, sink_type, data_node_name
+    </select>
+
+    <select id="selectAllSinkParams" resultMap="SortSinkParamsDTO">
+        select

Review Comment:
   Why not combine the `selectAllSinkParams` and `selectAllIdParams` into one query through the associated query?



##########
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/SortIdParamsDTO.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.inlong.manager.dao.entity;

Review Comment:
   Please move those `DTO` into `common/pojo` package, because the `entity` package should only be used for table entities.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/repository/SortConfigRepository.java:
##########
@@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.inlong.manager.service.repository;
+
+import com.google.gson.Gson;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.common.pojo.dataproxy.IRepository;
+import org.apache.inlong.common.pojo.sortstandalone.SortClusterConfig;
+import org.apache.inlong.common.pojo.sortstandalone.SortClusterResponse;
+import org.apache.inlong.common.pojo.sortstandalone.SortTaskConfig;
+import org.apache.inlong.manager.dao.entity.SortIdParamsDTO;
+import org.apache.inlong.manager.dao.entity.SortSinkParamsDTO;
+import org.apache.inlong.manager.dao.entity.SortTaskDTO;
+import org.apache.inlong.manager.dao.mapper.SortClusterMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.PostConstruct;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+/**
+ * Use to cache the sort cluster config and reduce the number of query to database.
+ */
+@Repository
+public class SortConfigRepository implements IRepository {

Review Comment:
   Do we really need to implements the `org.apache.inlong.common.pojo.dataproxy.IRepository` in inlong-common module?
   
   Just operate in the inlong-manager module, does it enough?



##########
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/SortIdParamsDTO.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.inlong.manager.dao.entity;
+
+import lombok.Data;
+
+@Data
+public class SortIdParamsDTO {

Review Comment:
   From the context, maybe the `SortSinkDTO` is a better name?



##########
inlong-manager/manager-dao/src/main/resources/mappers/SortClusterMapper.xml:
##########
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.inlong.manager.dao.mapper.SortClusterMapper">

Review Comment:
   It is suggested to operate tables in their related mappers, so it seems that no need to add an additional `SortClusterMapper` to handle?



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org