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
3ee34211
Unverified
Commit
3ee34211
authored
Dec 26, 2022
by
aiwenmo
Committed by
GitHub
Dec 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature-1466][admin,gateway] Add deploy session cluster by cluster configuration (#1467)
Co-authored-by:
wenmo
<
32723967+wenmo@users.noreply.github.com
>
parent
7f945387
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
312 additions
and
46 deletions
+312
-46
ClusterConfigurationController.java
.../com/dlink/controller/ClusterConfigurationController.java
+1
-0
ClusterController.java
...src/main/java/com/dlink/controller/ClusterController.java
+9
-1
ClusterService.java
...admin/src/main/java/com/dlink/service/ClusterService.java
+2
-0
ClusterServiceImpl.java
.../main/java/com/dlink/service/impl/ClusterServiceImpl.java
+20
-0
JobManager.java
dlink-core/src/main/java/com/dlink/job/JobManager.java
+4
-0
AbstractGateway.java
...eway/src/main/java/com/dlink/gateway/AbstractGateway.java
+19
-0
Gateway.java
dlink-gateway/src/main/java/com/dlink/gateway/Gateway.java
+2
-0
GatewayType.java
...-gateway/src/main/java/com/dlink/gateway/GatewayType.java
+12
-7
KubernetesApplicationGateway.java
...link/gateway/kubernetes/KubernetesApplicationGateway.java
+15
-16
KubernetesSessionGateway.java
...om/dlink/gateway/kubernetes/KubernetesSessionGateway.java
+103
-0
YarnApplicationGateway.java
...n/java/com/dlink/gateway/yarn/YarnApplicationGateway.java
+3
-11
YarnPerJobGateway.java
...c/main/java/com/dlink/gateway/yarn/YarnPerJobGateway.java
+1
-8
YarnSessionGateway.java
.../main/java/com/dlink/gateway/yarn/YarnSessionGateway.java
+99
-0
com.dlink.gateway.Gateway
...ain/resources/META-INF/services/com.dlink.gateway.Gateway
+4
-2
global.ts
dlink-web/src/locales/en-US/global.ts
+1
-0
pages.ts
dlink-web/src/locales/en-US/pages.ts
+2
-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
...rationCenter/ClusterManage/ClusterConfiguration/index.tsx
+12
-1
No files found.
dlink-admin/src/main/java/com/dlink/controller/ClusterConfigurationController.java
View file @
3ee34211
...
@@ -52,6 +52,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -52,6 +52,7 @@ import lombok.extern.slf4j.Slf4j;
@RestController
@RestController
@RequestMapping
(
"/api/clusterConfiguration"
)
@RequestMapping
(
"/api/clusterConfiguration"
)
public
class
ClusterConfigurationController
{
public
class
ClusterConfigurationController
{
@Autowired
@Autowired
private
ClusterConfigurationService
clusterConfigurationService
;
private
ClusterConfigurationService
clusterConfigurationService
;
...
...
dlink-admin/src/main/java/com/dlink/controller/ClusterController.java
View file @
3ee34211
...
@@ -186,6 +186,14 @@ public class ClusterController {
...
@@ -186,6 +186,14 @@ public class ClusterController {
clusterService
.
killCluster
(
item
.
asInt
());
clusterService
.
killCluster
(
item
.
asInt
());
}
}
}
}
return
Result
.
succeed
(
"Kill Cluster Succeed."
);
return
Result
.
succeed
(
"Kill cluster succeed."
);
}
/**
* 启动 Session 集群
*/
@GetMapping
(
"/deploySessionCluster"
)
public
Result
deploySessionCluster
(
@RequestParam
(
"id"
)
Integer
id
)
{
return
Result
.
succeed
(
clusterService
.
deploySessionCluster
(
id
),
"Deploy session cluster succeed."
);
}
}
}
}
dlink-admin/src/main/java/com/dlink/service/ClusterService.java
View file @
3ee34211
...
@@ -56,4 +56,6 @@ public interface ClusterService extends ISuperService<Cluster> {
...
@@ -56,4 +56,6 @@ public interface ClusterService extends ISuperService<Cluster> {
int
clearCluster
();
int
clearCluster
();
void
killCluster
(
Integer
id
);
void
killCluster
(
Integer
id
);
Cluster
deploySessionCluster
(
Integer
id
);
}
}
dlink-admin/src/main/java/com/dlink/service/impl/ClusterServiceImpl.java
View file @
3ee34211
...
@@ -28,6 +28,7 @@ import com.dlink.db.service.impl.SuperServiceImpl;
...
@@ -28,6 +28,7 @@ import com.dlink.db.service.impl.SuperServiceImpl;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.exception.GatewayException
;
import
com.dlink.gateway.exception.GatewayException
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.job.JobManager
;
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
;
...
@@ -37,6 +38,7 @@ import com.dlink.service.ClusterService;
...
@@ -37,6 +38,7 @@ import com.dlink.service.ClusterService;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -165,6 +167,24 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
...
@@ -165,6 +167,24 @@ public class ClusterServiceImpl extends SuperServiceImpl<ClusterMapper, Cluster>
JobManager
.
killCluster
(
gatewayConfig
,
cluster
.
getName
());
JobManager
.
killCluster
(
gatewayConfig
,
cluster
.
getName
());
}
}
@Override
public
Cluster
deploySessionCluster
(
Integer
id
)
{
ClusterConfiguration
clusterConfiguration
=
clusterConfigurationService
.
getClusterConfigById
(
id
);
if
(
Asserts
.
isNull
(
clusterConfiguration
))
{
throw
new
GatewayException
(
"The cluster configuration does not exist."
);
}
GatewayConfig
gatewayConfig
=
GatewayConfig
.
build
(
clusterConfiguration
.
getConfig
());
gatewayConfig
.
setType
(
GatewayType
.
getSessionType
(
clusterConfiguration
.
getType
()));
GatewayResult
gatewayResult
=
JobManager
.
deploySessionCluster
(
gatewayConfig
);
return
registersCluster
(
Cluster
.
autoRegistersCluster
(
gatewayResult
.
getWebURL
().
replace
(
"http://"
,
""
),
gatewayResult
.
getAppId
(),
clusterConfiguration
.
getName
()
+
LocalDateTime
.
now
(),
gatewayConfig
.
getType
().
getLongValue
(),
id
,
null
));
}
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/job/JobManager.java
View file @
3ee34211
...
@@ -696,6 +696,10 @@ public class JobManager {
...
@@ -696,6 +696,10 @@ public class JobManager {
Gateway
.
build
(
gatewayConfig
).
killCluster
();
Gateway
.
build
(
gatewayConfig
).
killCluster
();
}
}
public
static
GatewayResult
deploySessionCluster
(
GatewayConfig
gatewayConfig
)
{
return
Gateway
.
build
(
gatewayConfig
).
deployCluster
();
}
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 @
3ee34211
...
@@ -20,9 +20,12 @@
...
@@ -20,9 +20,12 @@
package
com
.
dlink
.
gateway
;
package
com
.
dlink
.
gateway
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.exception.GatewayException
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.model.JobStatus
;
import
com.dlink.model.JobStatus
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.runtime.jobgraph.JobGraph
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -63,8 +66,24 @@ public abstract class AbstractGateway implements Gateway {
...
@@ -63,8 +66,24 @@ public abstract class AbstractGateway implements Gateway {
return
JobStatus
.
UNKNOWN
;
return
JobStatus
.
UNKNOWN
;
}
}
@Override
public
GatewayResult
submitJobGraph
(
JobGraph
jobGraph
)
{
throw
new
GatewayException
(
"Couldn't deploy Flink Cluster with job graph."
);
}
@Override
public
GatewayResult
submitJar
()
{
throw
new
GatewayException
(
"Couldn't deploy Flink Cluster with User Application Jar."
);
}
@Override
@Override
public
void
killCluster
()
{
public
void
killCluster
()
{
logger
.
error
(
"Could not kill the Flink cluster"
);
logger
.
error
(
"Could not kill the Flink cluster"
);
}
}
@Override
public
GatewayResult
deployCluster
()
{
logger
.
error
(
"Could not deploy the Flink cluster"
);
return
null
;
}
}
}
dlink-gateway/src/main/java/com/dlink/gateway/Gateway.java
View file @
3ee34211
...
@@ -87,4 +87,6 @@ public interface Gateway {
...
@@ -87,4 +87,6 @@ public interface Gateway {
JobStatus
getJobStatusById
(
String
id
);
JobStatus
getJobStatusById
(
String
id
);
void
killCluster
();
void
killCluster
();
GatewayResult
deployCluster
();
}
}
dlink-gateway/src/main/java/com/dlink/gateway/GatewayType.java
View file @
3ee34211
...
@@ -29,13 +29,9 @@ import com.dlink.assertion.Asserts;
...
@@ -29,13 +29,9 @@ import com.dlink.assertion.Asserts;
**/
**/
public
enum
GatewayType
{
public
enum
GatewayType
{
LOCAL
(
"l"
,
"local"
),
LOCAL
(
"l"
,
"local"
),
STANDALONE
(
"s"
,
"standalone"
),
YARN_SESSION
(
"ys"
,
"yarn-session"
),
YARN_APPLICATION
(
"ya"
,
STANDALONE
(
"s"
,
"standalone"
),
"yarn-application"
),
YARN_PER_JOB
(
"ypj"
,
"yarn-per-job"
),
KUBERNETES_SESSION
(
"ks"
,
YARN_SESSION
(
"ys"
,
"yarn-session"
),
"kubernetes-session"
),
KUBERNETES_APPLICATION
(
"ka"
,
"kubernetes-application"
);
YARN_APPLICATION
(
"ya"
,
"yarn-application"
),
YARN_PER_JOB
(
"ypj"
,
"yarn-per-job"
),
KUBERNETES_SESSION
(
"ks"
,
"kubernetes-session"
),
KUBERNETES_APPLICATION
(
"ka"
,
"kubernetes-application"
);
private
final
String
value
;
private
final
String
value
;
private
final
String
longValue
;
private
final
String
longValue
;
...
@@ -62,6 +58,15 @@ public enum GatewayType {
...
@@ -62,6 +58,15 @@ public enum GatewayType {
return
GatewayType
.
YARN_APPLICATION
;
return
GatewayType
.
YARN_APPLICATION
;
}
}
public
static
GatewayType
getSessionType
(
String
value
)
{
switch
(
value
)
{
case
"Kubernetes"
:
return
GatewayType
.
KUBERNETES_SESSION
;
default
:
return
GatewayType
.
YARN_SESSION
;
}
}
public
boolean
equalsValue
(
String
type
)
{
public
boolean
equalsValue
(
String
type
)
{
return
Asserts
.
isEquals
(
value
,
type
)
||
Asserts
.
isEquals
(
longValue
,
type
);
return
Asserts
.
isEquals
(
value
,
type
)
||
Asserts
.
isEquals
(
longValue
,
type
);
}
}
...
...
dlink-gateway/src/main/java/com/dlink/gateway/kubernetes/KubernetesApplicationGateway.java
View file @
3ee34211
...
@@ -22,7 +22,6 @@ package com.dlink.gateway.kubernetes;
...
@@ -22,7 +22,6 @@ package com.dlink.gateway.kubernetes;
import
com.dlink.assertion.Asserts
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.config.AppConfig
;
import
com.dlink.gateway.config.AppConfig
;
import
com.dlink.gateway.exception.GatewayException
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.KubernetesResult
;
import
com.dlink.gateway.result.KubernetesResult
;
import
com.dlink.model.SystemConfiguration
;
import
com.dlink.model.SystemConfiguration
;
...
@@ -40,7 +39,6 @@ import org.apache.flink.configuration.PipelineOptions;
...
@@ -40,7 +39,6 @@ import org.apache.flink.configuration.PipelineOptions;
import
org.apache.flink.configuration.TaskManagerOptions
;
import
org.apache.flink.configuration.TaskManagerOptions
;
import
org.apache.flink.kubernetes.KubernetesClusterDescriptor
;
import
org.apache.flink.kubernetes.KubernetesClusterDescriptor
;
import
org.apache.flink.runtime.client.JobStatusMessage
;
import
org.apache.flink.runtime.client.JobStatusMessage
;
import
org.apache.flink.runtime.jobgraph.JobGraph
;
import
org.apache.http.util.TextUtils
;
import
org.apache.http.util.TextUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -55,16 +53,12 @@ import java.util.List;
...
@@ -55,16 +53,12 @@ import java.util.List;
* @since 2021/12/26 14:59
* @since 2021/12/26 14:59
*/
*/
public
class
KubernetesApplicationGateway
extends
KubernetesGateway
{
public
class
KubernetesApplicationGateway
extends
KubernetesGateway
{
@Override
@Override
public
GatewayType
getType
()
{
public
GatewayType
getType
()
{
return
GatewayType
.
KUBERNETES_APPLICATION
;
return
GatewayType
.
KUBERNETES_APPLICATION
;
}
}
@Override
public
GatewayResult
submitJobGraph
(
JobGraph
jobGraph
)
{
throw
new
GatewayException
(
"Couldn't deploy Kubernetes Application Cluster with job graph."
);
}
@Override
@Override
public
GatewayResult
submitJar
()
{
public
GatewayResult
submitJar
()
{
if
(
Asserts
.
isNull
(
client
))
{
if
(
Asserts
.
isNull
(
client
))
{
...
@@ -85,23 +79,28 @@ public class KubernetesApplicationGateway extends KubernetesGateway {
...
@@ -85,23 +79,28 @@ public class KubernetesApplicationGateway extends KubernetesGateway {
if
(
Asserts
.
isNull
(
userJarParas
))
{
if
(
Asserts
.
isNull
(
userJarParas
))
{
userJarParas
=
new
String
[
0
];
userJarParas
=
new
String
[
0
];
}
}
ApplicationConfiguration
applicationConfiguration
=
new
ApplicationConfiguration
(
userJarParas
,
appConfig
.
getUserJarMainAppClass
());
ApplicationConfiguration
applicationConfiguration
=
new
ApplicationConfiguration
(
userJarParas
,
KubernetesClusterDescriptor
kubernetesClusterDescriptor
=
new
KubernetesClusterDescriptor
(
configuration
,
client
);
appConfig
.
getUserJarMainAppClass
());
KubernetesClusterDescriptor
kubernetesClusterDescriptor
=
new
KubernetesClusterDescriptor
(
configuration
,
client
);
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
clusterSpecificationBuilder
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
}
}
if
(
configuration
.
contains
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
if
(
configuration
.
contains
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
.
setTaskManagerMemoryMB
(
configuration
.
get
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
clusterSpecificationBuilder
.
setTaskManagerMemoryMB
(
configuration
.
get
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
}
}
if
(
configuration
.
contains
(
TaskManagerOptions
.
NUM_TASK_SLOTS
))
{
if
(
configuration
.
contains
(
TaskManagerOptions
.
NUM_TASK_SLOTS
))
{
clusterSpecificationBuilder
.
setSlotsPerTaskManager
(
configuration
.
get
(
TaskManagerOptions
.
NUM_TASK_SLOTS
)).
createClusterSpecification
();
clusterSpecificationBuilder
.
setSlotsPerTaskManager
(
configuration
.
get
(
TaskManagerOptions
.
NUM_TASK_SLOTS
))
.
createClusterSpecification
();
}
}
try
{
try
{
ClusterClientProvider
<
String
>
clusterClientProvider
=
kubernetesClusterDescriptor
.
deployApplicationCluster
(
ClusterClientProvider
<
String
>
clusterClientProvider
=
kubernetesClusterDescriptor
.
deployApplicationCluster
(
clusterSpecificationBuilder
.
createClusterSpecification
(),
applicationConfiguration
);
clusterSpecificationBuilder
.
createClusterSpecification
(),
applicationConfiguration
);
ClusterClient
<
String
>
clusterClient
=
clusterClientProvider
.
getClusterClient
();
ClusterClient
<
String
>
clusterClient
=
clusterClientProvider
.
getClusterClient
();
Collection
<
JobStatusMessage
>
jobStatusMessages
=
clusterClient
.
listJobs
().
get
();
Collection
<
JobStatusMessage
>
jobStatusMessages
=
clusterClient
.
listJobs
().
get
();
int
counts
=
SystemConfiguration
.
getInstances
().
getJobIdWait
();
int
counts
=
SystemConfiguration
.
getInstances
().
getJobIdWait
();
...
@@ -121,12 +120,12 @@ public class KubernetesApplicationGateway extends KubernetesGateway {
...
@@ -121,12 +120,12 @@ public class KubernetesApplicationGateway extends KubernetesGateway {
result
.
setJids
(
jids
);
result
.
setJids
(
jids
);
}
}
String
jobId
=
""
;
String
jobId
=
""
;
//application mode only have one job, so we can get any one to be jobId
//
application mode only have one job, so we can get any one to be jobId
for
(
JobStatusMessage
jobStatusMessage
:
jobStatusMessages
)
{
for
(
JobStatusMessage
jobStatusMessage
:
jobStatusMessages
)
{
jobId
=
jobStatusMessage
.
getJobId
().
toHexString
();
jobId
=
jobStatusMessage
.
getJobId
().
toHexString
();
}
}
//if JobStatusMessage not have job id, use timestamp
//
if JobStatusMessage not have job id, use timestamp
//and... it`s maybe wrong with submit
//
and... it`s maybe wrong with submit
if
(
TextUtils
.
isEmpty
(
jobId
))
{
if
(
TextUtils
.
isEmpty
(
jobId
))
{
jobId
=
"unknown"
+
System
.
currentTimeMillis
();
jobId
=
"unknown"
+
System
.
currentTimeMillis
();
}
}
...
...
dlink-gateway/src/main/java/com/dlink/gateway/kubernetes/KubernetesSessionGateway.java
0 → 100644
View file @
3ee34211
/*
*
* 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
.
gateway
.
kubernetes
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.config.AppConfig
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.KubernetesResult
;
import
com.dlink.utils.LogUtil
;
import
org.apache.flink.client.deployment.ClusterSpecification
;
import
org.apache.flink.client.program.ClusterClient
;
import
org.apache.flink.client.program.ClusterClientProvider
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.configuration.DeploymentOptionsInternal
;
import
org.apache.flink.configuration.GlobalConfiguration
;
import
org.apache.flink.configuration.JobManagerOptions
;
import
org.apache.flink.configuration.PipelineOptions
;
import
org.apache.flink.configuration.TaskManagerOptions
;
import
org.apache.flink.kubernetes.KubernetesClusterDescriptor
;
import
java.util.Collections
;
/**
* KubernetesSessionGateway
*
* @author wenmo
* @since 2022/12/25 23:25
*/
public
class
KubernetesSessionGateway
extends
KubernetesGateway
{
@Override
public
GatewayType
getType
()
{
return
GatewayType
.
KUBERNETES_SESSION
;
}
@Override
public
GatewayResult
deployCluster
()
{
if
(
Asserts
.
isNull
(
client
))
{
init
();
}
KubernetesResult
result
=
KubernetesResult
.
build
(
getType
());
AppConfig
appConfig
=
config
.
getAppConfig
();
String
flinkConfigPath
=
config
.
getClusterConfig
().
getFlinkConfigPath
();
Configuration
loadConfiguration
=
GlobalConfiguration
.
loadConfiguration
(
flinkConfigPath
);
if
(
loadConfiguration
!=
null
)
{
loadConfiguration
.
addAll
(
configuration
);
configuration
=
loadConfiguration
;
}
configuration
.
set
(
DeploymentOptionsInternal
.
CONF_DIR
,
flinkConfigPath
);
configuration
.
set
(
PipelineOptions
.
JARS
,
Collections
.
singletonList
(
appConfig
.
getUserJarPath
()));
KubernetesClusterDescriptor
kubernetesClusterDescriptor
=
new
KubernetesClusterDescriptor
(
configuration
,
client
);
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
}
if
(
configuration
.
contains
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
.
setTaskManagerMemoryMB
(
configuration
.
get
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
}
if
(
configuration
.
contains
(
TaskManagerOptions
.
NUM_TASK_SLOTS
))
{
clusterSpecificationBuilder
.
setSlotsPerTaskManager
(
configuration
.
get
(
TaskManagerOptions
.
NUM_TASK_SLOTS
))
.
createClusterSpecification
();
}
try
{
ClusterClientProvider
<
String
>
clusterClientProvider
=
kubernetesClusterDescriptor
.
deploySessionCluster
(
clusterSpecificationBuilder
.
createClusterSpecification
());
ClusterClient
<
String
>
clusterClient
=
clusterClientProvider
.
getClusterClient
();
result
.
setClusterId
(
clusterClient
.
getClusterId
());
result
.
setWebURL
(
clusterClient
.
getWebInterfaceURL
());
result
.
success
();
}
catch
(
Exception
e
)
{
result
.
fail
(
LogUtil
.
getError
(
e
));
}
finally
{
kubernetesClusterDescriptor
.
close
();
}
return
result
;
}
}
dlink-gateway/src/main/java/com/dlink/gateway/yarn/YarnApplicationGateway.java
View file @
3ee34211
...
@@ -23,7 +23,6 @@ import com.dlink.assertion.Asserts;
...
@@ -23,7 +23,6 @@ import com.dlink.assertion.Asserts;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.config.AppConfig
;
import
com.dlink.gateway.config.AppConfig
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.exception.GatewayException
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.YarnResult
;
import
com.dlink.gateway.result.YarnResult
;
import
com.dlink.model.SystemConfiguration
;
import
com.dlink.model.SystemConfiguration
;
...
@@ -37,7 +36,6 @@ import org.apache.flink.configuration.JobManagerOptions;
...
@@ -37,7 +36,6 @@ import org.apache.flink.configuration.JobManagerOptions;
import
org.apache.flink.configuration.PipelineOptions
;
import
org.apache.flink.configuration.PipelineOptions
;
import
org.apache.flink.configuration.TaskManagerOptions
;
import
org.apache.flink.configuration.TaskManagerOptions
;
import
org.apache.flink.runtime.client.JobStatusMessage
;
import
org.apache.flink.runtime.client.JobStatusMessage
;
import
org.apache.flink.runtime.jobgraph.JobGraph
;
import
org.apache.flink.yarn.YarnClientYarnClusterInformationRetriever
;
import
org.apache.flink.yarn.YarnClientYarnClusterInformationRetriever
;
import
org.apache.flink.yarn.YarnClusterDescriptor
;
import
org.apache.flink.yarn.YarnClusterDescriptor
;
import
org.apache.hadoop.yarn.api.records.ApplicationId
;
import
org.apache.hadoop.yarn.api.records.ApplicationId
;
...
@@ -71,11 +69,6 @@ public class YarnApplicationGateway extends YarnGateway {
...
@@ -71,11 +69,6 @@ public class YarnApplicationGateway extends YarnGateway {
return
GatewayType
.
YARN_APPLICATION
;
return
GatewayType
.
YARN_APPLICATION
;
}
}
@Override
public
GatewayResult
submitJobGraph
(
JobGraph
jobGraph
)
{
throw
new
GatewayException
(
"Couldn't deploy Yarn Application Cluster with job graph."
);
}
@Override
@Override
public
GatewayResult
submitJar
()
{
public
GatewayResult
submitJar
()
{
if
(
Asserts
.
isNull
(
yarnClient
))
{
if
(
Asserts
.
isNull
(
yarnClient
))
{
...
@@ -88,14 +81,13 @@ public class YarnApplicationGateway extends YarnGateway {
...
@@ -88,14 +81,13 @@ public class YarnApplicationGateway extends YarnGateway {
if
(
Asserts
.
isNull
(
userJarParas
))
{
if
(
Asserts
.
isNull
(
userJarParas
))
{
userJarParas
=
new
String
[
0
];
userJarParas
=
new
String
[
0
];
}
}
ApplicationConfiguration
applicationConfiguration
=
ApplicationConfiguration
applicationConfiguration
=
new
ApplicationConfiguration
(
userJarParas
,
new
ApplicationConfiguration
(
userJarParas
,
appConfig
.
getUserJarMainAppClass
());
appConfig
.
getUserJarMainAppClass
());
YarnClusterDescriptor
yarnClusterDescriptor
=
new
YarnClusterDescriptor
(
YarnClusterDescriptor
yarnClusterDescriptor
=
new
YarnClusterDescriptor
(
configuration
,
yarnConfiguration
,
yarnClient
,
configuration
,
yarnConfiguration
,
yarnClient
,
YarnClientYarnClusterInformationRetriever
.
create
(
yarnClient
),
true
);
YarnClientYarnClusterInformationRetriever
.
create
(
yarnClient
),
true
);
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
clusterSpecificationBuilder
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
...
...
dlink-gateway/src/main/java/com/dlink/gateway/yarn/YarnPerJobGateway.java
View file @
3ee34211
...
@@ -22,7 +22,6 @@ package com.dlink.gateway.yarn;
...
@@ -22,7 +22,6 @@ package com.dlink.gateway.yarn;
import
com.dlink.assertion.Asserts
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.config.GatewayConfig
;
import
com.dlink.gateway.exception.GatewayException
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.YarnResult
;
import
com.dlink.gateway.result.YarnResult
;
import
com.dlink.model.SystemConfiguration
;
import
com.dlink.model.SystemConfiguration
;
...
@@ -78,8 +77,7 @@ public class YarnPerJobGateway extends YarnGateway {
...
@@ -78,8 +77,7 @@ public class YarnPerJobGateway extends YarnGateway {
configuration
,
yarnConfiguration
,
yarnClient
,
configuration
,
yarnConfiguration
,
yarnClient
,
YarnClientYarnClusterInformationRetriever
.
create
(
yarnClient
),
true
);
YarnClientYarnClusterInformationRetriever
.
create
(
yarnClient
),
true
);
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
clusterSpecificationBuilder
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
...
@@ -130,9 +128,4 @@ public class YarnPerJobGateway extends YarnGateway {
...
@@ -130,9 +128,4 @@ public class YarnPerJobGateway extends YarnGateway {
}
}
return
result
;
return
result
;
}
}
@Override
public
GatewayResult
submitJar
()
{
throw
new
GatewayException
(
"Couldn't deploy Yarn Per-Job Cluster with User Application Jar."
);
}
}
}
dlink-gateway/src/main/java/com/dlink/gateway/yarn/YarnSessionGateway.java
0 → 100644
View file @
3ee34211
/*
*
* 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
.
gateway
.
yarn
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.gateway.GatewayType
;
import
com.dlink.gateway.result.GatewayResult
;
import
com.dlink.gateway.result.YarnResult
;
import
com.dlink.utils.LogUtil
;
import
org.apache.flink.client.deployment.ClusterSpecification
;
import
org.apache.flink.client.program.ClusterClient
;
import
org.apache.flink.client.program.ClusterClientProvider
;
import
org.apache.flink.configuration.JobManagerOptions
;
import
org.apache.flink.configuration.TaskManagerOptions
;
import
org.apache.flink.yarn.YarnClientYarnClusterInformationRetriever
;
import
org.apache.flink.yarn.YarnClusterDescriptor
;
import
org.apache.hadoop.yarn.api.records.ApplicationId
;
import
java.util.Arrays
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.io.FileUtil
;
/**
* YarnSessionGateway
*
* @author wenmo
* @since 2022/12/25
*/
public
class
YarnSessionGateway
extends
YarnGateway
{
@Override
public
GatewayType
getType
()
{
return
GatewayType
.
YARN_SESSION
;
}
@Override
public
GatewayResult
deployCluster
()
{
if
(
Asserts
.
isNull
(
yarnClient
))
{
init
();
}
YarnResult
result
=
YarnResult
.
build
(
getType
());
YarnClusterDescriptor
yarnClusterDescriptor
=
new
YarnClusterDescriptor
(
configuration
,
yarnConfiguration
,
yarnClient
,
YarnClientYarnClusterInformationRetriever
.
create
(
yarnClient
),
true
);
ClusterSpecification
.
ClusterSpecificationBuilder
clusterSpecificationBuilder
=
new
ClusterSpecification
.
ClusterSpecificationBuilder
();
if
(
configuration
.
contains
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
.
setMasterMemoryMB
(
configuration
.
get
(
JobManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
}
if
(
configuration
.
contains
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
))
{
clusterSpecificationBuilder
.
setTaskManagerMemoryMB
(
configuration
.
get
(
TaskManagerOptions
.
TOTAL_PROCESS_MEMORY
).
getMebiBytes
());
}
if
(
configuration
.
contains
(
TaskManagerOptions
.
NUM_TASK_SLOTS
))
{
clusterSpecificationBuilder
.
setSlotsPerTaskManager
(
configuration
.
get
(
TaskManagerOptions
.
NUM_TASK_SLOTS
))
.
createClusterSpecification
();
}
if
(
Asserts
.
isNotNull
(
config
.
getJarPaths
()))
{
yarnClusterDescriptor
.
addShipFiles
(
Arrays
.
stream
(
config
.
getJarPaths
()).
map
(
FileUtil:
:
file
).
collect
(
Collectors
.
toList
()));
}
try
{
ClusterClientProvider
<
ApplicationId
>
clusterClientProvider
=
yarnClusterDescriptor
.
deploySessionCluster
(
clusterSpecificationBuilder
.
createClusterSpecification
());
ClusterClient
<
ApplicationId
>
clusterClient
=
clusterClientProvider
.
getClusterClient
();
ApplicationId
applicationId
=
clusterClient
.
getClusterId
();
result
.
setAppId
(
applicationId
.
toString
());
result
.
setWebURL
(
clusterClient
.
getWebInterfaceURL
());
result
.
success
();
}
catch
(
Exception
e
)
{
result
.
fail
(
LogUtil
.
getError
(
e
));
}
finally
{
yarnClusterDescriptor
.
close
();
}
return
result
;
}
}
dlink-gateway/src/main/resources/META-INF/services/com.dlink.gateway.Gateway
View file @
3ee34211
com.dlink.gateway.yarn.YarnApplicationGateway
com.dlink.gateway.yarn.YarnApplicationGateway
com.dlink.gateway.yarn.YarnPerJobGateway
com.dlink.gateway.yarn.YarnPerJobGateway
com.dlink.gateway.kubernetes.KubernetesApplicationGateway
com.dlink.gateway.yarn.YarnSessionGateway
\ No newline at end of file
com.dlink.gateway.kubernetes.KubernetesApplicationGateway
com.dlink.gateway.kubernetes.KubernetesSessionGateway
\ No newline at end of file
dlink-web/src/locales/en-US/global.ts
View file @
3ee34211
...
@@ -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.start'
:
'Start'
,
'button.stop'
:
'Stop'
,
'button.stop'
:
'Stop'
,
'button.assignUser'
:
'Assign Users'
,
'button.assignUser'
:
'Assign Users'
,
'button.assignRole'
:
'Assign Role'
,
'button.assignRole'
:
'Assign Role'
,
...
...
dlink-web/src/locales/en-US/pages.ts
View file @
3ee34211
...
@@ -530,6 +530,8 @@ export default {
...
@@ -530,6 +530,8 @@ export default {
'pages.rc.clusterConfig.modify'
:
'Modify Cluster Config'
,
'pages.rc.clusterConfig.modify'
:
'Modify Cluster Config'
,
'pages.rc.clusterConfig.delete'
:
'Delete Cluster Config'
,
'pages.rc.clusterConfig.delete'
:
'Delete Cluster Config'
,
'pages.rc.clusterConfig.deleteConfirm'
:
'Are you sure you want to delete this Cluster Config? '
,
'pages.rc.clusterConfig.deleteConfirm'
:
'Are you sure you want to delete this Cluster Config? '
,
'pages.rc.clusterConfig.start'
:
'Start Session Cluster'
,
'pages.rc.clusterConfig.startConfirm'
:
'Are you sure you want to start session cluster by this cluster config? '
,
'pages.rc.clusterConfig.enable'
:
'Enable Cluster Config'
,
'pages.rc.clusterConfig.enable'
:
'Enable Cluster Config'
,
'pages.rc.clusterConfig.enableConfirm'
:
'Are you sure you want to enable this Cluster Config? '
,
'pages.rc.clusterConfig.enableConfirm'
:
'Are you sure you want to enable this Cluster Config? '
,
'pages.rc.clusterConfig.disable'
:
'Disable Cluster Config'
,
'pages.rc.clusterConfig.disable'
:
'Disable Cluster Config'
,
...
...
dlink-web/src/locales/zh-CN/global.ts
View file @
3ee34211
...
@@ -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.start'
:
'启动'
,
'button.stop'
:
'停止'
,
'button.stop'
:
'停止'
,
'button.assignUser'
:
'分配用户'
,
'button.assignUser'
:
'分配用户'
,
'button.assignRole'
:
'分配角色'
,
'button.assignRole'
:
'分配角色'
,
...
...
dlink-web/src/locales/zh-CN/pages.ts
View file @
3ee34211
...
@@ -536,6 +536,8 @@ export default {
...
@@ -536,6 +536,8 @@ export default {
'pages.rc.clusterConfig.modify'
:
'修改集群'
,
'pages.rc.clusterConfig.modify'
:
'修改集群'
,
'pages.rc.clusterConfig.delete'
:
'删除集群配置'
,
'pages.rc.clusterConfig.delete'
:
'删除集群配置'
,
'pages.rc.clusterConfig.deleteConfirm'
:
'确定删除该集群配置吗?'
,
'pages.rc.clusterConfig.deleteConfirm'
:
'确定删除该集群配置吗?'
,
'pages.rc.clusterConfig.start'
:
'启动 Session 集群'
,
'pages.rc.clusterConfig.startConfirm'
:
'确定通过该集群配置启动 Session 集群吗?'
,
'pages.rc.clusterConfig.enable'
:
'启用集群配置'
,
'pages.rc.clusterConfig.enable'
:
'启用集群配置'
,
'pages.rc.clusterConfig.enableConfirm'
:
'您确定要启用此集群配置吗?'
,
'pages.rc.clusterConfig.enableConfirm'
:
'您确定要启用此集群配置吗?'
,
'pages.rc.clusterConfig.disable'
:
'禁用集群配置'
,
'pages.rc.clusterConfig.disable'
:
'禁用集群配置'
,
...
...
dlink-web/src/pages/RegistrationCenter/ClusterManage/ClusterConfiguration/index.tsx
View file @
3ee34211
...
@@ -25,7 +25,7 @@ import {Button, Drawer, Dropdown, Menu, Modal} from 'antd';
...
@@ -25,7 +25,7 @@ import {Button, Drawer, Dropdown, Menu, Modal} from 'antd';
import
{
FooterToolbar
,
PageContainer
}
from
'@ant-design/pro-layout'
;
import
{
FooterToolbar
,
PageContainer
}
from
'@ant-design/pro-layout'
;
import
ProDescriptions
from
'@ant-design/pro-descriptions'
;
import
ProDescriptions
from
'@ant-design/pro-descriptions'
;
import
{
ClusterConfigurationTableListItem
}
from
"@/pages/RegistrationCenter/data"
;
import
{
ClusterConfigurationTableListItem
}
from
"@/pages/RegistrationCenter/data"
;
import
{
handleAddOrUpdate
,
handleRemove
,
queryData
,
updateEnabled
}
from
"@/components/Common/crud"
;
import
{
handleAddOrUpdate
,
handle
Data
,
handle
Remove
,
queryData
,
updateEnabled
}
from
"@/components/Common/crud"
;
import
{
showClusterConfiguration
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
showClusterConfiguration
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
ClusterConfigurationForm
import
ClusterConfigurationForm
from
"@/pages/RegistrationCenter/ClusterManage/ClusterConfiguration/components/ClusterConfigurationForm"
;
from
"@/pages/RegistrationCenter/ClusterManage/ClusterConfiguration/components/ClusterConfigurationForm"
;
...
@@ -57,6 +57,16 @@ const ClusterConfigurationTableList: React.FC<{}> = (props: any) => {
...
@@ -57,6 +57,16 @@ const ClusterConfigurationTableList: React.FC<{}> = (props: any) => {
actionRef
.
current
?.
reloadAndRest
?.();
actionRef
.
current
?.
reloadAndRest
?.();
}
}
});
});
}
else
if
(
key
===
'start'
)
{
Modal
.
confirm
({
title
:
l
(
'pages.rc.clusterConfig.start'
),
content
:
l
(
'pages.rc.clusterConfig.startConfirm'
),
okText
:
l
(
'button.confirm'
),
cancelText
:
l
(
'button.cancel'
),
onOk
:
async
()
=>
{
await
handleData
(
'/api/cluster/deploySessionCluster'
,
{
id
:
currentItem
.
id
});
}
});
}
}
};
};
...
@@ -66,6 +76,7 @@ const ClusterConfigurationTableList: React.FC<{}> = (props: any) => {
...
@@ -66,6 +76,7 @@ const ClusterConfigurationTableList: React.FC<{}> = (props: any) => {
<
Dropdown
<
Dropdown
overlay=
{
overlay=
{
<
Menu
onClick=
{
({
key
})
=>
editAndDelete
(
key
,
item
)
}
>
<
Menu
onClick=
{
({
key
})
=>
editAndDelete
(
key
,
item
)
}
>
<
Menu
.
Item
key=
"start"
>
{
l
(
'button.start'
)
}
</
Menu
.
Item
>
<
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