Skip to content

Commit

Permalink
Merge pull request #168 from DataDog/nick/add_read_timeout
Browse files Browse the repository at this point in the history
Add read timeout for how long we query beans
  • Loading branch information
nmuesch authored Mar 7, 2018
2 parents 855ac76 + 25b7061 commit 030d70e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/datadog/jmxfetch/RemoteConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public class RemoteConnection extends Connection {
private String password;
private String path = "jmxrmi";
private String jmx_url;
private String rmi_timeout;
private static final String TRUST_STORE_PATH_KEY = "trust_store_path";
private static final String TRUST_STORE_PASSWORD_KEY = "trust_store_password";
private static final String DEFAULT_RMI_RESPONSE_TIMEOUT = "15000"; //Match the collection period default
private final static Logger LOGGER = Logger.getLogger(Connection.class.getName());

public RemoteConnection(LinkedHashMap<String, Object> connectionParams)
Expand All @@ -33,6 +35,10 @@ public RemoteConnection(LinkedHashMap<String, Object> connectionParams)
user = (String) connectionParams.get("user");
password = (String) connectionParams.get("password");
jmx_url = (String) connectionParams.get("jmx_url");
rmi_timeout = (String) connectionParams.get("rmi_client_timeout");
if (rmi_timeout == null) {
rmi_timeout = DEFAULT_RMI_RESPONSE_TIMEOUT;
}
if (connectionParams.containsKey("path")){
path = (String) connectionParams.get("path");
}
Expand All @@ -53,6 +59,10 @@ public RemoteConnection(LinkedHashMap<String, Object> connectionParams)
}

}

//Set an RMI timeout so we don't get stuck waiting for a bean to report a value
System.setProperty("sun.rmi.transport.tcp.responseTimeout", rmi_timeout);

createConnection();

}
Expand Down

0 comments on commit 030d70e

Please sign in to comment.