Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-dsc-flink
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
shezaixing
dsk-dsc-flink
Commits
01f8cec1
Commit
01f8cec1
authored
Jan 08, 2025
by
liaowenwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
ac8354d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
13 deletions
+14
-13
AsyncMysqlDataTransferFunctionNew.java
...sc/common/function/AsyncMysqlDataTransferFunctionNew.java
+1
-1
MysqlDataTransferSink.java
.../com/dsk/flink/dsc/common/sink/MysqlDataTransferSink.java
+3
-4
SyncCustomerDataSource.java
...n/java/com/dsk/flink/dsc/sync/SyncCustomerDataSource.java
+4
-4
EtlUtils.java
src/main/java/com/dsk/flink/dsc/utils/EtlUtils.java
+6
-4
No files found.
src/main/java/com/dsk/flink/dsc/common/function/AsyncMysqlDataTransferFunctionNew.java
View file @
01f8cec1
...
@@ -36,7 +36,7 @@ public class AsyncMysqlDataTransferFunctionNew extends RichAsyncFunction<JSONObj
...
@@ -36,7 +36,7 @@ public class AsyncMysqlDataTransferFunctionNew extends RichAsyncFunction<JSONObj
@Override
@Override
public
void
open
(
Configuration
parameters
)
throws
Exception
{
public
void
open
(
Configuration
parameters
)
throws
Exception
{
//初始化线程池
//初始化线程池
executorService
=
new
ThreadPoolExecutor
(
1
0
,
10
,
20
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>());
executorService
=
new
ThreadPoolExecutor
(
1
2
,
12
,
20
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>());
}
}
@Override
@Override
...
...
src/main/java/com/dsk/flink/dsc/common/sink/MysqlDataTransferSink.java
View file @
01f8cec1
...
@@ -22,8 +22,8 @@ public class MysqlDataTransferSink extends RichSinkFunction<String> {
...
@@ -22,8 +22,8 @@ public class MysqlDataTransferSink extends RichSinkFunction<String> {
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MysqlDataTransferSink
.
class
);
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MysqlDataTransferSink
.
class
);
EnvProperties
envProps
;
EnvProperties
envProps
;
ExecutorService
executorService
;
private
static
transient
ExecutorService
executorService
;
DruidDataSource
dataSource
;
private
static
transient
DruidDataSource
dataSource
;
public
MysqlDataTransferSink
(
EnvProperties
envProps
)
{
public
MysqlDataTransferSink
(
EnvProperties
envProps
)
{
this
.
envProps
=
envProps
;
this
.
envProps
=
envProps
;
...
@@ -68,8 +68,7 @@ public class MysqlDataTransferSink extends RichSinkFunction<String> {
...
@@ -68,8 +68,7 @@ public class MysqlDataTransferSink extends RichSinkFunction<String> {
pt
=
connection
.
prepareStatement
(
sql
);
pt
=
connection
.
prepareStatement
(
sql
);
pt
.
execute
();
pt
.
execute
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"sql报错----->"
+
sql
);
//logger.error("------错误时间:{}-----,sql:{}--------异常:{}", DateUtil.now(),sql,e.getMessage());
logger
.
error
(
"------错误时间:{}-----,sql:{}--------异常:{}"
,
DateUtil
.
now
(),
sql
,
e
.
getMessage
());
logger
.
error
(
"异常信息:"
,
e
);
logger
.
error
(
"异常信息:"
,
e
);
SqlErrorLog
errorLog
=
new
SqlErrorLog
(
new
Date
(),
sql
,
e
.
getMessage
());
SqlErrorLog
errorLog
=
new
SqlErrorLog
(
new
Date
(),
sql
,
e
.
getMessage
());
try
{
try
{
...
...
src/main/java/com/dsk/flink/dsc/sync/SyncCustomerDataSource.java
View file @
01f8cec1
...
@@ -78,7 +78,7 @@ public class SyncCustomerDataSource {
...
@@ -78,7 +78,7 @@ public class SyncCustomerDataSource {
}
}
SingleOutputStreamOperator
<
String
>
kafkaSource
=
env
.
addSource
(
kafkaConsumer
)
SingleOutputStreamOperator
<
String
>
kafkaSource
=
env
.
addSource
(
kafkaConsumer
)
//
.setParallelism(1)
.
setParallelism
(
1
)
.
name
(
"kafka-source"
)
.
name
(
"kafka-source"
)
.
uid
(
"kafka-source"
);
.
uid
(
"kafka-source"
);
...
@@ -99,11 +99,11 @@ public class SyncCustomerDataSource {
...
@@ -99,11 +99,11 @@ public class SyncCustomerDataSource {
SingleOutputStreamOperator
<
Tuple3
<
JSONObject
,
String
,
Long
>>
tsGroupStream
=
canalJsonStream
.
map
(
new
CanalMapToTsGroupFunction
());
SingleOutputStreamOperator
<
Tuple3
<
JSONObject
,
String
,
Long
>>
tsGroupStream
=
canalJsonStream
.
map
(
new
CanalMapToTsGroupFunction
());
SingleOutputStreamOperator
<
JSONObject
>
process
=
tsGroupStream
.
keyBy
(
x
->
x
.
f1
)
SingleOutputStreamOperator
<
JSONObject
>
process
=
tsGroupStream
.
keyBy
(
x
->
x
.
f1
)
.
window
(
TumblingProcessingTimeWindows
.
of
(
Time
.
milliseconds
(
3
00
)))
.
window
(
TumblingProcessingTimeWindows
.
of
(
Time
.
milliseconds
(
1
00
)))
.
process
(
new
GroupTsProcessWindowFunction
());
.
process
(
new
GroupTsProcessWindowFunction
());
SingleOutputStreamOperator
<
Tuple3
<
String
,
String
,
Long
>>
sqlResultStream1
=
AsyncDataStream
.
orderedWait
(
process
,
SingleOutputStreamOperator
<
Tuple3
<
String
,
String
,
Long
>>
sqlResultStream1
=
AsyncDataStream
.
orderedWait
(
process
,
new
AsyncMysqlDataTransferFunctionNew
(
envProps
),
30
0L
,
TimeUnit
.
SECONDS
)
new
AsyncMysqlDataTransferFunctionNew
(
envProps
),
12
0L
,
TimeUnit
.
SECONDS
)
.
filter
(
new
FilterFunction
<
Tuple3
<
String
,
String
,
Long
>>()
{
.
filter
(
new
FilterFunction
<
Tuple3
<
String
,
String
,
Long
>>()
{
@Override
@Override
public
boolean
filter
(
Tuple3
<
String
,
String
,
Long
>
value
)
throws
Exception
{
public
boolean
filter
(
Tuple3
<
String
,
String
,
Long
>
value
)
throws
Exception
{
...
@@ -116,7 +116,7 @@ public class SyncCustomerDataSource {
...
@@ -116,7 +116,7 @@ public class SyncCustomerDataSource {
//sqlResultStream1.print("async sql==>");
//sqlResultStream1.print("async sql==>");
SingleOutputStreamOperator
<
String
>
groupWindowSqlResultStream
=
sqlResultStream1
.
keyBy
(
value
->
value
.
f1
)
SingleOutputStreamOperator
<
String
>
groupWindowSqlResultStream
=
sqlResultStream1
.
keyBy
(
value
->
value
.
f1
)
.
window
(
TumblingProcessingTimeWindows
.
of
(
Time
.
milliseconds
(
3
00
)))
.
window
(
TumblingProcessingTimeWindows
.
of
(
Time
.
milliseconds
(
1
00
)))
.
process
(
new
ProcessWindowFunction
<
Tuple3
<
String
,
String
,
Long
>,
String
,
String
,
TimeWindow
>()
{
.
process
(
new
ProcessWindowFunction
<
Tuple3
<
String
,
String
,
Long
>,
String
,
String
,
TimeWindow
>()
{
@Override
@Override
public
void
process
(
String
s
,
ProcessWindowFunction
<
Tuple3
<
String
,
String
,
Long
>,
String
,
String
,
public
void
process
(
String
s
,
ProcessWindowFunction
<
Tuple3
<
String
,
String
,
Long
>,
String
,
String
,
...
...
src/main/java/com/dsk/flink/dsc/utils/EtlUtils.java
View file @
01f8cec1
...
@@ -16,15 +16,17 @@ public class EtlUtils {
...
@@ -16,15 +16,17 @@ public class EtlUtils {
properties
.
setProperty
(
"sasl.jaas.config"
,
getSaslJaasConfig
(
username
,
password
));
properties
.
setProperty
(
"sasl.jaas.config"
,
getSaslJaasConfig
(
username
,
password
));
properties
.
setProperty
(
"security.protocol"
,
"SASL_PLAINTEXT"
);
properties
.
setProperty
(
"security.protocol"
,
"SASL_PLAINTEXT"
);
properties
.
setProperty
(
"sasl.mechanism"
,
"SCRAM-SHA-512"
);
properties
.
setProperty
(
"sasl.mechanism"
,
"SCRAM-SHA-512"
);
properties
.
setProperty
(
"fetch.max.bytes"
,
"
2097152000"
);
properties
.
setProperty
(
"fetch.max.bytes"
,
"
10485760"
);
//10M
properties
.
setProperty
(
"max.partition.fetch.bytes"
,
"20971520
00"
);
//properties.setProperty("max.partition.fetch.bytes", "1048576
00");
properties
.
setProperty
(
"flink.consumer.max.fetch.size"
,
"
2097152000"
);
properties
.
setProperty
(
"flink.consumer.max.fetch.size"
,
"
5242880"
);
//5m
properties
.
setProperty
(
"frame.size"
,
"2097152000"
);
//
properties.setProperty("frame.size", "2097152000");
properties
.
setProperty
(
"session.timeout.ms"
,
"30000"
);
properties
.
setProperty
(
"session.timeout.ms"
,
"30000"
);
properties
.
setProperty
(
"heartbeat.interval.ms"
,
"10000"
);
properties
.
setProperty
(
"heartbeat.interval.ms"
,
"10000"
);
properties
.
setProperty
(
"request.timeout.ms"
,
"60000"
);
properties
.
setProperty
(
"request.timeout.ms"
,
"60000"
);
properties
.
setProperty
(
"retries"
,
"3"
);
properties
.
setProperty
(
"retries"
,
"3"
);
properties
.
setProperty
(
"retry.backoff.ms"
,
"5000"
);
properties
.
setProperty
(
"retry.backoff.ms"
,
"5000"
);
properties
.
setProperty
(
"receive.buffer.bytes"
,
"2621440"
);
//2.5m
properties
.
setProperty
(
"max.poll.records"
,
"50"
);
return
properties
;
return
properties
;
}
}
...
...
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