我想对我的云中的许多服务器进行BIT(内置测试)。我需要大超时失败的请求。
我应该如何用Java做到这一点?
尝试以下操作似乎无效。
public class TestNodeAliveness {
public static NodeStatus nodeBIT(String elasticIP) throws ClientProtocolException, IOException {
HttpClient client = new DefaultHttpClient();
client.getParams().setIntParameter("http.connection.timeout", 1);
HttpUriRequest request = new HttpGet("http://192.168.20.43");
HttpResponse response = client.execute(request);
System.out.println(response.toString());
return null;
}
public static void main(String[] args) throws ClientProtocolException, IOException {
nodeBIT("");
}
}
-编辑:澄清正在使用的库-
我正在使用来自Apache的httpclient,这是相关的pom.xml部分
org.apache.httpcomponents
httpclient
4.0.1
jar