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/01/19 07:28:54 UTC

[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2182: [INLONG-2161][Feature] Manager support getClusterConfig

luchunliang commented on a change in pull request #2182:
URL: https://github.com/apache/incubator-inlong/pull/2182#discussion_r787283828



##########
File path: inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sort/SortClusterConfigResponse.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.common.pojo.sort;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+@Data
+@ApiModel("sort cluster config")

Review comment:
       Avoid to use lombok plugin for readability. Coder need to add getter/setter code when coder want to find usages. Coder want to check source code, then coder must to install lombok plugin.

##########
File path: inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/SortClusterConfig.java
##########
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+@Data
+public class SortClusterConfig implements Serializable {
+    private Integer id;
+
+    private String clusterName;
+
+    private String taskName;
+
+    private static final long serialVersionUID = 1L;

Review comment:
       incorrect serialVersionUID

##########
File path: inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/TaskIdParamsKafkaEntity.java
##########
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+@Data
+public class TaskIdParamsKafkaEntity implements Serializable {
+    private Integer id;
+
+    private String parentName;
+
+    private String topic;
+
+    private static final long serialVersionUID = 1L;

Review comment:
       ditto

##########
File path: inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterConfigServiceImpl.java
##########
@@ -0,0 +1,258 @@
+/*
+ * 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.core.impl;
+
+import com.google.gson.Gson;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
+import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse.SortClusterConfig;
+import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse.SortTaskConfig;
+import org.apache.inlong.manager.dao.entity.TaskConfigEntity;
+import org.apache.inlong.manager.dao.mapper.SortClusterConfigMapper;
+import org.apache.inlong.manager.service.core.SortClusterConfigService;
+import org.apache.inlong.manager.service.core.TaskConfigService;
+import org.apache.inlong.manager.service.core.TaskIdParamsKafkaService;
+import org.apache.inlong.manager.service.core.TaskIdParamsPulsarService;
+import org.apache.inlong.manager.service.core.TaskSinkParamsEsService;
+import org.apache.inlong.manager.service.core.TaskSinkParamsKafkaService;
+import org.apache.inlong.manager.service.core.TaskSinkParamsPulsarService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Implementation of tSort Cluster config service layer interface.
+ */
+@Service
+@Slf4j
+public class SortClusterConfigServiceImpl implements SortClusterConfigService {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(SortClusterConfigServiceImpl.class);
+
+    @Autowired
+    private SortClusterConfigMapper sortClusterConfigMapper;
+
+    @Autowired
+    private TaskConfigService configService;
+
+    @Autowired
+    private TaskIdParamsPulsarService idParamsPulsarService;
+
+    @Autowired
+    private TaskIdParamsKafkaService idParamsKafkaService;
+
+    @Autowired
+    private TaskSinkParamsEsService sinkParamsEsService;
+
+    @Autowired
+    private TaskSinkParamsKafkaService sinkParamsKafkaService;
+
+    @Autowired
+    private TaskSinkParamsPulsarService sinkParamsPulsarService;
+
+    private static final Gson gson = new Gson();
+
+    @Override
+    public SortClusterConfigResponse get(
+            String clusterName,
+            String md5) {
+        SortClusterConfigResponse response = new SortClusterConfigResponse();
+        response.setResult(true);
+
+        // if the cluster name is invalid, return RESP_CODE_REQ_PARAMS_ERROR
+        if (isErrorReqParams(clusterName)) {
+            LOGGER.error("Empty cluster name, return RESP_CODE_REQ_PARAMS_ERROR");
+            response.setErrCode(SortClusterConfigResponse.RESP_CODE_REQ_PARAMS_ERROR);
+            response.setResult(false);
+            return response;
+        }
+
+        // if the cluster config is null, return RESP_CODE_FAIL
+        SortClusterConfig clusterConfig = this.getClusterConfig(clusterName);
+        if (clusterConfig == null) {
+            LOGGER.error("Cannot find cluster config for cluster {}, return RESP_CODE_FAIL", clusterName);
+            response.setErrCode(SortClusterConfigResponse.RESP_CODE_FAIL);
+            response.setResult(false);
+            return response;
+        }
+
+        // if md5 is the same as last request, return RESP_CODE_NO_UPDATE
+        String jsonClusterConfig = gson.toJson(clusterConfig);

Review comment:
       gson can not sort parameter name, then md5 maybe not  be a stable value.

##########
File path: inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/TaskConfigEntity.java
##########
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+@Data
+public class TaskConfigEntity implements Serializable {
+    private Integer id;
+
+    private String name;
+
+    private String type;
+
+    private String inlongGroupId;
+
+    private String inlongStreamId;
+
+    private static final long serialVersionUID = 1L;

Review comment:
       ditto

##########
File path: inlong-manager/manager-dao/src/main/resources/generatorConfig.xml
##########
@@ -212,5 +212,53 @@
                 enableCountByExample="false" enableDeleteByExample="false"
                 enableSelectByExample="false" enableUpdateByExample="false"/>-->
 
+        <!--<table tableName="task_config" domainObjectName="TaskConfigEntity"
+               enableSelectByPrimaryKey="true"
+               enableUpdateByPrimaryKey="true"
+               enableDeleteByPrimaryKey="true" enableInsert="true"
+               enableCountByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" enableUpdateByExample="false"/>
+
+        <table tableName="task_id_params_kafka" domainObjectName="TaskIdParamsKafkaEntity"
+               enableSelectByPrimaryKey="true"
+               enableUpdateByPrimaryKey="true"
+               enableDeleteByPrimaryKey="true" enableInsert="true"
+               enableCountByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" enableUpdateByExample="false"/>
+
+        <table tableName="task_id_params_pulsar" domainObjectName="TaskIdParamsPulsarEntity"
+               enableSelectByPrimaryKey="true"
+               enableUpdateByPrimaryKey="true"
+               enableDeleteByPrimaryKey="true" enableInsert="true"
+               enableCountByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" enableUpdateByExample="false"/>
+
+        <table tableName="task_sink_params_kafka" domainObjectName="TaskSinkParamsKafkaEntity"
+               enableSelectByPrimaryKey="true"
+               enableUpdateByPrimaryKey="true"
+               enableDeleteByPrimaryKey="true" enableInsert="true"
+               enableCountByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" enableUpdateByExample="false"/>
+
+        <table tableName="task_sink_params_pulsar" domainObjectName="TaskSinkParamsPulsarEntity"
+               enableSelectByPrimaryKey="true"
+               enableUpdateByPrimaryKey="true"
+               enableDeleteByPrimaryKey="true" enableInsert="true"
+               enableCountByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" enableUpdateByExample="false"/>
+
+        <table tableName="task_sink_params_es" domainObjectName="TaskSinkParamsEsEntity"
+               enableSelectByPrimaryKey="true"
+               enableUpdateByPrimaryKey="true"
+               enableDeleteByPrimaryKey="true" enableInsert="true"
+               enableCountByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" enableUpdateByExample="false"/>-->

Review comment:
       Invalid code need to be removed.

##########
File path: inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/TaskSinkParamsKafkaEntity.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+@Data
+public class TaskSinkParamsKafkaEntity implements Serializable {
+    private Integer id;
+
+    private String parentName;
+
+    private String zkList;
+
+    private String brokerList;
+
+    private static final long serialVersionUID = 1L;

Review comment:
       serialVersionUID can be generated by IDE.

##########
File path: inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/SortClusterConfig.java
##########
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+
+@Data
+public class SortClusterConfig implements Serializable {
+    private Integer id;
+
+    private String clusterName;
+
+    private String taskName;
+
+    private static final long serialVersionUID = 1L;

Review comment:
       static variable is before member variable.

##########
File path: inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sort/SortStandAloneClusterConfigRequest.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.common.pojo.sort;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel("Sort-StandAlone cluster config request")
+public class SortStandAloneClusterConfigRequest {
+
+    @ApiModelProperty(value = "cluster name")

Review comment:
       ditto




-- 
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