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
963cb1d2
Unverified
Commit
963cb1d2
authored
Dec 11, 2023
by
aiwenmo
Committed by
GitHub
Dec 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature-2620][core] Local mode supports monitor (#2621)
Co-authored-by:
wenmo
<
32723967+wenmo@users.noreply.github.com
>
parent
3fa83e2a
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
59 additions
and
61 deletions
+59
-61
ClusterInstanceService.java
...c/main/java/org/dinky/service/ClusterInstanceService.java
+3
-18
ClusterInstanceServiceImpl.java
...va/org/dinky/service/impl/ClusterInstanceServiceImpl.java
+20
-19
TaskServiceImpl.java
...src/main/java/org/dinky/service/impl/TaskServiceImpl.java
+4
-3
URLUtils.java
dinky-common/src/main/java/org/dinky/utils/URLUtils.java
+6
-0
FlinkConstant.java
...-core/src/main/java/org/dinky/constant/FlinkConstant.java
+1
-10
ExecutorConfig.java
...core/src/main/java/org/dinky/executor/ExecutorConfig.java
+15
-0
LocalBatchExecutor.java
.../src/main/java/org/dinky/executor/LocalBatchExecutor.java
+4
-5
LocalStreamExecutor.java
...src/main/java/org/dinky/executor/LocalStreamExecutor.java
+4
-5
JobManager.java
dinky-core/src/main/java/org/dinky/job/JobManager.java
+1
-0
auto.sh
script/bin/auto.sh
+1
-1
No files found.
dinky-admin/src/main/java/org/dinky/service/ClusterInstanceService.java
View file @
963cb1d2
...
@@ -22,6 +22,7 @@ package org.dinky.service;
...
@@ -22,6 +22,7 @@ package org.dinky.service;
import
org.dinky.cluster.FlinkClusterInfo
;
import
org.dinky.cluster.FlinkClusterInfo
;
import
org.dinky.data.dto.ClusterInstanceDTO
;
import
org.dinky.data.dto.ClusterInstanceDTO
;
import
org.dinky.data.model.ClusterInstance
;
import
org.dinky.data.model.ClusterInstance
;
import
org.dinky.job.JobConfig
;
import
org.dinky.mybatis.service.ISuperService
;
import
org.dinky.mybatis.service.ISuperService
;
import
java.util.List
;
import
java.util.List
;
...
@@ -49,26 +50,10 @@ public interface ClusterInstanceService extends ISuperService<ClusterInstance> {
...
@@ -49,26 +50,10 @@ public interface ClusterInstanceService extends ISuperService<ClusterInstance> {
/**
/**
* build environment address
* build environment address
*
*
* @param useRemote {@link Boolean} use remote or local
* @param config {@link JobConfig} the config of job
* @param id {@link Integer} cluster id
* @return {@link String} eg: host1:8081
*/
String
buildEnvironmentAddress
(
boolean
useRemote
,
Integer
id
);
/**
* build remote environment address by cluster id
*
* @param id {@link Integer} cluster id
* @return {@link String} eg: host1:8081
*/
String
buildRemoteEnvironmentAddress
(
Integer
id
);
/**
* build local environment address
*
* @return {@link String} eg: host1:8081
* @return {@link String} eg: host1:8081
*/
*/
String
build
LocalEnvironmentAddress
(
);
String
build
EnvironmentAddress
(
JobConfig
config
);
/**
/**
* list enabled cluster instances
* list enabled cluster instances
...
...
dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java
View file @
963cb1d2
...
@@ -23,7 +23,6 @@ import org.dinky.assertion.Assert;
...
@@ -23,7 +23,6 @@ import org.dinky.assertion.Assert;
import
org.dinky.assertion.Asserts
;
import
org.dinky.assertion.Asserts
;
import
org.dinky.cluster.FlinkCluster
;
import
org.dinky.cluster.FlinkCluster
;
import
org.dinky.cluster.FlinkClusterInfo
;
import
org.dinky.cluster.FlinkClusterInfo
;
import
org.dinky.constant.FlinkConstant
;
import
org.dinky.data.dto.ClusterInstanceDTO
;
import
org.dinky.data.dto.ClusterInstanceDTO
;
import
org.dinky.data.model.ClusterConfiguration
;
import
org.dinky.data.model.ClusterConfiguration
;
import
org.dinky.data.model.ClusterInstance
;
import
org.dinky.data.model.ClusterInstance
;
...
@@ -31,16 +30,18 @@ import org.dinky.gateway.config.GatewayConfig;
...
@@ -31,16 +30,18 @@ import org.dinky.gateway.config.GatewayConfig;
import
org.dinky.gateway.exception.GatewayException
;
import
org.dinky.gateway.exception.GatewayException
;
import
org.dinky.gateway.model.FlinkClusterConfig
;
import
org.dinky.gateway.model.FlinkClusterConfig
;
import
org.dinky.gateway.result.GatewayResult
;
import
org.dinky.gateway.result.GatewayResult
;
import
org.dinky.job.JobConfig
;
import
org.dinky.job.JobManager
;
import
org.dinky.job.JobManager
;
import
org.dinky.mapper.ClusterInstanceMapper
;
import
org.dinky.mapper.ClusterInstanceMapper
;
import
org.dinky.mybatis.service.impl.SuperServiceImpl
;
import
org.dinky.mybatis.service.impl.SuperServiceImpl
;
import
org.dinky.service.ClusterConfigurationService
;
import
org.dinky.service.ClusterConfigurationService
;
import
org.dinky.service.ClusterInstanceService
;
import
org.dinky.service.ClusterInstanceService
;
import
org.dinky.utils.IpUtils
;
import
org.dinky.utils.URLUtils
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -87,30 +88,30 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
...
@@ -87,30 +88,30 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
}
}
@Override
@Override
public
String
buildEnvironmentAddress
(
boolean
useRemote
,
Integer
id
)
{
public
String
buildEnvironmentAddress
(
JobConfig
config
)
{
if
(
useRemote
&&
id
!=
0
)
{
Integer
id
=
config
.
getClusterId
();
Boolean
useRemote
=
config
.
isUseRemote
();
if
(
useRemote
&&
id
!=
null
&&
id
!=
0
)
{
return
buildRemoteEnvironmentAddress
(
id
);
return
buildRemoteEnvironmentAddress
(
id
);
}
else
{
}
else
{
return
buildLocalEnvironmentAddress
();
Map
<
String
,
String
>
flinkConfig
=
config
.
getConfigJson
();
int
port
;
if
(
Asserts
.
isNotNull
(
flinkConfig
)
&&
flinkConfig
.
containsKey
(
"rest.port"
))
{
port
=
Integer
.
valueOf
(
flinkConfig
.
get
(
"rest.port"
));
}
else
{
port
=
URLUtils
.
getRandomPort
();
}
return
buildLocalEnvironmentAddress
(
port
);
}
}
}
}
@Override
private
String
buildRemoteEnvironmentAddress
(
Integer
id
)
{
public
String
buildRemoteEnvironmentAddress
(
Integer
id
)
{
return
getJobManagerAddress
(
getById
(
id
));
return
getJobManagerAddress
(
getById
(
id
));
}
}
@Override
private
String
buildLocalEnvironmentAddress
(
int
port
)
{
public
String
buildLocalEnvironmentAddress
()
{
String
host
=
IpUtils
.
getHostIp
();
try
{
return
host
+
":"
+
port
;
InetAddress
inetAddress
=
InetAddress
.
getLocalHost
();
if
(
inetAddress
!=
null
)
{
return
inetAddress
.
getHostAddress
();
}
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
}
return
FlinkConstant
.
LOCAL_HOST
;
}
}
@Override
@Override
...
...
dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java
View file @
963cb1d2
...
@@ -224,14 +224,15 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
...
@@ -224,14 +224,15 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
JobInstance
jobInstance
=
jobInstanceService
.
getById
(
task
.
getJobInstanceId
());
JobInstance
jobInstance
=
jobInstanceService
.
getById
(
task
.
getJobInstanceId
());
config
.
setClusterId
(
jobInstance
.
getClusterId
());
config
.
setClusterId
(
jobInstance
.
getClusterId
());
}
}
}
else
if
(
GatewayType
.
LOCAL
.
equalsValue
(
task
.
getType
()))
{
config
.
setClusterId
(
null
);
config
.
setClusterConfigurationId
(
null
);
}
else
{
}
else
{
Optional
.
ofNullable
(
task
.
getClusterId
()).
ifPresent
(
config:
:
setClusterId
);
Optional
.
ofNullable
(
task
.
getClusterId
()).
ifPresent
(
config:
:
setClusterId
);
}
}
log
.
info
(
"Init remote cluster"
);
log
.
info
(
"Init remote cluster"
);
try
{
try
{
Optional
.
ofNullable
(
config
.
getClusterId
()).
ifPresent
(
i
->
{
config
.
setAddress
(
clusterInstanceService
.
buildEnvironmentAddress
(
config
));
config
.
setAddress
(
clusterInstanceService
.
buildEnvironmentAddress
(
config
.
isUseRemote
(),
i
));
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Init remote cluster error"
,
e
);
log
.
error
(
"Init remote cluster error"
,
e
);
}
}
...
...
dinky-common/src/main/java/org/dinky/utils/URLUtils.java
View file @
963cb1d2
...
@@ -26,6 +26,7 @@ import java.net.MalformedURLException;
...
@@ -26,6 +26,7 @@ import java.net.MalformedURLException;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLConnection
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Random
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -103,4 +104,9 @@ public class URLUtils {
...
@@ -103,4 +104,9 @@ public class URLUtils {
return
""
;
return
""
;
}
}
}
}
public
static
int
getRandomPort
()
{
Random
random
=
new
Random
();
return
random
.
nextInt
(
65536
);
}
}
}
dinky-core/src/main/java/org/dinky/constant/FlinkConstant.java
View file @
963cb1d2
...
@@ -25,17 +25,8 @@ package org.dinky.constant;
...
@@ -25,17 +25,8 @@ package org.dinky.constant;
* @since 2021/5/25 14:39
* @since 2021/5/25 14:39
*/
*/
public
interface
FlinkConstant
{
public
interface
FlinkConstant
{
/** flink端口 */
Integer
FLINK_REST_DEFAULT_PORT
=
8081
;
/** flink会话默认个数 */
Integer
DEFAULT_SESSION_COUNT
=
256
;
/** flink加载因子 */
Double
DEFAULT_FACTOR
=
0.75
;
/** 本地模式host */
/** 本地模式host */
String
LOCAL_HOST
=
"localhost
:8081
"
;
String
LOCAL_HOST
=
"localhost"
;
/** changlog op */
/** changlog op */
String
OP
=
"op"
;
String
OP
=
"op"
;
String
DEFAULT_FLINK_HOME
=
"/opt/flink"
;
}
}
dinky-core/src/main/java/org/dinky/executor/ExecutorConfig.java
View file @
963cb1d2
...
@@ -90,6 +90,13 @@ public class ExecutorConfig {
...
@@ -90,6 +90,13 @@ public class ExecutorConfig {
notes
=
"Flag indicating whether to use batch model"
)
notes
=
"Flag indicating whether to use batch model"
)
private
boolean
useBatchModel
;
private
boolean
useBatchModel
;
@ApiModelProperty
(
value
=
"Whether to only build plans"
,
dataType
=
"boolean"
,
example
=
"true"
,
notes
=
"Build plan only"
)
private
boolean
isPlan
;
@ApiModelProperty
(
@ApiModelProperty
(
value
=
"Checkpoint interval"
,
value
=
"Checkpoint interval"
,
dataType
=
"Integer"
,
dataType
=
"Integer"
,
...
@@ -263,6 +270,14 @@ public class ExecutorConfig {
...
@@ -263,6 +270,14 @@ public class ExecutorConfig {
return
Asserts
.
isNotNull
(
this
.
getJarFiles
());
return
Asserts
.
isNotNull
(
this
.
getJarFiles
());
}
}
public
boolean
isPlan
()
{
return
isPlan
;
}
public
void
setPlan
(
boolean
plan
)
{
isPlan
=
plan
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
String
.
format
(
return
String
.
format
(
...
...
dinky-core/src/main/java/org/dinky/executor/LocalBatchExecutor.java
View file @
963cb1d2
...
@@ -47,13 +47,12 @@ public class LocalBatchExecutor extends Executor {
...
@@ -47,13 +47,12 @@ public class LocalBatchExecutor extends Executor {
.
map
(
FileUtil:
:
getAbsolutePath
)
.
map
(
FileUtil:
:
getAbsolutePath
)
.
collect
(
Collectors
.
joining
(
","
)));
.
collect
(
Collectors
.
joining
(
","
)));
}
}
if
(
executorConfig
.
isValidConfig
())
{
if
(
!
executorConfig
.
isPlan
())
{
Configuration
configuration
=
Configuration
.
fromMap
(
executorConfig
.
getConfig
());
Configuration
configuration
=
Configuration
.
fromMap
(
executorConfig
.
getConfig
());
if
(
configuration
.
contains
(
RestOptions
.
PORT
))
{
if
(!
configuration
.
contains
(
RestOptions
.
PORT
))
{
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironmentWithWebUI
(
configuration
);
configuration
.
set
(
RestOptions
.
PORT
,
executorConfig
.
getPort
());
}
else
{
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
(
configuration
);
}
}
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
(
configuration
);
}
else
{
}
else
{
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
();
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
();
}
}
...
...
dinky-core/src/main/java/org/dinky/executor/LocalStreamExecutor.java
View file @
963cb1d2
...
@@ -47,13 +47,12 @@ public class LocalStreamExecutor extends Executor {
...
@@ -47,13 +47,12 @@ public class LocalStreamExecutor extends Executor {
.
map
(
FileUtil:
:
getAbsolutePath
)
.
map
(
FileUtil:
:
getAbsolutePath
)
.
collect
(
Collectors
.
joining
(
","
)));
.
collect
(
Collectors
.
joining
(
","
)));
}
}
if
(
executorConfig
.
isValidConfig
())
{
if
(
!
executorConfig
.
isPlan
())
{
Configuration
configuration
=
Configuration
.
fromMap
(
executorConfig
.
getConfig
());
Configuration
configuration
=
Configuration
.
fromMap
(
executorConfig
.
getConfig
());
if
(
configuration
.
contains
(
RestOptions
.
PORT
))
{
if
(!
configuration
.
contains
(
RestOptions
.
PORT
))
{
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironmentWithWebUI
(
configuration
);
configuration
.
set
(
RestOptions
.
PORT
,
executorConfig
.
getPort
());
}
else
{
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
(
configuration
);
}
}
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
(
configuration
);
}
else
{
}
else
{
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
();
this
.
environment
=
StreamExecutionEnvironment
.
createLocalEnvironment
();
}
}
...
...
dinky-core/src/main/java/org/dinky/job/JobManager.java
View file @
963cb1d2
...
@@ -177,6 +177,7 @@ public class JobManager {
...
@@ -177,6 +177,7 @@ public class JobManager {
useRestAPI
=
SystemConfiguration
.
getInstances
().
isUseRestAPI
();
useRestAPI
=
SystemConfiguration
.
getInstances
().
isUseRestAPI
();
sqlSeparator
=
SystemConfiguration
.
getInstances
().
getSqlSeparator
();
sqlSeparator
=
SystemConfiguration
.
getInstances
().
getSqlSeparator
();
executorConfig
=
config
.
getExecutorSetting
();
executorConfig
=
config
.
getExecutorSetting
();
executorConfig
.
setPlan
(
isPlanMode
);
executor
=
ExecutorFactory
.
buildExecutor
(
executorConfig
);
executor
=
ExecutorFactory
.
buildExecutor
(
executorConfig
);
ExecutorContext
.
setExecutor
(
executor
);
ExecutorContext
.
setExecutor
(
executor
);
}
}
...
...
script/bin/auto.sh
View file @
963cb1d2
...
@@ -5,7 +5,7 @@ FLINK_VERSION=${2:-1.14}
...
@@ -5,7 +5,7 @@ FLINK_VERSION=${2:-1.14}
JAR_NAME
=
"dinky-admin"
JAR_NAME
=
"dinky-admin"
# Use FLINK_HOME:
# Use FLINK_HOME:
CLASS_PATH
=
".:./lib/*:config:./plugins/*:./customJar/*:./plugins/flink
${
FLINK_VERSION
}
/*"
CLASS_PATH
=
".:./lib/*:config:./plugins/*:./customJar/*:./plugins/flink
${
FLINK_VERSION
}
/
dinky/*:./plugins/flink
${
FLINK_VERSION
}
/
*"
PID_FILE
=
"dinky.pid"
PID_FILE
=
"dinky.pid"
...
...
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