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

Adding partitioner endpoint to cassadmin resource to get C* partitioner name #689

Merged
merged 1 commit into from
Jul 11, 2018
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2018/07/11: 3.1.56
* (#689) Adding partitioner endpoint to cassadmin resource to get C* partitioner name.

## 2018/06/28: 3.1.54
### Improvements
* (#683) PostRestoreHook logging improvements.
Expand Down
125 changes: 70 additions & 55 deletions priam/src/main/java/com/netflix/priam/resources/CassandraAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,46 +93,61 @@ public Response cassRefresh(@QueryParam(REST_HEADER_KEYSPACES) String keyspaces)
if (StringUtils.isBlank(keyspaces))
return Response.status(400).entity("Missing keyspace in request").build();

JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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(",")));
nodeTool.refresh(Lists.newArrayList(keyspaces.split(",")));
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/info")
public Response cassInfo() throws IOException, InterruptedException, JSONException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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");
return Response.ok(nodetool.info(), MediaType.APPLICATION_JSON).build();
return Response.ok(nodeTool.info(), MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/partitioner")
public Response cassPartitioner() throws IOException, InterruptedException, 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 getPartitioner being called");
return Response.ok(nodeTool.getPartitioner(), MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/ring/{id}")
public Response cassRing(@PathParam("id") String keyspace) throws IOException, InterruptedException, JSONException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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 ring being called");
return Response.ok(nodetool.ring(keyspace), MediaType.APPLICATION_JSON).build();
return Response.ok(nodeTool.ring(keyspace), MediaType.APPLICATION_JSON).build();
}

@GET
Expand Down Expand Up @@ -196,77 +211,77 @@ public Response cassFlush() throws IOException, InterruptedException, ExecutionE
@GET
@Path("/compact")
public Response cassCompact() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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 compact being called");
nodetool.compact();
nodeTool.compact();
return Response.ok().build();
}

@GET
@Path("/cleanup")
public Response cassCleanup() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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");
nodetool.cleanup();
nodeTool.cleanup();
return Response.ok().build();
}

@GET
@Path("/repair")
public Response cassRepair(@QueryParam("sequential") boolean isSequential, @QueryParam("localDC") boolean localDCOnly, @DefaultValue("false") @QueryParam("primaryRange") boolean primaryRange) throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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");
nodetool.repair(isSequential, localDCOnly, primaryRange);
nodeTool.repair(isSequential, localDCOnly, primaryRange);
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/version")
public Response version() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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(new JSONArray().put(nodetool.getReleaseVersion()), MediaType.APPLICATION_JSON).build();
return Response.ok(new JSONArray().put(nodeTool.getReleaseVersion()), MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/tpstats")
public Response tpstats() throws IOException, ExecutionException, InterruptedException, JSONException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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();
}
Iterator<Map.Entry<String, JMXEnabledThreadPoolExecutorMBean>> threads = nodetool.getThreadPoolMBeanProxies();
Iterator<Map.Entry<String, JMXEnabledThreadPoolExecutorMBean>> threads = nodeTool.getThreadPoolMBeanProxies();
JSONArray threadPoolArray = new JSONArray();
while (threads.hasNext()) {
Entry<String, JMXEnabledThreadPoolExecutorMBean> thread = threads.next();
Expand All @@ -283,7 +298,7 @@ public Response tpstats() throws IOException, ExecutionException, InterruptedExc
threadPoolArray.put(tpObj);
}
JSONObject droppedMsgs = new JSONObject();
for (Entry<String, Integer> entry : nodetool.getDroppedMessages().entrySet())
for (Entry<String, Integer> entry : nodeTool.getDroppedMessages().entrySet())
droppedMsgs.put(entry.getKey(), entry.getValue());

JSONObject rootObj = new JSONObject();
Expand All @@ -296,16 +311,16 @@ public Response tpstats() throws IOException, ExecutionException, InterruptedExc
@GET
@Path("/compactionstats")
public Response compactionStats() throws IOException, ExecutionException, InterruptedException, JSONException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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();
}
JSONObject rootObj = new JSONObject();
CompactionManagerMBean cm = nodetool.getCompactionManagerProxy();
CompactionManagerMBean cm = nodeTool.getCompactionManagerProxy();
rootObj.put("pending tasks", cm.getPendingTasks());
JSONArray compStats = new JSONArray();
for (Map<String, String> c : cm.getCompactions()) {
Expand All @@ -327,89 +342,89 @@ public Response compactionStats() throws IOException, ExecutionException, Interr
@GET
@Path("/disablegossip")
public Response disablegossip() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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();
nodeTool.stopGossiping();
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/enablegossip")
public Response enablegossip() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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();
nodeTool.startGossiping();
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/disablethrift")
public Response disablethrift() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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();
nodeTool.stopThriftServer();
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/enablethrift")
public Response enablethrift() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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();
nodeTool.startThriftServer();
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/statusthrift")
public Response statusthrift() throws IOException, ExecutionException, InterruptedException, JSONException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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(new JSONObject().put("status", (nodetool.isThriftServerRunning() ? "running" : "not running")), MediaType.APPLICATION_JSON).build();
return Response.ok(new JSONObject().put("status", (nodeTool.isThriftServerRunning() ? "running" : "not running")), MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/gossipinfo")
public Response gossipinfo() throws IOException, ExecutionException, InterruptedException, JSONException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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();
}
JSONObject rootObj = parseGossipInfo(nodetool.getGossipInfo());
JSONObject rootObj = parseGossipInfo(nodeTool.getGossipInfo());
return Response.ok(rootObj, MediaType.APPLICATION_JSON).build();
}

Expand Down Expand Up @@ -558,15 +573,15 @@ public Response netstats(@QueryParam("host") String hostname) throws IOException
@GET
@Path("/move")
public Response moveToken(@QueryParam(REST_HEADER_TOKEN) String newToken) throws IOException, ExecutionException, InterruptedException, ConfigurationException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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);
nodeTool.move(newToken);
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

Expand Down Expand Up @@ -599,9 +614,9 @@ public Response scrub(@QueryParam(REST_HEADER_KEYSPACES) String keyspaces, @Quer
@Path("/cfhistograms")
public Response cfhistograms(@QueryParam(REST_HEADER_KEYSPACES) String keyspace, @QueryParam(REST_HEADER_CFS) String cfname) throws IOException, ExecutionException, InterruptedException,
JSONException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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")
Expand All @@ -610,7 +625,7 @@ public Response cfhistograms(@QueryParam(REST_HEADER_KEYSPACES) String keyspace,
if (StringUtils.isBlank(keyspace) || StringUtils.isBlank(cfname))
return Response.status(400).entity("Missing keyspace/cfname in request").build();

ColumnFamilyStoreMBean store = nodetool.getCfsProxy(keyspace, cfname);
ColumnFamilyStoreMBean store = nodeTool.getCfsProxy(keyspace, cfname);

// default is 90 offsets
long[] offsets = new EstimatedHistogram().getBucketOffsets();
Expand Down Expand Up @@ -648,16 +663,16 @@ public Response cfhistograms(@QueryParam(REST_HEADER_KEYSPACES) String keyspace,
@GET
@Path("/drain")
public Response cassDrain() throws IOException, ExecutionException, InterruptedException {
JMXNodeTool nodetool = null;
JMXNodeTool nodeTool;
try {
nodetool = JMXNodeTool.instance(config);
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");
nodetool.drain();
nodeTool.drain();
return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build();
}

Expand Down