Skip to content

Commit

Permalink
Remove redundant log statements from CassandraAdmin (#903)
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 13c3e91 commit 2dc7d6c
Showing 1 changed file with 18 additions and 53 deletions.
71 changes: 18 additions & 53 deletions priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -82,23 +80,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 @@ -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(",")));
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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 {
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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(
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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(
Expand All @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 2dc7d6c

Please sign in to comment.