|
|
@ -30,7 +30,6 @@ import cn.hippo4j.config.model.biz.adapter.ThreadPoolAdapterReqDTO;
|
|
|
|
import cn.hippo4j.config.model.biz.adapter.ThreadPoolAdapterRespDTO;
|
|
|
|
import cn.hippo4j.config.model.biz.adapter.ThreadPoolAdapterRespDTO;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +37,6 @@ import java.util.*;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.hippo4j.common.constant.Constants.HTTP_EXECUTE_TIMEOUT;
|
|
|
|
|
|
|
|
import static cn.hippo4j.common.constant.Constants.IDENTIFY_SLICER_SYMBOL;
|
|
|
|
import static cn.hippo4j.common.constant.Constants.IDENTIFY_SLICER_SYMBOL;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -49,7 +47,7 @@ import static cn.hippo4j.common.constant.Constants.IDENTIFY_SLICER_SYMBOL;
|
|
|
|
public class ThreadPoolAdapterService {
|
|
|
|
public class ThreadPoolAdapterService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Map<mark, Map<tenantItem, Map<threadPoolKey, List<ThreadPoolAdapterState>>>>
|
|
|
|
* Map<mark, Map<tenantItem, Map<threadPoolKey, List<ThreadPoolAdapterState>>>>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static final Map<String, Map<String, Map<String, List<ThreadPoolAdapterState>>>> THREAD_POOL_ADAPTER_MAP = new ConcurrentHashMap<>();
|
|
|
|
private static final Map<String, Map<String, Map<String, List<ThreadPoolAdapterState>>>> THREAD_POOL_ADAPTER_MAP = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
|
@ -98,18 +96,23 @@ public class ThreadPoolAdapterService {
|
|
|
|
List<String> addressList = actual.stream().map(ThreadPoolAdapterState::getClientAddress).collect(Collectors.toList());
|
|
|
|
List<String> addressList = actual.stream().map(ThreadPoolAdapterState::getClientAddress).collect(Collectors.toList());
|
|
|
|
List<ThreadPoolAdapterRespDTO> result = new ArrayList<>(addressList.size());
|
|
|
|
List<ThreadPoolAdapterRespDTO> result = new ArrayList<>(addressList.size());
|
|
|
|
addressList.forEach(each -> {
|
|
|
|
addressList.forEach(each -> {
|
|
|
|
String urlString = new StringBuilder()
|
|
|
|
StringBuilder builder = StringUtil.createBuilder("http://", each, "/adapter/thread-pool/info");
|
|
|
|
.append("http://")
|
|
|
|
|
|
|
|
.append(each)
|
|
|
|
|
|
|
|
.append("/adapter/thread-pool/info")
|
|
|
|
|
|
|
|
.toString();
|
|
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
param.put("mark", requestParameter.getMark());
|
|
|
|
param.put("mark", requestParameter.getMark());
|
|
|
|
param.put("threadPoolKey", requestParameter.getThreadPoolKey());
|
|
|
|
param.put("threadPoolKey", requestParameter.getThreadPoolKey());
|
|
|
|
|
|
|
|
List<String> paramKey = new ArrayList<>(param.keySet());
|
|
|
|
|
|
|
|
for (int i = 0; i < paramKey.size(); i++) {
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
|
|
builder.append("?");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
builder.append("&");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String s = paramKey.get(i);
|
|
|
|
|
|
|
|
builder.append(StringUtil.newBuilder(s, "={", s, "}"));
|
|
|
|
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
RestTemplate template = new RestTemplate();
|
|
|
|
RestTemplate template = new RestTemplate();
|
|
|
|
String resultStr = template.getForObject(urlString, String.class, param);
|
|
|
|
String resultStr = template.getForObject(builder.toString(), String.class, param);
|
|
|
|
if (StringUtil.isNotBlank(resultStr)) {
|
|
|
|
if (StringUtil.isNotBlank(resultStr)) {
|
|
|
|
Result<ThreadPoolAdapterRespDTO> restResult = JSONUtil.parseObject(resultStr, new TypeReference<Result<ThreadPoolAdapterRespDTO>>() {
|
|
|
|
Result<ThreadPoolAdapterRespDTO> restResult = JSONUtil.parseObject(resultStr, new TypeReference<Result<ThreadPoolAdapterRespDTO>>() {
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -131,22 +134,16 @@ public class ThreadPoolAdapterService {
|
|
|
|
return actual.keySet();
|
|
|
|
return actual.keySet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new HashSet();
|
|
|
|
return new HashSet<>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void remove(String identify) {
|
|
|
|
public static void remove(String identify) {
|
|
|
|
synchronized (ThreadPoolAdapterService.class) {
|
|
|
|
synchronized (ThreadPoolAdapterService.class) {
|
|
|
|
THREAD_POOL_ADAPTER_MAP.values().forEach(each -> each.forEach((key, val) -> {
|
|
|
|
THREAD_POOL_ADAPTER_MAP.values().forEach(each -> each.forEach((key, val) ->
|
|
|
|
val.forEach((threadPoolKey, states) -> {
|
|
|
|
val.forEach((threadPoolKey, states) ->
|
|
|
|
Iterator<ThreadPoolAdapterState> iterator = states.iterator();
|
|
|
|
states.removeIf(adapterState -> Objects.equals(adapterState.getIdentify(), identify))
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
)
|
|
|
|
ThreadPoolAdapterState adapterState = iterator.next();
|
|
|
|
));
|
|
|
|
if (Objects.equals(adapterState.getIdentify(), identify)) {
|
|
|
|
|
|
|
|
iterator.remove();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|