Merge commit log API
Amnon says: "After this patch series, it will be possible to run the JMX API and using jconsole get the ActiveSegmentName and (the empty) ArchivingSegmentNames."
This commit is contained in:
commit
088c7c356b
@ -5,6 +5,7 @@ package com.cloudius.urchin.api;
|
|||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -71,8 +72,15 @@ public class APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getListStrValue(String string) {
|
public List<String> getListStrValue(String string) {
|
||||||
// TODO Auto-generated method stub
|
JsonReader reader = getReader(string);
|
||||||
return null;
|
JsonArray arr = reader.readArray();
|
||||||
|
List<String> res = new ArrayList<String>(arr.size());
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
res.add(arr.getString(i));
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<List<String>, List<String>> getMapListStrValue(String string) {
|
public Map<List<String>, List<String>> getMapListStrValue(String string) {
|
||||||
|
@ -43,7 +43,6 @@ public class CommitLog implements CommitLogMBean {
|
|||||||
private APIClient c = new APIClient();
|
private APIClient c = new APIClient();
|
||||||
|
|
||||||
public void log(String str) {
|
public void log(String str) {
|
||||||
System.out.println(str);
|
|
||||||
logger.info(str);
|
logger.info(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +51,7 @@ public class CommitLog implements CommitLogMBean {
|
|||||||
public static CommitLog getInstance() {
|
public static CommitLog getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommitLog() {
|
private CommitLog() {
|
||||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||||
try {
|
try {
|
||||||
@ -108,7 +108,13 @@ public class CommitLog implements CommitLogMBean {
|
|||||||
*/
|
*/
|
||||||
public List<String> getActiveSegmentNames() {
|
public List<String> getActiveSegmentNames() {
|
||||||
log(" getActiveSegmentNames()");
|
log(" getActiveSegmentNames()");
|
||||||
return c.getListStrValue("");
|
List<String> lst = c.getListStrValue("/commitlog/segments/active");
|
||||||
|
Set<String> set = new HashSet<String>();
|
||||||
|
for (String l : lst) {
|
||||||
|
String name = l.substring(l.lastIndexOf("/") + 1, l.length());
|
||||||
|
set.add(name);
|
||||||
|
}
|
||||||
|
return new ArrayList<String>(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +123,13 @@ public class CommitLog implements CommitLogMBean {
|
|||||||
*/
|
*/
|
||||||
public List<String> getArchivingSegmentNames() {
|
public List<String> getArchivingSegmentNames() {
|
||||||
log(" getArchivingSegmentNames()");
|
log(" getArchivingSegmentNames()");
|
||||||
return c.getListStrValue("");
|
List<String> lst = c.getListStrValue("/commitlog/segments/archiving");
|
||||||
|
Set<String> set = new HashSet<String>();
|
||||||
|
for (String l : lst) {
|
||||||
|
String name = l.substring(l.lastIndexOf("/") + 1, l.length());
|
||||||
|
set.add(name);
|
||||||
|
}
|
||||||
|
return new ArrayList<String>(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class EndpointSnitchInfo implements EndpointSnitchInfoMBean {
|
|||||||
private EndpointSnitchInfo() {
|
private EndpointSnitchInfo() {
|
||||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||||
try {
|
try {
|
||||||
mbs.registerMBean(new EndpointSnitchInfo(), new ObjectName(
|
mbs.registerMBean(this, new ObjectName(
|
||||||
"org.apache.cassandra.db:type=EndpointSnitchInfo"));
|
"org.apache.cassandra.db:type=EndpointSnitchInfo"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user