From 2dc7d6ca4dfa46f97bebdffc5dfa53bc64928231 Mon Sep 17 00:00:00 2001 From: mattl-netflix <63665634+mattl-netflix@users.noreply.github.com> Date: Tue, 8 Sep 2020 13:53:07 -0700 Subject: [PATCH] Remove redundant log statements from CassandraAdmin (#903) * 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 | 71 +++++-------------- 1 file changed, 18 insertions(+), 53 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 07ac56e8a..3c18d106e 100644 --- a/priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java +++ b/priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java @@ -41,7 +41,6 @@ import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutorMBean; import org.apache.cassandra.db.ColumnFamilyStoreMBean; import org.apache.cassandra.db.compaction.CompactionManagerMBean; -import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.cassandra.utils.EstimatedHistogram; import org.apache.commons.lang3.StringUtils; import org.codehaus.jettison.json.JSONArray; @@ -51,7 +50,6 @@ 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 { @@ -82,7 +80,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(); } @@ -90,7 +88,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(); } @@ -98,7 +96,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(); @@ -107,8 +105,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(","))); @@ -117,13 +113,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"); @@ -132,13 +126,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"); @@ -147,14 +139,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"); @@ -168,8 +157,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"); @@ -178,7 +165,7 @@ public Response statusInfo() throws JSONException { @GET @Path("/flush") - public Response cassFlush() throws IOException, InterruptedException, ExecutionException { + public Response cassFlush() { JSONObject rootObj = new JSONObject(); try { @@ -187,7 +174,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(); @@ -198,16 +185,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(); @@ -223,8 +210,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"); @@ -243,8 +228,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"); @@ -254,13 +237,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( @@ -351,13 +332,11 @@ public Response compactionStats() @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(); @@ -366,13 +345,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(); @@ -381,13 +358,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(); @@ -396,13 +371,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(); @@ -411,14 +384,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( @@ -441,14 +411,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); @@ -514,8 +481,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");