Commit 8e1d6c25 authored by Daniel Seybold's avatar Daniel Seybold

limited memory for cassandra get record count command

parent 2b89662a
Pipeline #54368 passed with stage
in 12 minutes and 38 seconds
......@@ -184,7 +184,7 @@
<version>1.0.0</version>
</dependency>
<!-- Maki Manager client -->
<!-- MakiExecutor Manager client -->
<dependency>
<groupId>de.uulm.omi.mowgli.maki</groupId>
<artifactId>maki-manager-client</artifactId>
......
......@@ -50,6 +50,18 @@ public class ScenarioApiServiceImpl extends ScenarioApiService {
NoiseyNeighbour noiseyNeighbour = new NoiseyNeighbour(scenarioName, runs, scenarioSpec, cleanUp.booleanValue());
noiseyNeighbour.execute();
/*
EvaluationContext evaluationContext = new EvaluationContext();
evaluationContext.setRunCounter(0);
evaluationContext.setStartTime(System.currentTimeMillis());
ClusterContext clusterContext = new ClusterContext();
clusterContext.setIdApplicationInstance("1245185");
RemoteCommand remoteCommand = new RemoteCommand(evaluationContext,clusterContext,"cassandra");
remoteCommand.call();
*/
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "Evaluation started!")).build();
}
......
package de.uulm.omi.evaluation.jungle;
import com.google.common.io.CharStreams;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by Daniel Seybold on 21.08.2019.
*/
public class MakiExecutor {
private static final Logger LOGGER = LoggerFactory.getLogger(MakiExecutor.class);
private static String MAKI_SECRET = "TopSecret";
private static String USER = "ubuntu";
private static int PORT = 22;
private Session makiSession;
public MakiExecutor(String privateKey, String publicKey, String enpoint){
JSch jsch = new JSch();
try {
jsch.addIdentity("maki_rsa", privateKey.getBytes(), publicKey.getBytes(), MAKI_SECRET.getBytes());
makiSession = jsch.getSession(USER, enpoint, PORT);
makiSession.setConfig("StrictHostKeyChecking", "no");
makiSession.connect();
LOGGER.debug("MakiExecutor session connected!");
} catch (JSchException e) {
LOGGER.error("Error while adding identity!" , e);
}
}
public String execute(String command){
String result = null;
ChannelExec channel = null;
try {
channel = (ChannelExec) makiSession.openChannel("exec");
channel.setInputStream(null);
InputStream output = channel.getInputStream();
channel.setErrStream(System.err);
channel.setCommand(command);
channel.connect();
result = CharStreams.toString(new InputStreamReader(output));
channel.disconnect();
LOGGER.debug("The remote clusterState command is: " + result);
} catch (JSchException e) {
LOGGER.error("Error while executing ssh command!", e);
} catch (IOException e) {
LOGGER.error("Error while reading ssh result!", e);
}
return result;
}
public void close(){
makiSession.disconnect();
}
}
......@@ -100,18 +100,20 @@ public class RemoteCommand extends EvaluationTask {
//TODO: refactor into a generic ssh command helper tool and make this task the getNumberOfRecords task
JSch jsch = new JSch();
final String user = "ubuntu";
final int port = 22;
try {
jsch.addIdentity("test_rsa", privateKeyPlain.getBytes(), publicKeyPlain.getBytes(), "secret".getBytes());
/**
* get cluster state session
*/
JSch jsch = new JSch();
jsch.addIdentity("test_rsa", privateKeyPlain.getBytes(), publicKeyPlain.getBytes(), "secret".getBytes());
Session session = jsch.getSession(user, seedEnpoint, port);
session.setConfig("StrictHostKeyChecking", "no");
LOGGER.debug("session created.");
......@@ -125,52 +127,60 @@ public class RemoteCommand extends EvaluationTask {
channel.connect();
String clusterStateResult = CharStreams.toString(new InputStreamReader(output));
//printOutput(channel);
channel.disconnect();
LOGGER.debug(this.loggerPrefix + "The remote clusterState command is: " + clusterStateResult);
session.disconnect();
/**
* Log the total number of records
*/
logCustomEntry("CLUSTER_STATE",clusterStateResult);
JSch jsch2 = new JSch();
jsch2.addIdentity("test_rsa", privateKeyPlain.getBytes(), publicKeyPlain.getBytes(), "secret".getBytes());
/**
* get record count session
*/
session = jsch.getSession(user, seedEnpoint, port);
session.setConfig("StrictHostKeyChecking", "no");
LOGGER.debug("session created.");
session.connect();
Session session2 = jsch2.getSession(user, seedEnpoint, port);
session2.setConfig("StrictHostKeyChecking", "no");
session2.connect();
LOGGER.debug("session2 connected!");
channel = (ChannelExec) session.openChannel("exec");
channel.setInputStream(null);
output = channel.getInputStream();
channel.setErrStream(System.err);
channel.setCommand(recordCountCommand);
ChannelExec channel2 = (ChannelExec) session2.openChannel("exec");
channel2.setInputStream(null);
InputStream output2 = channel2.getInputStream();
channel2.setErrStream(System.err);
LOGGER.debug(recordCountCommand);
channel2.setCommand(recordCountCommand);
channel.connect(300000);
String recordCountResult = CharStreams.toString(new InputStreamReader(output));
//printOutput(channel);
channel.disconnect();
channel2.connect();
String recordCountResult = CharStreams.toString(new InputStreamReader(output2));
channel2.disconnect();
LOGGER.debug(this.loggerPrefix + "The remote recordCount command result is: " + recordCountResult);
session2.disconnect();
/**
* Log the total number of records
*/
logCustomEntry("RECORD_COUNT",recordCountResult);
logCustomEntry("RECORD_COUNT",recordCountResult);
session.disconnect();
} catch (JSchException e) {
LOGGER.error(e.getStackTrace().toString());
LOGGER.error("Error while executing SSH command!",e);
return new DefaultWorkReport(WorkStatus.FAILED);
} catch (IOException e) {
LOGGER.error(e.getStackTrace().toString());
LOGGER.error("Error while reading command result!",e);
return new DefaultWorkReport(WorkStatus.FAILED);
}
......@@ -213,8 +223,10 @@ public class RemoteCommand extends EvaluationTask {
*/
int numOfSplits = 256;
String command = "source /etc/environment && sudo -E ./cassandra-count -host $LOCAL_ADDRESS -keyspace ycsb -table usertable -splitSize " + splitSize + " -numSplits " + numOfSplits;
//String command = "source /etc/environment && sudo -E ./cassandra-count -Xmx512m -host $LOCAL_ADDRESS -keyspace ycsb -table usertable -splitSize " + splitSize + " -numSplits " + numOfSplits;
String command = "source /etc/environment && sudo -E java -Xmx512m -jar cassandra-count -host $LOCAL_ADDRESS -keyspace ycsb -table usertable -splitSize " + splitSize + " -numSplits " + numOfSplits;
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