Commit a7ee3ce9 authored by Daniel Seybold's avatar Daniel Seybold

added command for getting cluster state for cassandra and couchbase

parent de11c688
Pipeline #54218 passed with stage
in 9 minutes and 52 seconds
......@@ -62,10 +62,14 @@ public class RemoteCommand extends EvaluationTask {
String seedEnpoint = endpoints.get(0);
String command = null;
String statusCommand = null;
if(this.DBMSType.toLowerCase().equals("cassandra")){
command = getCassandraCommand();
command = getCassandraRecordCountCommand();
statusCommand = getCassandraClusterStateCommand();
}else if(this.DBMSType.toLowerCase().equals("couchbase")){
command = getCouchbaseCommand();
command = getCouchbaseRecordCountCommand();
statusCommand = getCouchbaseClusterStateCommand();
}else {
LOGGER.error(this.loggerPrefix + "Unsupported command target: " + this.DBMSType + "! Skipping RemoteCommand Task!");
return new DefaultWorkReport(WorkStatus.COMPLETED);
......@@ -98,16 +102,16 @@ public class RemoteCommand extends EvaluationTask {
JSch jsch = new JSch();
String user = "ubuntu";
//String host = "134.60.64.116";
int port = 22;
//String privateKey = ".ssh/id_rsa";
final String user = "ubuntu";
final int port = 22;
try {
jsch.addIdentity("test_rsa", privateKeyPlain.getBytes(), publicKeyPlain.getBytes(), "secret".getBytes());
/**
* get Records session
*/
Session session = jsch.getSession(user, seedEnpoint, port);
session.setConfig("StrictHostKeyChecking", "no");
LOGGER.debug("session created.");
......@@ -130,7 +134,35 @@ public class RemoteCommand extends EvaluationTask {
/**
* Log the total number of records
*/
logNumberOfRecords(result);
logCustomEntry("CLUSTER_STATE",result);
/**
* get Cluster state session
*/
session = jsch.getSession(user, seedEnpoint, port);
session.setConfig("StrictHostKeyChecking", "no");
LOGGER.debug("session created.");
session.connect();
channel = (ChannelExec) session.openChannel("exec");
channel.setInputStream(null);
output = channel.getInputStream();
channel.setErrStream(System.err);
channel.setCommand(command);
channel.connect();
String clusterResult = CharStreams.toString(new InputStreamReader(output));
//printOutput(channel);
channel.disconnect();
LOGGER.debug(this.loggerPrefix + "The remote result command is: " + clusterResult);
/**
* Log the total number of records
*/
logCustomEntry("CLUSTER_STATE",clusterResult);
} catch (JSchException e) {
LOGGER.error(e.getStackTrace().toString());
......@@ -145,13 +177,13 @@ public class RemoteCommand extends EvaluationTask {
return new DefaultWorkReport(WorkStatus.COMPLETED);
}
private void logNumberOfRecords(String numberOfRecords){
private void logCustomEntry(String id, String value){
long currentTimestamp = System.currentTimeMillis()/1000;
long eventTimestamp = currentTimestamp - this.evaluationContext.getStartTime();
String taskLogMessage = new SimpleDateFormat("dd.MM.yyyy-HH:mm:ss").format(new Date()) +"; " +eventTimestamp + "s; " + "NUMBER_OF_RECORDS" + "; " + numberOfRecords + "\n";
String taskLogMessage = new SimpleDateFormat("dd.MM.yyyy-HH:mm:ss").format(new Date()) +"; " +eventTimestamp + "s; " + id + "; " + value + "\n";
String taskLogUri = this.evaluationContext.getEvluationRun()
......@@ -168,7 +200,7 @@ public class RemoteCommand extends EvaluationTask {
}
private static String getCassandraCommand(){
private static String getCassandraRecordCountCommand(){
//TODO: check if these values need to be derived dynamically based on total number of records?
/**
......@@ -186,9 +218,26 @@ public class RemoteCommand extends EvaluationTask {
return command;
}
private static String getCouchbaseCommand(){
private static String getCassandraClusterStateCommand(){
String command = "source /etc/environment && sudo -E ./cassandra/bin/nodetool -h $LOCAL_ADDRESS status ycsb ";
return command;
}
private static String getCouchbaseRecordCountCommand(){
String commnad = "source /etc/environment && sudo -E curl -s http://$LOCAL_ADDRESS:8091/pools/default/buckets/ycsb/ -u ycsb:mowgli19 | jq '.basicStats | {itemCount: .itemCount }' | grep itemCount";
return commnad;
}
private static String getCouchbaseClusterStateCommand(){
String command = "source /etc/environment && sudo -E /opt/couchbase/bin/couchbase-cli server-list -c $LOCAL_ADDRESS --username carlos --password mowgli19";
return command;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment