Hisoka-X commented on code in PR #5542:
URL: https://github.com/apache/seatunnel/pull/5542#discussion_r1365252490


##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobExecutionEnvironment.java:
##########
@@ -64,6 +83,92 @@ protected MultipleTableJobConfigParser getJobConfigParser() {
                 jobFilePath, idGenerator, jobConfig, commonPluginJars, 
isStartWithSavePoint);
     }
 
+    @Override
+    protected LogicalDag getLogicalDag() {
+        ImmutablePair<List<Action>, Set<URL>> immutablePair = 
getJobConfigParser().parse();
+        actions.addAll(immutablePair.getLeft());
+        // Enable upload connector jar package to engine server, automatically 
upload connector Jar
+        // packages
+        // and dependent third-party Jar packages to the server before job 
execution.
+        // Enabling this configuration does not require the server to hold all 
connector Jar
+        // packages.
+        boolean enableUploadConnectorJarPackage =
+                
seaTunnelConfig.getEngineConfig().getConnectorJarStorageConfig().getEnable();
+        if (enableUploadConnectorJarPackage == true) {
+            /**
+             * TODO: Before uploading the Jar package file the server, first 
determine whether the
+             * server holds the current Jar. If the server holds the same Jar 
package file, there is
+             * no need for additional uploads.
+             */
+            Set<ConnectorJarIdentifier> commonJarIdentifiers =
+                    connectorPackageClient.uploadCommonPluginJars(
+                            
Long.parseLong(jobConfig.getJobContext().getJobId()), commonPluginJars);
+            Set<URL> commonPluginJarUrls = 
getJarUrlsFromIdentifiers(commonJarIdentifiers);
+            Set<ConnectorJarIdentifier> pluginJarIdentifiers = new HashSet<>();
+            transformActionPluginJarUrls(actions, pluginJarIdentifiers);
+            Set<URL> connectorPluginJarUrls = 
getJarUrlsFromIdentifiers(pluginJarIdentifiers);
+            connectorJarIdentifiers.addAll(commonJarIdentifiers);
+            connectorJarIdentifiers.addAll(pluginJarIdentifiers);
+            jarUrls.addAll(commonPluginJarUrls);
+            jarUrls.addAll(connectorPluginJarUrls);
+            actions.forEach(
+                    action -> {
+                        addCommonPluginJarsToAction(
+                                action, commonPluginJarUrls, 
commonJarIdentifiers);
+                    });
+            actions.forEach(
+                    action -> {
+                        org.apache.seatunnel.engine.core.dag.actions.Config 
config =
+                                action.getConfig();
+                    });
+        } else {
+            jarUrls.addAll(commonPluginJars);
+            jarUrls.addAll(immutablePair.getRight());
+            actions.forEach(
+                    action -> {
+                        addCommonPluginJarsToAction(
+                                action, new HashSet<>(commonPluginJars), 
Collections.emptySet());
+                    });

Review Comment:
   ditto



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/job/JobImmutableInformationEnv.java:
##########
@@ -62,6 +71,20 @@ public Long getJobId() {
         return jobId;
     }
 
+    @Override
+    protected LogicalDag getLogicalDag() {
+        ImmutablePair<List<Action>, Set<URL>> immutablePair = 
getJobConfigParser().parse();
+        actions.addAll(immutablePair.getLeft());
+        jarUrls.addAll(commonPluginJars);
+        jarUrls.addAll(immutablePair.getRight());
+        actions.forEach(
+                action -> {
+                    addCommonPluginJarsToAction(
+                            action, new HashSet<>(commonPluginJars), 
Collections.emptySet());
+                });
+        return getLogicalDagGenerator().generate();
+    }

Review Comment:
   Compare with 
https://github.com/apache/seatunnel/pull/5542/files#diff-466c4277b9a67418eb669f75714d0b035ef17ad838977c5556dc58b3aa38e030L108-L113,
 seem like you add commPluginJars for all actions and jarUrls. Why do this 
change? Is there any problem before this PR?



##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobExecutionEnvironment.java:
##########
@@ -64,6 +83,82 @@ protected MultipleTableJobConfigParser getJobConfigParser() {
                 jobFilePath, idGenerator, jobConfig, commonPluginJars, 
isStartWithSavePoint);
     }
 
+    @Override
+    protected LogicalDag getLogicalDag() {
+        ImmutablePair<List<Action>, Set<URL>> immutablePair = 
getJobConfigParser().parse();
+        actions.addAll(immutablePair.getLeft());
+        // Enable upload connector jar package to engine server, automatically 
upload connector Jar
+        // packages
+        // and dependent third-party Jar packages to the server before job 
execution.
+        // Enabling this configuration does not require the server to hold all 
connector Jar
+        // packages.
+        boolean enableUploadConnectorJarPackage =
+                
seaTunnelConfig.getEngineConfig().getConnectorJarStorageConfig().getEnable();
+        if (enableUploadConnectorJarPackage == true) {
+            Set<ConnectorJarIdentifier> commonJarIdentifiers =
+                    connectorPackageClient.uploadCommonPluginJars(
+                            
Long.parseLong(jobConfig.getJobContext().getJobId()), commonPluginJars);

Review Comment:
   This feature can be done in server side. When client upload jar to server, 
server can do check for jar already existed or not. If existed, just skip save 
jar into server, finally return successed to client. So you don't need to send 
another check request, all be done in one request.



##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobExecutionEnvironment.java:
##########
@@ -64,6 +83,92 @@ protected MultipleTableJobConfigParser getJobConfigParser() {
                 jobFilePath, idGenerator, jobConfig, commonPluginJars, 
isStartWithSavePoint);
     }
 
+    @Override
+    protected LogicalDag getLogicalDag() {
+        ImmutablePair<List<Action>, Set<URL>> immutablePair = 
getJobConfigParser().parse();
+        actions.addAll(immutablePair.getLeft());
+        // Enable upload connector jar package to engine server, automatically 
upload connector Jar
+        // packages
+        // and dependent third-party Jar packages to the server before job 
execution.
+        // Enabling this configuration does not require the server to hold all 
connector Jar
+        // packages.
+        boolean enableUploadConnectorJarPackage =
+                
seaTunnelConfig.getEngineConfig().getConnectorJarStorageConfig().getEnable();
+        if (enableUploadConnectorJarPackage == true) {

Review Comment:
   ```suggestion
           if (enableUploadConnectorJarPackage) {
   ```



##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/ConnectorPackageClient.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.seatunnel.engine.client.job;
+
+import org.apache.seatunnel.engine.client.SeaTunnelHazelcastClient;
+import org.apache.seatunnel.engine.common.utils.MDUtil;
+import org.apache.seatunnel.engine.core.job.ConnectorJar;
+import org.apache.seatunnel.engine.core.job.ConnectorJarIdentifier;
+import org.apache.seatunnel.engine.core.job.ConnectorJarType;
+import 
org.apache.seatunnel.engine.core.protocol.codec.SeaTunnelUploadConnectorJarCodec;
+
+import com.hazelcast.logging.ILogger;
+import com.hazelcast.logging.Logger;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static 
org.apache.seatunnel.shade.com.google.common.base.Preconditions.checkNotNull;
+
+public class ConnectorPackageClient {
+
+    private static final ILogger LOGGER = 
Logger.getLogger(ConnectorPackageClient.class);
+
+    private final SeaTunnelHazelcastClient hazelcastClient;
+
+    public ConnectorPackageClient(SeaTunnelHazelcastClient hazelcastClient) {
+        checkNotNull(hazelcastClient);
+        this.hazelcastClient = hazelcastClient;
+    }
+
+    public Set<ConnectorJarIdentifier> uploadCommonPluginJars(
+            long jobId, List<URL> commonPluginJars) {
+        Set<ConnectorJarIdentifier> connectorJarIdentifiers = new HashSet<>();
+        // Upload commonPluginJar
+        for (URL commonPluginJar : commonPluginJars) {
+            // handle the local file path
+            // origin path : 
/${SEATUNNEL_HOME}/plugins/Jdbc/lib/mysql-connector-java-5.1.32.jar ->
+            // handled path : 
${SEATUNNEL_HOME}/plugins/Jdbc/lib/mysql-connector-java-5.1.32.jar
+            Path path = Paths.get(commonPluginJar.getPath().substring(1));
+            // Obtain the directory name of the relative location of the file 
path.
+            // for example, The path is
+            // 
${SEATUNNEL_HOME}/plugins/Jdbc/lib/mysql-connector-java-5.1.32.jar, so the name
+            // obtained here is the connector plugin name : JDBC

Review Comment:
   The logic not right. In fact, we don't must use plugin name like `Jdbc` to 
create directory. It could be any name, like `today`, `mysql` etc. Directory 
name doesn't have any relation with plugin name. The jar in `plugin/` should 
used for all connector. (PS: in Zeta engine, we mark `plugin` directory as 
deprecated. Refer: 
https://github.com/apache/seatunnel/blob/dev/plugins/README.md, user should put 
jar into `lib` on all node. I think in this situation, you should not care 
common jar). But we supported define common jar in job env. Refer 
https://seatunnel.apache.org/docs/2.3.3/concept/JobEnvConfig#jars



##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobExecutionEnvironment.java:
##########
@@ -64,6 +83,92 @@ protected MultipleTableJobConfigParser getJobConfigParser() {
                 jobFilePath, idGenerator, jobConfig, commonPluginJars, 
isStartWithSavePoint);
     }
 
+    @Override
+    protected LogicalDag getLogicalDag() {
+        ImmutablePair<List<Action>, Set<URL>> immutablePair = 
getJobConfigParser().parse();
+        actions.addAll(immutablePair.getLeft());
+        // Enable upload connector jar package to engine server, automatically 
upload connector Jar
+        // packages
+        // and dependent third-party Jar packages to the server before job 
execution.
+        // Enabling this configuration does not require the server to hold all 
connector Jar
+        // packages.
+        boolean enableUploadConnectorJarPackage =
+                
seaTunnelConfig.getEngineConfig().getConnectorJarStorageConfig().getEnable();
+        if (enableUploadConnectorJarPackage == true) {
+            /**
+             * TODO: Before uploading the Jar package file the server, first 
determine whether the
+             * server holds the current Jar. If the server holds the same Jar 
package file, there is
+             * no need for additional uploads.
+             */
+            Set<ConnectorJarIdentifier> commonJarIdentifiers =
+                    connectorPackageClient.uploadCommonPluginJars(
+                            
Long.parseLong(jobConfig.getJobContext().getJobId()), commonPluginJars);
+            Set<URL> commonPluginJarUrls = 
getJarUrlsFromIdentifiers(commonJarIdentifiers);
+            Set<ConnectorJarIdentifier> pluginJarIdentifiers = new HashSet<>();
+            transformActionPluginJarUrls(actions, pluginJarIdentifiers);
+            Set<URL> connectorPluginJarUrls = 
getJarUrlsFromIdentifiers(pluginJarIdentifiers);
+            connectorJarIdentifiers.addAll(commonJarIdentifiers);
+            connectorJarIdentifiers.addAll(pluginJarIdentifiers);
+            jarUrls.addAll(commonPluginJarUrls);
+            jarUrls.addAll(connectorPluginJarUrls);
+            actions.forEach(
+                    action -> {
+                        addCommonPluginJarsToAction(
+                                action, commonPluginJarUrls, 
commonJarIdentifiers);
+                    });
+            actions.forEach(
+                    action -> {
+                        org.apache.seatunnel.engine.core.dag.actions.Config 
config =
+                                action.getConfig();
+                    });
+        } else {
+            jarUrls.addAll(commonPluginJars);
+            jarUrls.addAll(immutablePair.getRight());
+            actions.forEach(
+                    action -> {
+                        addCommonPluginJarsToAction(
+                                action, new HashSet<>(commonPluginJars), 
Collections.emptySet());
+                    });
+        }
+        return getLogicalDagGenerator().generate();
+    }
+
+    protected Set<ConnectorJarIdentifier> uploadPluginJarUrls(Set<URL> 
pluginJarUrls) {
+        Set<ConnectorJarIdentifier> pluginJarIdentifiers = new HashSet<>();
+        pluginJarUrls.forEach(
+                pluginJarUrl -> {
+                    /**
+                     * TODO: Before uploading the Jar package file the server, 
first determine
+                     * whether the server holds the current Jar. If the server 
holds the same Jar
+                     * package file, there is no need for additional uploads.
+                     */
+                    ConnectorJarIdentifier connectorJarIdentifier =
+                            connectorPackageClient.uploadConnectorPluginJar(
+                                    
Long.parseLong(jobConfig.getJobContext().getJobId()),
+                                    pluginJarUrl);
+                    pluginJarIdentifiers.add(connectorJarIdentifier);
+                });
+        return pluginJarIdentifiers;
+    }
+
+    private void transformActionPluginJarUrls(

Review Comment:
   ```suggestion
       private void uploadActionPluginJar(
   ```



##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobExecutionEnvironment.java:
##########
@@ -64,6 +83,92 @@ protected MultipleTableJobConfigParser getJobConfigParser() {
                 jobFilePath, idGenerator, jobConfig, commonPluginJars, 
isStartWithSavePoint);
     }
 
+    @Override
+    protected LogicalDag getLogicalDag() {
+        ImmutablePair<List<Action>, Set<URL>> immutablePair = 
getJobConfigParser().parse();
+        actions.addAll(immutablePair.getLeft());
+        // Enable upload connector jar package to engine server, automatically 
upload connector Jar
+        // packages
+        // and dependent third-party Jar packages to the server before job 
execution.
+        // Enabling this configuration does not require the server to hold all 
connector Jar
+        // packages.
+        boolean enableUploadConnectorJarPackage =
+                
seaTunnelConfig.getEngineConfig().getConnectorJarStorageConfig().getEnable();
+        if (enableUploadConnectorJarPackage == true) {
+            /**
+             * TODO: Before uploading the Jar package file the server, first 
determine whether the
+             * server holds the current Jar. If the server holds the same Jar 
package file, there is
+             * no need for additional uploads.
+             */
+            Set<ConnectorJarIdentifier> commonJarIdentifiers =
+                    connectorPackageClient.uploadCommonPluginJars(
+                            
Long.parseLong(jobConfig.getJobContext().getJobId()), commonPluginJars);
+            Set<URL> commonPluginJarUrls = 
getJarUrlsFromIdentifiers(commonJarIdentifiers);
+            Set<ConnectorJarIdentifier> pluginJarIdentifiers = new HashSet<>();
+            transformActionPluginJarUrls(actions, pluginJarIdentifiers);
+            Set<URL> connectorPluginJarUrls = 
getJarUrlsFromIdentifiers(pluginJarIdentifiers);
+            connectorJarIdentifiers.addAll(commonJarIdentifiers);
+            connectorJarIdentifiers.addAll(pluginJarIdentifiers);
+            jarUrls.addAll(commonPluginJarUrls);
+            jarUrls.addAll(connectorPluginJarUrls);
+            actions.forEach(
+                    action -> {
+                        addCommonPluginJarsToAction(
+                                action, commonPluginJarUrls, 
commonJarIdentifiers);
+                    });
+            actions.forEach(
+                    action -> {
+                        org.apache.seatunnel.engine.core.dag.actions.Config 
config =
+                                action.getConfig();
+                    });
+        } else {
+            jarUrls.addAll(commonPluginJars);
+            jarUrls.addAll(immutablePair.getRight());
+            actions.forEach(
+                    action -> {
+                        addCommonPluginJarsToAction(
+                                action, new HashSet<>(commonPluginJars), 
Collections.emptySet());
+                    });
+        }
+        return getLogicalDagGenerator().generate();
+    }
+
+    protected Set<ConnectorJarIdentifier> uploadPluginJarUrls(Set<URL> 
pluginJarUrls) {

Review Comment:
   You are doing upload jar, not upload jar url
   ```suggestion
       protected Set<ConnectorJarIdentifier> uploadPluginJar(Set<URL> 
pluginJarUrls) {
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to