This is an automated email from the ASF dual-hosted git repository.

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 2dbfa28  [INLONG-2161][Feature][Manager] Manager support 
getSortClusterConfig interface. (#2278)
2dbfa28 is described below

commit 2dbfa280c2c78b2144c9e984bdb3f275b3eba9a1
Author: imvan <[email protected]>
AuthorDate: Sun Jan 23 14:35:12 2022 +0800

    [INLONG-2161][Feature][Manager] Manager support getSortClusterConfig 
interface. (#2278)
---
 .../pojo/sort/SortClusterConfigResponse.java       | 47 ++++++++++++++++
 .../inlong/manager/service/core/SortService.java   | 41 ++++++++++++++
 .../manager/service/core/impl/SortServiceImpl.java | 41 ++++++++++++++
 .../web/controller/openapi/SortController.java     | 45 ++++++++++++++++
 .../web/controller/openapi/SortControllerTest.java | 63 ++++++++++++++++++++++
 5 files changed, 237 insertions(+)

diff --git 
a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sort/SortClusterConfigResponse.java
 
b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sort/SortClusterConfigResponse.java
new file mode 100644
index 0000000..78c9539
--- /dev/null
+++ 
b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sort/SortClusterConfigResponse.java
@@ -0,0 +1,47 @@
+/*
+ * 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 lombok.Builder;
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+@Data
+@Builder
+@ApiModel("Sort cluster config")
+public class SortClusterConfigResponse {
+    String msg;
+    int code;
+    String md5;
+    List<SortTaskConfig> tasks;
+
+    public static class SortClusterConfig {
+        String clusterName;
+        List<SortTaskConfig> sortTasks;
+    }
+
+    public static class SortTaskConfig {
+        String taskName;
+        String type;
+        List<Map<String, String>> idParams;
+        Map<String, String> sinkParams;
+    }
+}
diff --git 
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortService.java
 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortService.java
new file mode 100644
index 0000000..6542e6d
--- /dev/null
+++ 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortService.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
+
+/**
+ * Sort Service
+ */
+public interface SortService {
+    /**
+     * Get sort cluster config.
+     *
+     * <p>For a specific sort cluster, there are a series of tasks that 
defined how dataflow into and
+     * out from sort.</p>
+     *
+     * <p>The param of md5 represents the md5 value of last update response.
+     * if the md5 is same with the newest one, which means all configs are not 
updated,
+     * the detailed config in response will be <b>NULL</b>.</p>
+     *
+     * @param clusterName Name of sort cluster.
+     * @param md5 Last update md5.
+     * @return Response of sort cluster config {@link 
SortClusterConfigResponse}
+     */
+    SortClusterConfigResponse getClusterConfig(String clusterName, String md5);
+}
diff --git 
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
new file mode 100644
index 0000000..f287939
--- /dev/null
+++ 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
@@ -0,0 +1,41 @@
+/*
+ * 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 lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
+import org.apache.inlong.manager.service.core.SortService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * Sort service implementation.
+ */
+@Slf4j
+@Service
+public class SortServiceImpl implements SortService {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(SortServiceImpl.class);
+
+    @Override
+    public SortClusterConfigResponse getClusterConfig(String clusterName, 
String md5) {
+        LOGGER.info("start getClusterConfig");
+        return SortClusterConfigResponse.builder().build();
+    }
+}
diff --git 
a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/SortController.java
 
b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/SortController.java
new file mode 100644
index 0000000..fd1655e
--- /dev/null
+++ 
b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/SortController.java
@@ -0,0 +1,45 @@
+/*
+ * 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.web.controller.openapi;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
+import org.apache.inlong.manager.service.core.SortService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/openapi/sort")
+@Api(tags = "Sort Config")
+public class SortController {
+
+    @Autowired
+    private SortService sortService;
+
+    @GetMapping("/getClusterConfig")
+    @ApiOperation(value = "get sort cluster config")
+    public SortClusterConfigResponse getSortClusterConfig(
+            @RequestParam String clusterName,
+            @RequestParam String md5) {
+        return sortService.getClusterConfig(clusterName, md5);
+    }
+}
diff --git 
a/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/openapi/SortControllerTest.java
 
b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/openapi/SortControllerTest.java
new file mode 100644
index 0000000..8c1277f
--- /dev/null
+++ 
b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/openapi/SortControllerTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.web.controller.openapi;
+
+import static 
org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static 
org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static 
org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.RequestBuilder;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SortControllerTest {
+
+    private MockMvc mockMvc;
+
+    @Autowired
+    private WebApplicationContext webApplicationContext;
+
+    @Before
+    public void setUp() {
+        mockMvc = 
MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
+    }
+
+    /**
+     * Test if the interface works.
+     * @throws Exception Exceptions to request generating.
+     */
+    @Test
+    public void testGetSortClusterConfig() throws Exception {
+        RequestBuilder request =
+                get("/openapi/sort/getClusterConfig")
+                        .param("clusterName", "testName")
+                        .param("md5", "testMd5");
+        mockMvc.perform(request)
+                .andExpect(status().isOk())
+                .andDo(print());
+    }
+}
\ No newline at end of file

Reply via email to