[dev] finished omsOnlineLog, try to opt stop instance

This commit is contained in:
tjq 2020-05-07 20:54:16 +08:00
parent c074f64d30
commit 9ad07c5b8d
2 changed files with 9 additions and 11 deletions

View File

@ -97,7 +97,7 @@ public class InstanceLogService {
/**
* 获取任务实例运行日志默认存在本地数据需要由生成完成请求的路由与转发
* @param instanceId 任务实例ID
* @param index 页码
* @param index 页码从0开始
* @return 文本字符串
*/
public StringPage fetchInstanceLog(Long instanceId, long index) {

View File

@ -95,18 +95,16 @@ public class InstanceController {
return ResultDTO.success(instanceLogService.fetchInstanceLog(instanceId, index));
}
@GetMapping("/downloadLogUrl")
public ResultDTO<String> getDownloadUrl(Long instanceId) {
String targetServer = getTargetServer(instanceId);
String ip = targetServer.split(":")[0];
String url = "http://" + ip + ":" + port + "/instance/downloadLog?instanceId=" + instanceId;
return ResultDTO.success(url);
}
@GetMapping("/downloadLog")
public void downloadLogFile(Long instanceId , HttpServletResponse response) throws Exception {
String targetServer = getTargetServer(instanceId);
// 转发HTTP请求如果使用Akka则需要传输两次而转发HTTP请求只需要传输一次""数据包
if (!OhMyServer.getActorSystemAddress().equals(targetServer)) {
String ip = targetServer.split(":")[0];
String url = "http://" + ip + ":" + port + "/instance/downloadLog?instanceId=" + instanceId;
try {
response.sendRedirect(url);
}catch (Exception ignore) {
}
}
File file = instanceLogService.downloadInstanceLog(instanceId);
response.setContentType("application/octet-stream");