Skip to content

Commit

Permalink
Remove redundant log statements from CassandraAdmin (#902)
Browse files Browse the repository at this point in the history
* CASS-1870 remove dead code, clean imports

* CASS-1870 correct typos

* CASS-1870 Remove noisy log statements from CassandraAdmin. All removed logs are redundant with what
JMXNodeTool produces and sometimes print entire stack traces when the Exception is not a surprise
(i.e., C* is not up yet)
  • Loading branch information
mattl-netflix authored Sep 8, 2020
1 parent 05c8636 commit 9908f29
Showing 1 changed file with 18 additions and 54 deletions.
72 changes: 18 additions & 54 deletions priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
Expand All @@ -44,12 +43,10 @@
import org.slf4j.LoggerFactory;

/** Do general operations. Start/Stop and some JMX node tool commands */
@SuppressWarnings("deprecation")
@Path("/v1/cassadmin")
@Produces(MediaType.APPLICATION_JSON)
public class CassandraAdmin {
private static final String REST_HEADER_KEYSPACES = "keyspaces";
private static final String REST_HEADER_CFS = "cfnames";
private static final String REST_HEADER_TOKEN = "token";
private static final String REST_SUCCESS = "[\"ok\"]";
private static final Logger logger = LoggerFactory.getLogger(CassandraAdmin.class);
Expand All @@ -75,23 +72,23 @@ public CassandraAdmin(

@GET
@Path("/start")
public Response cassStart() throws IOException, InterruptedException, JSONException {
public Response cassStart() throws IOException {
cassProcess.start(true);
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/stop")
public Response cassStop(@DefaultValue("false") @QueryParam("force") boolean force)
throws IOException, InterruptedException, JSONException {
throws IOException {
cassProcess.stop(force);
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/refresh")
public Response cassRefresh(@QueryParam(REST_HEADER_KEYSPACES) String keyspaces)
throws IOException, ExecutionException, InterruptedException, JSONException {
throws IOException, ExecutionException, InterruptedException {
logger.debug("node tool refresh is being called");
if (StringUtils.isBlank(keyspaces))
return Response.status(400).entity("Missing keyspace in request").build();
Expand All @@ -100,8 +97,6 @@ public Response cassRefresh(@QueryParam(REST_HEADER_KEYSPACES) String keyspaces)
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
nodeTool.refresh(Lists.newArrayList(keyspaces.split(",")));
Expand All @@ -110,13 +105,11 @@ public Response cassRefresh(@QueryParam(REST_HEADER_KEYSPACES) String keyspaces)

@GET
@Path("/info")
public Response cassInfo() throws IOException, InterruptedException, JSONException {
public Response cassInfo() throws JSONException {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
logger.debug("node tool info being called");
Expand All @@ -125,13 +118,11 @@ public Response cassInfo() throws IOException, InterruptedException, JSONExcepti

@GET
@Path("/partitioner")
public Response cassPartitioner() throws IOException, InterruptedException, JSONException {
public Response cassPartitioner() {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msg: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
logger.debug("node tool getPartitioner being called");
Expand All @@ -140,14 +131,11 @@ public Response cassPartitioner() throws IOException, InterruptedException, JSON

@GET
@Path("/ring/{id}")
public Response cassRing(@PathParam("id") String keyspace)
throws IOException, InterruptedException, JSONException {
public Response cassRing(@PathParam("id") String keyspace) throws JSONException {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msg: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
logger.debug("node tool ring being called");
Expand All @@ -161,8 +149,6 @@ public Response statusInfo() throws JSONException {
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msg: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
logger.debug("node tool status being called");
Expand All @@ -171,7 +157,7 @@ public Response statusInfo() throws JSONException {

@GET
@Path("/flush")
public Response cassFlush() throws IOException, InterruptedException, ExecutionException {
public Response cassFlush() {
JSONObject rootObj = new JSONObject();

try {
Expand All @@ -180,7 +166,7 @@ public Response cassFlush() throws IOException, InterruptedException, ExecutionE
return Response.ok().entity(rootObj).build();
} catch (Exception e) {
try {
rootObj.put("status", "ERRROR");
rootObj.put("status", "ERROR");
rootObj.put("desc", e.getLocalizedMessage());
} catch (Exception e1) {
return Response.status(503).entity("FlushError").build();
Expand All @@ -191,16 +177,16 @@ public Response cassFlush() throws IOException, InterruptedException, ExecutionE

@GET
@Path("/compact")
public Response cassCompact() throws IOException, ExecutionException, InterruptedException {
public Response cassCompact() {
JSONObject rootObj = new JSONObject();

try {
compaction.execute();
rootObj.put("Compcated", true);
rootObj.put("Compacted", true);
return Response.ok().entity(rootObj).build();
} catch (Exception e) {
try {
rootObj.put("status", "ERRROR");
rootObj.put("status", "ERROR");
rootObj.put("desc", e.getLocalizedMessage());
} catch (Exception e1) {
return Response.status(503).entity("CompactionError").build();
Expand All @@ -216,8 +202,6 @@ public Response cassCleanup() throws IOException, ExecutionException, Interrupte
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
logger.debug("node tool cleanup being called");
Expand All @@ -236,8 +220,6 @@ public Response cassRepair(
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
logger.debug("node tool repair being called");
Expand All @@ -247,13 +229,11 @@ public Response cassRepair(

@GET
@Path("/version")
public Response version() throws IOException, ExecutionException, InterruptedException {
public Response version() {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
return Response.ok(
Expand All @@ -264,13 +244,11 @@ public Response version() throws IOException, ExecutionException, InterruptedExc

@GET
@Path("/disablegossip")
public Response disablegossip() throws IOException, ExecutionException, InterruptedException {
public Response disablegossip() {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
nodeTool.stopGossiping();
Expand All @@ -279,13 +257,11 @@ public Response disablegossip() throws IOException, ExecutionException, Interrup

@GET
@Path("/enablegossip")
public Response enablegossip() throws IOException, ExecutionException, InterruptedException {
public Response enablegossip() {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
nodeTool.startGossiping();
Expand All @@ -294,13 +270,11 @@ public Response enablegossip() throws IOException, ExecutionException, Interrupt

@GET
@Path("/disablethrift")
public Response disablethrift() throws IOException, ExecutionException, InterruptedException {
public Response disablethrift() {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
nodeTool.stopThriftServer();
Expand All @@ -309,13 +283,11 @@ public Response disablethrift() throws IOException, ExecutionException, Interrup

@GET
@Path("/enablethrift")
public Response enablethrift() throws IOException, ExecutionException, InterruptedException {
public Response enablethrift() {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
nodeTool.startThriftServer();
Expand All @@ -324,14 +296,11 @@ public Response enablethrift() throws IOException, ExecutionException, Interrupt

@GET
@Path("/statusthrift")
public Response statusthrift()
throws IOException, ExecutionException, InterruptedException, JSONException {
public Response statusthrift() throws JSONException {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
return Response.ok(
Expand All @@ -354,14 +323,11 @@ public Response gossipinfo() throws Exception {

@GET
@Path("/move")
public Response moveToken(@QueryParam(REST_HEADER_TOKEN) String newToken)
throws IOException, ExecutionException, InterruptedException, ConfigurationException {
public Response moveToken(@QueryParam(REST_HEADER_TOKEN) String newToken) throws IOException {
JMXNodeTool nodeTool;
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
nodeTool.move(newToken);
Expand All @@ -375,8 +341,6 @@ public Response cassDrain() throws IOException, ExecutionException, InterruptedE
try {
nodeTool = JMXNodeTool.instance(config);
} catch (JMXConnectionException e) {
logger.error(
"Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e);
return Response.status(503).entity("JMXConnectionException").build();
}
logger.debug("node tool drain being called");
Expand Down

0 comments on commit 9908f29

Please sign in to comment.