You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/09/23 10:41:29 UTC

[incubator-linkis] branch dev-1.3.1 updated: [sqoop]errorcode code optimization (#3524)

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

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new e495c1779 [sqoop]errorcode code optimization (#3524)
e495c1779 is described below

commit e495c1779b3254a42d481bca636321d4da170560
Author: 成彬彬 <10...@users.noreply.github.com>
AuthorDate: Fri Sep 23 18:41:23 2022 +0800

    [sqoop]errorcode code optimization (#3524)
---
 docs/errorcode/sqoop-errorcode.md                  | 10 +++
 .../engineconnplugin/sqoop/client/Sqoop.java       |  8 ++-
 .../client/errorcode/SqoopErrorCodeSummary.java    | 83 ++++++++++++++++++++++
 .../client/exception/JobClosableException.java     |  8 +--
 .../client/exception/JobExecutionException.java    |  8 +--
 .../sqoop/executor/SqoopExecutor.scala             |  3 +-
 .../sqoop/executor/SqoopOnceCodeExecutor.scala     |  3 +-
 7 files changed, 110 insertions(+), 13 deletions(-)

diff --git a/docs/errorcode/sqoop-errorcode.md b/docs/errorcode/sqoop-errorcode.md
new file mode 100644
index 000000000..62161bc0a
--- /dev/null
+++ b/docs/errorcode/sqoop-errorcode.md
@@ -0,0 +1,10 @@
+## sqoop errorcode
+
+| 模块名(服务名) | 错误码  | 描述 | Exception Class|
+| -------- | -------- | ----- |-----|
+|sqoop|16025|Unable to close the mapReduce job related to cluster(无法关闭与集群相关的 mapReduce 作业)|SqoopErrorCodeSummary|
+|sqoop|16025|Error in closing sqoop client(关闭 sqoop 客户端时出错)|SqoopErrorCodeSummary|
+|sqoop|16023|Not support method for requestExpectedResource.(不支持 requestExpectedResource 的方法)|SqoopErrorCodeSummary|
+|sqoop|16023|Exec Sqoop Code Error(执行 Sqoop 代码错误)|SqoopErrorCodeSummary|
+|sqoop|16023|New a instance of {} failed!(新建 {} 实例失败!)|SqoopErrorCodeSummary|
+
diff --git a/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/Sqoop.java b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/Sqoop.java
index d57d9bd3a..b86ed3821 100644
--- a/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/Sqoop.java
+++ b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/Sqoop.java
@@ -51,6 +51,9 @@ import com.cloudera.sqoop.manager.DefaultManagerFactory;
 import com.cloudera.sqoop.tool.SqoopTool;
 import com.cloudera.sqoop.util.OptionsFileUtil;
 
+import static org.apache.linkis.engineconnplugin.sqoop.client.errorcode.SqoopErrorCodeSummary.ERROR_IN_CLOSING;
+import static org.apache.linkis.engineconnplugin.sqoop.client.errorcode.SqoopErrorCodeSummary.UNABLE_TO_CLOSE;
+
 /**
  * Main entry-point for Sqoop Usage: hadoop jar (this_jar_name) com.cloudera.sqoop.Sqoop (options)
  * See the SqoopOptions class for options.
@@ -319,11 +322,10 @@ public class Sqoop extends Configured implements Tool {
         } catch (Exception e) {
           // Ignore
         }
-        throw new JobClosableException(
-            "Unable to close the mapReduce job related to cluster [" + cluster + "]", se);
+        throw new JobClosableException(UNABLE_TO_CLOSE.getErrorDesc() + "[" + cluster + "]", se);
       }
     } catch (IOException | SQLException e) {
-      throw new JobClosableException("Error in closing sqoop client", e);
+      throw new JobClosableException(ERROR_IN_CLOSING.getErrorDesc(), e);
     }
   }
 
diff --git a/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/errorcode/SqoopErrorCodeSummary.java b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/errorcode/SqoopErrorCodeSummary.java
new file mode 100644
index 000000000..6d44d5be6
--- /dev/null
+++ b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/errorcode/SqoopErrorCodeSummary.java
@@ -0,0 +1,83 @@
+/*
+ * 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.linkis.engineconnplugin.sqoop.client.errorcode;
+
+public enum SqoopErrorCodeSummary {
+  ERROR_IN_CLOSING_ID(16025, "", ""),
+  UNABLE_TO_CLOSE(
+      16025,
+      "Unable to close the mapReduce job related to cluster(无法关闭与集群相关的 mapReduce 作业)",
+      "Unable to close the mapReduce job related to cluster(无法关闭与集群相关的 mapReduce 作业)"),
+  ERROR_IN_CLOSING(
+      16025,
+      "Error in closing sqoop client(关闭 sqoop 客户端时出错)",
+      "Error in closing sqoop client(关闭 sqoop 客户端时出错)"),
+  NOT_SUPPORT_METHON_ID(16023, "", ""),
+  NOT_SUPPORT_METHON(
+      16023,
+      "Not support method for requestExpectedResource.(不支持 requestExpectedResource 的方法)",
+      "Not support method for requestExpectedResource.(不支持 requestExpectedResource 的方法)"),
+  EXEC_SQOOP_CODE_ERROR(
+      16023, "Exec Sqoop Code Error(执行 Sqoop 代码错误)", "Exec Sqoop Code Error(执行 Sqoop 代码错误)"),
+  NEW_A_INSTANCE_OF(
+      16023,
+      "New a instance of {} failed!(新建 {} 实例失败!)",
+      "New a instance of {} failed!(新建 {} 实例失败!)");
+
+  /** (errorCode)错误码 */
+  private int errorCode;
+  /** (errorDesc)错误描述 */
+  private String errorDesc;
+  /** Possible reasons for the error(错误可能出现的原因) */
+  private String comment;
+
+  SqoopErrorCodeSummary(int errorCode, String errorDesc, String comment) {
+    this.errorCode = errorCode;
+    this.errorDesc = errorDesc;
+    this.comment = comment;
+  }
+
+  public int getErrorCode() {
+    return errorCode;
+  }
+
+  public void setErrorCode(int errorCode) {
+    this.errorCode = errorCode;
+  }
+
+  public String getErrorDesc() {
+    return errorDesc;
+  }
+
+  public void setErrorDesc(String errorDesc) {
+    this.errorDesc = errorDesc;
+  }
+
+  public String getComment() {
+    return comment;
+  }
+
+  public void setComment(String comment) {
+    this.comment = comment;
+  }
+
+  @Override
+  public String toString() {
+    return "errorCode: " + this.errorCode + ", errorDesc:" + this.errorDesc;
+  }
+}
diff --git a/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobClosableException.java b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobClosableException.java
index 92bc0a023..49fa23d7f 100644
--- a/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobClosableException.java
+++ b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobClosableException.java
@@ -19,18 +19,18 @@ package org.apache.linkis.engineconnplugin.sqoop.client.exception;
 
 import org.apache.linkis.common.exception.ErrorException;
 
+import static org.apache.linkis.engineconnplugin.sqoop.client.errorcode.SqoopErrorCodeSummary.ERROR_IN_CLOSING_ID;
+
 /** Exception in closing/destroying the job */
 public class JobClosableException extends ErrorException {
   private static final long serialVersionUID = 1L;
 
-  public static final int ERROR_CODE = 16025;
-
   public JobClosableException(String message) {
-    super(ERROR_CODE, message);
+    super(ERROR_IN_CLOSING_ID.getErrorCode(), message);
   }
 
   public JobClosableException(String message, Throwable e) {
-    super(ERROR_CODE, message);
+    super(ERROR_IN_CLOSING_ID.getErrorCode(), message);
     this.initCause(e);
   }
 }
diff --git a/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobExecutionException.java b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobExecutionException.java
index 3f662b5cc..870e46f2c 100644
--- a/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobExecutionException.java
+++ b/linkis-engineconn-plugins/sqoop/src/main/java/org/apache/linkis/engineconnplugin/sqoop/client/exception/JobExecutionException.java
@@ -19,17 +19,17 @@ package org.apache.linkis.engineconnplugin.sqoop.client.exception;
 
 import org.apache.linkis.common.exception.ErrorException;
 
+import static org.apache.linkis.engineconnplugin.sqoop.client.errorcode.SqoopErrorCodeSummary.NOT_SUPPORT_METHON_ID;
+
 public class JobExecutionException extends ErrorException {
   private static final long serialVersionUID = 1L;
 
-  public static final int ERROR_CODE = 16023;
-
   public JobExecutionException(String message) {
-    super(ERROR_CODE, message);
+    super(NOT_SUPPORT_METHON_ID.getErrorCode(), message);
   }
 
   public JobExecutionException(String message, Throwable e) {
-    super(ERROR_CODE, message);
+    super(NOT_SUPPORT_METHON_ID.getErrorCode(), message);
     this.initCause(e);
   }
 }
diff --git a/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopExecutor.scala b/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopExecutor.scala
index ba82fd2c4..8756b7429 100644
--- a/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopExecutor.scala
+++ b/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopExecutor.scala
@@ -19,6 +19,7 @@ package org.apache.linkis.engineconnplugin.sqoop.executor
 
 import org.apache.linkis.engineconn.executor.entity.{LabelExecutor, ResourceExecutor, YarnExecutor}
 import org.apache.linkis.engineconnplugin.sqoop.client.Sqoop
+import org.apache.linkis.engineconnplugin.sqoop.client.errorcode.SqoopErrorCodeSummary.NOT_SUPPORT_METHON
 import org.apache.linkis.engineconnplugin.sqoop.client.exception.JobExecutionException
 import org.apache.linkis.engineconnplugin.sqoop.context.SqoopEngineConnContext
 import org.apache.linkis.engineconnplugin.sqoop.context.SqoopResourceConfiguration.LINKIS_QUEUE_NAME
@@ -44,7 +45,7 @@ trait SqoopExecutor extends YarnExecutor with LabelExecutor with ResourceExecuto
   override def setExecutorLabels(labels: util.List[Label[_]]): Unit = this.executorLabels = labels
 
   override def requestExpectedResource(expectedResource: NodeResource): NodeResource =
-    throw new JobExecutionException("Not support method for requestExpectedResource.")
+    throw new JobExecutionException(NOT_SUPPORT_METHON.getErrorDesc)
 
   protected val sqoopEngineConnContext: SqoopEngineConnContext
 }
diff --git a/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopOnceCodeExecutor.scala b/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopOnceCodeExecutor.scala
index 9dd796540..9b09d6b61 100644
--- a/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopOnceCodeExecutor.scala
+++ b/linkis-engineconn-plugins/sqoop/src/main/scala/org/apache/linkis/engineconnplugin/sqoop/executor/SqoopOnceCodeExecutor.scala
@@ -25,6 +25,7 @@ import org.apache.linkis.engineconn.once.executor.{
   OperableOnceExecutor
 }
 import org.apache.linkis.engineconnplugin.sqoop.client.LinkisSqoopClient
+import org.apache.linkis.engineconnplugin.sqoop.client.errorcode.SqoopErrorCodeSummary.EXEC_SQOOP_CODE_ERROR
 import org.apache.linkis.engineconnplugin.sqoop.client.exception.JobExecutionException
 import org.apache.linkis.engineconnplugin.sqoop.context.{
   SqoopEngineConnContext,
@@ -73,7 +74,7 @@ class SqoopOnceCodeExecutor(
           setResponse(
             ErrorExecuteResponse(
               "Run code failed!",
-              new JobExecutionException("Exec Sqoop Code Error")
+              new JobExecutionException(EXEC_SQOOP_CODE_ERROR.getErrorDesc)
             )
           )
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org