Commit 8d250145 authored by sml's avatar sml

azkaban登录调整

parent 7bfc4873
...@@ -9,9 +9,9 @@ import java.util.Map; ...@@ -9,9 +9,9 @@ import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.client.SimpleClientHttpRequestFactory;
...@@ -22,6 +22,7 @@ import org.springframework.web.client.RestTemplate; ...@@ -22,6 +22,7 @@ import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.support.spring.FastJsonRedisSerializer;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.jz.common.utils.web.HttpClientUtils; import com.jz.common.utils.web.HttpClientUtils;
import com.jz.common.utils.web.SessionUtils; import com.jz.common.utils.web.SessionUtils;
...@@ -43,19 +44,21 @@ public class AzkabanApiUtils2 { ...@@ -43,19 +44,21 @@ public class AzkabanApiUtils2 {
private String userName; private String userName;
private String password; private String password;
@Autowired private RedisTemplate redisTemplate;
RedisTemplate<String,SSOUserInfo> redisTemplate; private static final StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
private static final FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(SSOUserInfo.class);
public AzkabanApiUtils2(String azkabanServerUrl, String userName, String password) { public AzkabanApiUtils2(String azkabanServerUrl, String userName, String password, RedisTemplate<String,SSOUserInfo> redisTemplate) {
this(azkabanServerUrl); this(azkabanServerUrl, redisTemplate);
this.userName = userName; this.userName = userName;
this.password = password; this.password = password;
} }
public AzkabanApiUtils2(String azkabanServerUrl) { public AzkabanApiUtils2(String azkabanServerUrl, RedisTemplate<String,SSOUserInfo> redisTemplate) {
this.azkabanServerUrl = azkabanServerUrl; this.azkabanServerUrl = azkabanServerUrl;
this.userName = "admin"; this.userName = "admin";
this.password = "admin"; this.password = "admin";
this.redisTemplate = redisTemplate;
} }
/** /**
...@@ -101,13 +104,15 @@ public class AzkabanApiUtils2 { ...@@ -101,13 +104,15 @@ public class AzkabanApiUtils2 {
LOGGER.error(azkabanServerUrl+"-----"+linkedMultiValueMap+" sessionId 为空"); LOGGER.error(azkabanServerUrl+"-----"+linkedMultiValueMap+" sessionId 为空");
throw new RuntimeException("登陆失败"); throw new RuntimeException("登陆失败");
}*/ }*/
String sessionId = SessionUtils.getSession().getId(); //"dcfc608c-c58a-45b7-adc7-9902b652496e"; String sessionId = SessionUtils.getSession().getId();
//String sessionId = "f0d06f4a-874c-4dfc-8959-101b6add6bf5";
//通过redis方式登录Azkaban //通过redis方式登录Azkaban
String redisKey = "spring:sessions:sessions:"+sessionId; String redisKey = "spring:sessions:sessions:"+sessionId;
SSOUserInfo ssoUserInfo = redisTemplate.opsForValue().get(redisKey); SSOUserInfo ssoUserInfo = (SSOUserInfo) redisTemplate.opsForValue().get(redisKey);
if (ssoUserInfo==null) {
if (ssoUserInfo == null) {
redisTemplate.setKeySerializer(stringRedisSerializer);
redisTemplate.setValueSerializer(fastJsonRedisSerializer);
redisTemplate.opsForValue().set(redisKey, getSSOuserInfo()); redisTemplate.opsForValue().set(redisKey, getSSOuserInfo());
} }
...@@ -652,7 +657,7 @@ public class AzkabanApiUtils2 { ...@@ -652,7 +657,7 @@ public class AzkabanApiUtils2 {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2("http://119.23.32.151:8083"); AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2("http://119.23.32.151:8083", null);
boolean dw_test = azkabanApiUtils.checkFlowExists("dw_test", "123"); boolean dw_test = azkabanApiUtils.checkFlowExists("dw_test", "123");
System.err.println(dw_test); System.err.println(dw_test);
} }
......
...@@ -10,6 +10,7 @@ import java.util.Map; ...@@ -10,6 +10,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.data.redis.core.RedisTemplate;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.jz.common.enums.NodeChangeTypeEnum; import com.jz.common.enums.NodeChangeTypeEnum;
...@@ -21,6 +22,7 @@ import com.jz.dmp.modules.model.DmpNavigationTree; ...@@ -21,6 +22,7 @@ import com.jz.dmp.modules.model.DmpNavigationTree;
import com.jz.dmp.modules.model.DmpProject; import com.jz.dmp.modules.model.DmpProject;
import com.jz.dmp.modules.model.DmpProjectSystemInfo; import com.jz.dmp.modules.model.DmpProjectSystemInfo;
import com.jz.dmp.modules.model.DmpWorkFlowSubmitDetails; import com.jz.dmp.modules.model.DmpWorkFlowSubmitDetails;
import com.jz.dmp.modules.model.SSOUserInfo;
import com.jz.dmp.modules.service.DmpDevelopTaskService; import com.jz.dmp.modules.service.DmpDevelopTaskService;
import com.jz.dmp.modules.service.DmpNavigationTreeService; import com.jz.dmp.modules.service.DmpNavigationTreeService;
import com.jz.dmp.modules.service.DmpWorkFlowSubmitDetailsService; import com.jz.dmp.modules.service.DmpWorkFlowSubmitDetailsService;
...@@ -57,6 +59,8 @@ public class FlowParseTool { ...@@ -57,6 +59,8 @@ public class FlowParseTool {
private DmpWorkFlowSubmitDetailsService dmpWorkFlowSubmitDetailsService; private DmpWorkFlowSubmitDetailsService dmpWorkFlowSubmitDetailsService;
private RedisTemplate<String,SSOUserInfo> redisTemplate;
/** /**
* 流程属性 * 流程属性
*/ */
...@@ -104,12 +108,14 @@ public class FlowParseTool { ...@@ -104,12 +108,14 @@ public class FlowParseTool {
DmpProjectSystemInfo publishedToProjectSystemInfo, DmpProjectSystemInfo publishedToProjectSystemInfo,
DmpDevelopTaskService dmpDevelopTaskService, DmpDevelopTaskService dmpDevelopTaskService,
DmpNavigationTreeService dmpNavigationTreeService, DmpNavigationTreeService dmpNavigationTreeService,
DmpWorkFlowSubmitDetailsService dmpWorkFlowSubmitDetailsService) { DmpWorkFlowSubmitDetailsService dmpWorkFlowSubmitDetailsService,
RedisTemplate<String,SSOUserInfo> redisTemplate) {
this(flowPro, dmpWorkFlowSubmitDetailsService); this(flowPro, dmpWorkFlowSubmitDetailsService);
this.publishedToProject = publishedToProject; this.publishedToProject = publishedToProject;
//this.publishedToProjectSystemInfo = publishedToProjectSystemInfo; //this.publishedToProjectSystemInfo = publishedToProjectSystemInfo;
this.dmpDevelopTaskService = dmpDevelopTaskService; this.dmpDevelopTaskService = dmpDevelopTaskService;
this.dmpNavigationTreeService = dmpNavigationTreeService; this.dmpNavigationTreeService = dmpNavigationTreeService;
this.redisTemplate = redisTemplate;
} }
/** /**
...@@ -124,12 +130,14 @@ public class FlowParseTool { ...@@ -124,12 +130,14 @@ public class FlowParseTool {
DmpProjectConfigInfoDto dmpProjectConfigInfoDto, DmpProjectConfigInfoDto dmpProjectConfigInfoDto,
DmpDevelopTaskService dmpDevelopTaskService, DmpDevelopTaskService dmpDevelopTaskService,
DmpNavigationTreeService dmpNavigationTreeService, DmpNavigationTreeService dmpNavigationTreeService,
DmpWorkFlowSubmitDetailsService dmpWorkFlowSubmitDetailsService) { DmpWorkFlowSubmitDetailsService dmpWorkFlowSubmitDetailsService,
RedisTemplate<String,SSOUserInfo> redisTemplate) {
this(flowPro, dmpWorkFlowSubmitDetailsService); this(flowPro, dmpWorkFlowSubmitDetailsService);
this.publishedToProject = publishedToProject; this.publishedToProject = publishedToProject;
this.dmpProjectConfigInfoDto = dmpProjectConfigInfoDto; this.dmpProjectConfigInfoDto = dmpProjectConfigInfoDto;
this.dmpDevelopTaskService = dmpDevelopTaskService; this.dmpDevelopTaskService = dmpDevelopTaskService;
this.dmpNavigationTreeService = dmpNavigationTreeService; this.dmpNavigationTreeService = dmpNavigationTreeService;
this.redisTemplate = redisTemplate;
} }
private void parse() { private void parse() {
...@@ -456,7 +464,7 @@ public class FlowParseTool { ...@@ -456,7 +464,7 @@ public class FlowParseTool {
//上次zip包到azkaban //上次zip包到azkaban
String localTaskZipAbsolutePath = localTaskZipPath + "/" + localZipTargetFileName; String localTaskZipAbsolutePath = localTaskZipPath + "/" + localZipTargetFileName;
String azkabanApiUrl = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanMonitorUrl(); String azkabanApiUrl = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanMonitorUrl();
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanApiUrl); AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanApiUrl, redisTemplate);
return azkabanApiUtils.loginCreateProjectuploadZipAndSchedule("jz_workflow_new_" + publishedToProjectId, publishedToProject.getProjectDesc(), localTaskZipAbsolutePath, flowPro); return azkabanApiUtils.loginCreateProjectuploadZipAndSchedule("jz_workflow_new_" + publishedToProjectId, publishedToProject.getProjectDesc(), localTaskZipAbsolutePath, flowPro);
} }
...@@ -591,7 +599,7 @@ public class FlowParseTool { ...@@ -591,7 +599,7 @@ public class FlowParseTool {
String subProcessFlowName = flowNode.getScript(); String subProcessFlowName = flowNode.getScript();
//检查子流程是否存在 todo //检查子流程是否存在 todo
String azkabanApiUrl = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanMonitorUrl(); String azkabanApiUrl = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanMonitorUrl();
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanApiUrl); AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanApiUrl, redisTemplate);
boolean flowExists = azkabanApiUtils.checkFlowExists("jz_workflow_" + flowPro.getPublishedToProjectId(), subProcessFlowName); boolean flowExists = azkabanApiUtils.checkFlowExists("jz_workflow_" + flowPro.getPublishedToProjectId(), subProcessFlowName);
if (!flowExists) { if (!flowExists) {
throw new RuntimeException("节点:" + flowNode.getNodeName() + "设置的子流程:" + subProcessFlowName + "不存在,请先发布" + subProcessFlowName); throw new RuntimeException("节点:" + flowNode.getNodeName() + "设置的子流程:" + subProcessFlowName + "不存在,请先发布" + subProcessFlowName);
......
...@@ -11,6 +11,7 @@ public class DmpWorkFlowSubmitDetails implements Serializable { ...@@ -11,6 +11,7 @@ public class DmpWorkFlowSubmitDetails implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id;
private Long scheduleProjectId; private Long scheduleProjectId;
private String scheduleFlowName; private String scheduleFlowName;
private String nodeName; private String nodeName;
...@@ -24,6 +25,14 @@ public class DmpWorkFlowSubmitDetails implements Serializable { ...@@ -24,6 +25,14 @@ public class DmpWorkFlowSubmitDetails implements Serializable {
private String createTimeStr; private String createTimeStr;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getScheduleProjectId() { public Long getScheduleProjectId() {
return scheduleProjectId; return scheduleProjectId;
} }
......
...@@ -4,6 +4,7 @@ import java.util.Date; ...@@ -4,6 +4,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -21,6 +22,7 @@ import com.jz.dmp.modules.dao.projconfig.DmpProjectConfigInfoMapper; ...@@ -21,6 +22,7 @@ import com.jz.dmp.modules.dao.projconfig.DmpProjectConfigInfoMapper;
import com.jz.dmp.modules.model.DmpProject; import com.jz.dmp.modules.model.DmpProject;
import com.jz.dmp.modules.model.DmpProjectSystemInfo; import com.jz.dmp.modules.model.DmpProjectSystemInfo;
import com.jz.dmp.modules.model.DmpWorkFlowSubmitDetails; import com.jz.dmp.modules.model.DmpWorkFlowSubmitDetails;
import com.jz.dmp.modules.model.SSOUserInfo;
import com.jz.dmp.modules.service.DmpDevelopTaskService; import com.jz.dmp.modules.service.DmpDevelopTaskService;
import com.jz.dmp.modules.service.DmpNavigationTreeService; import com.jz.dmp.modules.service.DmpNavigationTreeService;
import com.jz.dmp.modules.service.DmpProjectService; import com.jz.dmp.modules.service.DmpProjectService;
...@@ -58,6 +60,9 @@ public class FlowServiceImpl implements FlowService { ...@@ -58,6 +60,9 @@ public class FlowServiceImpl implements FlowService {
@Autowired @Autowired
private DmpProjectConfigInfoService dmpProjectConfigInfoService; private DmpProjectConfigInfoService dmpProjectConfigInfoService;
@Autowired
private RedisTemplate redisTemplate;
/** /**
*工作流发布 *工作流发布
*/ */
...@@ -89,7 +94,8 @@ public class FlowServiceImpl implements FlowService { ...@@ -89,7 +94,8 @@ public class FlowServiceImpl implements FlowService {
dmpProjectConfigInfoDto, dmpProjectConfigInfoDto,
dmpDevelopTaskService, dmpDevelopTaskService,
dmpNavigationTreeService, dmpNavigationTreeService,
dmpWorkFlowSubmitDetailsService dmpWorkFlowSubmitDetailsService,
redisTemplate
); );
//保存发布信息 //保存发布信息
......
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