) new RowFieldAccessor(pos, typeInfo);
29 | }else{
30 | return FieldAccessorFactory.getAccessor(typeInfo, pos,config);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/java/com/leonside/dataroad/flink/utils/RawTypeConverter.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.flink.utils;
2 |
3 | import org.apache.flink.api.common.typeinfo.TypeInformation;
4 | import org.apache.flink.table.types.DataType;
5 |
6 | /**
7 | * Each connector implements. It is used to convert raw type to flink type.
8 | *
9 | * e.g.: convert string "SHORT" to {@link DataType}.
10 | */
11 | @FunctionalInterface
12 | public interface RawTypeConverter {
13 |
14 | /**
15 | * @param type raw type string. e.g.: "SHORT", "INT", "TIMESTAMP"
16 | * @return e.g.: DataTypes.INT(), DataTypes.TIMESTAMP().
17 | */
18 | TypeInformation apply(String type);
19 | }
20 |
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/java/com/leonside/dataroad/flink/utils/RawTypeUtils.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.flink.utils;
2 |
3 | import com.leonside.dataroad.common.domain.MetaColumn;
4 | import com.leonside.dataroad.common.exception.JobConfigException;
5 | import org.apache.commons.collections.CollectionUtils;
6 | import org.apache.commons.lang.StringUtils;
7 | import org.apache.flink.api.common.typeinfo.TypeInfo;
8 | import org.apache.flink.api.common.typeinfo.TypeInformation;
9 | import org.apache.flink.api.java.typeutils.RowTypeInfo;
10 | import org.apache.flink.table.types.DataType;
11 | import org.apache.flink.table.types.utils.TypeConversions;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * @author leon
17 | */
18 | public class RawTypeUtils {
19 |
20 | public static TypeInformation createRowTypeInfo(RawTypeConverter converter, List metaColumns) {
21 | if(CollectionUtils.isEmpty(metaColumns) || StringUtils.isEmpty(metaColumns.get(0).getType())){
22 | throw new JobConfigException("column and type can not be null");
23 | }
24 |
25 | TypeInformation[] types = metaColumns.stream().map(it -> converter.apply(it.getType())).toArray(TypeInformation[]::new);
26 | String[] names = metaColumns.stream().map(it -> it.getName()).toArray(String[]::new);
27 |
28 | return new RowTypeInfo(types, names);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/java/com/leonside/dataroad/flink/utils/RowFieldAccessor.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.flink.utils;
2 |
3 | import org.apache.commons.lang.StringUtils;
4 | import org.apache.flink.api.common.typeinfo.TypeInformation;
5 | import org.apache.flink.api.java.typeutils.RowTypeInfo;
6 | import org.apache.flink.streaming.util.typeutils.FieldAccessor;
7 | import org.apache.flink.types.Row;
8 |
9 | /**
10 | * @author leon
11 | */
12 | public class RowFieldAccessor extends FieldAccessor {
13 |
14 | public String field;
15 |
16 | public int pos;
17 |
18 | private TypeInformation typeInfo;
19 |
20 | public RowFieldAccessor(String field, TypeInformation typeInfo) {
21 | this.field = field;
22 | this.fieldType = ((RowTypeInfo) typeInfo).getTypeAt(field);
23 | }
24 |
25 | public RowFieldAccessor(int pos, TypeInformation typeInfo) {
26 | this.pos = pos;
27 | this.fieldType = ((RowTypeInfo) typeInfo).getTypeAt(pos);
28 | }
29 |
30 | @Override
31 | public F get(R record) {
32 | return StringUtils.isNotEmpty(field) ? (F)record.getField(field) : (F)record.getField(pos);
33 | }
34 |
35 | @Override
36 | public R set(R record, F fieldValue) {
37 | if(StringUtils.isNotEmpty(field)){
38 | record.setField(field, fieldValue);
39 | }else{
40 | record.setField(pos, fieldValue);
41 | }
42 | return record;
43 | }
44 |
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/java/com/leonside/dataroad/flink/writer/PrintItemWriter.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.flink.writer;
2 |
3 | import com.leonside.dataroad.common.spi.ItemWriter;
4 | import com.leonside.dataroad.core.component.ComponentNameSupport;
5 | import com.leonside.dataroad.flink.context.FlinkExecuteContext;
6 | import org.apache.flink.streaming.api.datastream.DataStream;
7 | import org.apache.flink.types.Row;
8 |
9 | /**
10 | * @author leon
11 | */
12 |
13 | public class PrintItemWriter extends ComponentNameSupport implements ItemWriter> {
14 |
15 | @Override
16 | public void write(FlinkExecuteContext executeContext, DataStream items) {
17 | items.print();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/java/com/leonside/dataroad/flink/writer/outputformat/GenericRichOutputFormatBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package com.leonside.dataroad.flink.writer.outputformat;
3 |
4 | import com.leonside.dataroad.common.constant.JobCommonConstant;
5 | import com.leonside.dataroad.common.context.RestoreConfig;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | /**
10 | * The builder of RichOutputFormat
11 | *
12 | */
13 | public abstract class GenericRichOutputFormatBuilder {
14 | protected final Logger LOG = LoggerFactory.getLogger(getClass());
15 |
16 | protected T format;
17 |
18 | public R setRestore(RestoreConfig restore){
19 | format.setRestoreConfig(restore);
20 | return (R)this;
21 | }
22 |
23 | public R setErrors(Integer errors) {
24 | format.errors = errors;
25 | return (R)this;
26 | }
27 |
28 | public R setErrorRatio(Double errorRatio) {
29 | format.errorRatio = errorRatio;
30 | return (R)this;
31 | }
32 |
33 | public R setMonitorUrls(String monitorUrl) {
34 | format.monitorUrl = monitorUrl;
35 | return (R)this;
36 | }
37 |
38 | public R setBatchInterval(int batchInterval) {
39 | format.batchInterval = batchInterval;
40 | return (R)this;
41 | }
42 |
43 | public R setRestoreConfig(RestoreConfig restoreConfig){
44 | format.restoreConfig = restoreConfig;
45 | return (R)this;
46 | }
47 |
48 | /**
49 | * Check the value of parameters
50 | */
51 | protected abstract void checkFormat();
52 |
53 | public GenericRichOutputFormat finish() {
54 | checkFormat();
55 |
56 | /**
57 | * 200000条限制的原因:
58 | * 按照目前的使用情况以及部署配置,假设写入字段数量平均为50个,一个单slot的TaskManager内存为1G,
59 | * 在不考虑各插件批量写入对内存特殊要求并且只考虑插件缓存这么多条数据的情况下,batchInterval为400000条时出现fullGC,
60 | * 为了避免fullGC以及OOM,并且保证batchInterval有足够的配置空间,取最大值的一半200000。
61 | */
62 | if (this.format.getBatchInterval() > JobCommonConstant.MAX_BATCH_SIZE) {
63 | throw new IllegalArgumentException("批量写入条数必须小于[200000]条");
64 | }
65 |
66 | return format;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemProcessor:
--------------------------------------------------------------------------------
1 | scriptTransformer=com.leonside.dataroad.flink.processor.filter.ScriptTransformerProcessor
2 | scriptFilter=com.leonside.dataroad.flink.processor.filter.ScriptFilterProcessor
3 | sqlTransformer=com.leonside.dataroad.flink.processor.sql.SqlTransformerProcessor
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemUnionProcessor:
--------------------------------------------------------------------------------
1 | unionProcessor=com.leonside.dataroad.flink.processor.union.GenericItemUnionProcessor
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemWriter:
--------------------------------------------------------------------------------
1 | printWriter=com.leonside.dataroad.flink.writer.PrintItemWriter
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.ItemAggregationProcessor:
--------------------------------------------------------------------------------
1 | countWindowAgg=com.leonside.dataroad.flink.processor.aggeration.CountWindowAggerationProcessor
2 | slidingWindowAgg=com.leonside.dataroad.flink.processor.aggeration.SlidingWindowAggerationProcessor
3 | tumblingWindowAgg=com.leonside.dataroad.flink.processor.aggeration.TumblingWindowAggerationProcessor
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.ItemDeciderProcessor:
--------------------------------------------------------------------------------
1 | flinkOutputTagDeciderProcessor=com.leonside.dataroad.flink.processor.decider.OutputTagDeciderProcessor
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.ItemLookupProcessor:
--------------------------------------------------------------------------------
1 | directLookup=com.leonside.dataroad.flink.processor.lookup.DirectAllLookupProcessor
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.JobEngineProvider:
--------------------------------------------------------------------------------
1 | flinkJobProvider=com.leonside.dataroad.flink.FlinkJobProvider
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.JobExecutionDecider:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.JobExecutionDecider
--------------------------------------------------------------------------------
/dataroad-engine/dataroad-engine-flink/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.JobPredicate:
--------------------------------------------------------------------------------
1 | expressionPredicate=com.leonside.dataroad.flink.predicate.ExpressionPredicate
2 | trueExpressionPredicate=com.leonside.dataroad.flink.predicate.TrueExpressionPredicate
--------------------------------------------------------------------------------
/dataroad-engine/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | dataroad-all
7 | io.github.leonside
8 | 0.5
9 |
10 | 4.0.0
11 |
12 | dataroad-engine
13 | pom
14 |
15 | dataroad-engine-flink
16 |
17 |
18 |
19 | 8
20 | 8
21 |
22 |
23 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-es/src/main/java/com/leonside/dataroad/plugin/es/config/EsConstants.java:
--------------------------------------------------------------------------------
1 |
2 | package com.leonside.dataroad.plugin.es.config;
3 |
4 | /**
5 | * Configuration Keys for EsDataWriter and EsDataReader
6 | *
7 | */
8 | public class EsConstants {
9 |
10 | public static final String KEY_TIMEOUT = "timeout";
11 |
12 | public static final String KEY_PATH_PREFIX = "pathPrefix";
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-es/src/main/java/com/leonside/dataroad/plugin/es/config/EsReaderConfig.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.es.config;
2 |
3 | import com.leonside.dataroad.common.config.BaseConfig;
4 | import com.leonside.dataroad.common.config.ConfigKey;
5 | import com.leonside.dataroad.common.config.Validation;
6 | import lombok.Data;
7 |
8 | import java.util.Map;
9 |
10 | /**
11 | * @author leon
12 | */
13 | @Data
14 | public class EsReaderConfig extends BaseConfig {
15 |
16 | public EsReaderConfig(Map parameter){
17 | super(parameter);
18 | }
19 |
20 | private String address;
21 | private String username;
22 | private String password;
23 | private Object query;
24 |
25 | private String index;
26 | private String indexType;
27 | private Integer batchSize;
28 |
29 | private Integer timeout;
30 | private String pathPrefix;
31 |
32 | @Override
33 | public Class extends ConfigKey> bindConfigKey() {
34 | return EsReaderConfigKey.class;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-es/src/main/java/com/leonside/dataroad/plugin/es/config/EsWriterConfig.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.es.config;
2 |
3 | import com.leonside.dataroad.common.config.BaseConfig;
4 | import com.leonside.dataroad.common.config.ConfigKey;
5 | import com.leonside.dataroad.common.utils.ParameterUtils;
6 | import lombok.Data;
7 |
8 | import java.util.HashMap;
9 | import java.util.Map;
10 |
11 | /**
12 | * @author leon
13 | */
14 | @Data
15 | public class EsWriterConfig extends BaseConfig {
16 | public EsWriterConfig(Map parameter) {
17 | super(parameter);
18 | }
19 |
20 | public String address;
21 | public String username;
22 | public String password;
23 | public String index;
24 | public String indexType;
25 | public int bulkAction;
26 |
27 | public Integer timeout;
28 | public String pathPrefix;
29 |
30 |
31 | @Override
32 | public Class extends ConfigKey> bindConfigKey() {
33 | return EsWriterConfigKey.class;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-es/src/main/java/com/leonside/dataroad/plugin/es/reader/EsInputSplit.java:
--------------------------------------------------------------------------------
1 |
2 | package com.leonside.dataroad.plugin.es.reader;
3 |
4 | import org.apache.flink.core.io.InputSplit;
5 |
6 | /**
7 | * The Class describing each InputSplit of Elasticsearch
8 | *
9 | */
10 | public class EsInputSplit implements InputSplit {
11 |
12 | private int from;
13 | private int size;
14 |
15 | public int getFrom() {
16 | return from;
17 | }
18 |
19 | public void setFrom(int from) {
20 | this.from = from;
21 | }
22 |
23 | public int getSize() {
24 | return size;
25 | }
26 |
27 | public void setSize(int size) {
28 | this.size = size;
29 | }
30 |
31 | public EsInputSplit(int from, int size) {
32 | this.from = from;
33 | this.size = size;
34 | }
35 |
36 | @Override
37 | public int getSplitNumber() {
38 | return 0;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-es/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemReader:
--------------------------------------------------------------------------------
1 | esReader=com.leonside.dataroad.plugin.es.reader.EsReader
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-es/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemWriter:
--------------------------------------------------------------------------------
1 | esWriter=com.leonside.dataroad.plugin.es.writer.EsWriter
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-hive/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | dataroad-plugin
7 | io.github.leonside
8 | 0.5
9 |
10 | 4.0.0
11 |
12 | dataroad-plugin-hive
13 |
14 |
15 | 8
16 | 8
17 |
18 |
19 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/DataSource.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.jdbc;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * @author jiangbo
7 | */
8 | public class DataSource implements Serializable {
9 |
10 | private String jdbcUrl;
11 | private String userName;
12 | private String password;
13 | private String table;
14 | private boolean isSplitByKey;
15 | private Object[] parameterValues;
16 | private boolean isFinished;
17 |
18 | public DataSource() {
19 | this.isSplitByKey = false;
20 | this.isFinished = false;
21 | }
22 |
23 | public String getJdbcUrl() {
24 | return jdbcUrl;
25 | }
26 |
27 | public void setJdbcUrl(String jdbcUrl) {
28 | this.jdbcUrl = jdbcUrl;
29 | }
30 |
31 | public String getUserName() {
32 | return userName;
33 | }
34 |
35 | public void setUserName(String userName) {
36 | this.userName = userName;
37 | }
38 |
39 | public String getPassword() {
40 | return password;
41 | }
42 |
43 | public void setPassword(String password) {
44 | this.password = password;
45 | }
46 |
47 | public String getTable() {
48 | return table;
49 | }
50 |
51 | public void setTable(String table) {
52 | this.table = table;
53 | }
54 |
55 | public boolean isSplitByKey() {
56 | return isSplitByKey;
57 | }
58 |
59 | public void setSplitByKey(boolean splitByKey) {
60 | isSplitByKey = splitByKey;
61 | }
62 |
63 | public Object[] getParameterValues() {
64 | return parameterValues;
65 | }
66 |
67 | public void setParameterValues(Object[] parameterValues) {
68 | this.parameterValues = parameterValues;
69 | }
70 |
71 | public boolean isFinished() {
72 | return isFinished;
73 | }
74 |
75 | public void setFinished(boolean finished) {
76 | isFinished = finished;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/ParameterValuesProvider.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.jdbc;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | */
7 | public interface ParameterValuesProvider {
8 |
9 | /**
10 | * 获取分片信息
11 | * TODO 优化这部分逻辑
12 | *
13 | * @return 分片信息
14 | */
15 | Serializable[][] getParameterValues();
16 | }
17 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/lookup/config/JdbcLookupConfig.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.jdbc.lookup.config;
2 |
3 | import com.leonside.dataroad.common.config.ConfigKey;
4 | import com.leonside.dataroad.common.exception.JobConfigException;
5 | import com.leonside.dataroad.common.config.Validation;
6 | import com.leonside.dataroad.flink.processor.lookup.config.BaseLookupConfig;
7 | import lombok.Data;
8 | import org.apache.commons.lang.StringUtils;
9 |
10 | import java.io.Serializable;
11 | import java.util.Map;
12 | import java.util.concurrent.ConcurrentHashMap;
13 |
14 | /**
15 | * @author leon
16 | */
17 | @Data
18 | public class JdbcLookupConfig extends BaseLookupConfig {
19 | public JdbcLookupConfig(Map parameter) {
20 | super(parameter);
21 | }
22 |
23 | public String username;
24 | public String password;
25 | public String jdbcUrl;
26 | public int fetchSize;
27 | public String schema;
28 | public String table;
29 | public String where;
30 | public String customSql;
31 | public Map druidConf = new ConcurrentHashMap<>();
32 |
33 | /** vertx pool size */
34 | public int asyncPoolSize = 5;
35 | /** 失败重试次数 */
36 | public int maxRetryTimes = 3;
37 | public int errorLogPrintNum = 3;
38 | public int dbConnPoolSize = 5;
39 | public int eventLoopPoolSize = 1;
40 | public int taskQueueSize = 100000;
41 | public int parallelism = 1;
42 |
43 |
44 | @Override
45 | public boolean validate() {
46 | if(StringUtils.isEmpty(table) && StringUtils.isEmpty(customSql)){
47 | throw new JobConfigException("Table and Custom Sql configurations cannot be empty at the same time.");
48 | }
49 |
50 | return super.validate();
51 | }
52 |
53 | @Override
54 | public Class extends ConfigKey> bindConfigKey() {
55 | return JdbcLookupKey.class;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/lookup/datasource/DruidDataSourceProvider.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.jdbc.lookup.datasource;
2 |
3 | import com.google.common.base.CaseFormat;
4 | import io.vertx.ext.jdbc.spi.DataSourceProvider;
5 | import com.alibaba.druid.pool.DruidDataSource;
6 | import io.vertx.core.json.JsonObject;
7 | import io.vertx.ext.jdbc.spi.DataSourceProvider;
8 |
9 | import javax.sql.DataSource;
10 |
11 | import java.util.Map;
12 | import java.util.Properties;
13 |
14 | public class DruidDataSourceProvider implements DataSourceProvider {
15 |
16 | @Override
17 | public DataSource getDataSource(JsonObject config) {
18 | DruidDataSource dataSource = new DruidDataSource();
19 | Properties props = new Properties();
20 | for (Map.Entry entry : config) {
21 | String key = entry.getKey();
22 | if (!"provider_class".equals(key)) {
23 | String formattedName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, key);
24 | props.setProperty(formattedName, entry.getValue().toString());
25 | }
26 | }
27 | dataSource.configFromPropety(props);
28 | return dataSource;
29 | }
30 |
31 | @Override
32 | public void close(DataSource dataSource) {
33 | if (dataSource instanceof DruidDataSource) {
34 | ((DruidDataSource) dataSource).close();
35 | }
36 | }
37 |
38 | @Override
39 | public int maximumPoolSize(DataSource dataSource, JsonObject config) {
40 | if (dataSource instanceof DruidDataSource) {
41 | return ((DruidDataSource) dataSource).getMaxActive();
42 | }
43 | return -1;
44 | }
45 | }
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/reader/config/JdbcReaderConfig.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.jdbc.reader.config;
2 |
3 | import com.leonside.dataroad.common.config.BaseConfig;
4 | import com.leonside.dataroad.common.domain.MetaColumn;
5 | import com.leonside.dataroad.plugin.jdbc.reader.inputformat.IncrementConfig;
6 | import lombok.Data;
7 |
8 | import java.io.Serializable;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | /**
13 | * @author leon
14 | */
15 | @Data
16 | public class JdbcReaderConfig extends BaseConfig {
17 |
18 | protected String username;
19 | protected String password;
20 | protected String jdbcUrl;
21 |
22 | protected String table;
23 | protected String where;
24 | protected String customSql;
25 | protected String orderByColumn;
26 |
27 | protected String splitKey;
28 | protected int fetchSize;
29 | protected int queryTimeOut;
30 | //手动设置
31 | protected List metaColumns;
32 |
33 | protected IncrementConfig incrementConfig;
34 |
35 | public JdbcReaderConfig(Map parameter) {
36 | super(parameter);
37 | }
38 |
39 | @Override
40 | public Class bindConfigKey() {
41 | return JdbcReaderConfigKey.class;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/reader/inputformat/StringAccumulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package com.leonside.dataroad.plugin.jdbc.reader.inputformat;
20 |
21 | import org.apache.flink.api.common.accumulators.Accumulator;
22 |
23 | /**
24 | * @author jiangbo
25 | * @explanation
26 | * @date 2018/12/21
27 | */
28 | public class StringAccumulator implements Accumulator {
29 |
30 | private String localValue;
31 |
32 | @Override
33 | public void add(String value) {
34 | localValue = value;
35 | }
36 |
37 | @Override
38 | public String getLocalValue() {
39 | return localValue;
40 | }
41 |
42 | @Override
43 | public void resetLocal() {
44 | localValue = null;
45 | }
46 |
47 | @Override
48 | public Accumulator clone() {
49 | StringAccumulator stringAccumulator = new StringAccumulator();
50 | stringAccumulator.add(localValue);
51 | return stringAccumulator;
52 | }
53 |
54 | @Override
55 | public void merge(Accumulator other) {
56 | // do nothing
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return "StringData " + this.localValue;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/type/TypeConverterInterface.java:
--------------------------------------------------------------------------------
1 |
2 | package com.leonside.dataroad.plugin.jdbc.type;
3 |
4 | import java.io.Serializable;
5 |
6 | /**
7 | * Data type converter
8 | *
9 | */
10 | public interface TypeConverterInterface extends Serializable {
11 |
12 | /**
13 | * 类型转换,将数据库数据某类型的对象转换为对应的Java基本数据对象实例
14 | * @param data 数据记录
15 | * @param typeName 数据类型
16 | * @return
17 | */
18 | Object convert(Object data,String typeName);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-jdbc/src/main/java/com/leonside/dataroad/plugin/jdbc/writer/config/JdbcWriterConfig.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.jdbc.writer.config;
2 |
3 | import com.leonside.dataroad.common.config.BaseConfig;
4 | import com.leonside.dataroad.common.config.ConfigKey;
5 | import com.leonside.dataroad.common.enums.WriteMode;
6 | import lombok.Data;
7 |
8 | import java.io.Serializable;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | /**
14 | * @author leon
15 | */
16 | @Data
17 | public class JdbcWriterConfig extends BaseConfig {
18 |
19 | protected String jdbcUrl;
20 | protected String username;
21 | protected String password;
22 | protected List column = new ArrayList<>();
23 | protected List fullColumn = new ArrayList<>();
24 | protected String table;
25 | protected List preSql;
26 | protected List postSql;
27 | protected int batchSize;
28 | protected Map> updateKey;
29 |
30 | public String writeMode = WriteMode.INSERT.name();
31 |
32 | public JdbcWriterConfig(Map parameter) {
33 | super(parameter);
34 | }
35 |
36 | @Override
37 | public Class extends ConfigKey> bindConfigKey() {
38 | return JdbcWriterConfigKey.class;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-kafka/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | dataroad-all
7 | io.github.leonside
8 | 0.5
9 | ../../pom.xml
10 |
11 | 4.0.0
12 |
13 | dataroad-plugin-kafka
14 |
15 |
16 | 8
17 | 8
18 |
19 |
20 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysql/src/main/java/com/leonside/dataroad/plugin/mysql/reader/MysqlJdbcReader.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.mysql.reader;
2 |
3 | import com.leonside.dataroad.common.config.BaseConfig;
4 | import com.leonside.dataroad.plugin.jdbc.DatabaseDialect;
5 | import com.leonside.dataroad.plugin.jdbc.reader.GenericJdbcReader;
6 | import com.leonside.dataroad.plugin.jdbc.reader.inputformat.GenericJdbcInputFormatBuilder;
7 | import com.leonside.dataroad.plugin.mysql.MySqlDatabaseDialect;
8 |
9 | /**
10 | * @author leon
11 | */
12 | public class MysqlJdbcReader extends GenericJdbcReader {
13 |
14 | @Override
15 | protected GenericJdbcInputFormatBuilder getGenericJdbcInputFormatBuilder() {
16 | return new GenericJdbcInputFormatBuilder(new MysqlJdbcInputFormat());
17 | }
18 |
19 | @Override
20 | protected DatabaseDialect obtainDatabaseDialect() {
21 | return new MySqlDatabaseDialect();
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysql/src/main/java/com/leonside/dataroad/plugin/mysql/writer/MysqlJdbcOutputFormat.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.mysql.writer;
2 |
3 | import com.leonside.dataroad.plugin.jdbc.writer.outputformat.GenericJdbcOutputFormat;
4 |
5 | /**
6 | * @author leon
7 | */
8 | public class MysqlJdbcOutputFormat extends GenericJdbcOutputFormat {
9 | }
10 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysql/src/main/java/com/leonside/dataroad/plugin/mysql/writer/MysqlJdbcWriter.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.mysql.writer;
2 |
3 | import com.leonside.dataroad.plugin.jdbc.DatabaseDialect;
4 | import com.leonside.dataroad.plugin.jdbc.writer.GenericJdbcWriter;
5 | import com.leonside.dataroad.plugin.jdbc.writer.outputformat.GenericJdbcOutputFormatBuilder;
6 | import com.leonside.dataroad.plugin.mysql.MySqlDatabaseDialect;
7 |
8 | /**
9 | * @author leon
10 | */
11 | public class MysqlJdbcWriter extends GenericJdbcWriter {
12 | @Override
13 | protected GenericJdbcOutputFormatBuilder getBuilder() {
14 | return new GenericJdbcOutputFormatBuilder(new MysqlJdbcOutputFormat());
15 | }
16 |
17 | @Override
18 | protected DatabaseDialect obtainDatabaseDialect() {
19 | return new MySqlDatabaseDialect();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysql/src/main/java/com/leonside/dataroad/plugin/mysql/writer/MysqlStreamJdbcOutputFormat.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.mysql.writer;
2 |
3 | import com.leonside.dataroad.plugin.jdbc.writer.outputformat.GenericStreamJdbcOutputFormat;
4 |
5 | /**
6 | * @author leon
7 | */
8 | public class MysqlStreamJdbcOutputFormat extends GenericStreamJdbcOutputFormat {
9 | }
10 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysql/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemReader:
--------------------------------------------------------------------------------
1 | mysqlReader=com.leonside.dataroad.plugin.mysql.reader.MysqlJdbcReader
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysql/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemWriter:
--------------------------------------------------------------------------------
1 | mysqlWriter=com.leonside.dataroad.plugin.mysql.writer.MysqlJdbcWriter
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysql/src/main/resources/META-INF/services/com.leonside.dataroad.core.spi.ItemLookupProcessor:
--------------------------------------------------------------------------------
1 | mysqlLookup=com.leonside.dataroad.plugin.mysql.lookup.MysqlLookupProcessor
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysqlstream/src/main/java/com/leonside/dataroad/plugin/mysqlstream/config/MysqlStreamReaderConfig.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.mysqlstream.config;
2 |
3 | import com.leonside.dataroad.common.config.BaseConfig;
4 | import com.leonside.dataroad.common.config.ConfigKey;
5 | import com.leonside.dataroad.common.config.Validation;
6 | import lombok.Data;
7 |
8 | import java.util.Map;
9 |
10 | /**
11 | * @author leon
12 | */
13 | @Data
14 | public class MysqlStreamReaderConfig extends BaseConfig {
15 |
16 | protected String hostname;
17 | protected int port;
18 | protected String schema;
19 |
20 | protected String username;
21 | protected String password;
22 | protected String table;
23 |
24 | public MysqlStreamReaderConfig(Map parameter) {
25 | super(parameter);
26 | }
27 |
28 | @Override
29 | public Class extends ConfigKey> bindConfigKey() {
30 | return MysqlStreamReaderConfigKey.class;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysqlstream/src/main/java/com/leonside/dataroad/plugin/mysqlstream/writer/MysqlStreamJdbcOutputFormat.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.mysqlstream.writer;
2 |
3 |
4 | import com.leonside.dataroad.plugin.jdbc.writer.outputformat.GenericStreamJdbcOutputFormat;
5 |
6 | /**
7 | * @author leon
8 | */
9 | public class MysqlStreamJdbcOutputFormat extends GenericStreamJdbcOutputFormat {
10 | }
11 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysqlstream/src/main/java/com/leonside/dataroad/plugin/mysqlstream/writer/MysqlStreamJdbcWriter.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.mysqlstream.writer;
2 |
3 | import com.leonside.dataroad.common.enums.WriteMode;
4 | import com.leonside.dataroad.common.exception.JobConfigException;
5 | import com.leonside.dataroad.flink.context.FlinkExecuteContext;
6 | import com.leonside.dataroad.plugin.jdbc.DatabaseDialect;
7 | import com.leonside.dataroad.plugin.jdbc.writer.GenericJdbcWriter;
8 | import com.leonside.dataroad.plugin.jdbc.writer.outputformat.GenericJdbcOutputFormatBuilder;
9 | import com.leonside.dataroad.plugin.mysql.MySqlDatabaseDialect;
10 |
11 | import java.util.Map;
12 |
13 | /**
14 | * @author leon
15 | */
16 | public class MysqlStreamJdbcWriter extends GenericJdbcWriter {
17 | @Override
18 | protected GenericJdbcOutputFormatBuilder getBuilder() {
19 | return new GenericJdbcOutputFormatBuilder(new MysqlStreamJdbcOutputFormat()) ;
20 | }
21 |
22 | @Override
23 | public void initialize(FlinkExecuteContext executeContext, Map parameter) {
24 | super.initialize(executeContext, parameter);
25 | if(mode != null && !mode.equalsIgnoreCase(WriteMode.STREAM.name())){
26 | throw new JobConfigException("There is no need to set mode or set stream type for Mysql stream writer ");
27 | }
28 | mode = WriteMode.STREAM.name();
29 | }
30 |
31 | @Override
32 | protected DatabaseDialect obtainDatabaseDialect() {
33 | return new MySqlDatabaseDialect();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysqlstream/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemReader:
--------------------------------------------------------------------------------
1 | mysqlStreamReader=com.leonside.dataroad.plugin.mysqlstream.reader.MysqlStreamJdbcReader
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-mysqlstream/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemWriter:
--------------------------------------------------------------------------------
1 | mysqlStreamWriter=com.leonside.dataroad.plugin.mysqlstream.writer.MysqlStreamJdbcWriter
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-oracle/src/main/java/com/leonside/dataroad/plugin/oracle/reader/OracleJdbcReader.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.oracle.reader;
2 |
3 | import com.leonside.dataroad.plugin.jdbc.DatabaseDialect;
4 | import com.leonside.dataroad.plugin.jdbc.reader.GenericJdbcReader;
5 | import com.leonside.dataroad.plugin.jdbc.reader.inputformat.GenericJdbcInputFormatBuilder;
6 | import com.leonside.dataroad.plugin.oracle.OracleDatabaseDialect;
7 |
8 | /**
9 | * @author leon
10 | */
11 | public class OracleJdbcReader extends GenericJdbcReader {
12 | @Override
13 | protected GenericJdbcInputFormatBuilder getGenericJdbcInputFormatBuilder() {
14 | return new GenericJdbcInputFormatBuilder(new OracleJdbcInputFormat());
15 | }
16 |
17 | @Override
18 | protected DatabaseDialect obtainDatabaseDialect() {
19 | return new OracleDatabaseDialect();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-oracle/src/main/java/com/leonside/dataroad/plugin/oracle/writer/OracleJdbcWriter.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.oracle.writer;
2 |
3 | import com.leonside.dataroad.plugin.jdbc.DatabaseDialect;
4 | import com.leonside.dataroad.plugin.jdbc.writer.GenericJdbcWriter;
5 | import com.leonside.dataroad.plugin.jdbc.writer.outputformat.GenericJdbcOutputFormatBuilder;
6 | import com.leonside.dataroad.plugin.oracle.OracleDatabaseDialect;
7 |
8 | /**
9 | * @author leon
10 | */
11 | public class OracleJdbcWriter extends GenericJdbcWriter {
12 | @Override
13 | protected GenericJdbcOutputFormatBuilder getBuilder() {
14 | return new GenericJdbcOutputFormatBuilder(new OracleJdbcOutputFormat());
15 | }
16 |
17 | @Override
18 | protected DatabaseDialect obtainDatabaseDialect() {
19 | return new OracleDatabaseDialect();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-oracle/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemReader:
--------------------------------------------------------------------------------
1 | oracleReader=com.leonside.dataroad.plugin.oracle.reader.OracleJdbcReader
2 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-oracle/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemWriter:
--------------------------------------------------------------------------------
1 | oracleWriter=com.leonside.dataroad.plugin.oracle.writer.OracleJdbcWriter
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-postgresql/src/main/java/com/leonside/dataroad/plugin/postgresql/reader/PostgresqlJdbcInputFormat.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.postgresql.reader;
2 |
3 | import com.leonside.dataroad.plugin.jdbc.reader.inputformat.GenericJdbcInputFormat;
4 | import com.leonside.dataroad.plugin.jdbc.utils.DbUtil;
5 | import org.apache.commons.collections.CollectionUtils;
6 | import org.apache.flink.types.Row;
7 |
8 | import java.io.IOException;
9 |
10 | /**
11 | * @author leon
12 | */
13 | public class PostgresqlJdbcInputFormat extends GenericJdbcInputFormat {
14 |
15 | @Override
16 | public Row doNextRecord(Row row) throws IOException {
17 | if (!hasNext) {
18 | return null;
19 | }
20 | row = Row.withNames();
21 |
22 | try {
23 | for (int pos = 0; pos < row.getArity(); pos++) {
24 | Object obj = resultSet.getObject(pos + 1);
25 | if(obj != null) {
26 | if(CollectionUtils.isNotEmpty(columnTypeList)) {
27 | obj = typeConverter.convert(obj, columnTypeList.get(pos));
28 | }
29 | obj = DbUtil.clobToString(obj);
30 | }
31 |
32 | row.setField(metaData.getColumnName(pos + 1), obj);
33 | }
34 |
35 | return super.doNextRecord(row);
36 | }catch (Exception e) {
37 | throw new IOException("Couldn't read data - " + e.getMessage(), e);
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-postgresql/src/main/java/com/leonside/dataroad/plugin/postgresql/writer/PostgresqlJdbcWriter.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.plugin.postgresql.writer;
2 |
3 | import com.leonside.dataroad.common.config.BaseConfig;
4 | import com.leonside.dataroad.plugin.jdbc.DatabaseDialect;
5 | import com.leonside.dataroad.plugin.jdbc.writer.GenericJdbcWriter;
6 | import com.leonside.dataroad.plugin.jdbc.writer.outputformat.GenericJdbcOutputFormatBuilder;
7 | import com.leonside.dataroad.plugin.postgresql.PostgresqlDatabaseDialect;
8 |
9 | /**
10 | * @author leon
11 | */
12 | public class PostgresqlJdbcWriter extends GenericJdbcWriter {
13 | @Override
14 | protected GenericJdbcOutputFormatBuilder getBuilder() {
15 | return new GenericJdbcOutputFormatBuilder(new PostgresqlJdbcOutputFormat());
16 | }
17 |
18 | @Override
19 | protected DatabaseDialect obtainDatabaseDialect() {
20 | return new PostgresqlDatabaseDialect();
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-postgresql/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemReader:
--------------------------------------------------------------------------------
1 | postgresqlReader=com.leonside.dataroad.plugin.postgresql.reader.PostgresqlJdbcReader
2 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-postgresql/src/main/resources/META-INF/services/com.leonside.dataroad.common.spi.ItemWriter:
--------------------------------------------------------------------------------
1 | postgresqlWriter=com.leonside.dataroad.plugin.postgresql.writer.PostgresqlJdbcWriter
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-redis/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | dataroad-plugin
7 | io.github.leonside
8 | 0.5
9 |
10 | 4.0.0
11 |
12 | dataroad-plugin-redis
13 |
14 |
15 | 8
16 | 8
17 |
18 |
19 |
--------------------------------------------------------------------------------
/dataroad-plugin/dataroad-plugin-sqlserver/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | dataroad-plugin
7 | io.github.leonside
8 | 0.5
9 |
10 | 4.0.0
11 |
12 | dataroad-plugin-sqlserver
13 |
14 |
15 | 8
16 | 8
17 |
18 |
19 |
--------------------------------------------------------------------------------
/dataroad-plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | dataroad-all
7 | io.github.leonside
8 | 0.5
9 |
10 | 4.0.0
11 | pom
12 |
13 | dataroad-plugin
14 |
15 |
16 | dataroad-plugin-jdbc
17 | dataroad-plugin-mysql
18 | dataroad-plugin-oracle
19 | dataroad-plugin-sqlserver
20 | dataroad-plugin-postgresql
21 | dataroad-plugin-mysqlstream
22 | dataroad-plugin-hive
23 | dataroad-plugin-redis
24 | dataroad-plugin-es
25 |
26 |
27 |
28 | 8
29 | 8
30 |
31 |
32 |
--------------------------------------------------------------------------------
/dataroad/src/main/java/com/leonside/dataroad/DataroadEngine.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad;
2 |
3 | import com.leonside.dataroad.config.JobCreator;
4 | import com.leonside.dataroad.common.config.Options;
5 | import com.leonside.dataroad.config.job.JsonJobCreator;
6 | import com.leonside.dataroad.config.job.JsonJobSchemaParser;
7 | import com.leonside.dataroad.core.Job;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.apache.commons.collections.map.HashedMap;
10 | import org.apache.commons.lang.StringUtils;
11 | import org.apache.flink.api.java.utils.ParameterTool;
12 |
13 | import java.util.HashMap;
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | /**
18 | * @author leon
19 | */
20 | @Slf4j
21 | public class DataroadEngine {
22 |
23 | public static void main(String[] args) throws Exception {
24 |
25 | ParameterTool parameters = ParameterTool.fromArgs(args);
26 |
27 | Options options = Options.of(parameters.toMap());
28 |
29 | if(StringUtils.isEmpty(options.getConf())){
30 | throw new UnsupportedOperationException("schema path can not be null!");
31 | }
32 |
33 | log.info("Start job,schema path is [{}]...." , options.getConf() );
34 |
35 | JobCreator jsonJobCreator = new JsonJobCreator(new JsonJobSchemaParser(), options);
36 |
37 | List jobs = jsonJobCreator.createJob();
38 |
39 | jobs.forEach(job ->{
40 |
41 | try {
42 | job.execute();
43 | } catch (Exception e) {
44 | e.printStackTrace();
45 | }
46 |
47 | });
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/dataroad/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy ofGenericTopN the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ################################################################################
18 |
19 | log4j.rootLogger=INFO, console
20 |
21 | log4j.appender.console=org.apache.log4j.ConsoleAppender
22 | log4j.appender.console.layout=org.apache.log4j.PatternLayout
23 | log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n
24 |
--------------------------------------------------------------------------------
/dataroad/src/main/resources/mysql_filter_mysql.json:
--------------------------------------------------------------------------------
1 | {
2 | "job": {
3 | "content": [
4 | {
5 | "mysqlreader": {
6 | "type": "reader",
7 | "pluginName": "mysqlReader",
8 | "parameter": {
9 | "username": "duceap",
10 | "password": "123",
11 | "jdbcUrl": "jdbc:mysql://10.254.10.31:3306/duceap_job_demo?useunicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai",
12 | "table": "job_execution_log",
13 | "column": ["id","job_name","ip"],
14 | "customSql": "",
15 | "splitKey": "",
16 | "queryTimeOut": 1000,
17 | "requestAccumulatorInterval": 2
18 | }
19 | },
20 | "myprocessor1": {
21 | "type": "processor",
22 | "pluginName": "filterProcessor",
23 | "dependencies": ["mysqlreader"],
24 | "parameter": {
25 | "expression": "row.getField('age')>=20"
26 | }
27 | },
28 | "mywriter": {
29 | "type": "writer",
30 | "pluginName": "mysqlWriter",
31 | "parameter": {
32 | "username": "duceap",
33 | "password": "123",
34 | "jdbcUrl": "jdbc:mysql://10.254.10.31:3306/duceap_job_demo?useunicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai",
35 | "table": "job_execution_log2",
36 | "writeMode": "insert",
37 | "column": ["id","job_name","ip"],
38 | "batchSize": 1024
39 | }
40 | }
41 | }
42 | ],
43 | "setting":{
44 | "name": "myJob"
45 | }
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/dataroad/src/main/resources/mysql_filter_print_restore.json:
--------------------------------------------------------------------------------
1 | {
2 | "job": {
3 | "content": [
4 | {
5 | "mysqlreader": {
6 | "type": "reader",
7 | "pluginName": "mysqlReader",
8 | "parameter": {
9 | "username": "duceap",
10 | "password": "123",
11 | "jdbcUrl": "jdbc:mysql://10.254.10.31:3306/duceap_job_demo?useunicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai",
12 | "table": [
13 | "student"
14 | ],
15 | "column": [
16 | "id",
17 | "name",
18 | "sex",
19 | "age",
20 | "address",
21 | "idcard",
22 | "phone",
23 | "code",
24 | "create_time",
25 | "area_code"
26 | ],
27 | "customSql": "",
28 | "splitKey": "",
29 | "queryTimeOut": 1000,
30 | "requestAccumulatorInterval": 2
31 | }
32 | },
33 | "myprocessor1": {
34 | "type": "processor",
35 | "pluginName": "filterProcessor",
36 | "dependencies": [
37 | "mysqlreader"
38 | ],
39 | "parameter": {
40 | "expression": "row.getField('age')>=20"
41 | }
42 | },
43 | "mywriter": {
44 | "type": "writer",
45 | "pluginName": "printWriter"
46 | }
47 | }
48 | ],
49 | "setting":{
50 | "speed": {
51 | "channel": 4,
52 | "bytes": 0
53 | },
54 | "errorLimit": {
55 | "record": 1
56 | },
57 | "restore": {
58 | "maxRowNumForCheckpoint": 0,
59 | "isRestore": true,
60 | "restoreColumnName": "id",
61 | "restoreColumnIndex": 0
62 | },
63 | "log" : {
64 | "isLogger": false,
65 | "level" : "debug",
66 | "path" : "",
67 | "pattern":""
68 | }
69 | }
70 | }
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/dataroad/src/main/resources/mysqlstream_es.json:
--------------------------------------------------------------------------------
1 | {
2 | "job": {
3 | "content": [
4 | {
5 | "mysqlreader": {
6 | "type": "reader",
7 | "pluginName": "mysqlStreamReader",
8 | "parameter": {
9 | "username": "root",
10 | "password": "dragon@1qaz!QAZ",
11 | "hostname": "10.254.10.31",
12 | "port": 3306,
13 | "table": "student",
14 | "schema": "duceap_job_demo"
15 | }
16 | },
17 | "mywriter": {
18 | "type": "writer",
19 | "pluginName": "esWriter",
20 | "parameter": {
21 | "address": "bigdata33:9200",
22 | "index": "student1",
23 | "username": "",
24 | "password": "",
25 | "type": "_doc",
26 | "bulkAction": 2,
27 | "timeout": 1000,
28 | "idColumn": [
29 | {
30 | "name": "id",
31 | "type": "integer"
32 | }
33 | ],
34 | "column": [
35 | {"name": "id","type": "int"},
36 | {"name": "name","type": "string"},
37 | {"name": "sex","type": "int"},
38 | {"name": "age","type": "int"},
39 | {"name": "address","type": "string"},
40 | {"name": "idcard","type": "string"},
41 | {"name": "phone","type": "string"},
42 | {"name": "code","type": "int"},
43 | {"name": "create_time","type": "timestamp"},
44 | {"name": "area_code","type": "string"}
45 | ]
46 | }
47 | }
48 | }
49 | ],
50 | "setting":{
51 | "monitorUrls": "",
52 | "speed": {
53 | "channel": 1,
54 | "bytes": 0
55 | },
56 | "errorLimit": {
57 | "record": 1
58 | },
59 | "restore": {
60 | "isRestore": true,
61 | "savepointPath": "file:///D:\\conf\\checkpoint",
62 | "savepointRestorePath": "D:\\conf\\checkpoint\\b75a0f3ef253b34d2f2e63c8ad3f7c04\\chk-13",
63 | "savepointInterval": 10000
64 | },
65 | "log" : {
66 | "isLogger": false,
67 | "level" : "debug",
68 | "path" : "",
69 | "pattern":""
70 | }
71 | }
72 | }
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/dataroad/src/main/resources/mysqlstream_mysqlstreamwriter_postsql_fromcheckpoint.json:
--------------------------------------------------------------------------------
1 | {
2 | "job": {
3 | "content": [
4 | {
5 | "mysqlreader": {
6 | "type": "reader",
7 | "pluginName": "mysqlStreamReader",
8 | "parameter": {
9 | "username": "root",
10 | "password": "dragon@1qaz!QAZ",
11 | "hostname": "10.254.10.31",
12 | "port": 3306,
13 | "table": "student",
14 | "schema": "duceap_job_demo"
15 | }
16 | },
17 | "mywriter": {
18 | "type": "writer",
19 | "pluginName": "mysqlStreamWriter",
20 | "parameter": {
21 | "username": "duceap",
22 | "password": "123",
23 | "jdbcUrl": "jdbc:mysql://10.254.10.31:3306/duceap_job_demo?useunicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai",
24 | "table": "student1",
25 | "preSql": [],
26 | "postSql": [
27 | "update student1 set code = '1000';"
28 | ],
29 | "batchSize": 1
30 | }
31 | }
32 | }
33 | ],
34 | "setting":{
35 | "monitorUrls": "",
36 | "speed": {
37 | "channel": 1,
38 | "bytes": 0
39 | },
40 | "errorLimit": {
41 | "record": 1
42 | },
43 | "restore": {
44 | "isRestore": true,
45 | "savepointPath": "file:///D:\\conf\\checkpoint",
46 | "savepointRestorePath": "D:\\conf\\checkpoint\\b75a0f3ef253b34d2f2e63c8ad3f7c04\\chk-13",
47 | "savepointInterval": 10000
48 | },
49 | "log" : {
50 | "isLogger": false,
51 | "level" : "debug",
52 | "path" : "",
53 | "pattern":""
54 | }
55 | }
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/dataroad/src/test/java/com/leonside/dataroad/common/GroovyScriptTest.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.common;
2 |
3 | import com.leonside.dataroad.common.script.ScriptEvaluator;
4 | import com.leonside.dataroad.common.script.ScriptEvaluatorFactory;
5 | import org.apache.flink.types.Row;
6 |
7 | /**
8 | * @author leon
9 | */
10 | public class GroovyScriptTest {
11 |
12 | public static void main(String[] args) throws Exception {
13 | String exp = "row.getField('score')>=500 ";
14 |
15 | Row row = Row.withNames();
16 | row.setField("name","zhangsan");
17 | row.setField("score", 599);
18 |
19 | long l = System.currentTimeMillis();
20 |
21 | ScriptEvaluator scriptEvalutor = ScriptEvaluatorFactory.createScriptEvalutor(ScriptEvaluatorFactory.ScriptEngine.groovy, exp, new String[]{"import org.apache.flink.types.Row;"});
22 | for (int i = 0; i < 10000; i++) {
23 |
24 | Object evaluate = scriptEvalutor.evaluate(row, null);
25 | // System.out.println(evaluate);
26 | }
27 | // 1w耗时:1978 耗时:N久
28 | System.out.println("耗时:"+ (System.currentTimeMillis() - l));
29 |
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/dataroad/src/test/java/com/leonside/dataroad/common/TestMain.java:
--------------------------------------------------------------------------------
1 | package com.leonside.dataroad.common;
2 |
3 | import org.apache.flink.types.Row;
4 |
5 | /**
6 | * @author leon
7 | */
8 | public class TestMain {
9 | public static void main(String[] args) {
10 | Row row = Row.withNames();
11 | row.setField("name1","zhangs");
12 | row.setField("name2","lisi");
13 |
14 | Row row2 = Row.withNames();
15 | row2.setField("name3","zhangs2");
16 | row2.setField("name1","lisi2");
17 |
18 | Row join = row.copy(row2);
19 | System.out.println(join);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/doc/images/dashboard-commit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-commit.png
--------------------------------------------------------------------------------
/doc/images/dashboard-create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-create.png
--------------------------------------------------------------------------------
/doc/images/dashboard-designer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-designer.png
--------------------------------------------------------------------------------
/doc/images/dashboard-guide-commit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-guide-commit.png
--------------------------------------------------------------------------------
/doc/images/dashboard-guide-designer-line.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-guide-designer-line.png
--------------------------------------------------------------------------------
/doc/images/dashboard-guide-designer-node.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-guide-designer-node.png
--------------------------------------------------------------------------------
/doc/images/dashboard-guide-designer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-guide-designer.png
--------------------------------------------------------------------------------
/doc/images/dashboard-guide-download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-guide-download.png
--------------------------------------------------------------------------------
/doc/images/dashboard-guide-json.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-guide-json.png
--------------------------------------------------------------------------------
/doc/images/dashboard-guide-upload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-guide-upload.png
--------------------------------------------------------------------------------
/doc/images/dashboard-json.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dashboard-json.png
--------------------------------------------------------------------------------
/doc/images/dataroad-arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dataroad-arch.png
--------------------------------------------------------------------------------
/doc/images/dataroad-designer-flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/dataroad-designer-flow.png
--------------------------------------------------------------------------------
/doc/images/designer-json.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/doc/images/designer-json.png
--------------------------------------------------------------------------------
/doc/plugin/scripttrans.md:
--------------------------------------------------------------------------------
1 | ## Script Transformer脚本转换
2 |
3 | ### 一、插件名称
4 | 类型:**processor**
5 | 名称:**scriptTransformer**
6 | ### 二、参数说明
7 |
8 | - **language**
9 | - 描述:脚本语言类型,支持groovy,fel,bsh,javascript
10 | - 必选:否
11 | - 字段类型:String
12 | - 默认值:默认采用fel语言
13 |
14 |
15 | - **expression**
16 | - 描述:脚本语言表达,无需返回值。
17 | - 注意:
18 | - 可通过"row"变量获取到Row行记录集,例如判断如果性别为空则设置默认值为0: if(row.getField("sex") == null){row.setField("sex",0) ;}。其中sex对应配置的数据库column列名。
19 | - 脚本转换,通过表达式修改row值,无需返回值!
20 | - 具体的表达式语法可参见各个脚本语言的编写规则。
21 | - 必选:是
22 | - 字段类型:String
23 | - 默认值:无
24 |
25 |
26 | ### 三、配置示例
27 | #### 1、groovy
28 | ```json
29 | {
30 | "type": "processor",
31 | "pluginName": "scriptFilter",
32 | "parameter": {
33 | "expression": "int sex = row.getField('sex'); if(sex==0){row.setField("sex_value", "男");}else{row.setField("sex_value", "女");} " ,
34 | "language": "groovy"
35 | }
36 | }
37 | ```
38 |
39 |
40 | #### 2、fel
41 |
42 | ```json
43 | {
44 | "type": "processor",
45 | "pluginName": "scriptFilter",
46 | "parameter": {
47 | "expression": "row.setField("area_code",row.getField("area_code").substring(0,4)) ",
48 | "language": "fel"
49 | }
50 | }
51 | ```
52 |
53 | #### 3、javascript
54 |
55 | ```json
56 | {
57 | "type": "processor",
58 | "pluginName": "scriptFilter",
59 | "parameter": {
60 | "expression": " if(row.getField("sex") == null){row.setField("sex",0) ;} " ,
61 | "language": "javascript"
62 | }
63 | }
64 | ```
65 |
66 | #### 4、bsh
67 | ```json
68 | {
69 | "type": "processor",
70 | "pluginName": "scriptFilter",
71 | "parameter": {
72 | "expression": "row.setField("score",row.getField("score")+1); " ,
73 | "language": "bsh"
74 | }
75 | }
76 | ```
--------------------------------------------------------------------------------
/doc/plugin/sqltrans.md:
--------------------------------------------------------------------------------
1 | ## SQL Transformer SQL转换
2 |
3 | ### 一、插件名称
4 | 类型:**processor**
5 | 名称:**sqlTransformer**
6 | ### 二、参数说明
7 |
8 | - **tableName**
9 | - 描述:临时表名,如:t1
10 | - 必选:是
11 | - 字段类型:String
12 | - 默认值:否
13 |
14 |
15 | - **sql**
16 | - 描述:转换的SQL语句,此处语法参照Flink SQL语法,例如:select * from t1 where score>=600 and area_code like '3501%'
17 | - 必选:是
18 | - 字段类型:String
19 | - 默认值:无
20 |
21 |
22 | ### 三、配置示例
23 | #### 1、groovy
24 | ```json
25 | {
26 | "type": "processor",
27 | "pluginName": "sqlTransformer",
28 | "parameter": {
29 | "sql": "select * from t1 where score>=600 and area_code like '3501%'" ,
30 | "tabelName": "t1"
31 | }
32 | }
33 | ```
34 |
--------------------------------------------------------------------------------
/jars/bsh-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/jars/bsh-1.0.jar
--------------------------------------------------------------------------------
/jars/install_jars.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | mvn install:install-file -DgroupId=bsh -DartifactId=bsh -Dversion=1.0 -Dpackaging=jar -Dfile=./bsh-1.0.jar
4 |
5 | ## oracle driver
6 | mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.1.0 -Dpackaging=jar -Dfile=./ojdbc6-11.2.0.1.0.jar
7 |
--------------------------------------------------------------------------------
/jars/ojdbc6-11.2.0.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonside/dataroad-all/92364dfdc4f141a3d6e181186bedc09342a4b7df/jars/ojdbc6-11.2.0.1.0.jar
--------------------------------------------------------------------------------