Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
ZHHT-IRN-BD-ANALYSIS
Project
Overview
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
李凯旋
ZHHT-IRN-BD-ANALYSIS
Commits
e15b0bad
Commit
e15b0bad
authored
Dec 05, 2022
by
吴延飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改读取文件的方式,目前的代码会直接从classpath中获取文件
parent
57e5a60c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
27 deletions
+12
-27
LaneNormProcessFunction.java
...in/java/com/zhht/irn/process/LaneNormProcessFunction.java
+1
-1
LaneNormSink.java
...reaming/src/main/java/com/zhht/irn/sink/LaneNormSink.java
+1
-2
DorisUtils.java
...treaming/src/main/java/com/zhht/irn/utils/DorisUtils.java
+3
-6
FlinkUtils.java
...treaming/src/main/java/com/zhht/irn/utils/FlinkUtils.java
+4
-2
MySQLUtils.java
...treaming/src/main/java/com/zhht/irn/utils/MySQLUtils.java
+3
-16
No files found.
realtime/hologram-streaming/src/main/java/com/zhht/irn/process/LaneNormProcessFunction.java
View file @
e15b0bad
...
@@ -422,7 +422,7 @@ public class LaneNormProcessFunction extends KeyedCoProcessFunction<String, Cycl
...
@@ -422,7 +422,7 @@ public class LaneNormProcessFunction extends KeyedCoProcessFunction<String, Cycl
}
}
private
static
Connection
getConnection
()
throws
Exception
{
private
static
Connection
getConnection
()
throws
Exception
{
Connection
connection
=
MySQLUtils
.
getConnection
(
"E:\\zhht\\ZHHT-IRN-BD-ANALYSIS\\realtime\\hologram-streaming\\src\\main\\resources\\mysql.properties"
);
Connection
connection
=
MySQLUtils
.
getConnection
();
return
connection
;
return
connection
;
}
}
...
...
realtime/hologram-streaming/src/main/java/com/zhht/irn/sink/LaneNormSink.java
View file @
e15b0bad
...
@@ -29,8 +29,7 @@ public class LaneNormSink extends RichSinkFunction<LaneNorm> {
...
@@ -29,8 +29,7 @@ public class LaneNormSink extends RichSinkFunction<LaneNorm> {
public
void
open
(
Configuration
parameters
)
throws
Exception
{
public
void
open
(
Configuration
parameters
)
throws
Exception
{
super
.
open
(
parameters
);
super
.
open
(
parameters
);
// path暂定为固定值
// path暂定为固定值
String
path
=
"E:\\zhht\\ZHHT-IRN-BD-ANALYSIS\\realtime\\hologram-streaming\\src\\main\\resources\\mysql.properties"
;
connection
=
MySQLUtils
.
getConnection
();
connection
=
MySQLUtils
.
getConnection
(
path
);
insertPstmt
=
connection
.
prepareStatement
(
"insert into "
+
insertPstmt
=
connection
.
prepareStatement
(
"insert into "
+
"app_cross_dimension_norm(cross_id,lane_id,direction,cycle_id,max_queue_length,effect_green_time,pass_capacity,traffic_capacity,saturation,residual_capacity,"
+
"app_cross_dimension_norm(cross_id,lane_id,direction,cycle_id,max_queue_length,effect_green_time,pass_capacity,traffic_capacity,saturation,residual_capacity,"
+
"spot_space_share,dimension_name,`order`,update_time,`type`,spot_space_length) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
);
"spot_space_share,dimension_name,`order`,update_time,`type`,spot_space_length) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
);
...
...
realtime/hologram-streaming/src/main/java/com/zhht/irn/utils/DorisUtils.java
View file @
e15b0bad
...
@@ -2,6 +2,7 @@ package com.zhht.irn.utils;
...
@@ -2,6 +2,7 @@ package com.zhht.irn.utils;
import
org.apache.flink.api.java.utils.ParameterTool
;
import
org.apache.flink.api.java.utils.ParameterTool
;
import
java.io.InputStream
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
...
@@ -10,12 +11,8 @@ import java.sql.SQLException;
...
@@ -10,12 +11,8 @@ import java.sql.SQLException;
public
class
DorisUtils
{
public
class
DorisUtils
{
public
static
Connection
getConnection
()
throws
Exception
{
public
static
Connection
getConnection
()
throws
Exception
{
String
propertyPath
=
"./doris.properties"
;
InputStream
inputStream
=
DorisUtils
.
class
.
getClassLoader
().
getResourceAsStream
(
"doris.properties"
);
return
getConnection
(
propertyPath
);
ParameterTool
tool
=
ParameterTool
.
fromPropertiesFile
(
inputStream
);
}
public
static
Connection
getConnection
(
String
propertyPath
)
throws
Exception
{
ParameterTool
tool
=
ParameterTool
.
fromPropertiesFile
(
propertyPath
);
// 根据路径的配置文件获取MySQL链接参数
// 根据路径的配置文件获取MySQL链接参数
String
driver
=
tool
.
getRequired
(
"driver"
);
String
driver
=
tool
.
getRequired
(
"driver"
);
...
...
realtime/hologram-streaming/src/main/java/com/zhht/irn/utils/FlinkUtils.java
View file @
e15b0bad
...
@@ -11,10 +11,12 @@ import org.apache.flink.streaming.api.environment.CheckpointConfig;
...
@@ -11,10 +11,12 @@ import org.apache.flink.streaming.api.environment.CheckpointConfig;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer
;
import
org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer
;
import
org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema
;
import
org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema
;
import
org.apache.flink.util.PropertiesUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.Properties
;
...
@@ -43,10 +45,10 @@ public class FlinkUtils {
...
@@ -43,10 +45,10 @@ public class FlinkUtils {
static
{
static
{
// 获取Kafka配置文件, 直接读取当前程序目录下的
// 获取Kafka配置文件, 直接读取当前程序目录下的
String
kafkaConfigPath
=
"kafka.properties"
;
ParameterTool
kafkaTool
;
ParameterTool
kafkaTool
;
try
{
try
{
kafkaTool
=
ParameterTool
.
fromPropertiesFile
(
kafkaConfigPath
);
InputStream
inputStream
=
FlinkUtils
.
class
.
getClassLoader
().
getResourceAsStream
(
"kafka.properties"
);
kafkaTool
=
ParameterTool
.
fromPropertiesFile
(
inputStream
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
error
(
"kafka 配置文件未设置,请检查!"
);
logger
.
error
(
"kafka 配置文件未设置,请检查!"
);
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
...
...
realtime/hologram-streaming/src/main/java/com/zhht/irn/utils/MySQLUtils.java
View file @
e15b0bad
...
@@ -3,21 +3,16 @@ package com.zhht.irn.utils;
...
@@ -3,21 +3,16 @@ package com.zhht.irn.utils;
import
org.apache.flink.api.java.utils.ParameterTool
;
import
org.apache.flink.api.java.utils.ParameterTool
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
public
class
MySQLUtils
{
public
class
MySQLUtils
{
public
static
Connection
getConnection
()
throws
Exception
{
public
static
Connection
getConnection
()
throws
Exception
{
String
propertyPath
=
"./mysql.properties"
;
InputStream
inputStream
=
DorisUtils
.
class
.
getClassLoader
().
getResourceAsStream
(
"mysql.properties"
);
return
getConnection
(
propertyPath
);
ParameterTool
tool
=
ParameterTool
.
fromPropertiesFile
(
inputStream
);
}
public
static
Connection
getConnection
(
String
propertyPath
)
throws
Exception
{
ParameterTool
tool
=
ParameterTool
.
fromPropertiesFile
(
propertyPath
);
// 根据路径的配置文件获取MySQL链接参数
// 根据路径的配置文件获取MySQL链接参数
String
driver
=
tool
.
getRequired
(
"driver"
);
String
driver
=
tool
.
getRequired
(
"driver"
);
String
username
=
tool
.
getRequired
(
"username"
);
String
username
=
tool
.
getRequired
(
"username"
);
...
@@ -48,12 +43,4 @@ public class MySQLUtils {
...
@@ -48,12 +43,4 @@ public class MySQLUtils {
}
}
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
try
{
System
.
out
.
println
(
getConnection
(
"F:\\workspace\\ZHHT-IRN-BD-ANALYSIS\\realtime\\hologram-streaming\\src\\main\\resources\\mysql.properties"
));
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
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