fix(yarn-query): 修复没有关闭的 close
This commit is contained in:
@@ -2,6 +2,7 @@ package com.lanyuanxiaoyao.service.yarn.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.core.util.URLUtil;
|
import cn.hutool.core.util.URLUtil;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@@ -42,8 +43,9 @@ public class JobServiceImpl implements JobService {
|
|||||||
@Override
|
@Override
|
||||||
public ImmutableList<YarnApplication> list() throws JsonProcessingException {
|
public ImmutableList<YarnApplication> list() throws JsonProcessingException {
|
||||||
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/apps");
|
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/apps");
|
||||||
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
|
try (HttpResponse response = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute()) {
|
||||||
return mapper.readValue(body, ApplicationsListResponse.class).getApps().getApp();
|
return mapper.readValue(response.body(), ApplicationsListResponse.class).getApps().getApp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = "job-list", sync = true, key = "#{methodName+name}")
|
@Cacheable(value = "job-list", sync = true, key = "#{methodName+name}")
|
||||||
@@ -69,7 +71,8 @@ public class JobServiceImpl implements JobService {
|
|||||||
@Override
|
@Override
|
||||||
public YarnApplication detail(String applicationId) throws JsonProcessingException {
|
public YarnApplication detail(String applicationId) throws JsonProcessingException {
|
||||||
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/apps/" + applicationId);
|
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/apps/" + applicationId);
|
||||||
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
|
try (HttpResponse response = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute()) {
|
||||||
return mapper.readValue(body, ApplicationDetailResponse.class).getApp();
|
return mapper.readValue(response.body(), ApplicationDetailResponse.class).getApp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user