校验资源池服务器是否可用时,添加超时限制

This commit is contained in:
shiziyuan9527 2020-06-10 16:21:40 +08:00
parent 302d4ea5a3
commit c2f91a140e
2 changed files with 10 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
@ -185,9 +186,15 @@ public class TestResourcePoolService {
private boolean validateNode(NodeDTO node) {
try {
HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setConnectionRequestTimeout(4000);
httpRequestFactory.setConnectTimeout(4000);
httpRequestFactory.setReadTimeout(5000);
restTemplate.setRequestFactory(httpRequestFactory);
ResponseEntity<String> entity = restTemplate.getForEntity(String.format(nodeControllerUrl, node.getIp(), node.getPort()), String.class);
return HttpStatus.OK.equals(entity.getStatusCode());
} catch (Exception e) {
LogUtil.error(e);
return false;
}
}

View File

@ -48,7 +48,9 @@
:title="$t('test_resource_pool.create_resource_pool')"
:visible.sync="createVisible" width="70%"
@closed="closeFunc"
:destroy-on-close="true">
:destroy-on-close="true"
v-loading="result.loading"
>
<el-form :model="form" label-position="right" label-width="100px" size="small" :rules="rule"
ref="createTestResourcePoolForm">
<el-form-item :label="$t('commons.name')" prop="name">