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/02/21 03:26:01 UTC

[GitHub] [incubator-inlong] EMsnap commented on a change in pull request #2547: [INLONG-2545][Agent] agent pull task (binlog,file) from manager

EMsnap commented on a change in pull request #2547:
URL: https://github.com/apache/incubator-inlong/pull/2547#discussion_r809942307



##########
File path: inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/dtos/JobProfileDto.java
##########
@@ -130,11 +219,21 @@ public static TriggerProfile convertToTriggerProfile(DataConfig dataConfigs) {
         if (!dataConfigs.isValid()) {
             throw new IllegalArgumentException("input dataConfig" + dataConfigs + "is invalid please check");
         }
+        TaskTypeEnum taskType=TaskTypeEnum.getTaskType(dataConfigs.getTaskType());
         JobProfileDto profileDto = new JobProfileDto();
         Proxy proxy = getProxy(dataConfigs);
-        Job job = getJob(dataConfigs);
+        switch (taskType) {
+            case SQL:
+            case BINLOG:
+                BinlogJob binlogJob = getBinlogJob(dataConfigs);
+                profileDto.setBinlogJob(binlogJob);
+            case FILE:
+                FileJob job = getFileJob(dataConfigs);

Review comment:
       The name of fileJob should be job since the Jobprofile use job.propertise to get property from profile

##########
File path: inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/dtos/JobProfileDto.java
##########
@@ -91,27 +144,63 @@
         private Manager manager;
     }
 
-    private static Job getJob(DataConfig dataConfigs) {
-        Job job = new Job();
+    private static BinlogJob getBinlogJob(DataConfig dataConfigs) {
+
+        BinlogJob binlogJob = new BinlogJob();
+        BinlogJobTaskConfig binlogJobTaskConfig =new BinlogJobTaskConfig();
+        Gson gson = new Gson();
+        binlogJobTaskConfig=gson.fromJson(dataConfigs.getTaskConfig(),BinlogJobTaskConfig.class);
+
+
+        binlogJob.setTrigger(DEFAULT_TRIGGER);
+        binlogJob.setChannel(DEFAULT_CHANNEL);
+        binlogJob.setName(MANAGER_JOB);
+        binlogJob.setSource(DEFAULT_SOURCE);
+        binlogJob.setSink(DEFAULT_DATAPROXY_SINK);
+        binlogJob.setOp(dataConfigs.getOp());
+        binlogJob.setDeliveryTime(dataConfigs.getDeliveryTime());
+
+        binlogJob.setJob_database_hostname(binlogJobTaskConfig.getJob_database_hostname());

Review comment:
       Camel-Case pls

##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/enums/ManagerOpEnum.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.agent.enums;
+
+import static java.util.Objects.requireNonNull;
+
+public enum ManagerOpEnum {

Review comment:
       PLS extract to inlong common 

##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/enums/TaskTypeEnum.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.agent.enums;
+
+import static java.util.Objects.requireNonNull;
+
+public enum TaskTypeEnum {

Review comment:
       Pls extract to inlong common

##########
File path: inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/dtos/JobProfileDto.java
##########
@@ -58,24 +62,73 @@
     }
 
     @Data
-    public static class Job {
+    public static class FileJob {
 
-        private Dir dir;
-        private String trigger;
-        private int id;
-        private Thread thread;
+        private String op;
         private String name;
         private String source;
         private String sink;
         private String channel;
+        private String trigger;
+        private String deliveryTime;
+
+
+        private Dir dir;
+        private int id;
+        private Thread thread;
         private String pattern;
-        private String op;
         private String cycleUnit;
         private String timeOffset;
-        private String deliveryTime;
         private String addictiveString;
     }
 
+    @Data
+    public static class FileJobTaskConfig {
+
+        private String dataName;
+        private String path;
+        private int taskId;
+        private Thread thread;
+        private String pattern;
+        private String cycleUnit;
+        private String timeOffset;
+        private String additionalAttr;
+    }
+
+    @Data
+    public static class BinlogJob {
+
+        private String op;
+        private String trigger;
+        private String name;
+        private String source;
+        private String sink;
+        private String channel;
+        private String deliveryTime;
+
+        private  String job_database_user;

Review comment:
       camel case 




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