I would like to make BIT (built-in tests) on several servers in my cloud. I need a failed request with a large timeout.
How do I do this using java?
Trying to do something like below does not work.
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(""); } }
- EDIT: clarify which library is used -
I am using httpclient from apache, here is the corresponding pom.xml section
<dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.0.1</version> <type>jar</type> </dependency>
Maxim Veksler Jun 08 2018-10-18T00-06-08 18:36
source share