use of org.apache.cassandra.tools.NodeProbe in project eiger by wlloyd.
the class CliClient method describeKeySpace.
private void describeKeySpace(String keySpaceName, KsDef metadata) throws TException {
NodeProbe probe = sessionState.getNodeProbe();
// getting compaction manager MBean to displaying index building information
CompactionManagerMBean compactionManagerMBean = (probe == null) ? null : probe.getCompactionManagerProxy();
// Describe and display
sessionState.out.println("Keyspace: " + keySpaceName + ":");
try {
KsDef ks_def;
ks_def = metadata == null ? thriftClient.describe_keyspace(keySpaceName) : metadata;
sessionState.out.println(" Replication Strategy: " + ks_def.strategy_class);
sessionState.out.println(" Durable Writes: " + ks_def.durable_writes);
Map<String, String> options = ks_def.strategy_options;
sessionState.out.println(" Options: [" + ((options == null) ? "" : FBUtilities.toString(options)) + "]");
sessionState.out.println(" Column Families:");
Collections.sort(ks_def.cf_defs, new CfDefNamesComparator());
for (CfDef cf_def : ks_def.cf_defs) describeColumnFamily(ks_def, cf_def, probe);
// compaction manager information
if (compactionManagerMBean != null) {
for (Map<String, String> info : compactionManagerMBean.getCompactions()) {
// if ongoing compaction type is index build
if (info.get("taskType").equals(OperationType.INDEX_BUILD.toString()))
continue;
sessionState.out.printf("%nCurrently building index %s, completed %d of %d bytes.%n", info.get("columnfamily"), info.get("bytesComplete"), info.get("totalBytes"));
}
}
// closing JMX connection
if (probe != null)
probe.close();
} catch (InvalidRequestException e) {
sessionState.out.println("Invalid request: " + e);
} catch (NotFoundException e) {
sessionState.out.println("Keyspace " + keySpaceName + " could not be found.");
} catch (IOException e) {
sessionState.out.println("Error while closing JMX connection: " + e.getMessage());
}
}
use of org.apache.cassandra.tools.NodeProbe in project coprhd-controller by CoprHD.
the class GeoDbSvcStartupTest method checkSchema.
@Test
public void checkSchema() throws Exception {
// Check if snitch setup is OK
NodeProbe cmd = new NodeProbe(HOST, JMX_PORT);
String dc = cmd.getDataCenter();
Assert.assertTrue("Unexpected DC name " + dc, "vdc1".equalsIgnoreCase(dc));
// Check schema setup is OK
TSocket socket = new TSocket(HOST, RPC_PORT);
TTransport transport = new TFastFramedTransport(socket);
transport.open();
try {
Cassandra.Client client = new Cassandra.Client(new TBinaryProtocol(transport, true, true));
KsDef def = client.describe_keyspace(DbClientContext.GEO_KEYSPACE_NAME);
String strategyClass = def.strategy_class;
log.info("Current strategy class in geodb schema: " + strategyClass);
Assert.assertTrue("Unexpected strategy class " + strategyClass, strategyClass.contains("NetworkTopologyStrategy"));
Map<String, String> strategyOptions = def.getStrategy_options();
Assert.assertTrue(strategyOptions.size() > 0);
} finally {
transport.close();
}
}
use of org.apache.cassandra.tools.NodeProbe in project eiger by wlloyd.
the class CliClient method executeDescribe.
// DESCRIBE KEYSPACE (<keyspace> | <column_family>)?
private void executeDescribe(Tree statement) throws TException, InvalidRequestException {
if (!CliMain.isConnected())
return;
int argCount = statement.getChildCount();
KsDef currentKeySpace = keyspacesMap.get(keySpace);
if (// in case somebody changes Cli grammar
argCount > 1)
throw new RuntimeException("`describe` command take maximum one argument. See `help describe;`");
if (argCount == 0) {
if (currentKeySpace != null) {
describeKeySpace(currentKeySpace.name, null);
return;
}
sessionState.out.println("Authenticate to a Keyspace, before using `describe` or `describe <column_family>`");
} else if (argCount == 1) {
// name of the keyspace or ColumnFamily
String entityName = statement.getChild(0).getText();
KsDef inputKsDef = CliUtils.getKeySpaceDef(entityName, thriftClient.describe_keyspaces());
if (inputKsDef == null && currentKeySpace == null)
throw new RuntimeException(String.format("Keyspace with name '%s' wasn't found, " + "to lookup ColumnFamily with that name, please, authorize to one " + "of the keyspaces first.", entityName));
CfDef inputCfDef = (inputKsDef == null) ? getCfDef(currentKeySpace, entityName) : // no need to lookup CfDef if we know that it was keyspace
null;
if (inputKsDef != null) {
describeKeySpace(inputKsDef.name, inputKsDef);
} else if (inputCfDef != null) {
NodeProbe probe = sessionState.getNodeProbe();
try {
describeColumnFamily(currentKeySpace, inputCfDef, probe);
if (probe != null)
probe.close();
} catch (IOException e) {
sessionState.out.println("Error while closing JMX connection: " + e.getMessage());
}
} else {
sessionState.out.println("Sorry, no Keyspace nor ColumnFamily was found with name: " + entityName);
}
}
}
use of org.apache.cassandra.tools.NodeProbe in project cassandra by apache.
the class ClearSnapshotTest method setup.
@BeforeClass
public static void setup() throws Exception {
startJMXServer();
probe = new NodeProbe(jmxHost, jmxPort);
}
use of org.apache.cassandra.tools.NodeProbe in project cassandra by apache.
the class JmxCollector method call.
public GcStats call() throws Exception {
final List<Future<GcStats>> futures = new ArrayList<>();
for (final NodeProbe probe : probes) {
futures.add(TPE.submit(new Callable<GcStats>() {
public GcStats call() throws Exception {
final double[] stats = probe.getAndResetGCStats();
return new GcStats(stats[5], stats[4], stats[1], stats[2], stats[3]);
}
}));
}
List<GcStats> results = new ArrayList<>();
for (Future<GcStats> future : futures) results.add(future.get());
return GcStats.aggregate(results);
}
Aggregations