|
57 | 57 | public class JolokiaChecker extends ItemChecker { |
58 | 58 |
|
59 | 59 | private static final String JMX_OPERATION = "jmx.operation"; |
60 | | - |
61 | 60 | private static final String JMX_READ = "jmx"; |
| 61 | + private static final int SOCKET_TIMEOUT = 10 * 1000; // wait for at most 10 seconds for a response |
| 62 | + private static final int CONNECTION_TIMEOUT = 5 * 1000; // wait for at most 5 seconds for |
| 63 | + // the connection to be established |
62 | 64 |
|
63 | 65 | private static final Logger logger = LoggerFactory |
64 | 66 | .getLogger(JolokiaChecker.class); |
| 67 | + |
| 68 | + // Performance Metrics |
| 69 | + private static final Histogram _requestSizes = Metrics.newHistogram(JolokiaChecker.class, "request-sizes"); |
| 70 | + private static final Timer _requestTime = Metrics.newTimer(JolokiaChecker.class, "request-time", TimeUnit.MILLISECONDS, TimeUnit.MINUTES); |
65 | 71 |
|
66 | 72 | private J4pClient _j4pClient; |
67 | 73 |
|
68 | 74 | private Map<String, String> _foundKeys = new HashMap<String, String>(); |
69 | 75 | private Map<String, String> _errorKeys = new HashMap<String, String>(); |
70 | | - |
71 | | - // Performance Metrics |
72 | | - private static final Histogram _requestSizes = Metrics.newHistogram(JolokiaChecker.class, "request-sizes"); |
73 | | - private static final Timer _requestTime = Metrics.newTimer(JolokiaChecker.class, "request-time", TimeUnit.MILLISECONDS, TimeUnit.MINUTES); |
74 | 76 |
|
75 | 77 | protected JolokiaChecker(JSONObject request) throws ZabbixException { |
76 | 78 | this(request, null); |
@@ -101,7 +103,8 @@ protected JolokiaChecker(JSONObject request, JmxConfiguration config) throws Zab |
101 | 103 |
|
102 | 104 | logger.debug("Jolokia URL is: " + jolokiaUrl); |
103 | 105 | J4pClientBuilder builder = J4pClient.url(jolokiaUrl) |
104 | | - .connectionTimeout(5000); |
| 106 | + .socketTimeout(SOCKET_TIMEOUT) |
| 107 | + .connectionTimeout(CONNECTION_TIMEOUT); |
105 | 108 |
|
106 | 109 | if (null != username) { |
107 | 110 | builder.user(username).password(password); |
|
0 commit comments