Skip to content

Commit

Permalink
Remove duplicate invoke init() method
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzhao committed Dec 11, 2021
1 parent fd6995f commit 0a46d6c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public void start()
isDryRun = configuration.getBool(CoreConstant.JOB_SETTING_DRY_RUN, false);
if (isDryRun) {
LOG.info("jobContainer starts to do preCheck ...");
this.init();
this.preCheck();
}
else {
Expand All @@ -128,6 +129,8 @@ public void start()

LOG.debug("jobContainer starts to do init ...");
this.init();
LOG.debug("jobContainer starts to do preCheck ...");
this.preCheck();
LOG.debug("jobContainer starts to do prepare ...");
this.prepare();
LOG.debug("jobContainer starts to do split ...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
package com.wgzhao.addax.plugin.reader.clickhousereader;

import com.wgzhao.addax.common.base.Key;
import com.wgzhao.addax.common.element.BytesColumn;
import com.wgzhao.addax.common.element.Column;
import com.wgzhao.addax.common.element.DateColumn;
import com.wgzhao.addax.common.element.StringColumn;
import com.wgzhao.addax.common.element.TimestampColumn;
import com.wgzhao.addax.common.plugin.RecordSender;
Expand All @@ -38,7 +36,6 @@
import java.sql.Types;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;

public class ClickHouseReader
extends Reader
Expand Down Expand Up @@ -66,7 +63,6 @@ public void init()
@Override
public void preCheck()
{
init();
this.commonRdbmsReaderJob.preCheck(this.originalConfig, DATABASE_TYPE);
}

Expand Down Expand Up @@ -116,7 +112,8 @@ else if (dataType == Types.OTHER) {
String dType = metaData.getColumnTypeName(i);
if (dType.startsWith("DateTime")) {
return new TimestampColumn(rs.getTimestamp(i));
} else {
}
else {
return new StringColumn(rs.getObject(i).toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package com.wgzhao.addax.plugin.reader.hivereader;

import com.wgzhao.addax.common.base.Key;
import com.wgzhao.addax.common.exception.AddaxException;
import com.wgzhao.addax.common.plugin.RecordSender;
import com.wgzhao.addax.common.spi.Reader;
Expand Down Expand Up @@ -58,8 +57,6 @@ public void init()
{
this.originalConfig = getPluginJobConf();

// this.originalConfig.set(Key.FETCH_SIZE, Integer.MIN_VALUE);

boolean haveKerberos = originalConfig.getBool(HAVE_KERBEROS, false);
if (haveKerberos) {
LOG.info("Try to login Hadoop via kerberos");
Expand All @@ -76,7 +73,6 @@ public void init()
@Override
public void preCheck()
{
init();
this.commonRdbmsReaderJob.preCheck(originalConfig, DATABASE_TYPE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public class MysqlReader
public static class Job
extends Reader.Job
{
private static final Logger LOG = LoggerFactory
.getLogger(Job.class);
private static final Logger LOG = LoggerFactory.getLogger(Job.class);

private Configuration originalConfig = null;
private CommonRdbmsReader.Job commonRdbmsReaderJob;
Expand All @@ -68,11 +67,9 @@ public void init()
this.originalConfig = this.commonRdbmsReaderJob.init(this.originalConfig);
}


@Override
public void preCheck()
{
init();
this.commonRdbmsReaderJob.preCheck(this.originalConfig, DATABASE_TYPE);
}

Expand Down Expand Up @@ -106,7 +103,8 @@ public static class Task
public void init()
{
this.readerSliceConfig = getPluginJobConf();
this.commonRdbmsReaderTask = new CommonRdbmsReader.Task(DATABASE_TYPE, getTaskGroupId(), getTaskId()) {
this.commonRdbmsReaderTask = new CommonRdbmsReader.Task(DATABASE_TYPE, getTaskGroupId(), getTaskId())
{
@Override
protected Column createColumn(ResultSet rs, ResultSetMetaData metaData, int i)
throws SQLException, UnsupportedEncodingException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

package com.wgzhao.addax.plugin.reader.oraclereader;

import com.wgzhao.addax.common.base.Key;
import com.wgzhao.addax.common.exception.AddaxException;
import com.wgzhao.addax.common.plugin.RecordSender;
import com.wgzhao.addax.common.spi.Reader;
import com.wgzhao.addax.common.util.Configuration;
import com.wgzhao.addax.rdbms.reader.CommonRdbmsReader;
import com.wgzhao.addax.common.base.Key;
import com.wgzhao.addax.rdbms.reader.util.HintUtil;
import com.wgzhao.addax.rdbms.util.DBUtilErrorCode;
import com.wgzhao.addax.rdbms.util.DataBaseType;
Expand Down Expand Up @@ -66,7 +66,6 @@ public void init()
@Override
public void preCheck()
{
init();
this.commonRdbmsReaderJob.preCheck(this.originalConfig, DATABASE_TYPE);
}

Expand Down Expand Up @@ -98,9 +97,7 @@ private void dealFetchSize(Configuration originalConfig)
String.format("您配置的 fetchSize 有误,fetchSize:[%d] 值不能小于 1.",
fetchSize));
}
originalConfig.set(
FETCH_SIZE,
fetchSize);
originalConfig.set(FETCH_SIZE, fetchSize);
}

private void dealHint(Configuration originalConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public void init()
this.originalConfig = this.commonRdbmsReaderJob.init(this.originalConfig);
}


@Override
public void preCheck()
public void prepare()
{
init();
this.commonRdbmsReaderJob.preCheck(this.originalConfig, DATABASE_TYPE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void init()
@Override
public void preCheck()
{
init();
this.commonRdbmsReaderJob.preCheck(this.originalConfig, DATABASE_TYPE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.List;

import static com.wgzhao.addax.common.base.Constant.DEFAULT_DATE_FORMAT;

public class MysqlWriter
extends Writer
{
Expand All @@ -50,7 +46,6 @@ public static class Job
@Override
public void preCheck()
{
this.init();
this.commonRdbmsWriterJob.writerPreCheck(this.originalConfig, DATABASE_TYPE);
}

Expand Down Expand Up @@ -101,7 +96,8 @@ public static class Task
public void init()
{
this.writerSliceConfig = super.getPluginJobConf();
this.commonRdbmsWriterTask = new CommonRdbmsWriter.Task(DATABASE_TYPE) {
this.commonRdbmsWriterTask = new CommonRdbmsWriter.Task(DATABASE_TYPE)
{

@Override
protected PreparedStatement fillPreparedStatementColumnType(PreparedStatement preparedStatement, int columnIndex,
Expand All @@ -116,7 +112,8 @@ protected PreparedStatement fillPreparedStatementColumnType(PreparedStatement pr
// BIT(1) -> java.lang.Boolean
if (column.getType() == Column.Type.BOOL) {
preparedStatement.setBoolean(columnIndex, column.asBoolean());
} else {
}
else {
// BIT ( > 1) -> byte[]
preparedStatement.setObject(columnIndex, Integer.valueOf(column.asString(), 2));
}
Expand Down

0 comments on commit 0a46d6c

Please sign in to comment.