diff --git a/src/main/java/de/uulm/omi/dbms/evlautor/server/api/impl/ScenarioApiServiceImpl.java b/src/main/java/de/uulm/omi/dbms/evlautor/server/api/impl/ScenarioApiServiceImpl.java index f06249a461e148a0bc6f1adf502d71b4e71894f5..dab59a46026b41dcb835b81d2e69d23810fec605 100644 --- a/src/main/java/de/uulm/omi/dbms/evlautor/server/api/impl/ScenarioApiServiceImpl.java +++ b/src/main/java/de/uulm/omi/dbms/evlautor/server/api/impl/ScenarioApiServiceImpl.java @@ -57,7 +57,7 @@ public class ScenarioApiServiceImpl extends ScenarioApiService { evaluationContext.setRunCounter(0); evaluationContext.setStartTime(System.currentTimeMillis()); ClusterContext clusterContext = new ClusterContext(); - clusterContext.setIdApplicationInstance("1376257"); + clusterContext.setIdApplicationInstance("1605632"); RemoteCommand remoteCommand = new RemoteCommand(evaluationContext,clusterContext,"cassandra"); remoteCommand.call(); diff --git a/src/main/java/de/uulm/omi/evaluation/task/RemoteCommand.java b/src/main/java/de/uulm/omi/evaluation/task/RemoteCommand.java index 75639ab45728442af6cf3af8d31ee8a473ca8537..13cb04c5f6f02e2fbce3e320a4c32317889e29dc 100644 --- a/src/main/java/de/uulm/omi/evaluation/task/RemoteCommand.java +++ b/src/main/java/de/uulm/omi/evaluation/task/RemoteCommand.java @@ -143,8 +143,6 @@ public class RemoteCommand extends EvaluationTask { session.disconnect(); - - /** * Log the cluster state */ @@ -163,6 +161,10 @@ public class RemoteCommand extends EvaluationTask { ChannelExec channel2 = (ChannelExec) session2.openChannel("exec"); + channel2.setCommand(recordCountCommand); + + + /* channel2.setInputStream(null); InputStream output2 = channel2.getInputStream(); channel2.setErrStream(System.err); @@ -178,6 +180,52 @@ public class RemoteCommand extends EvaluationTask { session2.disconnect(); + + */ + + InputStream commandOutput = channel2.getExtInputStream(); + + StringBuilder outputBuffer = new StringBuilder(); + StringBuilder errorBuffer = new StringBuilder(); + + InputStream in = channel2.getInputStream(); + InputStream err = channel2.getExtInputStream(); + + channel2.connect(); + + byte[] tmp = new byte[1024]; + while (true) { + while (in.available() > 0) { + int i = in.read(tmp, 0, 1024); + if (i < 0) break; + outputBuffer.append(new String(tmp, 0, i)); + } + while (err.available() > 0) { + int i = err.read(tmp, 0, 1024); + if (i < 0) break; + errorBuffer.append(new String(tmp, 0, i)); + } + if (channel2.isClosed()) { + if ((in.available() > 0) || (err.available() > 0)) continue; + LOGGER.debug(this.loggerPrefix + "The remote recordCount command exit-status: " + channel2.getExitStatus()); + break; + } + try { + Thread.sleep(1000); + } catch (Exception ee) { + LOGGER.debug("Exception while executing record count command!",ee); + } + } + + String recordCountResult = outputBuffer.toString(); + String recordCountError = errorBuffer.toString(); + + LOGGER.debug(this.loggerPrefix + "The remote recordCount command result is: " + recordCountResult); + LOGGER.debug(this.loggerPrefix + "The remote recordCount error result is: " + recordCountError); + + + channel2.disconnect(); + /** * Log the total number of records */