bList,
if (!all.contains(oneValue)) {
throw AddaxException
.asAddaxException(
- CommonErrorCode.CONFIG_ERROR,
+ ErrorCode.CONFIG_ERROR,
String.format(
"您提供的作业配置信息有误, String:[%s] 不存在于列表中:[%s].",
oneValue, StringUtils.join(aList, ",")));
diff --git a/core/src/main/java/com/wgzhao/addax/core/Engine.java b/core/src/main/java/com/wgzhao/addax/core/Engine.java
index 5cf6730ba..f522a2e24 100644
--- a/core/src/main/java/com/wgzhao/addax/core/Engine.java
+++ b/core/src/main/java/com/wgzhao/addax/core/Engine.java
@@ -124,13 +124,13 @@ public static String getVersion() {
}
public static void main(String[] args) {
- System.out.println("\n ___ _ _ \n" +
+ LOG.info("\n ___ _ _ \n" +
" / _ \\ | | | | \n" +
"/ /_\\ \\ __| | __| | __ ___ __\n" +
"| _ |/ _` |/ _` |/ _` \\ \\/ /\n" +
"| | | | (_| | (_| | (_| |> < \n" +
- "\\_| |_/\\__,_|\\__,_|\\__,_/_/\\_\\\n");
- System.out.println(":: Addax version :: (v" + Engine.getVersion() + ")\n");
+ "\\_| |_/\\__,_|\\__,_|\\__,_/_/\\_\\\n"+
+ ":: Addax version :: (v{})", Engine.getVersion());
if (args.length < 2) {
LOG.error("need a job file");
System.exit(1);
diff --git a/core/src/main/java/com/wgzhao/addax/core/job/JobContainer.java b/core/src/main/java/com/wgzhao/addax/core/job/JobContainer.java
index 674c7b901..5a9f4883a 100644
--- a/core/src/main/java/com/wgzhao/addax/core/job/JobContainer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/job/JobContainer.java
@@ -41,7 +41,6 @@
import com.wgzhao.addax.core.statistics.container.communicator.job.StandAloneJobContainerCommunicator;
import com.wgzhao.addax.core.statistics.plugin.DefaultJobPluginCollector;
import com.wgzhao.addax.core.util.ErrorRecordChecker;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import com.wgzhao.addax.core.util.container.ClassLoaderSwapper;
import com.wgzhao.addax.core.util.container.CoreConstant;
import com.wgzhao.addax.core.util.container.LoadUtil;
@@ -63,6 +62,10 @@
import java.util.List;
import java.util.Map;
+import static com.wgzhao.addax.common.spi.ErrorCode.CONFIG_ERROR;
+import static com.wgzhao.addax.common.spi.ErrorCode.EXECUTE_FAIL;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
/*
* Created by jingxing on 14-8-24.
*
@@ -163,7 +166,7 @@ public void start() {
super.getContainerCommunicator().report(reportCommunication);
throw AddaxException.asAddaxException(
- FrameworkErrorCode.RUNTIME_ERROR, e);
+ RUNTIME_ERROR, e);
} finally {
if (!isDryRun) {
@@ -282,7 +285,7 @@ private void preHandle() {
handlerPluginType = PluginType.valueOf(handlerPluginTypeStr.toUpperCase());
} catch (IllegalArgumentException e) {
throw AddaxException.asAddaxException(
- FrameworkErrorCode.CONFIG_ERROR,
+ CONFIG_ERROR,
String.format("The plugin type (%s) set for the pre-handler of job failed, reason: %s", handlerPluginTypeStr.toUpperCase(), e.getMessage()));
}
@@ -313,7 +316,7 @@ private void postHandle() {
handlerPluginType = PluginType.valueOf(handlerPluginTypeStr.toUpperCase());
} catch (IllegalArgumentException e) {
throw AddaxException.asAddaxException(
- FrameworkErrorCode.CONFIG_ERROR,
+ CONFIG_ERROR,
String.format("The plugin type (%s) set for the post-handler of job failed, reason: %s", handlerPluginTypeStr.toUpperCase(), e.getMessage()));
}
@@ -373,7 +376,7 @@ private void adjustChannelNumber() {
Long channelLimitedByteSpeed = this.configuration.getLong(CoreConstant.CORE_TRANSPORT_CHANNEL_SPEED_BYTE, -1);
if (channelLimitedByteSpeed == null || channelLimitedByteSpeed <= 0) {
throw AddaxException.asAddaxException(
- FrameworkErrorCode.CONFIG_ERROR,
+ CONFIG_ERROR,
"Under the condition of total bps limit, the bps value of a single channel cannot be empty or non-positive");
}
@@ -387,7 +390,7 @@ private void adjustChannelNumber() {
long globalLimitedRecordSpeed = this.configuration.getInt(CoreConstant.JOB_SETTING_SPEED_RECORD, 100000);
Long channelLimitedRecordSpeed = this.configuration.getLong(CoreConstant.CORE_TRANSPORT_CHANNEL_SPEED_RECORD, -1);
if (channelLimitedRecordSpeed == null || channelLimitedRecordSpeed <= 0) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.CONFIG_ERROR,
+ throw AddaxException.asAddaxException(CONFIG_ERROR,
"Under the condition of total tps limit, the tps value of a single channel cannot be empty or non-positive");
}
@@ -443,7 +446,7 @@ private void schedule() {
LOG.error("The scheduler failed to run.");
this.endTransferTimeStamp = System.currentTimeMillis();
throw AddaxException.asAddaxException(
- FrameworkErrorCode.RUNTIME_ERROR, e);
+ RUNTIME_ERROR, e);
}
/*
@@ -631,7 +634,7 @@ private List doReaderSplit(int adviceNumber) {
classLoaderSwapper.setCurrentThreadClassLoader(LoadUtil.getJarLoader(PluginType.READER, this.readerPluginName));
List readerSlicesConfigs = this.jobReader.split(adviceNumber);
if (readerSlicesConfigs == null || readerSlicesConfigs.isEmpty()) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.PLUGIN_SPLIT_ERROR,
+ throw AddaxException.asAddaxException(EXECUTE_FAIL,
"The number of tasks divided by the reader's job cannot be less than or equal to zero");
}
LOG.info("The Reader.Job [{}] is divided into [{}] task(s).", this.readerPluginName, readerSlicesConfigs.size());
@@ -644,7 +647,7 @@ private List doWriterSplit(int readerTaskNumber) {
List writerSlicesConfigs = this.jobWriter.split(readerTaskNumber);
if (writerSlicesConfigs == null || writerSlicesConfigs.isEmpty()) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.PLUGIN_SPLIT_ERROR,
+ throw AddaxException.asAddaxException(EXECUTE_FAIL,
"The number of tasks divided by the writer's job cannot be less than or equal to zero");
}
LOG.info("The Writer.Job [{}] is divided into [{}] task(s).", this.writerPluginName, writerSlicesConfigs.size());
@@ -662,7 +665,7 @@ private List mergeReaderAndWriterTaskConfigs(
List transformerConfigs) {
if (readerTasksConfigs.size() != writerTasksConfigs.size()) {
throw AddaxException.asAddaxException(
- FrameworkErrorCode.PLUGIN_SPLIT_ERROR,
+ CONFIG_ERROR,
String.format("The number of tasks [%d] divided by the reader's job does not equal " +
"the number of tasks [%d] divided by the writer's job",
readerTasksConfigs.size(), writerTasksConfigs.size())
diff --git a/core/src/main/java/com/wgzhao/addax/core/job/scheduler/AbstractScheduler.java b/core/src/main/java/com/wgzhao/addax/core/job/scheduler/AbstractScheduler.java
index 3e238da1e..abf501b0f 100644
--- a/core/src/main/java/com/wgzhao/addax/core/job/scheduler/AbstractScheduler.java
+++ b/core/src/main/java/com/wgzhao/addax/core/job/scheduler/AbstractScheduler.java
@@ -26,7 +26,6 @@
import com.wgzhao.addax.core.statistics.communication.CommunicationTool;
import com.wgzhao.addax.core.statistics.container.communicator.AbstractContainerCommunicator;
import com.wgzhao.addax.core.util.ErrorRecordChecker;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import com.wgzhao.addax.core.util.container.CoreConstant;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
@@ -34,6 +33,8 @@
import java.util.List;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
public abstract class AbstractScheduler
{
private static final Logger LOG = LoggerFactory.getLogger(AbstractScheduler.class);
@@ -114,8 +115,7 @@ public void schedule(List configurations)
// 以 failed 状态退出
LOG.error("An InterruptedException was caught!", e);
- throw AddaxException.asAddaxException(
- FrameworkErrorCode.RUNTIME_ERROR, e);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, e);
}
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/job/scheduler/processinner/ProcessInnerScheduler.java b/core/src/main/java/com/wgzhao/addax/core/job/scheduler/processinner/ProcessInnerScheduler.java
index 6a183a05a..b648e5a1d 100644
--- a/core/src/main/java/com/wgzhao/addax/core/job/scheduler/processinner/ProcessInnerScheduler.java
+++ b/core/src/main/java/com/wgzhao/addax/core/job/scheduler/processinner/ProcessInnerScheduler.java
@@ -25,12 +25,13 @@
import com.wgzhao.addax.core.statistics.container.communicator.AbstractContainerCommunicator;
import com.wgzhao.addax.core.taskgroup.TaskGroupContainer;
import com.wgzhao.addax.core.taskgroup.runner.TaskGroupContainerRunner;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
public abstract class ProcessInnerScheduler
extends AbstractScheduler
{
@@ -61,7 +62,7 @@ public void dealFailedStat(AbstractContainerCommunicator frameworkCollector, Thr
{
this.taskGroupContainerExecutorService.shutdownNow();
throw AddaxException.asAddaxException(
- FrameworkErrorCode.PLUGIN_RUNTIME_ERROR, throwable);
+ RUNTIME_ERROR, throwable);
}
@Override
@@ -69,7 +70,7 @@ public void dealKillingStat(AbstractContainerCommunicator frameworkCollector, in
{
//通过进程退出返回码标示状态
this.taskGroupContainerExecutorService.shutdownNow();
- throw AddaxException.asAddaxException(FrameworkErrorCode.KILLED_EXIT_VALUE, "The job was terminated");
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, "The job was terminated");
}
private TaskGroupContainerRunner newTaskGroupContainerRunner(
diff --git a/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/AbstractTaskPluginCollector.java b/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/AbstractTaskPluginCollector.java
index e22a2f37f..e2e754b48 100644
--- a/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/AbstractTaskPluginCollector.java
+++ b/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/AbstractTaskPluginCollector.java
@@ -26,10 +26,11 @@
import com.wgzhao.addax.common.util.Configuration;
import com.wgzhao.addax.core.statistics.communication.Communication;
import com.wgzhao.addax.core.statistics.communication.CommunicationTool;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
/**
* Created by jingxing on 14-9-11.
*/
@@ -90,7 +91,7 @@ else if (this.pluginType.equals(PluginType.WRITER)) {
this.communication.increaseCounter(CommunicationTool.WRITE_FAILED_BYTES, dirtyRecord.getByteSize());
}
else {
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, String.format("不知道的插件类型[%s].", this.pluginType));
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, String.format("不知道的插件类型[%s].", this.pluginType));
}
}
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/util/DirtyRecord.java b/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/util/DirtyRecord.java
index 507d6ffb8..44a242334 100644
--- a/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/util/DirtyRecord.java
+++ b/core/src/main/java/com/wgzhao/addax/core/statistics/plugin/task/util/DirtyRecord.java
@@ -23,7 +23,6 @@
import com.wgzhao.addax.common.element.Column;
import com.wgzhao.addax.common.element.Record;
import com.wgzhao.addax.common.exception.AddaxException;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -33,6 +32,8 @@
import java.util.List;
import java.util.Map;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
public class DirtyRecord
implements Record
{
@@ -68,31 +69,31 @@ public String toString()
@Override
public void setColumn(int i, Column column)
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public Column getColumn(int i)
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public int getColumnNumber()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public int getByteSize()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public int getMemorySize()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
@@ -145,54 +146,54 @@ public static Column asDirtyColumn(final Column column, int index)
@Override
public Long asLong()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public Double asDouble()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public String asString()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public Date asDate()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public byte[] asBytes()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public Boolean asBoolean()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public BigDecimal asBigDecimal()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public BigInteger asBigInteger()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
@Override
public Timestamp asTimestamp()
{
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, NOT_SUPPORT_METHOD);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, NOT_SUPPORT_METHOD);
}
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/taskgroup/TaskGroupContainer.java b/core/src/main/java/com/wgzhao/addax/core/taskgroup/TaskGroupContainer.java
index ee52c0a49..5b6cf6ad7 100644
--- a/core/src/main/java/com/wgzhao/addax/core/taskgroup/TaskGroupContainer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/taskgroup/TaskGroupContainer.java
@@ -22,7 +22,7 @@
import com.alibaba.fastjson2.JSON;
import com.wgzhao.addax.common.constant.PluginType;
import com.wgzhao.addax.common.exception.AddaxException;
-import com.wgzhao.addax.common.exception.CommonErrorCode;
+import com.wgzhao.addax.common.spi.ErrorCode;
import com.wgzhao.addax.common.plugin.RecordSender;
import com.wgzhao.addax.common.plugin.TaskPluginCollector;
import com.wgzhao.addax.common.util.Configuration;
@@ -42,7 +42,6 @@
import com.wgzhao.addax.core.transport.exchanger.BufferedRecordTransformerExchanger;
import com.wgzhao.addax.core.transport.transformer.TransformerExecution;
import com.wgzhao.addax.core.util.ClassUtil;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import com.wgzhao.addax.core.util.TransformerUtil;
import com.wgzhao.addax.core.util.container.CoreConstant;
import com.wgzhao.addax.core.util.container.LoadUtil;
@@ -56,6 +55,9 @@
import java.util.List;
import java.util.Map;
+import static com.wgzhao.addax.common.spi.ErrorCode.CONFIG_ERROR;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
public class TaskGroupContainer
extends AbstractContainer
{
@@ -185,7 +187,7 @@ else if (taskCommunication.getState() == State.SUCCEEDED) {
if (failedOrKilled) {
lastTaskGroupContainerCommunication = reportTaskGroupCommunication(lastTaskGroupContainerCommunication, taskCountInThisTaskGroup);
- throw AddaxException.asAddaxException(FrameworkErrorCode.PLUGIN_RUNTIME_ERROR, lastTaskGroupContainerCommunication.getThrowable());
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, lastTaskGroupContainerCommunication.getThrowable());
}
//3.有任务未执行,且正在运行的任务数小于最大通道限制
@@ -206,7 +208,7 @@ else if (taskCommunication.getState() == State.SUCCEEDED) {
if (now - failedTime > taskMaxWaitInMs) {
markCommunicationFailed(taskId);
reportTaskGroupCommunication(lastTaskGroupContainerCommunication, taskCountInThisTaskGroup);
- throw AddaxException.asAddaxException(CommonErrorCode.WAIT_TIME_EXCEED, "The task failover wait timed out.");
+ throw AddaxException.asAddaxException(ErrorCode.WAIT_TIME_EXCEED, "The task failover wait timed out.");
}
else {
lastExecutor.shutdown(); //try to close again
@@ -272,7 +274,7 @@ else if (taskCommunication.getState() == State.SUCCEEDED) {
this.containerCommunicator.report(nowTaskGroupContainerCommunication);
throw AddaxException.asAddaxException(
- FrameworkErrorCode.RUNTIME_ERROR, e);
+ RUNTIME_ERROR, e);
}
}
@@ -415,7 +417,7 @@ public void doStart()
// reader没有起来,writer不可能结束
if (!this.writerThread.isAlive() || this.taskCommunication.getState() == State.FAILED) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, this.taskCommunication.getThrowable());
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, this.taskCommunication.getThrowable());
}
this.readerThread.start();
@@ -423,7 +425,7 @@ public void doStart()
// 这里reader可能很快结束
if (!this.readerThread.isAlive() && this.taskCommunication.getState() == State.FAILED) {
// 这里有可能出现Reader线上启动即挂情况 对于这类情况 需要立刻抛出异常
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, this.taskCommunication.getThrowable());
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, this.taskCommunication.getThrowable());
}
}
@@ -471,7 +473,7 @@ private AbstractRunner generateRunner(PluginType pluginType, List rs)
notEmpty.signalAll();
}
catch (InterruptedException e) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, e);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, e);
}
finally {
lock.unlock();
@@ -151,7 +152,7 @@ protected void doPullAll(Collection rs)
notInsufficient.signalAll();
}
catch (InterruptedException e) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.RUNTIME_ERROR, e);
+ throw AddaxException.asAddaxException(RUNTIME_ERROR, e);
}
finally {
lock.unlock();
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordExchanger.java b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordExchanger.java
index 96bd8e21d..f38634461 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordExchanger.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordExchanger.java
@@ -20,7 +20,7 @@
package com.wgzhao.addax.core.transport.exchanger;
import com.wgzhao.addax.common.element.Record;
-import com.wgzhao.addax.common.exception.CommonErrorCode;
+import com.wgzhao.addax.common.spi.ErrorCode;
import com.wgzhao.addax.common.exception.AddaxException;
import com.wgzhao.addax.common.plugin.RecordReceiver;
import com.wgzhao.addax.common.plugin.RecordSender;
@@ -28,7 +28,6 @@
import com.wgzhao.addax.common.util.Configuration;
import com.wgzhao.addax.core.transport.channel.Channel;
import com.wgzhao.addax.core.transport.record.TerminateRecord;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import com.wgzhao.addax.core.util.container.CoreConstant;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
@@ -38,6 +37,8 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
+import static com.wgzhao.addax.common.spi.ErrorCode.CONFIG_ERROR;
+
public class BufferedRecordExchanger
implements RecordSender, RecordReceiver
{
@@ -78,7 +79,7 @@ public BufferedRecordExchanger(Channel channel, TaskPluginCollector pluginCollec
"com.wgzhao.addax.core.transport.record.DefaultRecord")));
}
catch (Exception e) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.CONFIG_ERROR, e);
+ throw AddaxException.asAddaxException(CONFIG_ERROR, e);
}
}
@@ -89,7 +90,7 @@ public Record createRecord()
return BufferedRecordExchanger.recordClass.getConstructor().newInstance();
}
catch (Exception e) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.CONFIG_ERROR, e);
+ throw AddaxException.asAddaxException(CONFIG_ERROR, e);
}
}
@@ -97,7 +98,7 @@ public Record createRecord()
public void sendToWriter(Record record)
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
Validate.notNull(record, "The record cannot be empty.");
@@ -123,7 +124,7 @@ public void sendToWriter(Record record)
public void flush()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
this.channel.pushAll(this.buffer);
this.buffer.clear();
@@ -135,7 +136,7 @@ public void flush()
public void terminate()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
flush();
this.channel.pushTerminate(TerminateRecord.get());
@@ -145,7 +146,7 @@ public void terminate()
public Record getFromReader()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
boolean isEmpty = (this.bufferIndex >= this.buffer.size());
if (isEmpty) {
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordTransformerExchanger.java b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordTransformerExchanger.java
index e2a68a9e7..36c5c94be 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordTransformerExchanger.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/BufferedRecordTransformerExchanger.java
@@ -20,7 +20,7 @@
package com.wgzhao.addax.core.transport.exchanger;
import com.wgzhao.addax.common.element.Record;
-import com.wgzhao.addax.common.exception.CommonErrorCode;
+import com.wgzhao.addax.common.spi.ErrorCode;
import com.wgzhao.addax.common.exception.AddaxException;
import com.wgzhao.addax.common.plugin.RecordReceiver;
import com.wgzhao.addax.common.plugin.RecordSender;
@@ -30,7 +30,6 @@
import com.wgzhao.addax.core.transport.channel.Channel;
import com.wgzhao.addax.core.transport.record.TerminateRecord;
import com.wgzhao.addax.core.transport.transformer.TransformerExecution;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import com.wgzhao.addax.core.util.container.CoreConstant;
import org.apache.commons.lang3.Validate;
@@ -38,6 +37,8 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
+import static com.wgzhao.addax.common.spi.ErrorCode.CONFIG_ERROR;
+
public class BufferedRecordTransformerExchanger
extends TransformerExchanger
implements RecordSender, RecordReceiver
@@ -79,8 +80,7 @@ public BufferedRecordTransformerExchanger(int taskGroupId, int taskId,
"com.wgzhao.addax.core.transport.record.DefaultRecord")));
}
catch (Exception e) {
- throw AddaxException.asAddaxException(
- FrameworkErrorCode.CONFIG_ERROR, e);
+ throw AddaxException.asAddaxException(CONFIG_ERROR, e);
}
}
@@ -91,8 +91,7 @@ public Record createRecord()
return BufferedRecordTransformerExchanger.RECORD_CLASS.getConstructor().newInstance();
}
catch (Exception e) {
- throw AddaxException.asAddaxException(
- FrameworkErrorCode.CONFIG_ERROR, e);
+ throw AddaxException.asAddaxException(CONFIG_ERROR, e);
}
}
@@ -100,7 +99,7 @@ public Record createRecord()
public void sendToWriter(Record record)
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
Validate.notNull(record, "The record cannot be empty.");
@@ -132,7 +131,7 @@ record = doTransformer(record);
public void flush()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
this.channel.pushAll(this.buffer);
//和channel的统计保持同步
@@ -146,7 +145,7 @@ public void flush()
public void terminate()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
flush();
this.channel.pushTerminate(TerminateRecord.get());
@@ -156,7 +155,7 @@ public void terminate()
public Record getFromReader()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
boolean isEmpty = (this.bufferIndex >= this.buffer.size());
if (isEmpty) {
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/RecordExchanger.java b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/RecordExchanger.java
index a301a6c9c..b73863671 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/RecordExchanger.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/RecordExchanger.java
@@ -20,7 +20,7 @@
package com.wgzhao.addax.core.transport.exchanger;
import com.wgzhao.addax.common.element.Record;
-import com.wgzhao.addax.common.exception.CommonErrorCode;
+import com.wgzhao.addax.common.spi.ErrorCode;
import com.wgzhao.addax.common.exception.AddaxException;
import com.wgzhao.addax.common.plugin.RecordReceiver;
import com.wgzhao.addax.common.plugin.RecordSender;
@@ -30,11 +30,12 @@
import com.wgzhao.addax.core.transport.channel.Channel;
import com.wgzhao.addax.core.transport.record.TerminateRecord;
import com.wgzhao.addax.core.transport.transformer.TransformerExecution;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import com.wgzhao.addax.core.util.container.CoreConstant;
import java.util.List;
+import static com.wgzhao.addax.common.spi.ErrorCode.CONFIG_ERROR;
+
public class RecordExchanger
extends TransformerExchanger
implements RecordSender, RecordReceiver
@@ -59,8 +60,7 @@ public RecordExchanger(int taskGroupId, int taskId, Channel channel, Communicati
"com.wgzhao.addax.core.transport.record.DefaultRecord"));
}
catch (ClassNotFoundException e) {
- throw AddaxException.asAddaxException(
- FrameworkErrorCode.CONFIG_ERROR, e);
+ throw AddaxException.asAddaxException(CONFIG_ERROR, e);
}
}
@@ -68,7 +68,7 @@ public RecordExchanger(int taskGroupId, int taskId, Channel channel, Communicati
public Record getFromReader()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
Record record = this.channel.pull();
return (record instanceof TerminateRecord ? null : record);
@@ -81,8 +81,7 @@ public Record createRecord()
return RECORD_CLASS.getConstructor().newInstance();
}
catch (Exception e) {
- throw AddaxException.asAddaxException(
- FrameworkErrorCode.CONFIG_ERROR, e);
+ throw AddaxException.asAddaxException(CONFIG_ERROR, e);
}
}
@@ -90,7 +89,7 @@ public Record createRecord()
public void sendToWriter(Record record)
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
record = doTransformer(record);
if (record == null) {
@@ -110,7 +109,7 @@ public void flush()
public void terminate()
{
if (shutdown) {
- throw AddaxException.asAddaxException(CommonErrorCode.SHUT_DOWN_TASK, "");
+ throw AddaxException.asAddaxException(ErrorCode.SHUT_DOWN_TASK, "");
}
this.channel.pushTerminate(TerminateRecord.get());
//和channel的统计保持同步
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/TransformerExchanger.java b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/TransformerExchanger.java
index bdaf8e9e6..38ad98221 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/TransformerExchanger.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/exchanger/TransformerExchanger.java
@@ -24,12 +24,13 @@
import com.wgzhao.addax.common.plugin.TaskPluginCollector;
import com.wgzhao.addax.core.statistics.communication.Communication;
import com.wgzhao.addax.core.statistics.communication.CommunicationTool;
-import com.wgzhao.addax.core.transport.transformer.TransformerErrorCode;
import com.wgzhao.addax.core.transport.transformer.TransformerExecution;
import com.wgzhao.addax.core.util.container.ClassLoaderSwapper;
import java.util.List;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+
/**
* no comments.
* Created by liqiang on 16/3/9.
@@ -87,7 +88,7 @@ public Record doTransformer(Record record)
if (transformerInfoExec.getColumnIndex() != null
&& transformerInfoExec.getColumnIndex() >= record.getColumnNumber()) {
- throw AddaxException.asAddaxException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER,
+ throw AddaxException.asAddaxException(ILLEGAL_VALUE,
String.format("columnIndex[%s] out of bound[%s]. name=%s",
transformerInfoExec.getColumnIndex(), record.getColumnNumber(),
transformerInfoExec.getTransformerName()));
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/record/DefaultRecord.java b/core/src/main/java/com/wgzhao/addax/core/transport/record/DefaultRecord.java
index f94aa97e5..9197f93e3 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/record/DefaultRecord.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/record/DefaultRecord.java
@@ -24,13 +24,14 @@
import com.wgzhao.addax.common.element.Record;
import com.wgzhao.addax.common.exception.AddaxException;
import com.wgzhao.addax.core.util.ClassSize;
-import com.wgzhao.addax.core.util.FrameworkErrorCode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+
/**
* Created by jingxing on 14-8-24.
*/
@@ -75,7 +76,7 @@ public Column getColumn(int i)
public void setColumn(int i, Column column)
{
if (i < 0) {
- throw AddaxException.asAddaxException(FrameworkErrorCode.ARGUMENT_ERROR,
+ throw AddaxException.asAddaxException(ILLEGAL_VALUE,
"Cannot set a value for a column with an index less than 0");
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/FilterTransformer.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/FilterTransformer.java
index cd04444af..7bfb4c046 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/FilterTransformer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/FilterTransformer.java
@@ -33,6 +33,9 @@
import java.util.Arrays;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
/**
* no comments.
* Created by liqiang on 16/3/4.
@@ -67,7 +70,7 @@ public Record evaluate(Record record, Object... paras)
}
}
catch (Exception e) {
- throw AddaxException.asAddaxException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER,
+ throw AddaxException.asAddaxException(ILLEGAL_VALUE,
"paras:" + Arrays.asList(paras) + " => " + e.getMessage());
}
@@ -105,7 +108,7 @@ else if ("<=".equalsIgnoreCase(code)) {
}
catch (Exception e) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(), e);
+ RUNTIME_ERROR, e.getMessage(), e);
}
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/GroovyTransformer.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/GroovyTransformer.java
index 01ba9afbd..9a1cea4a3 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/GroovyTransformer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/GroovyTransformer.java
@@ -29,6 +29,9 @@
import java.util.Arrays;
import java.util.List;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
/**
* no comments.
* Created by liqiang on 16/3/4.
@@ -51,7 +54,7 @@ public Record evaluate(Record record, Object... paras)
//全局唯一
if (paras.length < 1 || paras.length > 2) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER,
+ ILLEGAL_VALUE,
"The dx_groovy parameters must be 1 or 2. The current parameter is: " + Arrays.asList(paras));
}
synchronized (this) {
@@ -79,21 +82,21 @@ private void initGroovyTransformer(String code, List extraPackage)
}
catch (CompilationFailedException cfe) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_GROOVY_INIT_EXCEPTION, cfe);
+ RUNTIME_ERROR, cfe);
}
try {
Object t = groovyClass.getConstructor().newInstance();
if (!(t instanceof Transformer)) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_GROOVY_INIT_EXCEPTION,
+ RUNTIME_ERROR,
"Addax bug! ");
}
this.groovyTransformer = (Transformer) t;
}
catch (Throwable ex) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_GROOVY_INIT_EXCEPTION, ex);
+ RUNTIME_ERROR, ex);
}
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/MapTransformer.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/MapTransformer.java
index 096557283..5ff7198f7 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/MapTransformer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/MapTransformer.java
@@ -27,6 +27,8 @@
import java.util.Arrays;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
import static com.wgzhao.addax.common.util.MathUtil.add;
import static com.wgzhao.addax.common.util.MathUtil.divide;
import static com.wgzhao.addax.common.util.MathUtil.mod;
@@ -75,7 +77,7 @@ public Record evaluate(Record record, Object... paras)
}
catch (Exception e) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER,
+ ILLEGAL_VALUE,
"paras:" + Arrays.asList(paras) + " => " + e.getMessage());
}
@@ -111,7 +113,7 @@ public Record evaluate(Record record, Object... paras)
}
catch (Exception e) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(), e);
+ RUNTIME_ERROR, e.getMessage(), e);
}
}
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/PadTransformer.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/PadTransformer.java
index ac6ffafed..8a49c7598 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/PadTransformer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/PadTransformer.java
@@ -27,6 +27,9 @@
import java.util.Arrays;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
/**
* no comments.
* Created by liqiang on 16/3/4.
@@ -60,7 +63,7 @@ public Record evaluate(Record record, Object... paras)
}
catch (Exception e) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER,
+ ILLEGAL_VALUE,
"paras:" + Arrays.asList(paras) + " => " + e.getMessage());
}
@@ -90,7 +93,7 @@ public Record evaluate(Record record, Object... paras)
}
catch (Exception e) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(), e);
+ RUNTIME_ERROR, e.getMessage(), e);
}
return record;
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/ReplaceTransformer.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/ReplaceTransformer.java
index ca785dc35..de04b7307 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/ReplaceTransformer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/ReplaceTransformer.java
@@ -27,6 +27,9 @@
import java.util.Arrays;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
/**
* no comments.
* Created by liqiang on 16/3/4.
@@ -58,7 +61,7 @@ public Record evaluate(Record record, Object... paras)
replaceString = (String) paras[3];
}
catch (Exception e) {
- throw AddaxException.asAddaxException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER,
+ throw AddaxException.asAddaxException(ILLEGAL_VALUE,
"paras:" + Arrays.asList(paras) + " => " + e.getMessage());
}
@@ -88,7 +91,7 @@ public Record evaluate(Record record, Object... paras)
}
catch (Exception e) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(), e);
+ RUNTIME_ERROR, e.getMessage(), e);
}
return record;
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/SubstrTransformer.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/SubstrTransformer.java
index 1ead8a2e9..9bdd93b67 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/SubstrTransformer.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/SubstrTransformer.java
@@ -27,6 +27,9 @@
import java.util.Arrays;
+import static com.wgzhao.addax.common.spi.ErrorCode.ILLEGAL_VALUE;
+import static com.wgzhao.addax.common.spi.ErrorCode.RUNTIME_ERROR;
+
/**
* no comments.
* Created by liqiang on 16/3/4.
@@ -57,7 +60,7 @@ public Record evaluate(Record record, Object... paras)
length = Integer.parseInt((String) paras[2]);
}
catch (Exception e) {
- throw AddaxException.asAddaxException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER,
+ throw AddaxException.asAddaxException(ILLEGAL_VALUE,
"paras:" + Arrays.asList(paras) + " => " + e.getMessage());
}
@@ -85,7 +88,7 @@ public Record evaluate(Record record, Object... paras)
}
catch (Exception e) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(), e);
+ RUNTIME_ERROR, e.getMessage(), e);
}
return record;
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/TransformerErrorCode.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/TransformerErrorCode.java
deleted file mode 100644
index c38acebec..000000000
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/TransformerErrorCode.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 com.wgzhao.addax.core.transport.transformer;
-
-import com.wgzhao.addax.common.spi.ErrorCode;
-
-public enum TransformerErrorCode
- implements ErrorCode
-{
- //重复命名
- TRANSFORMER_NAME_ERROR("TransformerErrorCode-01", "Transformer name illegal"),
- TRANSFORMER_DUPLICATE_ERROR("TransformerErrorCode-02", "Transformer name has existed"),
- TRANSFORMER_NOTFOUND_ERROR("TransformerErrorCode-03", "Transformer name not found"),
- TRANSFORMER_CONFIGURATION_ERROR("TransformerErrorCode-04", "Transformer configuration error"),
- TRANSFORMER_ILLEGAL_PARAMETER("TransformerErrorCode-05", "Transformer parameter illegal"),
- TRANSFORMER_RUN_EXCEPTION("TransformerErrorCode-06", "Transformer run exception"),
- TRANSFORMER_GROOVY_INIT_EXCEPTION("TransformerErrorCode-07", "Transformer Groovy init exception"),
- ;
-
- private final String code;
-
- private final String description;
-
- TransformerErrorCode(String code, String description)
- {
- this.code = code;
- this.description = description;
- }
-
- @Override
- public String getCode()
- {
- return this.code;
- }
-
- @Override
- public String getDescription()
- {
- return this.description;
- }
-
- @Override
- public String toString()
- {
- return String.format("Code:[%s], Description:[%s]. ", this.code,
- this.description);
- }
-}
diff --git a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/TransformerRegistry.java b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/TransformerRegistry.java
index 18d1efa27..45bd67c9e 100644
--- a/core/src/main/java/com/wgzhao/addax/core/transport/transformer/TransformerRegistry.java
+++ b/core/src/main/java/com/wgzhao/addax/core/transport/transformer/TransformerRegistry.java
@@ -36,6 +36,8 @@
import java.util.List;
import java.util.Map;
+import static com.wgzhao.addax.common.spi.ErrorCode.CONFIG_ERROR;
+
/**
* no comments.
* Created by liqiang on 16/3/3.
@@ -144,7 +146,7 @@ public static synchronized void registryTransformer(Transformer transformer,
if (registeredTransformer.containsKey(transformer.getTransformerName())) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_DUPLICATE_ERROR,
+ CONFIG_ERROR,
" name=" + transformer.getTransformerName());
}
@@ -161,7 +163,7 @@ public static synchronized void registryComplexTransformer(ComplexTransformer co
if (registeredTransformer.containsKey(complexTransformer.getTransformerName())) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_DUPLICATE_ERROR,
+ CONFIG_ERROR,
" name=" + complexTransformer.getTransformerName());
}
@@ -185,7 +187,7 @@ private static void checkName(String functionName, boolean isNative)
if (!checkResult) {
throw AddaxException.asAddaxException(
- TransformerErrorCode.TRANSFORMER_NAME_ERROR,
+ CONFIG_ERROR,
" name=" + functionName + ": isNative=" + isNative);
}
}
diff --git a/core/src/main/java/com/wgzhao/addax/core/util/ConfigParser.java b/core/src/main/java/com/wgzhao/addax/core/util/ConfigParser.java
index 63a3dd4bf..e207e58c0 100644
--- a/core/src/main/java/com/wgzhao/addax/core/util/ConfigParser.java
+++ b/core/src/main/java/com/wgzhao/addax/core/util/ConfigParser.java
@@ -39,6 +39,9 @@
import org.slf4j.LoggerFactory;
import static com.wgzhao.addax.common.base.Key.CONNECTION;
+import static com.wgzhao.addax.common.spi.ErrorCode.CONFIG_ERROR;
+import static com.wgzhao.addax.common.spi.ErrorCode.PLUGIN_INIT_ERROR;
+import static com.wgzhao.addax.common.spi.ErrorCode.REQUIRED_VALUE;
import static com.wgzhao.addax.core.util.container.CoreConstant.CONF_PATH;
import static com.wgzhao.addax.core.util.container.CoreConstant.CORE_SERVER_TIMEOUT_SEC;
import static com.wgzhao.addax.core.util.container.CoreConstant.JOB_CONTENT;
@@ -54,17 +57,19 @@
import static com.wgzhao.addax.core.util.container.CoreConstant.PLUGIN_READER_HOME;
import static com.wgzhao.addax.core.util.container.CoreConstant.PLUGIN_WRITER_HOME;
-
-public final class ConfigParser {
+public final class ConfigParser
+{
private static final Logger LOG = LoggerFactory.getLogger(ConfigParser.class);
- private ConfigParser() {
+ private ConfigParser()
+ {
}
/*
* 指定Job配置路径,ConfigParser会解析Job、Plugin、Core全部信息,并以Configuration返回
*/
- public static Configuration parse(String jobPath) {
+ public static Configuration parse(String jobPath)
+ {
Configuration configuration = ConfigParser.parseJobConfig(jobPath);
// Upgrade the new job format to the old one
@@ -90,18 +95,7 @@ public static Configuration parse(String jobPath) {
if (StringUtils.isNotEmpty(postHandlerName)) {
pluginList.add(postHandlerName);
}
- try {
- configuration.merge(parsePluginConfig(new ArrayList<>(pluginList)), false);
- } catch (Exception e) {
- //吞掉异常,保持log干净。这里message足够。
- LOG.warn("Failed to load plugin(s) [{},{}]: {}, try after 1 second.", readerPluginName, writerPluginName, e.getMessage());
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e1) {
- //
- }
- configuration.merge(parsePluginConfig(new ArrayList<>(pluginList)), false);
- }
+ configuration.merge(parsePluginConfig(new ArrayList<>(pluginList)), false);
return configuration;
}
@@ -112,7 +106,9 @@ public static Configuration parse(String jobPath) {
*
* @param configuration {@link Configuration}
*/
- private static void upgradeJobConfig(Configuration configuration) {
+ private static void upgradeJobConfig(Configuration configuration)
+ {
+ configuration.getNecessaryValue(JOB_CONTENT);
if (configuration.getString(JOB_CONTENT).startsWith("[")) {
// get the first element
List