Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
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
zhaowei
dlink
Commits
2767b4b5
Commit
2767b4b5
authored
Mar 20, 2022
by
wenmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateway format
parent
7698c3e4
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
97 additions
and
101 deletions
+97
-101
Gateway.java
dlink-gateway/src/main/java/com/dlink/gateway/Gateway.java
+8
-8
ActionType.java
...ay/src/main/java/com/dlink/gateway/config/ActionType.java
+5
-5
AppConfig.java
...way/src/main/java/com/dlink/gateway/config/AppConfig.java
+5
-5
GatewayConfig.java
...src/main/java/com/dlink/gateway/config/GatewayConfig.java
+14
-16
SavePointType.java
...src/main/java/com/dlink/gateway/config/SavePointType.java
+5
-5
JobInfo.java
...ateway/src/main/java/com/dlink/gateway/model/JobInfo.java
+3
-3
AbstractGatewayResult.java
.../java/com/dlink/gateway/result/AbstractGatewayResult.java
+2
-2
KubernetesResult.java
.../main/java/com/dlink/gateway/result/KubernetesResult.java
+2
-2
SavePointResult.java
...c/main/java/com/dlink/gateway/result/SavePointResult.java
+2
-2
TestResult.java
...ay/src/main/java/com/dlink/gateway/result/TestResult.java
+4
-4
YarnResult.java
...ay/src/main/java/com/dlink/gateway/result/YarnResult.java
+2
-4
YarnGateway.java
...way/src/main/java/com/dlink/gateway/yarn/YarnGateway.java
+45
-45
No files found.
dlink-gateway/src/main/java/com/dlink/gateway/Gateway.java
View file @
2767b4b5
...
...
@@ -20,14 +20,14 @@ import java.util.ServiceLoader;
**/
public
interface
Gateway
{
static
Optional
<
Gateway
>
get
(
GatewayConfig
config
){
Asserts
.
checkNotNull
(
config
,
"配置不能为空"
);
Asserts
.
checkNotNull
(
config
.
getType
(),
"配置类型不能为空"
);
static
Optional
<
Gateway
>
get
(
GatewayConfig
config
)
{
Asserts
.
checkNotNull
(
config
,
"配置不能为空"
);
Asserts
.
checkNotNull
(
config
.
getType
(),
"配置类型不能为空"
);
ServiceLoader
<
Gateway
>
loader
=
ServiceLoader
.
load
(
Gateway
.
class
);
Iterator
<
Gateway
>
iterator
=
loader
.
iterator
();
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
Gateway
gateway
=
iterator
.
next
();
if
(
gateway
.
canHandle
(
config
.
getType
()))
{
if
(
gateway
.
canHandle
(
config
.
getType
()))
{
gateway
.
setGatewayConfig
(
config
);
return
Optional
.
of
(
gateway
);
}
...
...
@@ -35,10 +35,10 @@ public interface Gateway {
return
Optional
.
empty
();
}
static
Gateway
build
(
GatewayConfig
config
){
static
Gateway
build
(
GatewayConfig
config
)
{
Optional
<
Gateway
>
optionalGateway
=
Gateway
.
get
(
config
);
if
(!
optionalGateway
.
isPresent
())
{
throw
new
GatewayException
(
"不支持 Flink Gateway 类型【"
+
config
.
getType
().
getLongValue
()+
"】,请添加扩展包"
);
if
(!
optionalGateway
.
isPresent
())
{
throw
new
GatewayException
(
"不支持 Flink Gateway 类型【"
+
config
.
getType
().
getLongValue
()
+
"】,请添加扩展包"
);
}
return
optionalGateway
.
get
();
}
...
...
dlink-gateway/src/main/java/com/dlink/gateway/config/ActionType.java
View file @
2767b4b5
...
...
@@ -8,12 +8,12 @@ import com.dlink.assertion.Asserts;
* @author wenmo
* @since 2021/11/3 21:58
*/
public
enum
ActionType
{
SAVEPOINT
(
"savepoint"
),
CANCEL
(
"cancel"
);
public
enum
ActionType
{
SAVEPOINT
(
"savepoint"
),
CANCEL
(
"cancel"
);
private
String
value
;
ActionType
(
String
value
){
ActionType
(
String
value
)
{
this
.
value
=
value
;
}
...
...
@@ -21,9 +21,9 @@ public enum ActionType{
return
value
;
}
public
static
ActionType
get
(
String
value
){
public
static
ActionType
get
(
String
value
)
{
for
(
ActionType
type
:
ActionType
.
values
())
{
if
(
Asserts
.
isEquals
(
type
.
getValue
(),
value
))
{
if
(
Asserts
.
isEquals
(
type
.
getValue
(),
value
))
{
return
type
;
}
}
...
...
dlink-gateway/src/main/java/com/dlink/gateway/config/AppConfig.java
View file @
2767b4b5
...
...
@@ -26,11 +26,11 @@ public class AppConfig {
this
.
userJarMainAppClass
=
userJarMainAppClass
;
}
public
static
AppConfig
build
(
String
userJarPath
,
String
userJarParasStr
,
String
userJarMainAppClass
){
if
(
Asserts
.
isNotNullString
(
userJarParasStr
))
{
return
new
AppConfig
(
userJarPath
,
userJarParasStr
.
split
(
" "
),
userJarMainAppClass
);
}
else
{
return
new
AppConfig
(
userJarPath
,
new
String
[]{},
userJarMainAppClass
);
public
static
AppConfig
build
(
String
userJarPath
,
String
userJarParasStr
,
String
userJarMainAppClass
)
{
if
(
Asserts
.
isNotNullString
(
userJarParasStr
))
{
return
new
AppConfig
(
userJarPath
,
userJarParasStr
.
split
(
" "
),
userJarMainAppClass
);
}
else
{
return
new
AppConfig
(
userJarPath
,
new
String
[]{},
userJarMainAppClass
);
}
}
...
...
dlink-gateway/src/main/java/com/dlink/gateway/config/GatewayConfig.java
View file @
2767b4b5
...
...
@@ -7,9 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -36,43 +34,43 @@ public class GatewayConfig {
appConfig
=
new
AppConfig
();
}
public
static
GatewayConfig
build
(
JsonNode
para
){
public
static
GatewayConfig
build
(
JsonNode
para
)
{
GatewayConfig
config
=
new
GatewayConfig
();
if
(
para
.
has
(
"taskId"
))
{
if
(
para
.
has
(
"taskId"
))
{
config
.
setTaskId
(
para
.
get
(
"taskId"
).
asInt
());
}
config
.
setType
(
GatewayType
.
get
(
para
.
get
(
"type"
).
asText
()));
if
(
para
.
has
(
"flinkConfigPath"
))
{
if
(
para
.
has
(
"flinkConfigPath"
))
{
config
.
getClusterConfig
().
setFlinkConfigPath
(
para
.
get
(
"flinkConfigPath"
).
asText
());
}
if
(
para
.
has
(
"flinkLibPath"
))
{
if
(
para
.
has
(
"flinkLibPath"
))
{
config
.
getClusterConfig
().
setFlinkLibPath
(
para
.
get
(
"flinkLibPath"
).
asText
());
}
if
(
para
.
has
(
"yarnConfigPath"
))
{
if
(
para
.
has
(
"yarnConfigPath"
))
{
config
.
getClusterConfig
().
setYarnConfigPath
(
para
.
get
(
"yarnConfigPath"
).
asText
());
}
if
(
para
.
has
(
"jobName"
))
{
if
(
para
.
has
(
"jobName"
))
{
config
.
getFlinkConfig
().
setJobName
(
para
.
get
(
"jobName"
).
asText
());
}
if
(
para
.
has
(
"userJarPath"
))
{
if
(
para
.
has
(
"userJarPath"
))
{
config
.
getAppConfig
().
setUserJarPath
(
para
.
get
(
"userJarPath"
).
asText
());
}
if
(
para
.
has
(
"userJarParas"
))
{
if
(
para
.
has
(
"userJarParas"
))
{
config
.
getAppConfig
().
setUserJarParas
(
para
.
get
(
"userJarParas"
).
asText
().
split
(
"\\s+"
));
}
if
(
para
.
has
(
"userJarMainAppClass"
))
{
if
(
para
.
has
(
"userJarMainAppClass"
))
{
config
.
getAppConfig
().
setUserJarMainAppClass
(
para
.
get
(
"userJarMainAppClass"
).
asText
());
}
if
(
para
.
has
(
"savePoint"
))
{
if
(
para
.
has
(
"savePoint"
))
{
config
.
getFlinkConfig
().
setSavePoint
(
para
.
get
(
"savePoint"
).
asText
());
}
if
(
para
.
has
(
"configParas"
))
{
if
(
para
.
has
(
"configParas"
))
{
try
{
Map
<
String
,
String
>
configMap
=
new
HashMap
<>();
JsonNode
paras
=
mapper
.
readTree
(
para
.
get
(
"configParas"
).
asText
());
paras
.
forEach
((
JsonNode
node
)->
{
configMap
.
put
(
node
.
get
(
"key"
).
asText
(),
node
.
get
(
"value"
).
asText
());
}
paras
.
forEach
((
JsonNode
node
)
->
{
configMap
.
put
(
node
.
get
(
"key"
).
asText
(),
node
.
get
(
"value"
).
asText
());
}
);
config
.
getFlinkConfig
().
setConfiguration
(
configMap
);
}
catch
(
JsonProcessingException
e
)
{
...
...
dlink-gateway/src/main/java/com/dlink/gateway/config/SavePointType.java
View file @
2767b4b5
...
...
@@ -8,12 +8,12 @@ import com.dlink.assertion.Asserts;
* @author wenmo
* @since 2021/11/3 21:58
*/
public
enum
SavePointType
{
TRIGGER
(
"trigger"
),
DISPOSE
(
"dispose"
),
STOP
(
"stop"
),
CANCEL
(
"cancel"
);
public
enum
SavePointType
{
TRIGGER
(
"trigger"
),
DISPOSE
(
"dispose"
),
STOP
(
"stop"
),
CANCEL
(
"cancel"
);
private
String
value
;
SavePointType
(
String
value
){
SavePointType
(
String
value
)
{
this
.
value
=
value
;
}
...
...
@@ -21,9 +21,9 @@ public enum SavePointType{
return
value
;
}
public
static
SavePointType
get
(
String
value
){
public
static
SavePointType
get
(
String
value
)
{
for
(
SavePointType
type
:
SavePointType
.
values
())
{
if
(
Asserts
.
isEqualsIgnoreCase
(
type
.
getValue
(),
value
))
{
if
(
Asserts
.
isEqualsIgnoreCase
(
type
.
getValue
(),
value
))
{
return
type
;
}
}
...
...
dlink-gateway/src/main/java/com/dlink/gateway/model/JobInfo.java
View file @
2767b4b5
...
...
@@ -25,12 +25,12 @@ public class JobInfo {
this
.
status
=
status
;
}
public
enum
JobStatus
{
RUN
(
"run"
),
STOP
(
"stop"
),
CANCEL
(
"cancel"
),
FAIL
(
"fail"
);
public
enum
JobStatus
{
RUN
(
"run"
),
STOP
(
"stop"
),
CANCEL
(
"cancel"
),
FAIL
(
"fail"
);
private
String
value
;
JobStatus
(
String
value
){
JobStatus
(
String
value
)
{
this
.
value
=
value
;
}
}
...
...
dlink-gateway/src/main/java/com/dlink/gateway/result/AbstractGatewayResult.java
View file @
2767b4b5
...
...
@@ -34,12 +34,12 @@ public abstract class AbstractGatewayResult implements GatewayResult {
this
.
exceptionMsg
=
exceptionMsg
;
}
public
void
success
(){
public
void
success
()
{
this
.
isSuccess
=
true
;
this
.
endTime
=
LocalDateTime
.
now
();
}
public
void
fail
(
String
error
){
public
void
fail
(
String
error
)
{
this
.
isSuccess
=
false
;
this
.
endTime
=
LocalDateTime
.
now
();
this
.
exceptionMsg
=
error
;
...
...
dlink-gateway/src/main/java/com/dlink/gateway/result/KubernetesResult.java
View file @
2767b4b5
...
...
@@ -55,7 +55,7 @@ public class KubernetesResult extends AbstractGatewayResult {
this
.
jids
=
jids
;
}
public
static
KubernetesResult
build
(
GatewayType
type
){
return
new
KubernetesResult
(
type
,
LocalDateTime
.
now
());
public
static
KubernetesResult
build
(
GatewayType
type
)
{
return
new
KubernetesResult
(
type
,
LocalDateTime
.
now
());
}
}
dlink-gateway/src/main/java/com/dlink/gateway/result/SavePointResult.java
View file @
2767b4b5
...
...
@@ -43,8 +43,8 @@ public class SavePointResult extends AbstractGatewayResult {
return
null
;
}
public
static
SavePointResult
build
(
GatewayType
type
){
return
new
SavePointResult
(
type
,
LocalDateTime
.
now
());
public
static
SavePointResult
build
(
GatewayType
type
)
{
return
new
SavePointResult
(
type
,
LocalDateTime
.
now
());
}
}
dlink-gateway/src/main/java/com/dlink/gateway/result/TestResult.java
View file @
2767b4b5
...
...
@@ -23,11 +23,11 @@ public class TestResult {
this
.
error
=
error
;
}
public
static
TestResult
success
(){
return
new
TestResult
(
true
,
null
);
public
static
TestResult
success
()
{
return
new
TestResult
(
true
,
null
);
}
public
static
TestResult
fail
(
String
error
){
return
new
TestResult
(
false
,
error
);
public
static
TestResult
fail
(
String
error
)
{
return
new
TestResult
(
false
,
error
);
}
}
dlink-gateway/src/main/java/com/dlink/gateway/result/YarnResult.java
View file @
2767b4b5
package
com
.
dlink
.
gateway
.
result
;
import
com.dlink.gateway.GatewayType
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.time.LocalDateTime
;
import
java.util.List
;
...
...
@@ -52,8 +50,8 @@ public class YarnResult extends AbstractGatewayResult {
this
.
jids
=
jids
;
}
public
static
YarnResult
build
(
GatewayType
type
){
return
new
YarnResult
(
type
,
LocalDateTime
.
now
());
public
static
YarnResult
build
(
GatewayType
type
)
{
return
new
YarnResult
(
type
,
LocalDateTime
.
now
());
}
}
dlink-gateway/src/main/java/com/dlink/gateway/yarn/YarnGateway.java
View file @
2767b4b5
This diff is collapsed.
Click to expand it.
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