APIClient: Fix error handling if connection to API server fails
Running 'nodetool status' now reports the following if the JMX proxy is not able to connect to an API server: nodetool: Unable to connect to Scylla API server: java.net.ConnectException: Connection refused See 'nodetool help' or 'nodetool help <command>'. instead of the scary-looking: error: javax.ws.rs.ProcessingException (no security manager: RMI class loader disabled) -- StackTrace -- java.lang.ClassNotFoundException: javax.ws.rs.ProcessingException (no security manager: RMI class loader disabled) at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:393) at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:185) at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:637) at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:264) at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:214) That happens because the MBean propagates a 'javax.ws.rs.ProcessingException' to nodetool which does not have it in it's classpath and loading via RMI fails. Fixes #25. Message-Id: <1457697628-31792-1-git-send-email-penberg@scylladb.com>
This commit is contained in:
parent
a38bbfd603
commit
02e0598506
@ -23,6 +23,7 @@ import javax.json.JsonReaderFactory;
|
|||||||
import javax.json.JsonString;
|
import javax.json.JsonString;
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
import javax.management.openmbean.TabularDataSupport;
|
import javax.management.openmbean.TabularDataSupport;
|
||||||
|
import javax.ws.rs.ProcessingException;
|
||||||
import javax.ws.rs.client.Client;
|
import javax.ws.rs.client.Client;
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
@ -141,6 +142,7 @@ public class APIClient {
|
|||||||
|
|
||||||
public String getRawValue(String string,
|
public String getRawValue(String string,
|
||||||
MultivaluedMap<String, String> queryParams, long duration) {
|
MultivaluedMap<String, String> queryParams, long duration) {
|
||||||
|
try {
|
||||||
if (string.equals("")) {
|
if (string.equals("")) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -162,6 +164,9 @@ public class APIClient {
|
|||||||
cache.put(key, new CacheEntry(res));
|
cache.put(key, new CacheEntry(res));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
} catch (ProcessingException e) {
|
||||||
|
throw new IllegalStateException("Unable to connect to Scylla API server: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRawValue(String string,
|
public String getRawValue(String string,
|
||||||
|
Loading…
Reference in New Issue
Block a user