Unverified Commit c6e87d9d authored by windWheel's avatar windWheel Committed by GitHub

Fix cluster submission taskId is empty (#862)

* The bug that the cluster information cannot be obtained in the savepoint save list

* Add taskId in case dlink maintains sql

* format code

* enhance manage logic

* 1. fix taskId is 0
2. reformat code

* reformat code

* refactor imports
parent 6a58b9a7
...@@ -29,6 +29,10 @@ import org.slf4j.Logger; ...@@ -29,6 +29,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.dlink.api.FlinkAPI; import com.dlink.api.FlinkAPI;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
...@@ -75,10 +79,6 @@ import com.dlink.session.SessionInfo; ...@@ -75,10 +79,6 @@ import com.dlink.session.SessionInfo;
import com.dlink.session.SessionPool; import com.dlink.session.SessionPool;
import com.dlink.sql.FlinkQuery; import com.dlink.sql.FlinkQuery;
import com.dlink.utils.RunTimeUtil; import com.dlink.utils.RunTimeUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
/** /**
* StudioServiceImpl * StudioServiceImpl
...@@ -101,6 +101,7 @@ public class StudioServiceImpl implements StudioService { ...@@ -101,6 +101,7 @@ public class StudioServiceImpl implements StudioService {
private DataBaseService dataBaseService; private DataBaseService dataBaseService;
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
@Autowired @Autowired
private FragmentVariableService fragmentVariableService; private FragmentVariableService fragmentVariableService;
...@@ -294,11 +295,7 @@ public class StudioServiceImpl implements StudioService { ...@@ -294,11 +295,7 @@ public class StudioServiceImpl implements StudioService {
@Override @Override
public boolean clearSession(String session) { public boolean clearSession(String session) {
if (SessionPool.remove(session) > 0) { return SessionPool.remove(session) > 0;
return true;
} else {
return false;
}
} }
@Override @Override
...@@ -360,24 +357,32 @@ public class StudioServiceImpl implements StudioService { ...@@ -360,24 +357,32 @@ public class StudioServiceImpl implements StudioService {
@Override @Override
public boolean savepoint(Integer taskId, Integer clusterId, String jobId, String savePointType, String name) { public boolean savepoint(Integer taskId, Integer clusterId, String jobId, String savePointType, String name) {
Cluster cluster = clusterService.getById(clusterId); Cluster cluster = clusterService.getById(clusterId);
Asserts.checkNotNull(cluster, "该集群不存在"); Asserts.checkNotNull(cluster, "该集群不存在");
boolean useGateway = false; boolean useGateway = false;
JobConfig jobConfig = new JobConfig(); JobConfig jobConfig = new JobConfig();
jobConfig.setAddress(cluster.getJobManagerHost()); jobConfig.setAddress(cluster.getJobManagerHost());
jobConfig.setType(cluster.getType()); jobConfig.setType(cluster.getType());
//如果用户选择用dlink平台来托管集群信息 说明任务一定是从dlink发起提交的
if (Asserts.isNotNull(cluster.getClusterConfigurationId())) { if (Asserts.isNotNull(cluster.getClusterConfigurationId())) {
Map<String, Object> gatewayConfig = clusterConfigurationService.getGatewayConfig(cluster.getClusterConfigurationId()); Map<String, Object> gatewayConfig = clusterConfigurationService.getGatewayConfig(cluster.getClusterConfigurationId());
jobConfig.buildGatewayConfig(gatewayConfig); jobConfig.buildGatewayConfig(gatewayConfig);
jobConfig.getGatewayConfig().getClusterConfig().setAppId(cluster.getName()); jobConfig.getGatewayConfig().getClusterConfig().setAppId(cluster.getName());
jobConfig.setTaskId(cluster.getTaskId()); jobConfig.setTaskId(cluster.getTaskId());
useGateway = true; useGateway = true;
} else { }
//用户选择外部的平台来托管集群信息,但是集群上的任务不一定是通过dlink提交的
else {
jobConfig.setTaskId(taskId); jobConfig.setTaskId(taskId);
} }
JobManager jobManager = JobManager.build(jobConfig); JobManager jobManager = JobManager.build(jobConfig);
jobManager.setUseGateway(useGateway); jobManager.setUseGateway(useGateway);
SavePointResult savePointResult = jobManager.savepoint(jobId, savePointType, null); SavePointResult savePointResult = jobManager.savepoint(jobId, savePointType, null);
if (Asserts.isNotNull(savePointResult)) { if (Asserts.isNotNull(savePointResult)) {
if (jobConfig.getTaskId().equals(0)) {
return true;
}
for (JobInfo item : savePointResult.getJobInfos()) { for (JobInfo item : savePointResult.getJobInfos()) {
if (Asserts.isEqualsIgnoreCase(jobId, item.getJobId()) && Asserts.isNotNull(jobConfig.getTaskId())) { if (Asserts.isEqualsIgnoreCase(jobId, item.getJobId()) && Asserts.isNotNull(jobConfig.getTaskId())) {
Savepoints savepoints = new Savepoints(); Savepoints savepoints = new Savepoints();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment