Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
09452e8d
Unverified
Commit
09452e8d
authored
Dec 07, 2022
by
aiwenmo
Committed by
GitHub
Dec 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature-1401][client] CDCSOURCE supports Doris schema evolution (#1402)
Co-authored-by:
wenmo
<
32723967+wenmo@users.noreply.github.com
>
parent
faa8f61b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
436 additions
and
32 deletions
+436
-32
SinkBuilderFactory.java
...-1.14/src/main/java/com/dlink/cdc/SinkBuilderFactory.java
+3
-1
DorisSchemaEvolutionSinkBuilder.java
.../com/dlink/cdc/doris/DorisSchemaEvolutionSinkBuilder.java
+198
-0
SinkBuilderFactory.java
...-1.15/src/main/java/com/dlink/cdc/SinkBuilderFactory.java
+3
-1
DorisSchemaEvolutionSinkBuilder.java
.../com/dlink/cdc/doris/DorisSchemaEvolutionSinkBuilder.java
+198
-0
AbstractSinkBuilder.java
...1.16/src/main/java/com/dlink/cdc/AbstractSinkBuilder.java
+22
-21
pom.xml
dlink-flink/dlink-flink-1.14/pom.xml
+1
-1
pom.xml
dlink-flink/dlink-flink-1.15/pom.xml
+2
-2
pom.xml
dlink-flink/dlink-flink-1.16/pom.xml
+9
-6
No files found.
dlink-client/dlink-client-1.14/src/main/java/com/dlink/cdc/SinkBuilderFactory.java
View file @
09452e8d
...
...
@@ -21,6 +21,7 @@ package com.dlink.cdc;
import
com.dlink.assertion.Asserts
;
import
com.dlink.cdc.doris.DorisExtendSinkBuilder
;
import
com.dlink.cdc.doris.DorisSchemaEvolutionSinkBuilder
;
import
com.dlink.cdc.doris.DorisSinkBuilder
;
import
com.dlink.cdc.kafka.KafkaSinkBuilder
;
import
com.dlink.cdc.kafka.KafkaSinkJsonBuilder
;
...
...
@@ -43,7 +44,8 @@ public class SinkBuilderFactory {
new
DorisSinkBuilder
(),
new
StarrocksSinkBuilder
(),
new
SQLSinkBuilder
(),
new
DorisExtendSinkBuilder
()
new
DorisExtendSinkBuilder
(),
new
DorisSchemaEvolutionSinkBuilder
()
};
public
static
SinkBuilder
buildSinkBuilder
(
FlinkCDCConfig
config
)
{
...
...
dlink-client/dlink-client-1.14/src/main/java/com/dlink/cdc/doris/DorisSchemaEvolutionSinkBuilder.java
0 → 100644
View file @
09452e8d
/*
*
* 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
.
dlink
.
cdc
.
doris
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.cdc.AbstractSinkBuilder
;
import
com.dlink.cdc.CDCBuilder
;
import
com.dlink.cdc.SinkBuilder
;
import
com.dlink.executor.CustomTableEnvironment
;
import
com.dlink.model.FlinkCDCConfig
;
import
com.dlink.model.Schema
;
import
com.dlink.model.Table
;
import
org.apache.doris.flink.cfg.DorisExecutionOptions
;
import
org.apache.doris.flink.cfg.DorisOptions
;
import
org.apache.doris.flink.cfg.DorisReadOptions
;
import
org.apache.doris.flink.sink.DorisSink
;
import
org.apache.doris.flink.sink.writer.JsonDebeziumSchemaSerializer
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.flink.streaming.api.datastream.DataStream
;
import
org.apache.flink.streaming.api.datastream.DataStreamSource
;
import
org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.api.functions.ProcessFunction
;
import
org.apache.flink.table.data.RowData
;
import
org.apache.flink.table.types.logical.LogicalType
;
import
org.apache.flink.util.Collector
;
import
org.apache.flink.util.OutputTag
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.UUID
;
/**
* DorisSchemaEvolutionSinkBuilder
*
* @author wenmo
* @since 2022/12/6
**/
public
class
DorisSchemaEvolutionSinkBuilder
extends
AbstractSinkBuilder
implements
Serializable
{
private
static
final
String
KEY_WORD
=
"datastream-doris-schema-evolution"
;
public
DorisSchemaEvolutionSinkBuilder
()
{
}
public
DorisSchemaEvolutionSinkBuilder
(
FlinkCDCConfig
config
)
{
super
(
config
);
}
@Override
public
void
addSink
(
StreamExecutionEnvironment
env
,
DataStream
<
RowData
>
rowDataDataStream
,
Table
table
,
List
<
String
>
columnNameList
,
List
<
LogicalType
>
columnTypeList
)
{
}
@Override
public
String
getHandle
()
{
return
KEY_WORD
;
}
@Override
public
SinkBuilder
create
(
FlinkCDCConfig
config
)
{
return
new
DorisSchemaEvolutionSinkBuilder
(
config
);
}
@Override
public
DataStreamSource
build
(
CDCBuilder
cdcBuilder
,
StreamExecutionEnvironment
env
,
CustomTableEnvironment
customTableEnvironment
,
DataStreamSource
<
String
>
dataStreamSource
)
{
Map
<
String
,
String
>
sink
=
config
.
getSink
();
Properties
properties
=
getProperties
();
// schema evolution need json format
properties
.
setProperty
(
"format"
,
"json"
);
properties
.
setProperty
(
"read_json_by_line"
,
"true"
);
Map
<
Table
,
OutputTag
<
String
>>
tagMap
=
new
HashMap
<>();
Map
<
String
,
Table
>
tableMap
=
new
HashMap
<>();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
SingleOutputStreamOperator
<
Map
>
mapOperator
=
dataStreamSource
.
map
(
x
->
objectMapper
.
readValue
(
x
,
Map
.
class
))
.
returns
(
Map
.
class
);
final
List
<
Schema
>
schemaList
=
config
.
getSchemaList
();
final
String
schemaFieldName
=
config
.
getSchemaFieldName
();
if
(
Asserts
.
isNotNullCollection
(
schemaList
))
{
for
(
Schema
schema
:
schemaList
)
{
for
(
Table
table
:
schema
.
getTables
())
{
String
sinkTableName
=
getSinkTableName
(
table
);
OutputTag
<
String
>
outputTag
=
new
OutputTag
<
String
>(
sinkTableName
)
{
};
tagMap
.
put
(
table
,
outputTag
);
tableMap
.
put
(
table
.
getSchemaTableName
(),
table
);
}
}
SingleOutputStreamOperator
<
String
>
process
=
mapOperator
.
process
(
new
ProcessFunction
<
Map
,
String
>()
{
@Override
public
void
processElement
(
Map
map
,
Context
ctx
,
Collector
<
String
>
out
)
throws
Exception
{
LinkedHashMap
source
=
(
LinkedHashMap
)
map
.
get
(
"source"
);
try
{
String
result
=
objectMapper
.
writeValueAsString
(
map
);
Table
table
=
tableMap
.
get
(
source
.
get
(
schemaFieldName
).
toString
()
+
"."
+
source
.
get
(
"table"
).
toString
());
OutputTag
<
String
>
outputTag
=
tagMap
.
get
(
table
);
ctx
.
output
(
outputTag
,
result
);
}
catch
(
Exception
e
)
{
out
.
collect
(
objectMapper
.
writeValueAsString
(
map
));
}
}
});
tagMap
.
forEach
((
table
,
v
)
->
{
DorisOptions
dorisOptions
=
DorisOptions
.
builder
()
.
setFenodes
(
config
.
getSink
().
get
(
DorisSinkOptions
.
FENODES
.
key
()))
.
setTableIdentifier
(
getSinkSchemaName
(
table
)
+
"."
+
getSinkTableName
(
table
))
.
setUsername
(
config
.
getSink
().
get
(
DorisSinkOptions
.
USERNAME
.
key
()))
.
setPassword
(
config
.
getSink
().
get
(
DorisSinkOptions
.
PASSWORD
.
key
())).
build
();
DorisExecutionOptions
.
Builder
executionBuilder
=
DorisExecutionOptions
.
builder
();
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_BUFFER_COUNT
.
key
()))
{
executionBuilder
.
setBufferCount
(
Integer
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_BUFFER_COUNT
.
key
())));
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_BUFFER_SIZE
.
key
()))
{
executionBuilder
.
setBufferSize
(
Integer
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_BUFFER_SIZE
.
key
())));
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_ENABLE_DELETE
.
key
()))
{
executionBuilder
.
setDeletable
(
Boolean
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_ENABLE_DELETE
.
key
())));
}
else
{
executionBuilder
.
setDeletable
(
true
);
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_LABEL_PREFIX
.
key
()))
{
executionBuilder
.
setLabelPrefix
(
sink
.
get
(
DorisSinkOptions
.
SINK_LABEL_PREFIX
.
key
())
+
"-"
+
getSinkSchemaName
(
table
)
+
"_"
+
getSinkTableName
(
table
));
}
else
{
executionBuilder
.
setLabelPrefix
(
"dlink-"
+
getSinkSchemaName
(
table
)
+
"_"
+
getSinkTableName
(
table
)
+
UUID
.
randomUUID
());
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_MAX_RETRIES
.
key
()))
{
executionBuilder
.
setMaxRetries
(
Integer
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_MAX_RETRIES
.
key
())));
}
executionBuilder
.
setStreamLoadProp
(
properties
).
setDeletable
(
true
);
DorisSink
.
Builder
<
String
>
builder
=
DorisSink
.
builder
();
builder
.
setDorisReadOptions
(
DorisReadOptions
.
builder
().
build
())
.
setDorisExecutionOptions
(
executionBuilder
.
build
())
.
setDorisOptions
(
dorisOptions
)
.
setSerializer
(
JsonDebeziumSchemaSerializer
.
builder
().
setDorisOptions
(
dorisOptions
).
build
());
process
.
getSideOutput
(
v
).
rebalance
().
sinkTo
(
builder
.
build
()).
name
(
"Doris Schema Evolution Sink(table=["
+
getSinkSchemaName
(
table
)
+
"."
+
getSinkTableName
(
table
)
+
"])"
);
});
}
return
dataStreamSource
;
}
@Override
protected
Properties
getProperties
()
{
Properties
properties
=
new
Properties
();
Map
<
String
,
String
>
sink
=
config
.
getSink
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
sink
.
entrySet
())
{
if
(
Asserts
.
isNotNullString
(
entry
.
getKey
())
&&
entry
.
getKey
().
startsWith
(
"sink.properties"
)
&&
Asserts
.
isNotNullString
(
entry
.
getValue
()))
{
properties
.
setProperty
(
entry
.
getKey
().
replace
(
"sink.properties."
,
""
),
entry
.
getValue
());
}
}
return
properties
;
}
}
dlink-client/dlink-client-1.15/src/main/java/com/dlink/cdc/SinkBuilderFactory.java
View file @
09452e8d
...
...
@@ -21,6 +21,7 @@ package com.dlink.cdc;
import
com.dlink.assertion.Asserts
;
import
com.dlink.cdc.doris.DorisExtendSinkBuilder
;
import
com.dlink.cdc.doris.DorisSchemaEvolutionSinkBuilder
;
import
com.dlink.cdc.doris.DorisSinkBuilder
;
import
com.dlink.cdc.kafka.KafkaSinkBuilder
;
import
com.dlink.cdc.kafka.KafkaSinkJsonBuilder
;
...
...
@@ -41,7 +42,8 @@ public class SinkBuilderFactory {
new
KafkaSinkJsonBuilder
(),
new
DorisSinkBuilder
(),
new
SQLSinkBuilder
(),
new
DorisExtendSinkBuilder
()
new
DorisExtendSinkBuilder
(),
new
DorisSchemaEvolutionSinkBuilder
()
};
public
static
SinkBuilder
buildSinkBuilder
(
FlinkCDCConfig
config
)
{
...
...
dlink-client/dlink-client-1.15/src/main/java/com/dlink/cdc/doris/DorisSchemaEvolutionSinkBuilder.java
0 → 100644
View file @
09452e8d
/*
*
* 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
.
dlink
.
cdc
.
doris
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.cdc.AbstractSinkBuilder
;
import
com.dlink.cdc.CDCBuilder
;
import
com.dlink.cdc.SinkBuilder
;
import
com.dlink.executor.CustomTableEnvironment
;
import
com.dlink.model.FlinkCDCConfig
;
import
com.dlink.model.Schema
;
import
com.dlink.model.Table
;
import
org.apache.doris.flink.cfg.DorisExecutionOptions
;
import
org.apache.doris.flink.cfg.DorisOptions
;
import
org.apache.doris.flink.cfg.DorisReadOptions
;
import
org.apache.doris.flink.sink.DorisSink
;
import
org.apache.doris.flink.sink.writer.JsonDebeziumSchemaSerializer
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.flink.streaming.api.datastream.DataStream
;
import
org.apache.flink.streaming.api.datastream.DataStreamSource
;
import
org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.api.functions.ProcessFunction
;
import
org.apache.flink.table.data.RowData
;
import
org.apache.flink.table.types.logical.LogicalType
;
import
org.apache.flink.util.Collector
;
import
org.apache.flink.util.OutputTag
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.UUID
;
/**
* DorisSchemaEvolutionSinkBuilder
*
* @author wenmo
* @since 2022/12/6
**/
public
class
DorisSchemaEvolutionSinkBuilder
extends
AbstractSinkBuilder
implements
Serializable
{
private
static
final
String
KEY_WORD
=
"datastream-doris-schema-evolution"
;
public
DorisSchemaEvolutionSinkBuilder
()
{
}
public
DorisSchemaEvolutionSinkBuilder
(
FlinkCDCConfig
config
)
{
super
(
config
);
}
@Override
public
void
addSink
(
StreamExecutionEnvironment
env
,
DataStream
<
RowData
>
rowDataDataStream
,
Table
table
,
List
<
String
>
columnNameList
,
List
<
LogicalType
>
columnTypeList
)
{
}
@Override
public
String
getHandle
()
{
return
KEY_WORD
;
}
@Override
public
SinkBuilder
create
(
FlinkCDCConfig
config
)
{
return
new
DorisSchemaEvolutionSinkBuilder
(
config
);
}
@Override
public
DataStreamSource
build
(
CDCBuilder
cdcBuilder
,
StreamExecutionEnvironment
env
,
CustomTableEnvironment
customTableEnvironment
,
DataStreamSource
<
String
>
dataStreamSource
)
{
Map
<
String
,
String
>
sink
=
config
.
getSink
();
Properties
properties
=
getProperties
();
// schema evolution need json format
properties
.
setProperty
(
"format"
,
"json"
);
properties
.
setProperty
(
"read_json_by_line"
,
"true"
);
Map
<
Table
,
OutputTag
<
String
>>
tagMap
=
new
HashMap
<>();
Map
<
String
,
Table
>
tableMap
=
new
HashMap
<>();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
SingleOutputStreamOperator
<
Map
>
mapOperator
=
dataStreamSource
.
map
(
x
->
objectMapper
.
readValue
(
x
,
Map
.
class
))
.
returns
(
Map
.
class
);
final
List
<
Schema
>
schemaList
=
config
.
getSchemaList
();
final
String
schemaFieldName
=
config
.
getSchemaFieldName
();
if
(
Asserts
.
isNotNullCollection
(
schemaList
))
{
for
(
Schema
schema
:
schemaList
)
{
for
(
Table
table
:
schema
.
getTables
())
{
String
sinkTableName
=
getSinkTableName
(
table
);
OutputTag
<
String
>
outputTag
=
new
OutputTag
<
String
>(
sinkTableName
)
{
};
tagMap
.
put
(
table
,
outputTag
);
tableMap
.
put
(
table
.
getSchemaTableName
(),
table
);
}
}
SingleOutputStreamOperator
<
String
>
process
=
mapOperator
.
process
(
new
ProcessFunction
<
Map
,
String
>()
{
@Override
public
void
processElement
(
Map
map
,
Context
ctx
,
Collector
<
String
>
out
)
throws
Exception
{
LinkedHashMap
source
=
(
LinkedHashMap
)
map
.
get
(
"source"
);
try
{
String
result
=
objectMapper
.
writeValueAsString
(
map
);
Table
table
=
tableMap
.
get
(
source
.
get
(
schemaFieldName
).
toString
()
+
"."
+
source
.
get
(
"table"
).
toString
());
OutputTag
<
String
>
outputTag
=
tagMap
.
get
(
table
);
ctx
.
output
(
outputTag
,
result
);
}
catch
(
Exception
e
)
{
out
.
collect
(
objectMapper
.
writeValueAsString
(
map
));
}
}
});
tagMap
.
forEach
((
table
,
v
)
->
{
DorisOptions
dorisOptions
=
DorisOptions
.
builder
()
.
setFenodes
(
config
.
getSink
().
get
(
DorisSinkOptions
.
FENODES
.
key
()))
.
setTableIdentifier
(
getSinkSchemaName
(
table
)
+
"."
+
getSinkTableName
(
table
))
.
setUsername
(
config
.
getSink
().
get
(
DorisSinkOptions
.
USERNAME
.
key
()))
.
setPassword
(
config
.
getSink
().
get
(
DorisSinkOptions
.
PASSWORD
.
key
())).
build
();
DorisExecutionOptions
.
Builder
executionBuilder
=
DorisExecutionOptions
.
builder
();
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_BUFFER_COUNT
.
key
()))
{
executionBuilder
.
setBufferCount
(
Integer
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_BUFFER_COUNT
.
key
())));
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_BUFFER_SIZE
.
key
()))
{
executionBuilder
.
setBufferSize
(
Integer
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_BUFFER_SIZE
.
key
())));
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_ENABLE_DELETE
.
key
()))
{
executionBuilder
.
setDeletable
(
Boolean
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_ENABLE_DELETE
.
key
())));
}
else
{
executionBuilder
.
setDeletable
(
true
);
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_LABEL_PREFIX
.
key
()))
{
executionBuilder
.
setLabelPrefix
(
sink
.
get
(
DorisSinkOptions
.
SINK_LABEL_PREFIX
.
key
())
+
"-"
+
getSinkSchemaName
(
table
)
+
"_"
+
getSinkTableName
(
table
));
}
else
{
executionBuilder
.
setLabelPrefix
(
"dlink-"
+
getSinkSchemaName
(
table
)
+
"_"
+
getSinkTableName
(
table
)
+
UUID
.
randomUUID
());
}
if
(
sink
.
containsKey
(
DorisSinkOptions
.
SINK_MAX_RETRIES
.
key
()))
{
executionBuilder
.
setMaxRetries
(
Integer
.
valueOf
(
sink
.
get
(
DorisSinkOptions
.
SINK_MAX_RETRIES
.
key
())));
}
executionBuilder
.
setStreamLoadProp
(
properties
).
setDeletable
(
true
);
DorisSink
.
Builder
<
String
>
builder
=
DorisSink
.
builder
();
builder
.
setDorisReadOptions
(
DorisReadOptions
.
builder
().
build
())
.
setDorisExecutionOptions
(
executionBuilder
.
build
())
.
setDorisOptions
(
dorisOptions
)
.
setSerializer
(
JsonDebeziumSchemaSerializer
.
builder
().
setDorisOptions
(
dorisOptions
).
build
());
process
.
getSideOutput
(
v
).
rebalance
().
sinkTo
(
builder
.
build
()).
name
(
"Doris Schema Evolution Sink(table=["
+
getSinkSchemaName
(
table
)
+
"."
+
getSinkTableName
(
table
)
+
"])"
);
});
}
return
dataStreamSource
;
}
@Override
protected
Properties
getProperties
()
{
Properties
properties
=
new
Properties
();
Map
<
String
,
String
>
sink
=
config
.
getSink
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
sink
.
entrySet
())
{
if
(
Asserts
.
isNotNullString
(
entry
.
getKey
())
&&
entry
.
getKey
().
startsWith
(
"sink.properties"
)
&&
Asserts
.
isNotNullString
(
entry
.
getValue
()))
{
properties
.
setProperty
(
entry
.
getKey
().
replace
(
"sink.properties."
,
""
),
entry
.
getValue
());
}
}
return
properties
;
}
}
dlink-client/dlink-client-1.16/src/main/java/com/dlink/cdc/AbstractSinkBuilder.java
View file @
09452e8d
...
...
@@ -83,6 +83,7 @@ public abstract class AbstractSinkBuilder implements SinkBuilder {
protected
FlinkCDCConfig
config
;
protected
List
<
ModifyOperation
>
modifyOperations
=
new
ArrayList
();
private
ZoneId
sinkTimeZone
=
ZoneId
.
of
(
"UTC"
);
public
AbstractSinkBuilder
()
{
}
...
...
@@ -123,9 +124,9 @@ public abstract class AbstractSinkBuilder implements SinkBuilder {
}
protected
SingleOutputStreamOperator
<
Map
>
shunt
(
SingleOutputStreamOperator
<
Map
>
mapOperator
,
Table
table
,
String
schemaFieldName
)
{
SingleOutputStreamOperator
<
Map
>
mapOperator
,
Table
table
,
String
schemaFieldName
)
{
final
String
tableName
=
table
.
getName
();
final
String
schemaName
=
table
.
getSchema
();
return
mapOperator
.
filter
(
new
FilterFunction
<
Map
>()
{
...
...
@@ -140,18 +141,18 @@ public abstract class AbstractSinkBuilder implements SinkBuilder {
}
protected
DataStream
<
Map
>
shunt
(
SingleOutputStreamOperator
<
Map
>
processOperator
,
Table
table
,
OutputTag
<
Map
>
tag
)
{
SingleOutputStreamOperator
<
Map
>
processOperator
,
Table
table
,
OutputTag
<
Map
>
tag
)
{
return
processOperator
.
getSideOutput
(
tag
);
}
protected
DataStream
<
RowData
>
buildRowData
(
SingleOutputStreamOperator
<
Map
>
filterOperator
,
List
<
String
>
columnNameList
,
List
<
LogicalType
>
columnTypeList
,
String
schemaTableName
)
{
SingleOutputStreamOperator
<
Map
>
filterOperator
,
List
<
String
>
columnNameList
,
List
<
LogicalType
>
columnTypeList
,
String
schemaTableName
)
{
return
filterOperator
.
flatMap
(
new
FlatMapFunction
<
Map
,
RowData
>()
{
...
...
@@ -210,18 +211,18 @@ public abstract class AbstractSinkBuilder implements SinkBuilder {
}
public
abstract
void
addSink
(
StreamExecutionEnvironment
env
,
DataStream
<
RowData
>
rowDataDataStream
,
Table
table
,
List
<
String
>
columnNameList
,
List
<
LogicalType
>
columnTypeList
);
StreamExecutionEnvironment
env
,
DataStream
<
RowData
>
rowDataDataStream
,
Table
table
,
List
<
String
>
columnNameList
,
List
<
LogicalType
>
columnTypeList
);
@Override
public
DataStreamSource
build
(
CDCBuilder
cdcBuilder
,
StreamExecutionEnvironment
env
,
CustomTableEnvironment
customTableEnvironment
,
DataStreamSource
<
String
>
dataStreamSource
)
{
CDCBuilder
cdcBuilder
,
StreamExecutionEnvironment
env
,
CustomTableEnvironment
customTableEnvironment
,
DataStreamSource
<
String
>
dataStreamSource
)
{
final
List
<
Schema
>
schemaList
=
config
.
getSchemaList
();
final
String
schemaFieldName
=
config
.
getSchemaFieldName
();
...
...
@@ -237,8 +238,8 @@ public abstract class AbstractSinkBuilder implements SinkBuilder {
buildColumn
(
columnNameList
,
columnTypeList
,
table
.
getColumns
());
DataStream
<
RowData
>
rowDataDataStream
=
buildRowData
(
filterOperator
,
columnNameList
,
columnTypeList
,
table
.
getSchemaTableName
());
DataStream
<
RowData
>
rowDataDataStream
=
buildRowData
(
filterOperator
,
columnNameList
,
columnTypeList
,
table
.
getSchemaTableName
());
addSink
(
env
,
rowDataDataStream
,
table
,
columnNameList
,
columnTypeList
);
}
...
...
dlink-flink/dlink-flink-1.14/pom.xml
View file @
09452e8d
...
...
@@ -170,7 +170,7 @@
<dependency>
<groupId>
org.apache.doris
</groupId>
<artifactId>
flink-doris-connector-1.14_${scala.binary.version}
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</dependency>
<dependency>
<groupId>
com.starrocks
</groupId>
...
...
dlink-flink/dlink-flink-1.15/pom.xml
View file @
09452e8d
...
...
@@ -160,8 +160,8 @@
</dependency>
<dependency>
<groupId>
org.apache.doris
</groupId>
<artifactId>
flink-doris-connector-1.1
4_2.12
</artifactId>
<version>
1.
1.0
</version>
<artifactId>
flink-doris-connector-1.1
5
</artifactId>
<version>
1.
2.1
</version>
</dependency>
<dependency>
<groupId>
org.apache.flink
</groupId>
...
...
dlink-flink/dlink-flink-1.16/pom.xml
View file @
09452e8d
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<artifactId>
dlink-flink
</artifactId>
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-flink
</artifactId>
<version>
0.7.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
dlink-flink-1.16
</artifactId>
...
...
@@ -144,10 +143,15 @@
<artifactId>
commons-cli
</artifactId>
<version>
${commons.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.doris
</groupId>
<artifactId>
flink-doris-connector-1.16
</artifactId>
<version>
1.3.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.flink
</groupId>
<artifactId>
flink-runtime-web
</artifactId>
<version>
${flink.version}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
</project>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment