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
7f945387
Unverified
Commit
7f945387
authored
Dec 23, 2022
by
aiwenmo
Committed by
GitHub
Dec 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature-1463][gateway,admin] Add kill cluster (#1464)
Co-authored-by:
wenmo
<
32723967+wenmo@users.noreply.github.com
>
parent
e363878d
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
192 additions
and
103 deletions
+192
-103
ClusterController.java
...src/main/java/com/dlink/controller/ClusterController.java
+22
-0
ClusterService.java
...admin/src/main/java/com/dlink/service/ClusterService.java
+2
-0
ClusterServiceImpl.java
.../main/java/com/dlink/service/impl/ClusterServiceImpl.java
+30
-0
FlinkAPI.java
dlink-core/src/main/java/com/dlink/api/FlinkAPI.java
+4
-1
JobConfig.java
dlink-core/src/main/java/com/dlink/job/JobConfig.java
+1
-50
JobManager.java
dlink-core/src/main/java/com/dlink/job/JobManager.java
+5
-0
AbstractGateway.java
...eway/src/main/java/com/dlink/gateway/AbstractGateway.java
+5
-0
Gateway.java
dlink-gateway/src/main/java/com/dlink/gateway/Gateway.java
+2
-0
GatewayConfig.java
...src/main/java/com/dlink/gateway/config/GatewayConfig.java
+53
-40
KubernetesGateway.java
.../java/com/dlink/gateway/kubernetes/KubernetesGateway.java
+36
-10
YarnGateway.java
...way/src/main/java/com/dlink/gateway/yarn/YarnGateway.java
+16
-2
global.ts
dlink-web/src/locales/en-US/global.ts
+1
-0
global.ts
dlink-web/src/locales/zh-CN/global.ts
+1
-0
pages.ts
dlink-web/src/locales/zh-CN/pages.ts
+2
-0
index.tsx
.../pages/RegistrationCenter/ClusterManage/Cluster/index.tsx
+12
-0
No files found.
dlink-admin/src/main/java/com/dlink/controller/ClusterController.java
View file @
7f945387
...
@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.PostMapping;
...
@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
...
@@ -166,4 +167,25 @@ public class ClusterController {
...
@@ -166,4 +167,25 @@ public class ClusterController {
return
Result
.
succeed
(
clusterService
.
clearCluster
(),
"回收完成"
);
return
Result
.
succeed
(
clusterService
.
clearCluster
(),
"回收完成"
);
}
}
/**
* 停止集群
*/
@GetMapping
(
"/killCluster"
)
public
Result
killCluster
(
@RequestParam
(
"id"
)
Integer
id
)
{
clusterService
.
killCluster
(
id
);
return
Result
.
succeed
(
"Kill Cluster Succeed."
);
}
/**
* 批量停止
*/
@DeleteMapping
(
"/killMulCluster"
)
public
Result
killMulCluster
(
@RequestBody
JsonNode
para
)
{
if
(
para
.
size
()
>
0
)
{
for
(
final
JsonNode
item
:
para
)
{
clusterService
.
killCluster
(
item
.
asInt
());
}
}
return
Result
.
succeed
(
"Kill Cluster Succeed."
);
}
}
}
dlink-admin/src/main/java/com/dlink/service/ClusterService.java
View file @
7f945387
...
@@ -54,4 +54,6 @@ public interface ClusterService extends ISuperService<Cluster> {
...
@@ -54,4 +54,6 @@ public interface ClusterService extends ISuperService<Cluster> {
boolean
enableCluster
(
Cluster
cluster
);
boolean
enableCluster
(
Cluster
cluster
);
int
clearCluster
();
int
clearCluster
();
void
killCluster
(
Integer
id
);
}
}
dlink-admin/src/main/java/com/dlink/service/impl/ClusterServiceImpl.java
View file @
7f945387
...
@@ -20,18 +20,26 @@
...
@@ -20,18 +20,26 @@
package
com
.
dlink
.
service
.
impl
;
package
com
.
dlink
.
service
.
impl
;
import
com.dlink.assertion.Assert
;
import
com.dlink.assertion.Assert
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.cluster.FlinkCluster
;
import
com.dlink.cluster.FlinkCluster
;
import
com.dlink.cluster.FlinkClusterInfo
;
import
com.dlink.cluster.FlinkClusterInfo
;
import
com.dlink.constant.FlinkConstant
;
import
com.dlink.constant.FlinkConstant
;
import
com.dlink.db.service.impl.SuperServiceImpl
;
import
com.dlink.db.service.impl.SuperServiceImpl
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.exception.GatewayException
;
import
com.dlink.job.JobManager
;
import
com.dlink.mapper.ClusterMapper
;
import
com.dlink.mapper.ClusterMapper
;
import
com.dlink.model.Cluster
;
import
com.dlink.model.Cluster
;
import
com.dlink.model.ClusterConfiguration
;
import
com.dlink.service.ClusterConfigurationService
;
import
com.dlink.service.ClusterService
;
import
com.dlink.service.ClusterService
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
@@ -45,6 +53,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...
@@ -45,6 +53,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@Service
@Service
public
class
ClusterServiceImpl
extends
SuperServiceImpl
<
ClusterMapper
,
Cluster
>
implements
ClusterService
{
public
class
ClusterServiceImpl
extends
SuperServiceImpl
<
ClusterMapper
,
Cluster
>
implements
ClusterService
{
@Autowired
private
ClusterConfigurationService
clusterConfigurationService
;
@Override
@Override
public
FlinkClusterInfo
checkHeartBeat
(
String
hosts
,
String
host
)
{
public
FlinkClusterInfo
checkHeartBeat
(
String
hosts
,
String
host
)
{
return
FlinkCluster
.
testFlinkJobManagerIP
(
hosts
,
host
);
return
FlinkCluster
.
testFlinkJobManagerIP
(
hosts
,
host
);
...
@@ -135,6 +146,25 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
...
@@ -135,6 +146,25 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
return
count
;
return
count
;
}
}
@Override
public
void
killCluster
(
Integer
id
)
{
Cluster
cluster
=
getById
(
id
);
if
(
Asserts
.
isNull
(
cluster
))
{
throw
new
GatewayException
(
"The cluster does not exist."
);
}
else
if
(!
checkHealth
(
cluster
))
{
throw
new
GatewayException
(
"The cluster has been killed."
);
}
Integer
clusterConfigurationId
=
cluster
.
getClusterConfigurationId
();
ClusterConfiguration
clusterConfiguration
=
clusterConfigurationService
.
getClusterConfigById
(
clusterConfigurationId
);
if
(
Asserts
.
isNull
(
clusterConfiguration
))
{
throw
new
GatewayException
(
"The cluster configuration does not exist."
);
}
GatewayConfig
gatewayConfig
=
GatewayConfig
.
build
(
clusterConfiguration
.
getConfig
());
gatewayConfig
.
setType
(
GatewayType
.
get
(
cluster
.
getType
()));
JobManager
.
killCluster
(
gatewayConfig
,
cluster
.
getName
());
}
private
boolean
checkHealth
(
Cluster
cluster
)
{
private
boolean
checkHealth
(
Cluster
cluster
)
{
FlinkClusterInfo
info
=
checkHeartBeat
(
cluster
.
getHosts
(),
cluster
.
getJobManagerHost
());
FlinkClusterInfo
info
=
checkHeartBeat
(
cluster
.
getHosts
(),
cluster
.
getJobManagerHost
());
if
(!
info
.
isEffective
())
{
if
(!
info
.
isEffective
())
{
...
...
dlink-core/src/main/java/com/dlink/api/FlinkAPI.java
View file @
7f945387
...
@@ -203,7 +203,10 @@ public class FlinkAPI {
...
@@ -203,7 +203,10 @@ public class FlinkAPI {
public
String
getVersion
()
{
public
String
getVersion
()
{
JsonNode
result
=
get
(
FlinkRestAPIConstant
.
FLINK_CONFIG
);
JsonNode
result
=
get
(
FlinkRestAPIConstant
.
FLINK_CONFIG
);
return
result
.
get
(
"flink-version"
).
asText
();
if
(
Asserts
.
isNotNull
(
result
)
&&
Asserts
.
isNotNull
(
result
.
get
(
"flink-version"
)))
{
return
result
.
get
(
"flink-version"
).
asText
();
}
return
null
;
}
}
public
JsonNode
getOverview
()
{
public
JsonNode
getOverview
()
{
...
...
dlink-core/src/main/java/com/dlink/job/JobConfig.java
View file @
7f945387
...
@@ -23,18 +23,13 @@ import com.dlink.assertion.Asserts;
...
@@ -23,18 +23,13 @@ import com.dlink.assertion.Asserts;
import
com.dlink.constant.NetConstant
;
import
com.dlink.constant.NetConstant
;
import
com.dlink.executor.ExecutorSetting
;
import
com.dlink.executor.ExecutorSetting
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.config.AppConfig
;
import
com.dlink.gateway.config.ClusterConfig
;
import
com.dlink.gateway.config.FlinkConfig
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.config.SavePointStrategy
;
import
com.dlink.gateway.config.SavePointStrategy
;
import
com.dlink.session.SessionConfig
;
import
com.dlink.session.SessionConfig
;
import
org.apache.flink.configuration.CoreOptions
;
import
org.apache.flink.configuration.CoreOptions
;
import
org.apache.flink.configuration.RestOptions
;
import
org.apache.flink.configuration.RestOptions
;
import
org.apache.http.util.TextUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -217,56 +212,12 @@ public class JobConfig {
...
@@ -217,56 +212,12 @@ public class JobConfig {
}
}
public
void
buildGatewayConfig
(
Map
<
String
,
Object
>
config
)
{
public
void
buildGatewayConfig
(
Map
<
String
,
Object
>
config
)
{
gatewayConfig
=
new
GatewayConfig
();
gatewayConfig
=
GatewayConfig
.
build
(
config
);
if
(
config
.
containsKey
(
"hadoopConfigPath"
))
{
gatewayConfig
.
setClusterConfig
(
ClusterConfig
.
build
(
config
.
get
(
"flinkConfigPath"
).
toString
(),
config
.
get
(
"flinkLibPath"
).
toString
(),
config
.
get
(
"hadoopConfigPath"
).
toString
()));
}
else
{
gatewayConfig
.
setClusterConfig
(
ClusterConfig
.
build
(
config
.
get
(
"flinkConfigPath"
).
toString
()));
}
AppConfig
appConfig
=
new
AppConfig
();
if
(
config
.
containsKey
(
"userJarPath"
)
&&
Asserts
.
isNotNullString
((
String
)
config
.
get
(
"userJarPath"
)))
{
appConfig
.
setUserJarPath
(
config
.
get
(
"userJarPath"
).
toString
());
if
(
config
.
containsKey
(
"userJarMainAppClass"
)
&&
Asserts
.
isNotNullString
((
String
)
config
.
get
(
"userJarMainAppClass"
)))
{
appConfig
.
setUserJarMainAppClass
(
config
.
get
(
"userJarMainAppClass"
).
toString
());
}
if
(
config
.
containsKey
(
"userJarParas"
)
&&
Asserts
.
isNotNullString
((
String
)
config
.
get
(
"userJarParas"
)))
{
// There may be multiple spaces between the parameter and value during user input,
// which will directly lead to a parameter passing error and needs to be eliminated
String
[]
temp
=
config
.
get
(
"userJarParas"
).
toString
().
split
(
" "
);
List
<
String
>
paraSplit
=
new
ArrayList
<>();
for
(
String
s
:
temp
)
{
if
(!
TextUtils
.
isEmpty
(
s
.
trim
()))
{
paraSplit
.
add
(
s
);
}
}
appConfig
.
setUserJarParas
(
paraSplit
.
toArray
(
new
String
[
0
]));
}
gatewayConfig
.
setAppConfig
(
appConfig
);
}
if
(
config
.
containsKey
(
"flinkConfig"
)
if
(
config
.
containsKey
(
"flinkConfig"
)
&&
Asserts
.
isNotNullMap
((
Map
<
String
,
String
>)
config
.
get
(
"flinkConfig"
)))
{
&&
Asserts
.
isNotNullMap
((
Map
<
String
,
String
>)
config
.
get
(
"flinkConfig"
)))
{
gatewayConfig
.
setFlinkConfig
(
FlinkConfig
.
build
((
Map
<
String
,
String
>)
config
.
get
(
"flinkConfig"
)));
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
put
(
CoreOptions
.
DEFAULT_PARALLELISM
.
key
(),
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
put
(
CoreOptions
.
DEFAULT_PARALLELISM
.
key
(),
String
.
valueOf
(
parallelism
));
String
.
valueOf
(
parallelism
));
}
}
if
(
config
.
containsKey
(
"kubernetesConfig"
))
{
Map
<
String
,
String
>
kubernetesConfig
=
(
Map
<
String
,
String
>)
config
.
get
(
"kubernetesConfig"
);
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
putAll
(
kubernetesConfig
);
}
// at present only k8s task have this
if
(
config
.
containsKey
(
"taskCustomConfig"
))
{
Map
<
String
,
Map
<
String
,
String
>>
taskCustomConfig
=
(
Map
<
String
,
Map
<
String
,
String
>>)
config
.
get
(
"taskCustomConfig"
);
if
(
taskCustomConfig
.
containsKey
(
"kubernetesConfig"
))
{
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
putAll
(
taskCustomConfig
.
get
(
"kubernetesConfig"
));
}
if
(
taskCustomConfig
.
containsKey
(
"flinkConfig"
))
{
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
putAll
(
taskCustomConfig
.
get
(
"flinkConfig"
));
}
}
}
}
public
void
addGatewayConfig
(
List
<
Map
<
String
,
String
>>
configList
)
{
public
void
addGatewayConfig
(
List
<
Map
<
String
,
String
>>
configList
)
{
...
...
dlink-core/src/main/java/com/dlink/job/JobManager.java
View file @
7f945387
...
@@ -691,6 +691,11 @@ public class JobManager {
...
@@ -691,6 +691,11 @@ public class JobManager {
}
}
}
}
public
static
void
killCluster
(
GatewayConfig
gatewayConfig
,
String
appId
)
{
gatewayConfig
.
getClusterConfig
().
setAppId
(
appId
);
Gateway
.
build
(
gatewayConfig
).
killCluster
();
}
public
JobResult
executeJar
()
{
public
JobResult
executeJar
()
{
ProcessEntity
process
=
ProcessContextHolder
.
getProcess
();
ProcessEntity
process
=
ProcessContextHolder
.
getProcess
();
Job
job
=
Job
.
init
(
runMode
,
config
,
executorSetting
,
executor
,
null
,
useGateway
);
Job
job
=
Job
.
init
(
runMode
,
config
,
executorSetting
,
executor
,
null
,
useGateway
);
...
...
dlink-gateway/src/main/java/com/dlink/gateway/AbstractGateway.java
View file @
7f945387
...
@@ -62,4 +62,9 @@ public abstract class AbstractGateway implements Gateway {
...
@@ -62,4 +62,9 @@ public abstract class AbstractGateway implements Gateway {
public
JobStatus
getJobStatusById
(
String
id
)
{
public
JobStatus
getJobStatusById
(
String
id
)
{
return
JobStatus
.
UNKNOWN
;
return
JobStatus
.
UNKNOWN
;
}
}
@Override
public
void
killCluster
()
{
logger
.
error
(
"Could not kill the Flink cluster"
);
}
}
}
dlink-gateway/src/main/java/com/dlink/gateway/Gateway.java
View file @
7f945387
...
@@ -85,4 +85,6 @@ public interface Gateway {
...
@@ -85,4 +85,6 @@ public interface Gateway {
TestResult
test
();
TestResult
test
();
JobStatus
getJobStatusById
(
String
id
);
JobStatus
getJobStatusById
(
String
id
);
void
killCluster
();
}
}
dlink-gateway/src/main/java/com/dlink/gateway/config/GatewayConfig.java
View file @
7f945387
...
@@ -19,13 +19,15 @@
...
@@ -19,13 +19,15 @@
package
com
.
dlink
.
gateway
.
config
;
package
com
.
dlink
.
gateway
.
config
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.GatewayType
;
import
java.util.HashMap
;
import
org.apache.http.util.TextUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.Getter
;
import
lombok.Getter
;
...
@@ -56,49 +58,60 @@ public class GatewayConfig {
...
@@ -56,49 +58,60 @@ public class GatewayConfig {
appConfig
=
new
AppConfig
();
appConfig
=
new
AppConfig
();
}
}
public
static
GatewayConfig
build
(
JsonNode
para
)
{
public
static
GatewayConfig
build
(
Map
<
String
,
Object
>
config
)
{
GatewayConfig
config
=
new
GatewayConfig
();
GatewayConfig
gatewayConfig
=
new
GatewayConfig
();
if
(
para
.
has
(
"taskId"
))
{
if
(
config
.
containsKey
(
"hadoopConfigPath"
))
{
config
.
setTaskId
(
para
.
get
(
"taskId"
).
asInt
());
gatewayConfig
.
setClusterConfig
(
ClusterConfig
.
build
(
config
.
get
(
"flinkConfigPath"
).
toString
(),
}
config
.
get
(
"flinkLibPath"
).
toString
(),
config
.
setType
(
GatewayType
.
get
(
para
.
get
(
"type"
).
asText
()));
config
.
get
(
"hadoopConfigPath"
).
toString
()));
if
(
para
.
has
(
"flinkConfigPath"
))
{
}
else
{
config
.
getClusterConfig
().
setFlinkConfigPath
(
para
.
get
(
"flinkConfigPath"
).
asText
());
gatewayConfig
.
setClusterConfig
(
ClusterConfig
.
build
(
config
.
get
(
"flinkConfigPath"
).
toString
()));
}
if
(
para
.
has
(
"flinkLibPath"
))
{
config
.
getClusterConfig
().
setFlinkLibPath
(
para
.
get
(
"flinkLibPath"
).
asText
());
}
if
(
para
.
has
(
"yarnConfigPath"
))
{
config
.
getClusterConfig
().
setYarnConfigPath
(
para
.
get
(
"yarnConfigPath"
).
asText
());
}
if
(
para
.
has
(
"jobName"
))
{
config
.
getFlinkConfig
().
setJobName
(
para
.
get
(
"jobName"
).
asText
());
}
}
if
(
para
.
has
(
"userJarPath"
))
{
AppConfig
appConfig
=
new
AppConfig
();
config
.
getAppConfig
().
setUserJarPath
(
para
.
get
(
"userJarPath"
).
asText
());
if
(
config
.
containsKey
(
"userJarPath"
)
&&
Asserts
.
isNotNullString
((
String
)
config
.
get
(
"userJarPath"
)))
{
}
appConfig
.
setUserJarPath
(
config
.
get
(
"userJarPath"
).
toString
());
if
(
para
.
has
(
"userJarParas"
))
{
if
(
config
.
containsKey
(
"userJarMainAppClass"
)
config
.
getAppConfig
().
setUserJarParas
(
para
.
get
(
"userJarParas"
).
asText
().
split
(
"\\s+"
));
&&
Asserts
.
isNotNullString
((
String
)
config
.
get
(
"userJarMainAppClass"
)))
{
appConfig
.
setUserJarMainAppClass
(
config
.
get
(
"userJarMainAppClass"
).
toString
());
}
if
(
config
.
containsKey
(
"userJarParas"
)
&&
Asserts
.
isNotNullString
((
String
)
config
.
get
(
"userJarParas"
)))
{
// There may be multiple spaces between the parameter and value during user input,
// which will directly lead to a parameter passing error and needs to be eliminated
String
[]
temp
=
config
.
get
(
"userJarParas"
).
toString
().
split
(
" "
);
List
<
String
>
paraSplit
=
new
ArrayList
<>();
for
(
String
s
:
temp
)
{
if
(!
TextUtils
.
isEmpty
(
s
.
trim
()))
{
paraSplit
.
add
(
s
);
}
}
appConfig
.
setUserJarParas
(
paraSplit
.
toArray
(
new
String
[
0
]));
}
gatewayConfig
.
setAppConfig
(
appConfig
);
}
}
if
(
para
.
has
(
"userJarMainAppClass"
))
{
if
(
config
.
containsKey
(
"flinkConfig"
)
config
.
getAppConfig
().
setUserJarMainAppClass
(
para
.
get
(
"userJarMainAppClass"
).
asText
());
&&
Asserts
.
isNotNullMap
((
Map
<
String
,
String
>)
config
.
get
(
"flinkConfig"
)))
{
gatewayConfig
.
setFlinkConfig
(
FlinkConfig
.
build
((
Map
<
String
,
String
>)
config
.
get
(
"flinkConfig"
)));
}
}
if
(
para
.
has
(
"savePoint"
))
{
if
(
config
.
containsKey
(
"kubernetesConfig"
))
{
config
.
getFlinkConfig
().
setSavePoint
(
para
.
get
(
"savePoint"
).
asText
());
Map
<
String
,
String
>
kubernetesConfig
=
(
Map
<
String
,
String
>)
config
.
get
(
"kubernetesConfig"
);
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
putAll
(
kubernetesConfig
);
}
}
if
(
para
.
has
(
"configParas"
))
{
// at present only k8s task have this
try
{
if
(
config
.
containsKey
(
"taskCustomConfig"
))
{
Map
<
String
,
String
>
configMap
=
new
HashMap
<>();
Map
<
String
,
Map
<
String
,
String
>>
taskCustomConfig
=
(
Map
<
String
,
Map
<
String
,
String
>>)
config
JsonNode
paras
=
mapper
.
readTree
(
para
.
get
(
"configParas"
).
asText
());
.
get
(
"taskCustomConfig"
);
paras
.
forEach
((
JsonNode
node
)
->
{
if
(
taskCustomConfig
.
containsKey
(
"kubernetesConfig"
))
{
configMap
.
put
(
node
.
get
(
"key"
).
asText
(),
node
.
get
(
"value"
).
asText
());
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
putAll
(
taskCustomConfig
.
get
(
"kubernetesConfig"
));
});
config
.
getFlinkConfig
().
setConfiguration
(
configMap
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
}
if
(
taskCustomConfig
.
containsKey
(
"flinkConfig"
))
{
gatewayConfig
.
getFlinkConfig
().
getConfiguration
().
putAll
(
taskCustomConfig
.
get
(
"flinkConfig"
));
}
}
if
(
config
.
containsKey
(
"taskId"
))
{
gatewayConfig
.
setTaskId
(
Integer
.
valueOf
(
config
.
get
(
"taskId"
).
toString
()));
}
}
return
config
;
// config.setType(GatewayType.get(para.get("type").asText()));
return
gatewayConfig
;
}
}
}
}
dlink-gateway/src/main/java/com/dlink/gateway/kubernetes/KubernetesGateway.java
View file @
7f945387
...
@@ -87,10 +87,12 @@ public abstract class KubernetesGateway extends AbstractGateway {
...
@@ -87,10 +87,12 @@ public abstract class KubernetesGateway extends AbstractGateway {
if
(
getType
().
isApplicationMode
())
{
if
(
getType
().
isApplicationMode
())
{
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
if
(
configuration
.
contains
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
))
{
if
(
configuration
.
contains
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
))
{
configuration
.
set
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
,
configuration
.
getString
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
)
+
"/"
+
uuid
);
configuration
.
set
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
,
configuration
.
getString
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
)
+
"/"
+
uuid
);
}
}
if
(
configuration
.
contains
(
CheckpointingOptions
.
SAVEPOINT_DIRECTORY
))
{
if
(
configuration
.
contains
(
CheckpointingOptions
.
SAVEPOINT_DIRECTORY
))
{
configuration
.
set
(
CheckpointingOptions
.
SAVEPOINT_DIRECTORY
,
configuration
.
getString
(
CheckpointingOptions
.
SAVEPOINT_DIRECTORY
)
+
"/"
+
uuid
);
configuration
.
set
(
CheckpointingOptions
.
SAVEPOINT_DIRECTORY
,
configuration
.
getString
(
CheckpointingOptions
.
SAVEPOINT_DIRECTORY
)
+
"/"
+
uuid
);
}
}
}
}
}
}
...
@@ -122,11 +124,12 @@ public abstract class KubernetesGateway extends AbstractGateway {
...
@@ -122,11 +124,12 @@ public abstract class KubernetesGateway extends AbstractGateway {
KubernetesClusterClientFactory
clusterClientFactory
=
new
KubernetesClusterClientFactory
();
KubernetesClusterClientFactory
clusterClientFactory
=
new
KubernetesClusterClientFactory
();
String
clusterId
=
clusterClientFactory
.
getClusterId
(
configuration
);
String
clusterId
=
clusterClientFactory
.
getClusterId
(
configuration
);
if
(
Asserts
.
isNull
(
clusterId
))
{
if
(
Asserts
.
isNull
(
clusterId
))
{
throw
new
GatewayException
(
"No cluster id was specified. Please specify a cluster to which you would like to connect."
);
throw
new
GatewayException
(
"No cluster id was specified. Please specify a cluster to which you would like to connect."
);
}
}
KubernetesClusterDescriptor
clusterDescriptor
=
clusterClientFactory
.
createClusterDescriptor
(
configuration
);
KubernetesClusterDescriptor
clusterDescriptor
=
clusterClientFactory
.
createClusterDescriptor
(
configuration
);
try
(
ClusterClient
<
String
>
clusterClient
=
clusterDescriptor
.
retrieve
(
try
(
ClusterClient
<
String
>
clusterClient
=
clusterDescriptor
.
retrieve
(
clusterId
).
getClusterClient
())
{
clusterId
).
getClusterClient
())
{
List
<
JobInfo
>
jobInfos
=
new
ArrayList
<>();
List
<
JobInfo
>
jobInfos
=
new
ArrayList
<>();
CompletableFuture
<
Collection
<
JobStatusMessage
>>
listJobsFuture
=
clusterClient
.
listJobs
();
CompletableFuture
<
Collection
<
JobStatusMessage
>>
listJobsFuture
=
clusterClient
.
listJobs
();
for
(
JobStatusMessage
jobStatusMessage
:
listJobsFuture
.
get
())
{
for
(
JobStatusMessage
jobStatusMessage
:
listJobsFuture
.
get
())
{
...
@@ -151,14 +154,16 @@ public abstract class KubernetesGateway extends AbstractGateway {
...
@@ -151,14 +154,16 @@ public abstract class KubernetesGateway extends AbstractGateway {
init
();
init
();
}
}
if
(
Asserts
.
isNull
(
config
.
getFlinkConfig
().
getJobId
()))
{
if
(
Asserts
.
isNull
(
config
.
getFlinkConfig
().
getJobId
()))
{
throw
new
GatewayException
(
"No job id was specified. Please specify a job to which you would like to savepont."
);
throw
new
GatewayException
(
"No job id was specified. Please specify a job to which you would like to savepont."
);
}
}
SavePointResult
result
=
SavePointResult
.
build
(
getType
());
SavePointResult
result
=
SavePointResult
.
build
(
getType
());
configuration
.
set
(
KubernetesConfigOptions
.
CLUSTER_ID
,
config
.
getClusterConfig
().
getAppId
());
configuration
.
set
(
KubernetesConfigOptions
.
CLUSTER_ID
,
config
.
getClusterConfig
().
getAppId
());
KubernetesClusterClientFactory
clusterClientFactory
=
new
KubernetesClusterClientFactory
();
KubernetesClusterClientFactory
clusterClientFactory
=
new
KubernetesClusterClientFactory
();
String
clusterId
=
clusterClientFactory
.
getClusterId
(
configuration
);
String
clusterId
=
clusterClientFactory
.
getClusterId
(
configuration
);
if
(
Asserts
.
isNull
(
clusterId
))
{
if
(
Asserts
.
isNull
(
clusterId
))
{
throw
new
GatewayException
(
"No cluster id was specified. Please specify a cluster to which you would like to connect."
);
throw
new
GatewayException
(
"No cluster id was specified. Please specify a cluster to which you would like to connect."
);
}
}
KubernetesClusterDescriptor
clusterDescriptor
=
clusterClientFactory
.
createClusterDescriptor
(
configuration
);
KubernetesClusterDescriptor
clusterDescriptor
=
clusterClientFactory
.
createClusterDescriptor
(
configuration
);
try
(
ClusterClient
<
String
>
clusterClient
=
clusterDescriptor
.
retrieve
(
clusterId
).
getClusterClient
())
{
try
(
ClusterClient
<
String
>
clusterClient
=
clusterDescriptor
.
retrieve
(
clusterId
).
getClusterClient
())
{
...
@@ -172,7 +177,8 @@ public abstract class KubernetesGateway extends AbstractGateway {
...
@@ -172,7 +177,8 @@ public abstract class KubernetesGateway extends AbstractGateway {
return
result
;
return
result
;
}
}
private
void
runSavePointJob
(
List
<
JobInfo
>
jobInfos
,
ClusterClient
<
String
>
clusterClient
,
String
savePoint
)
throws
Exception
{
private
void
runSavePointJob
(
List
<
JobInfo
>
jobInfos
,
ClusterClient
<
String
>
clusterClient
,
String
savePoint
)
throws
Exception
{
for
(
JobInfo
jobInfo
:
jobInfos
)
{
for
(
JobInfo
jobInfo
:
jobInfos
)
{
if
(
ActionType
.
CANCEL
==
config
.
getFlinkConfig
().
getAction
())
{
if
(
ActionType
.
CANCEL
==
config
.
getFlinkConfig
().
getAction
())
{
clusterClient
.
cancel
(
JobID
.
fromHexString
(
jobInfo
.
getJobId
()));
clusterClient
.
cancel
(
JobID
.
fromHexString
(
jobInfo
.
getJobId
()));
...
@@ -181,14 +187,14 @@ public abstract class KubernetesGateway extends AbstractGateway {
...
@@ -181,14 +187,14 @@ public abstract class KubernetesGateway extends AbstractGateway {
}
}
switch
(
config
.
getFlinkConfig
().
getSavePointType
())
{
switch
(
config
.
getFlinkConfig
().
getSavePointType
())
{
case
TRIGGER:
case
TRIGGER:
jobInfo
.
setSavePoint
(
FlinkUtil
.
triggerSavepoint
(
clusterClient
,
jobInfo
.
getJobId
(),
savePoint
));
jobInfo
.
setSavePoint
(
FlinkUtil
.
triggerSavepoint
(
clusterClient
,
jobInfo
.
getJobId
(),
savePoint
));
break
;
break
;
case
STOP:
case
STOP:
jobInfo
.
setSavePoint
(
FlinkUtil
.
stopWithSavepoint
(
clusterClient
,
jobInfo
.
getJobId
(),
savePoint
));
jobInfo
.
setSavePoint
(
FlinkUtil
.
stopWithSavepoint
(
clusterClient
,
jobInfo
.
getJobId
(),
savePoint
));
jobInfo
.
setStatus
(
JobInfo
.
JobStatus
.
STOP
);
jobInfo
.
setStatus
(
JobInfo
.
JobStatus
.
STOP
);
break
;
break
;
case
CANCEL:
case
CANCEL:
jobInfo
.
setSavePoint
(
FlinkUtil
.
cancelWithSavepoint
(
clusterClient
,
jobInfo
.
getJobId
(),
savePoint
));
jobInfo
.
setSavePoint
(
FlinkUtil
.
cancelWithSavepoint
(
clusterClient
,
jobInfo
.
getJobId
(),
savePoint
));
jobInfo
.
setStatus
(
JobInfo
.
JobStatus
.
CANCEL
);
jobInfo
.
setStatus
(
JobInfo
.
JobStatus
.
CANCEL
);
break
;
break
;
default
:
default
:
...
@@ -212,4 +218,24 @@ public abstract class KubernetesGateway extends AbstractGateway {
...
@@ -212,4 +218,24 @@ public abstract class KubernetesGateway extends AbstractGateway {
return
TestResult
.
fail
(
"测试 Kubernetes 配置失败:"
+
e
.
getMessage
());
return
TestResult
.
fail
(
"测试 Kubernetes 配置失败:"
+
e
.
getMessage
());
}
}
}
}
@Override
public
void
killCluster
()
{
if
(
Asserts
.
isNull
(
client
))
{
init
();
}
configuration
.
set
(
KubernetesConfigOptions
.
CLUSTER_ID
,
config
.
getClusterConfig
().
getAppId
());
KubernetesClusterClientFactory
clusterClientFactory
=
new
KubernetesClusterClientFactory
();
String
clusterId
=
clusterClientFactory
.
getClusterId
(
configuration
);
if
(
Asserts
.
isNull
(
clusterId
))
{
throw
new
GatewayException
(
"No cluster id was specified. Please specify a cluster to which you would like to connect."
);
}
KubernetesClusterDescriptor
clusterDescriptor
=
clusterClientFactory
.
createClusterDescriptor
(
configuration
);
try
{
clusterDescriptor
.
killCluster
(
clusterId
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
dlink-gateway/src/main/java/com/dlink/gateway/yarn/YarnGateway.java
View file @
7f945387
...
@@ -127,7 +127,7 @@ public abstract class YarnGateway extends AbstractGateway {
...
@@ -127,7 +127,7 @@ public abstract class YarnGateway extends AbstractGateway {
}
}
}
}
if
(
getType
().
isApplicationMode
())
{
if
(
getType
().
isApplicationMode
())
{
configuration
.
set
(
YarnConfigOptions
.
APPLICATION_TYPE
,
"Dinky Flink"
);
configuration
.
set
(
YarnConfigOptions
.
APPLICATION_TYPE
,
"Dinky Flink"
);
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
if
(
configuration
.
contains
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
))
{
if
(
configuration
.
contains
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
))
{
configuration
.
set
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
,
configuration
.
set
(
CheckpointingOptions
.
CHECKPOINTS_DIRECTORY
,
...
@@ -255,7 +255,7 @@ public abstract class YarnGateway extends AbstractGateway {
...
@@ -255,7 +255,7 @@ public abstract class YarnGateway extends AbstractGateway {
}
}
private
void
runSavePointJob
(
List
<
JobInfo
>
jobInfos
,
ClusterClient
<
ApplicationId
>
clusterClient
,
private
void
runSavePointJob
(
List
<
JobInfo
>
jobInfos
,
ClusterClient
<
ApplicationId
>
clusterClient
,
String
savePoint
)
throws
Exception
{
String
savePoint
)
throws
Exception
{
for
(
JobInfo
jobInfo
:
jobInfos
)
{
for
(
JobInfo
jobInfo
:
jobInfos
)
{
if
(
ActionType
.
CANCEL
==
config
.
getFlinkConfig
().
getAction
())
{
if
(
ActionType
.
CANCEL
==
config
.
getFlinkConfig
().
getAction
())
{
clusterClient
.
cancel
(
JobID
.
fromHexString
(
jobInfo
.
getJobId
()));
clusterClient
.
cancel
(
JobID
.
fromHexString
(
jobInfo
.
getJobId
()));
...
@@ -364,4 +364,18 @@ public abstract class YarnGateway extends AbstractGateway {
...
@@ -364,4 +364,18 @@ public abstract class YarnGateway extends AbstractGateway {
}
}
return
JobStatus
.
UNKNOWN
;
return
JobStatus
.
UNKNOWN
;
}
}
@Override
public
void
killCluster
()
{
if
(
Asserts
.
isNull
(
yarnClient
))
{
init
();
}
try
{
yarnClient
.
killApplication
(
getApplicationId
());
}
catch
(
YarnException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
dlink-web/src/locales/en-US/global.ts
View file @
7f945387
...
@@ -32,6 +32,7 @@ export default {
...
@@ -32,6 +32,7 @@ export default {
'button.more'
:
'More'
,
'button.more'
:
'More'
,
'button.config'
:
'Config'
,
'button.config'
:
'Config'
,
'button.edit'
:
'Edit'
,
'button.edit'
:
'Edit'
,
'button.stop'
:
'Stop'
,
'button.assignUser'
:
'Assign Users'
,
'button.assignUser'
:
'Assign Users'
,
'button.assignRole'
:
'Assign Role'
,
'button.assignRole'
:
'Assign Role'
,
'button.changePassword'
:
'Change Password'
,
'button.changePassword'
:
'Change Password'
,
...
...
dlink-web/src/locales/zh-CN/global.ts
View file @
7f945387
...
@@ -32,6 +32,7 @@ export default {
...
@@ -32,6 +32,7 @@ export default {
'button.more'
:
'更多'
,
'button.more'
:
'更多'
,
'button.config'
:
'配置'
,
'button.config'
:
'配置'
,
'button.edit'
:
'编辑'
,
'button.edit'
:
'编辑'
,
'button.stop'
:
'停止'
,
'button.assignUser'
:
'分配用户'
,
'button.assignUser'
:
'分配用户'
,
'button.assignRole'
:
'分配角色'
,
'button.assignRole'
:
'分配角色'
,
'button.changePassword'
:
'修改密码'
,
'button.changePassword'
:
'修改密码'
,
...
...
dlink-web/src/locales/zh-CN/pages.ts
View file @
7f945387
...
@@ -502,7 +502,9 @@ export default {
...
@@ -502,7 +502,9 @@ export default {
'pages.rc.cluster.create'
:
'创建集群'
,
'pages.rc.cluster.create'
:
'创建集群'
,
'pages.rc.cluster.modify'
:
'修改集群'
,
'pages.rc.cluster.modify'
:
'修改集群'
,
'pages.rc.cluster.delete'
:
'删除 Flink 实例'
,
'pages.rc.cluster.delete'
:
'删除 Flink 实例'
,
'pages.rc.cluster.stop'
:
'停止 Flink 实例'
,
'pages.rc.cluster.deleteConfirm'
:
'确定删除该 Flink 实例吗?'
,
'pages.rc.cluster.deleteConfirm'
:
'确定删除该 Flink 实例吗?'
,
'pages.rc.cluster.stopConfirm'
:
'确定停止该 Flink 实例吗?'
,
'pages.rc.cluster.recycle'
:
'回收 Flink 实例'
,
'pages.rc.cluster.recycle'
:
'回收 Flink 实例'
,
'pages.rc.cluster.recycleConfirm'
:
'确定回收所有自动创建且过期的 Flink 实例吗?'
,
'pages.rc.cluster.recycleConfirm'
:
'确定回收所有自动创建且过期的 Flink 实例吗?'
,
'pages.rc.cluster.recycle.success'
:
'成功回收{total}个 Flink 实例'
,
'pages.rc.cluster.recycle.success'
:
'成功回收{total}个 Flink 实例'
,
...
...
dlink-web/src/pages/RegistrationCenter/ClusterManage/Cluster/index.tsx
View file @
7f945387
...
@@ -71,6 +71,17 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
...
@@ -71,6 +71,17 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
actionRef
.
current
?.
reloadAndRest
?.();
actionRef
.
current
?.
reloadAndRest
?.();
}
}
});
});
}
else
if
(
key
===
'stop'
)
{
Modal
.
confirm
({
title
:
l
(
'pages.rc.cluster.stop'
),
content
:
l
(
'pages.rc.cluster.stopConfirm'
),
okText
:
l
(
'button.confirm'
),
cancelText
:
l
(
'button.cancel'
),
onOk
:
async
()
=>
{
await
handleRemove
(
url
+
'/killMulCluster'
,
[
currentItem
]);
actionRef
.
current
?.
reloadAndRest
?.();
}
});
}
}
};
};
...
@@ -100,6 +111,7 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
...
@@ -100,6 +111,7 @@ const ClusterTableList: React.FC<{}> = (props: any) => {
<
Dropdown
<
Dropdown
overlay=
{
overlay=
{
<
Menu
onClick=
{
({
key
})
=>
editAndDelete
(
key
,
item
)
}
>
<
Menu
onClick=
{
({
key
})
=>
editAndDelete
(
key
,
item
)
}
>
{
item
.
autoRegisters
==
1
?
(<
Menu
.
Item
key=
"stop"
>
{
l
(
'button.stop'
)
}
</
Menu
.
Item
>)
:
undefined
}
<
Menu
.
Item
key=
"edit"
>
{
l
(
'button.edit'
)
}
</
Menu
.
Item
>
<
Menu
.
Item
key=
"edit"
>
{
l
(
'button.edit'
)
}
</
Menu
.
Item
>
<
Menu
.
Item
key=
"delete"
>
{
l
(
'button.delete'
)
}
</
Menu
.
Item
>
<
Menu
.
Item
key=
"delete"
>
{
l
(
'button.delete'
)
}
</
Menu
.
Item
>
</
Menu
>
</
Menu
>
...
...
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