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

Fail cass admin requests when jmx isnt available early #1091

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static <T> T getRemoteBean(
*
* @return
*/
private static boolean testConnection() {
public static boolean testConnection() {
// connecting first time hence return false.
if (tool == null) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public Response cassRefresh(@QueryParam(REST_HEADER_KEYSPACES) String keyspaces)
@GET
@Path("/info")
public Response cassInfo() throws JSONException {
if (!JMXNodeTool.testConnection()) {
return Response.status(503).entity("JMXConnectionException").build();
}
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
Expand All @@ -137,6 +140,9 @@ public Response cassPartitioner() {
@GET
@Path("/ring/{id}")
public Response cassRing(@PathParam("id") String keyspace) throws JSONException {
if (!JMXNodeTool.testConnection()) {
return Response.status(503).entity("JMXConnectionException").build();
}
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
Expand All @@ -150,6 +156,9 @@ public Response cassRing(@PathParam("id") String keyspace) throws JSONException
@GET
@Path("/status")
public Response statusInfo() throws JSONException {
if (!JMXNodeTool.testConnection()) {
return Response.status(503).entity("JMXConnectionException").build();
}
if (!instanceState.isGossipActive() && !instanceState.isNativeTransportActive()) {
// if native is active but gossip isn't we still want to return to show that
// there is a problem. but if both gossip and native are down the instance is
Expand Down Expand Up @@ -228,6 +237,9 @@ public Response cassRepair(
@QueryParam("localDC") boolean localDCOnly,
@DefaultValue("false") @QueryParam("primaryRange") boolean primaryRange)
throws IOException, ExecutionException, InterruptedException {
if (!JMXNodeTool.testConnection()) {
return Response.status(503).entity("JMXConnectionException").build();
}
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
Expand All @@ -242,6 +254,9 @@ public Response cassRepair(
@GET
@Path("/version")
public Response version() {
if (!JMXNodeTool.testConnection()) {
return Response.status(503).entity("JMXConnectionException").build();
}
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
Expand Down
Loading