From 9908f29772575b9c2e53bcc1f1a4ecc2a3f53d7a Mon Sep 17 00:00:00 2001 From: mattl-netflix <63665634+mattl-netflix@users.noreply.github.com> Date: Tue, 8 Sep 2020 13:53:22 -0700 Subject: [PATCH] Remove redundant log statements from CassandraAdmin (#902) * 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) --- .../priam/resources/CassandraAdmin.java | 72 +++++-------------- 1 file changed, 18 insertions(+), 54 deletions(-) diff --git a/priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java b/priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java index 6894ffd4d..a9f2b895c 100644 --- a/priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java +++ b/priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java @@ -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; @@ -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); @@ -75,7 +72,7 @@ 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(); } @@ -83,7 +80,7 @@ public Response cassStart() throws IOException, InterruptedException, JSONExcept @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(); } @@ -91,7 +88,7 @@ public Response cassStop(@DefaultValue("false") @QueryParam("force") boolean for @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(); @@ -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(","))); @@ -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"); @@ -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"); @@ -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"); @@ -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"); @@ -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 { @@ -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(); @@ -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(); @@ -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"); @@ -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"); @@ -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( @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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( @@ -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); @@ -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");