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/07/13 07:23:01 UTC

[GitHub] [inlong] haifxu opened a new pull request, #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

haifxu opened a new pull request, #5021:
URL: https://github.com/apache/inlong/pull/5021

   ### [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager
   
   - Fixes #5020 
   
   ### Modifications
   
   Split `InnerInlongManagerClient` into multiple clients to prevent it from being too large.
   
   ### Verifying this change
   
   - [ ] This change is already covered by existing tests, such as:
   - org/apache/inlong/manager/client/api/impl/InlongGroupImplTest.java
   - org/apache/inlong/manager/client/api/impl/InlongStreamImplTest.java
   - org/apache/inlong/manager/client/api/inner/InnerInlongManagerClientTest.java
   
   


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


[GitHub] [inlong] healchow commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r921736440


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/ClientUtils.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.client.api.util;
+
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import org.apache.inlong.manager.client.api.ClientConfiguration;
+import org.apache.inlong.manager.client.api.inner.client.ClientFactory;
+import org.apache.inlong.manager.client.api.service.AuthInterceptor;
+import org.apache.inlong.manager.common.auth.Authentication;
+import org.apache.inlong.manager.common.auth.DefaultAuthentication;
+import org.apache.inlong.manager.common.beans.Response;
+import org.apache.inlong.manager.common.util.JsonUtils;
+import org.apache.inlong.manager.common.util.Preconditions;
+import retrofit2.Call;
+import retrofit2.Retrofit;
+import retrofit2.converter.jackson.JacksonConverterFactory;
+
+import java.io.IOException;
+import java.util.Optional;
+
+/**
+ * Utils for client
+ */
+@Slf4j
+@UtilityClass
+public class ClientUtils {
+
+    private static final String REQUEST_FAILED_MSG = "Request to Inlong %s failed: %s";
+
+    private static ClientFactory clientFactory;
+
+    public static ClientFactory getClientFactory(ClientConfiguration configuration) {

Review Comment:
   Please add Java docs for those public static methods.



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


[GitHub] [inlong] haifxu commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
haifxu commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r919811954


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/WorkflowClient.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.client.api.inner.client;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.github.pagehelper.PageInfo;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.client.api.ClientConfiguration;
+import org.apache.inlong.manager.client.api.service.StreamTransformApi;
+import org.apache.inlong.manager.client.api.service.WorkflowApi;
+import org.apache.inlong.manager.client.api.util.ClientUtils;
+import org.apache.inlong.manager.common.beans.Response;
+import org.apache.inlong.manager.common.pojo.workflow.EventLogView;
+import org.apache.inlong.manager.common.pojo.workflow.WorkflowResult;
+import org.apache.inlong.manager.common.pojo.workflow.form.process.NewGroupProcessForm;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Client for {@link WorkflowApi}.
+ */
+@Slf4j
+public class WorkflowClient {
+
+    private final WorkflowApi workflowApi;
+    private final ObjectMapper objectMapper = new ObjectMapper();
+
+    public WorkflowClient(ClientConfiguration configuration) {
+        workflowApi = ClientUtils.createRetrofit(configuration).create(WorkflowApi.class);
+    }
+
+    public WorkflowResult startInlongGroup(int taskId, NewGroupProcessForm newGroupProcessForm) {
+        ObjectNode workflowTaskOperation = objectMapper.createObjectNode();
+        workflowTaskOperation.putPOJO("transferTo", Lists.newArrayList());
+        workflowTaskOperation.put("remark", "approved by system");
+
+        ObjectNode inlongGroupApproveForm = objectMapper.createObjectNode();
+        inlongGroupApproveForm.putPOJO("groupApproveInfo", newGroupProcessForm.getGroupInfo());
+        inlongGroupApproveForm.putPOJO("streamApproveInfoList", newGroupProcessForm.getStreamInfoList());
+        inlongGroupApproveForm.put("formName", "InlongGroupApproveForm");
+        workflowTaskOperation.set("form", inlongGroupApproveForm);
+
+        log.info("startInlongGroup workflowTaskOperation: {}", inlongGroupApproveForm);
+
+        Map<String, Object> requestMap = JsonUtils.OBJECT_MAPPER.convertValue(workflowTaskOperation,
+                new TypeReference<Map<String, Object>>() {
+                });
+        Response<WorkflowResult> response = ClientUtils.executeHttpCall(
+                workflowApi.startInlongGroup(taskId, requestMap));
+        ClientUtils.assertRespSuccess(response);
+
+        return response.getData();
+    }
+
+    /**
+     * get inlong group error messages
+     */
+    public List<EventLogView> getInlongGroupError(String inlongGroupId) {
+        Response<PageInfo<EventLogView>> response = ClientUtils.executeHttpCall(
+                workflowApi.getInlongGroupError(inlongGroupId, -1));

Review Comment:
   This method is just copied from innerClient, but I'll figure out what it means and comment.



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


[GitHub] [inlong] healchow commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r921762613


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/impl/InlongStreamImpl.java:
##########
@@ -67,10 +82,17 @@ public class InlongStreamImpl implements InlongStream {
     /**
      * Constructor of InlongStreamImpl.
      */
-    public InlongStreamImpl(InlongStreamInfo streamInfo, InnerInlongManagerClient managerClient) {
-        this.managerClient = managerClient;
+    public InlongStreamImpl(InlongStreamInfo streamInfo, ClientConfiguration configuration) {
+//        this.managerClient = managerClient;

Review Comment:
   Why comment on this line? If it is unnecessary, please remove it.



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


[GitHub] [inlong] haifxu commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
haifxu commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r920696171


##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/util/ClientUtils.java:
##########
@@ -84,4 +85,17 @@ public static String readFile(File file) {
         return null;
     }
 
+    private static void initClientConfiguration() throws IOException {
+        Properties properties = new Properties();
+        String path = Thread.currentThread().getContextClassLoader().getResource("").getPath() + CONFIG_FILE;
+        InputStream inputStream = new BufferedInputStream(Files.newInputStream(Paths.get(path)));

Review Comment:
   done



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


[GitHub] [inlong] haifxu commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
haifxu commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r921746785


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/ClientUtils.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.client.api.util;
+
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import org.apache.inlong.manager.client.api.ClientConfiguration;
+import org.apache.inlong.manager.client.api.inner.client.ClientFactory;
+import org.apache.inlong.manager.client.api.service.AuthInterceptor;
+import org.apache.inlong.manager.common.auth.Authentication;
+import org.apache.inlong.manager.common.auth.DefaultAuthentication;
+import org.apache.inlong.manager.common.beans.Response;
+import org.apache.inlong.manager.common.util.JsonUtils;
+import org.apache.inlong.manager.common.util.Preconditions;
+import retrofit2.Call;
+import retrofit2.Retrofit;
+import retrofit2.converter.jackson.JacksonConverterFactory;
+
+import java.io.IOException;
+import java.util.Optional;
+
+/**
+ * Utils for client
+ */
+@Slf4j
+@UtilityClass
+public class ClientUtils {
+
+    private static final String REQUEST_FAILED_MSG = "Request to Inlong %s failed: %s";
+
+    private static ClientFactory clientFactory;
+
+    public static ClientFactory getClientFactory(ClientConfiguration configuration) {

Review Comment:
   Done.



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


[GitHub] [inlong] leosanqing commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
leosanqing commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r919754195


##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/util/ClientUtils.java:
##########
@@ -84,4 +85,17 @@ public static String readFile(File file) {
         return null;
     }
 
+    private static void initClientConfiguration() throws IOException {
+        Properties properties = new Properties();
+        String path = Thread.currentThread().getContextClassLoader().getResource("").getPath() + CONFIG_FILE;
+        InputStream inputStream = new BufferedInputStream(Files.newInputStream(Paths.get(path)));

Review Comment:
   please use try-with-resource to close the stream



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


[GitHub] [inlong] healchow merged pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
healchow merged PR #5021:
URL: https://github.com/apache/inlong/pull/5021


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


[GitHub] [inlong] leosanqing commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
leosanqing commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r919763840


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/impl/InlongGroupImpl.java:
##########
@@ -62,30 +67,38 @@ public class InlongGroupImpl implements InlongGroup {
 
     private final InnerGroupContext groupContext;
     private InlongGroupInfo groupInfo;
-    private InnerInlongManagerClient managerClient;
+    private final InlongGroupClient groupClient;
+    private final WorkflowClient workFlowClient;
+    private final InlongStreamClient streamClient;
+    private final ClientConfiguration configuration;
 
-    public InlongGroupImpl(InlongGroupInfo groupInfo, InlongClientImpl inlongClient) {
+    public InlongGroupImpl(InlongGroupInfo groupInfo, ClientConfiguration configuration) {
         this.groupInfo = groupInfo;
         this.groupContext = new InnerGroupContext();
         this.groupContext.setGroupInfo(groupInfo);
-        if (this.managerClient == null) {
-            this.managerClient = new InnerInlongManagerClient(inlongClient.getConfiguration());
-        }
+        this.configuration = configuration;
+
+        ClientFactory clientFactory = ClientUtils.getClientFactory(configuration);
+        this.streamClient = clientFactory.getStreamClient();
+        this.groupClient = clientFactory.getGroupClient();
+        this.workFlowClient = clientFactory.getWorkflowClient();
+
+//        this.groupClient =
 
-        InlongGroupInfo newGroupInfo = managerClient.getGroupIfExists(groupInfo.getInlongGroupId());
+        InlongGroupInfo newGroupInfo = groupClient.getGroupIfExists(groupInfo.getInlongGroupId());
         if (newGroupInfo != null) {
             this.groupContext.setGroupInfo(groupInfo);

Review Comment:
   Should this be newGroupInfo?



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


[GitHub] [inlong] haifxu commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
haifxu commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r919809160


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/WorkflowClient.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.client.api.inner.client;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.github.pagehelper.PageInfo;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.client.api.ClientConfiguration;
+import org.apache.inlong.manager.client.api.service.StreamTransformApi;
+import org.apache.inlong.manager.client.api.service.WorkflowApi;
+import org.apache.inlong.manager.client.api.util.ClientUtils;
+import org.apache.inlong.manager.common.beans.Response;
+import org.apache.inlong.manager.common.pojo.workflow.EventLogView;
+import org.apache.inlong.manager.common.pojo.workflow.WorkflowResult;
+import org.apache.inlong.manager.common.pojo.workflow.form.process.NewGroupProcessForm;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Client for {@link WorkflowApi}.
+ */
+@Slf4j
+public class WorkflowClient {
+
+    private final WorkflowApi workflowApi;
+    private final ObjectMapper objectMapper = new ObjectMapper();
+
+    public WorkflowClient(ClientConfiguration configuration) {
+        workflowApi = ClientUtils.createRetrofit(configuration).create(WorkflowApi.class);
+    }
+
+    public WorkflowResult startInlongGroup(int taskId, NewGroupProcessForm newGroupProcessForm) {
+        ObjectNode workflowTaskOperation = objectMapper.createObjectNode();
+        workflowTaskOperation.putPOJO("transferTo", Lists.newArrayList());
+        workflowTaskOperation.put("remark", "approved by system");
+
+        ObjectNode inlongGroupApproveForm = objectMapper.createObjectNode();
+        inlongGroupApproveForm.putPOJO("groupApproveInfo", newGroupProcessForm.getGroupInfo());
+        inlongGroupApproveForm.putPOJO("streamApproveInfoList", newGroupProcessForm.getStreamInfoList());
+        inlongGroupApproveForm.put("formName", "InlongGroupApproveForm");
+        workflowTaskOperation.set("form", inlongGroupApproveForm);
+
+        log.info("startInlongGroup workflowTaskOperation: {}", inlongGroupApproveForm);
+
+        Map<String, Object> requestMap = JsonUtils.OBJECT_MAPPER.convertValue(workflowTaskOperation,
+                new TypeReference<Map<String, Object>>() {
+                });

Review Comment:
   This is the code style for anonymous inner classes, so it must be in a new line.



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


[GitHub] [inlong] vernedeng commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r919751073


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/WorkflowClient.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.client.api.inner.client;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.github.pagehelper.PageInfo;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.client.api.ClientConfiguration;
+import org.apache.inlong.manager.client.api.service.StreamTransformApi;
+import org.apache.inlong.manager.client.api.service.WorkflowApi;
+import org.apache.inlong.manager.client.api.util.ClientUtils;
+import org.apache.inlong.manager.common.beans.Response;
+import org.apache.inlong.manager.common.pojo.workflow.EventLogView;
+import org.apache.inlong.manager.common.pojo.workflow.WorkflowResult;
+import org.apache.inlong.manager.common.pojo.workflow.form.process.NewGroupProcessForm;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Client for {@link WorkflowApi}.
+ */
+@Slf4j
+public class WorkflowClient {
+
+    private final WorkflowApi workflowApi;
+    private final ObjectMapper objectMapper = new ObjectMapper();
+
+    public WorkflowClient(ClientConfiguration configuration) {
+        workflowApi = ClientUtils.createRetrofit(configuration).create(WorkflowApi.class);
+    }
+
+    public WorkflowResult startInlongGroup(int taskId, NewGroupProcessForm newGroupProcessForm) {
+        ObjectNode workflowTaskOperation = objectMapper.createObjectNode();
+        workflowTaskOperation.putPOJO("transferTo", Lists.newArrayList());
+        workflowTaskOperation.put("remark", "approved by system");
+
+        ObjectNode inlongGroupApproveForm = objectMapper.createObjectNode();
+        inlongGroupApproveForm.putPOJO("groupApproveInfo", newGroupProcessForm.getGroupInfo());
+        inlongGroupApproveForm.putPOJO("streamApproveInfoList", newGroupProcessForm.getStreamInfoList());
+        inlongGroupApproveForm.put("formName", "InlongGroupApproveForm");
+        workflowTaskOperation.set("form", inlongGroupApproveForm);
+
+        log.info("startInlongGroup workflowTaskOperation: {}", inlongGroupApproveForm);
+
+        Map<String, Object> requestMap = JsonUtils.OBJECT_MAPPER.convertValue(workflowTaskOperation,
+                new TypeReference<Map<String, Object>>() {
+                });
+        Response<WorkflowResult> response = ClientUtils.executeHttpCall(
+                workflowApi.startInlongGroup(taskId, requestMap));
+        ClientUtils.assertRespSuccess(response);
+
+        return response.getData();
+    }
+
+    /**
+     * get inlong group error messages
+     */
+    public List<EventLogView> getInlongGroupError(String inlongGroupId) {
+        Response<PageInfo<EventLogView>> response = ClientUtils.executeHttpCall(
+                workflowApi.getInlongGroupError(inlongGroupId, -1));

Review Comment:
   magic number -1 , plz add comment to explan what "-1" stand for



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


[GitHub] [inlong] haifxu commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
haifxu commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r921770274


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/impl/InlongStreamImpl.java:
##########
@@ -67,10 +82,17 @@ public class InlongStreamImpl implements InlongStream {
     /**
      * Constructor of InlongStreamImpl.
      */
-    public InlongStreamImpl(InlongStreamInfo streamInfo, InnerInlongManagerClient managerClient) {
-        this.managerClient = managerClient;
+    public InlongStreamImpl(InlongStreamInfo streamInfo, ClientConfiguration configuration) {
+//        this.managerClient = managerClient;

Review Comment:
   Removed.



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


[GitHub] [inlong] vernedeng commented on a diff in pull request #5021: [INLONG-5020][Manager] Refactoring InnerInlongManagerClient of manager

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #5021:
URL: https://github.com/apache/inlong/pull/5021#discussion_r919751971


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/WorkflowClient.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.client.api.inner.client;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.github.pagehelper.PageInfo;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.client.api.ClientConfiguration;
+import org.apache.inlong.manager.client.api.service.StreamTransformApi;
+import org.apache.inlong.manager.client.api.service.WorkflowApi;
+import org.apache.inlong.manager.client.api.util.ClientUtils;
+import org.apache.inlong.manager.common.beans.Response;
+import org.apache.inlong.manager.common.pojo.workflow.EventLogView;
+import org.apache.inlong.manager.common.pojo.workflow.WorkflowResult;
+import org.apache.inlong.manager.common.pojo.workflow.form.process.NewGroupProcessForm;
+import org.apache.inlong.manager.common.util.JsonUtils;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Client for {@link WorkflowApi}.
+ */
+@Slf4j
+public class WorkflowClient {
+
+    private final WorkflowApi workflowApi;
+    private final ObjectMapper objectMapper = new ObjectMapper();
+
+    public WorkflowClient(ClientConfiguration configuration) {
+        workflowApi = ClientUtils.createRetrofit(configuration).create(WorkflowApi.class);
+    }
+
+    public WorkflowResult startInlongGroup(int taskId, NewGroupProcessForm newGroupProcessForm) {
+        ObjectNode workflowTaskOperation = objectMapper.createObjectNode();
+        workflowTaskOperation.putPOJO("transferTo", Lists.newArrayList());
+        workflowTaskOperation.put("remark", "approved by system");
+
+        ObjectNode inlongGroupApproveForm = objectMapper.createObjectNode();
+        inlongGroupApproveForm.putPOJO("groupApproveInfo", newGroupProcessForm.getGroupInfo());
+        inlongGroupApproveForm.putPOJO("streamApproveInfoList", newGroupProcessForm.getStreamInfoList());
+        inlongGroupApproveForm.put("formName", "InlongGroupApproveForm");
+        workflowTaskOperation.set("form", inlongGroupApproveForm);
+
+        log.info("startInlongGroup workflowTaskOperation: {}", inlongGroupApproveForm);
+
+        Map<String, Object> requestMap = JsonUtils.OBJECT_MAPPER.convertValue(workflowTaskOperation,
+                new TypeReference<Map<String, Object>>() {
+                });

Review Comment:
   no need to make a new line



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