Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read timeout for how long we query beans #168

Merged
merged 5 commits into from
Mar 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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