Repository: airavata-sandbox
Updated Branches:
  refs/heads/master cf4119a56 -> be595299e


Adding Big-Data-Integration tools


Project: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/commit/be595299
Tree: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/tree/be595299
Diff: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/diff/be595299

Branch: refs/heads/master
Commit: be595299e95f63829418b949ca9c1e7eb19e1227
Parents: cf4119a
Author: Gourav Rattihalli <[email protected]>
Authored: Wed Oct 26 14:27:38 2016 -0400
Committer: Gourav Rattihalli <[email protected]>
Committed: Wed Oct 26 14:27:38 2016 -0400

----------------------------------------------------------------------
 .../AuroraIntegration/README                    |  45 +++
 .../AuroraIntegration/src/README.txt            |  16 +
 .../AuroraIntegration/src/build.xml             |  53 ++++
 .../auroraClient/AuroraJobSchedulerI.java       |  23 ++
 .../auroraClient/AuroraJobSchedulerImpl.java    | 239 +++++++++++++++
 .../bigDataInjections/AuroraInjectorImpl.java   |  81 +++++
 .../bigDataInjections/BigDataInjectorI.java     |  12 +
 .../cloud/aurora/driver/AuroraAdminDriver.java  |  62 ++++
 .../cloud/aurora/exception/AuroraException.java |  15 +
 .../cloud/aurora/utilities/AuroraUtilI.java     |   9 +
 .../cloud/aurora/utilities/AuroraUtilImpl.java  |  25 ++
 .../MarathonIntegration/src/README.txt          |  16 +
 .../MarathonIntegration/src/build.xml           |  53 ++++
 .../bigDataInjections/BigDataInjectorI.java     |  12 +
 .../bigDataInjections/MarathonInjectorImpl.java |  52 ++++
 .../marathon/driver/MarathonAdminDriver.java    |  61 ++++
 .../marathon/exception/MarathonException.java   |  15 +
 .../marathonClient/MarathonJobSchedulerI.java   |  28 ++
 .../MarathonJobSchedulerImpl.java               | 296 +++++++++++++++++++
 .../cloud/marathon/utilities/MarathonUtilI.java |   9 +
 .../marathon/utilities/MarathonUtilImpl.java    |  25 ++
 21 files changed, 1147 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/README
----------------------------------------------------------------------
diff --git a/gsoc2016/Big-Data-Integration/AuroraIntegration/README 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/README
new file mode 100644
index 0000000..379100a
--- /dev/null
+++ b/gsoc2016/Big-Data-Integration/AuroraIntegration/README
@@ -0,0 +1,45 @@
+Requirements:
+1: Apache Aurora
+2: Apache Mesos
+
+Installation:
+Please follow the link to set up Apache Aurora and Apache Mesos
+1) http://mesos.apache.org/gettingstarted/ OR 
https://open.mesosphere.com/getting-started/install/
+2) http://aurora.apache.org/documentation/latest/operations/installation/
+
+Usage:
+
+Options:
+-o = create/kill
+-n = name of the job
+-r = amount of RAM
+-c = CPU count
+-d = disk space
+-i = executable/image
+
+Examples:
+
+To create and launch: AuroraAdminDriver -o create -r 1024 -n batik -c 2.0 -d 
1000 -i gouravr/dacapo:tag9
+Sample Output: 
+       Job create succeeded: job 
url=http://127.0.1.1:8081/scheduler/benchmarks/devel/batik
+
+To kill: AuroraAdminDriver -o kill -n batik
+Sample Output: 
+       Successfully killed instances [0]
+       Job killall succeeded
+
+To update: AuroraAdminDriver -o update -n batik
+
+To retrieve update information: AuroraAdminDriver -o update-info -n batik
+
+To pause an update: AuroraAdminDriver -o update-pause -n batik
+
+To list the update progress: AuroraAdminDriver -o update-list -n batik
+
+To abort an update: AuroraAdminDriver -o update-abort -n batik
+
+To resume an update: AuroraAdminDriver -o update-resume -n batik
+
+To restart a job: AuroraAdminDriver -o restart -n batik
+
+To execute a command inside a running job: AuroraAdminDriver -o command -n 
batik -cmd some-command (eg: ls)

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/README.txt
----------------------------------------------------------------------
diff --git a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/README.txt 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/README.txt
new file mode 100644
index 0000000..a5d51f6
--- /dev/null
+++ b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/README.txt
@@ -0,0 +1,16 @@
+
+
+## Temporarily using ANT compile the Aurora Management code.
+## TODO: integrate with maven build system, instead of using ANT
+
+#In the following directory run the compilation command:
+airavata/modules/cloud/AuroraIntegration/src
+
+#Compilation command
+ant all
+
+#Run command
+## TODO: add the command to run and test the code
+
+## Add sample output that shows the Aurora code working
+

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/build.xml
----------------------------------------------------------------------
diff --git a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/build.xml 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/build.xml
new file mode 100644
index 0000000..5533336
--- /dev/null
+++ b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/build.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project name="aurora" default="compile_all" basedir="..">
+
+  <property name="BUILD.compiler"       value="modern"/>
+  <property name="src"                  value="src"/>
+  <property name="BUILD"                value="BUILD"/>
+  <property name="classes"              value="${BUILD}/classes"/>
+
+
+  <target name="all" depends="compile_all"/>
+
+  <target name="compile_all"
+          depends="org"/>
+
+  <target name="clean">
+       <delete dir="${BUILD}"/>
+  </target>
+
+  <!-- Prepare target directories -->
+  <target name="prepare">
+        <mkdir dir="${BUILD}"/>
+        <mkdir dir="${classes}"/>
+  </target>
+
+
+ <target name="jar">
+        <mkdir dir="${BUILD}/jar"/>
+        <jar destfile="${BUILD}/jar/auroraDriverl.jar" 
basedir="${BUILD}/classes">
+            <manifest>
+                <attribute name="Main-Class" 
value="org.apache.airavata.cloud.aurora.driver.AuroraAdminDriver"/>
+            </manifest>
+        </jar>
+    </target>
+
+
+
+  <!-- ** means all subdirectories as well -->
+  <!-- * means all files in the current directory -->
+  <!-- for just java files use *.java -->
+
+  <target name="org" depends="prepare">
+    <javac srcdir="${src}"
+           includes="org/**"
+           excludes="**/package.html"
+           destdir="${classes}"
+           classpath="${classes}"
+           debug="on"
+           optimize="on"
+           deprecation="off"/>
+  </target>
+
+
+</project>

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerI.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerI.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerI.java
new file mode 100644
index 0000000..06e6935
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerI.java
@@ -0,0 +1,23 @@
+package org.apache.airavata.cloud.aurora.auroraClient;
+
+import org.apache.airavata.cloud.aurora.exception.AuroraException;
+
+public interface AuroraJobSchedulerI {
+
+       public void jobUpdateInfo(String info) throws AuroraException;
+       public void jobUpdate(String update) throws AuroraException;
+       public void jobUpdateResume(String info) throws AuroraException;
+       public void jobUpdateAbort(String info) throws AuroraException;
+       public void jobUpdateList(String info) throws AuroraException;
+       public void jobUpdatePause(String info) throws AuroraException;
+       public void auroraJobCommand(String info, String command) throws 
AuroraException;
+       public void jobRestart(String restart) throws AuroraException;
+       public void jobKill(String kill) throws AuroraException;
+       public void jobLaunch(String name) throws AuroraException;
+       public void jobDiff(String key, String config) throws AuroraException;
+       public void jobInspect(String key, String config) throws 
AuroraException;
+       public void clusterQuota(String key) throws AuroraException;
+       public void configList(String config) throws AuroraException;
+       public void openWebUI(String key) throws AuroraException;
+       public void configCreate(String name, String ram, String cpu, String 
disk, String image) throws AuroraException;
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerImpl.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerImpl.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerImpl.java
new file mode 100644
index 0000000..c7771dd
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/auroraClient/AuroraJobSchedulerImpl.java
@@ -0,0 +1,239 @@
+package org.apache.airavata.cloud.aurora.auroraClient;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.airavata.cloud.aurora.exception.AuroraException;
+import org.apache.airavata.cloud.aurora.utilities.AuroraUtilImpl;
+import org.apache.airavata.cloud.aurora.utilities.AuroraUtilI;
+
+public class AuroraJobSchedulerImpl implements AuroraJobSchedulerI {
+       AuroraUtilI util = new AuroraUtilImpl();
+       public void openWebUI(String key) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
job open "+key);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
opening the browser.\n"+ex.toString());
+               }
+       }
+       public void clusterQuota(String key) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
quota get "+key);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
retrieving the production quota of the cluster.\n"+ex.toString());
+               }
+       }
+       public void jobInspect(String key, String config) throws 
AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
job inspect "+key+" "+config);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
inspecting the job.\n"+ex.toString());
+               }
+       }
+       public void configList(String config) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
config list "+config);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
retrieving the list of jobs.\n"+ex.toString());
+               }
+       }
+       public void jobDiff(String key, String config) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
job diff "+key+" "+config);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
retrieving the job difference.\n"+ex.toString());
+               }
+       }
+       public void auroraJobCommand(String info, String command) throws 
AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
task run example/benchmarks/devel/"+info+" "+command);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
passing the command.\n"+ex.toString());
+               }
+       }
+       public void jobUpdateList(String info) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
update list example/benchmarks/devel/"+info);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+
+                       throw new AuroraException("Exception occured while 
listing the update.\n"+ex.toString());
+               }
+       }
+       public void jobUpdateAbort(String info) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
abort pause example/benchmarks/devel/"+info);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+
+                       throw new AuroraException("Exception occured while 
aborting the update.\n"+ex.toString());
+               }
+       }
+       public void jobUpdateResume(String info) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
update resume example/benchmarks/devel/"+info);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+
+                       throw new AuroraException("Exception occured while 
resuming the update.\n"+ex.toString());
+               }
+       }
+       public void jobUpdatePause(String info) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
update pause example/benchmarks/devel/"+info);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+
+                       throw new AuroraException("Exception occured while 
pausing the update.\n"+ex.toString());
+               }
+       }
+       public void jobUpdateInfo(String info) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
update info example/benchmarks/devel/"+info);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+
+                       throw new AuroraException("Exception occured while 
retrieving the update info."+ex.toString());
+               }
+       }
+
+       public void jobUpdate(String update) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
update start example/benchmarks/devel/"+update+" "+update+".aurora");
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+
+                       throw new AuroraException("Exception occured while 
updating the job.\n"+ex.toString());
+               }
+       }
+       public void jobRestart(String restart) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
job restart example/benchmarks/devel/"+restart);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
restarting the job.\n"+ex.toString());
+               }
+       }
+
+       public void jobKill(String kill) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
job killall example/benchmarks/devel/"+kill);
+                       auroraJob.waitFor();
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
killing the job.\n"+ex.toString());
+               }
+       }
+       public void jobLaunch(String name) throws AuroraException{
+               try{
+                       String line;
+                       Process auroraJob = Runtime.getRuntime().exec("aurora 
job create example/benchmarks/devel/"+name+" "+name+".aurora");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(auroraJob.getInputStream()));
+                       util.printLog(stdout);
+                       auroraJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
launching the job.\n"+ex.toString());
+               }
+       }
+       public void configCreate(String name, String ram, String cpu, String 
disk, String image) throws AuroraException{
+       try {
+               String config = "import hashlib\n"+name+"= Process(name = 
'"+name+"', cmdline = 'java -jar /dacapo-9.12-bach.jar "+name+" -s 
small')\n"+name+"_task = SequentialTask(processes = [ "+name+"], resources = 
Resources(cpu = "+cpu+", ram = "+ram+"*MB, disk="+disk+"*MB))\njobs = [ 
Job(cluster = 'example', environment = 'devel', role = 'benchmarks', name = 
'"+name+"', task = "+name+"_task, instances =1 , container = Container(docker = 
Docker(image = '"+image+"')))]\n";
+               File file = new File(name+".aurora");
+
+               if (!file.exists()) {
+                       file.createNewFile();
+               }
+
+               FileWriter fw = new FileWriter(file.getAbsoluteFile());
+               BufferedWriter bw = new BufferedWriter(fw);
+               bw.write(config);
+               bw.close();
+
+               }catch (IOException ex) {
+                       throw new AuroraException("IO Exception occured while 
creating the configuration file.\n"+ex.toString());
+               }catch (Exception ex) {
+                       throw new AuroraException("Exception occured while 
creating the configuration file.\n"+ex.toString());
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/AuroraInjectorImpl.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/AuroraInjectorImpl.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/AuroraInjectorImpl.java
new file mode 100644
index 0000000..25b54fe
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/AuroraInjectorImpl.java
@@ -0,0 +1,81 @@
+
+package org.apache.airavata.cloud.aurora.bigDataInjections;
+
+import java.util.Map;
+import java.util.List;
+
+
+import org.apache.airavata.cloud.aurora.auroraClient.AuroraJobSchedulerI;
+import org.apache.airavata.cloud.aurora.auroraClient.AuroraJobSchedulerImpl;
+import org.apache.airavata.cloud.aurora.exception.AuroraException;
+
+
+public class AuroraInjectorImpl implements BigDataInjectorI {
+    private AuroraJobSchedulerI auroraJS = null;
+    
+    public AuroraInjectorImpl(AuroraJobSchedulerI auroraJSIn) {
+       auroraJS = auroraJSIn;
+    }
+
+
+    public void executeTheBigDataClientSideCommand(Map<String, List<String>> 
commandLineOptions) {
+
+       
+       String commandName = commandLineOptions.get("o").get(0);
+       String RamSize, JobName, CpuCount, DiskSize, Image;
+
+               switch(commandName)
+               {
+                       case "kill" :
+                               try {
+                                       
auroraJS.jobKill(commandLineOptions.get("n").get(0));
+                               } catch(AuroraException ex){
+                               } break;
+                       case "restart" :
+                               try {
+                                       
auroraJS.jobRestart(commandLineOptions.get("n").get(0));
+                               } catch (AuroraException ex) {
+                               } break;
+                       case "update" :
+                               try {
+                                       
auroraJS.jobUpdate(commandLineOptions.get("n").get(0));
+                               } catch(AuroraException ex){
+                               } break;
+                       case "update-info" :
+                               try {
+                                       
auroraJS.jobUpdateInfo(commandLineOptions.get("n").get(0));
+                               } catch(AuroraException ex){
+                               } break;
+                       case "update-pause" :
+                               try {
+                                       
auroraJS.jobUpdatePause(commandLineOptions.get("n").get(0));
+                               } catch(AuroraException ex){
+                               } break;
+                       case "inspect" :
+                               try {
+                                       
auroraJS.jobInspect(commandLineOptions.get("n").get(0), 
commandLineOptions.get("k").get(0));
+                               } catch(AuroraException ex){
+                               } break;
+                       case "quota" :
+                               try {
+                                       
auroraJS.clusterQuota(commandLineOptions.get("k").get(0));
+                               } catch(AuroraException ex){
+                               } break;
+                       case "create" :
+                               JobName = commandLineOptions.get("n").get(0);
+                               RamSize = commandLineOptions.get("r").get(0);
+                               CpuCount = commandLineOptions.get("c").get(0);
+                               DiskSize = commandLineOptions.get("d").get(0);
+                               Image = commandLineOptions.get("i").get(0);
+                               try {
+                                       
auroraJS.configCreate(JobName,RamSize,CpuCount,DiskSize,Image);
+                               } catch (AuroraException ex) {}
+                               try {
+                                       auroraJS.jobLaunch(JobName);
+                               } catch (AuroraException ex) {
+                               } break;
+                       default :
+                               System.out.println("Improper option\nOptions 
available:\n1) create\n2) kill\n3) restart\n4) update\n 5) update-info\n6) 
update-pause\n");
+               }
+    } // end of public void executeTheBigDataCommand
+} // end of public class AuroraInjectorImpl

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/BigDataInjectorI.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/BigDataInjectorI.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/BigDataInjectorI.java
new file mode 100644
index 0000000..e821bc8
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/bigDataInjections/BigDataInjectorI.java
@@ -0,0 +1,12 @@
+
+package org.apache.airavata.cloud.aurora.bigDataInjections;
+
+import java.util.Map;
+import java.util.List;
+
+
+public interface BigDataInjectorI {
+
+    // TODO: this interface should throw an exception
+    public void executeTheBigDataClientSideCommand(Map<String, List<String>> 
commandLineOptions);
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/driver/AuroraAdminDriver.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/driver/AuroraAdminDriver.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/driver/AuroraAdminDriver.java
new file mode 100644
index 0000000..0a3cc62
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/driver/AuroraAdminDriver.java
@@ -0,0 +1,62 @@
+package org.apache.airavata.cloud.aurora.driver;
+
+// TODO: need javadoc documentation at the top of each method
+
+// TODO: individually import the types
+import java.util.*;
+
+import org.apache.airavata.cloud.aurora.exception.AuroraException;
+import org.apache.airavata.cloud.aurora.auroraClient.AuroraJobSchedulerI;
+import org.apache.airavata.cloud.aurora.auroraClient.AuroraJobSchedulerImpl;
+import org.apache.airavata.cloud.aurora.bigDataInjections.AuroraInjectorImpl;
+import org.apache.airavata.cloud.aurora.bigDataInjections.BigDataInjectorI;
+
+public class AuroraAdminDriver{
+       public static void main(String[] args) {
+
+           // TODO: do command line validation
+
+           // Processing of the command line arguments should be moved to a 
different method
+
+
+
+           // This code to add command line arguments is based on Apache 
Commons
+
+           // TODO: explain why this Map data structure is needed
+               Map<String, List<String>> params = new HashMap<>();
+               
+               // TODO: explain what is the purpose of this List
+               List<String> options = null;
+               for (int i = 0; i < args.length; i++) {
+                       final String a = args[i];
+                       if (a.charAt(0) == '-') {
+                               if (a.length() < 2) {
+                                   // TOOD: need more details in the error 
statement
+                                   System.err.println("Error at argument " + 
a);
+                                   return;
+                               }
+                               // TODO: explain the purpose of this ArrayList
+                               options = new ArrayList<>();
+                               params.put(a.substring(1), options);
+                       }
+                       // TODO: explain when this "else" branch is taken
+                       else if (options != null) {
+                               options.add(a);
+                       }
+                       else {
+
+                               System.err.println("Illegal parameter 
\n[USAGE]\nOptions:\n1) -o\tcreate, kill, restart, update, update-info, 
update-pause\n2) -n\tname of the job\n 3) -r\tamount of RAM\n 4) -c\tCPU 
count\n 5) -d\tdisk space\n 6) -k\tname of the task to be killed\n 7) 
-i\texecutable/image\n ");
+                               return;
+                       }
+
+                       
+               }// end of for (int i=0; ...
+               
+               // use the code below to decide between injecting Aurora, 
Marathon, etc. as injections 
+               AuroraJobSchedulerI auroraJS = new AuroraJobSchedulerImpl();
+               BigDataInjectorI auroraInjector = new 
AuroraInjectorImpl(auroraJS);
+               auroraInjector.executeTheBigDataClientSideCommand(params); 
+
+
+       } // end of public static void main
+} // end of class

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/exception/AuroraException.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/exception/AuroraException.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/exception/AuroraException.java
new file mode 100644
index 0000000..b3a6abd
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/exception/AuroraException.java
@@ -0,0 +1,15 @@
+package org.apache.airavata.cloud.aurora.exception;
+
+public class AuroraException extends Exception {
+    private String exceptionMsg;
+    public AuroraException(){
+       exceptionMsg="";
+    }
+    public AuroraException(String exceptionMsgIn){
+       exceptionMsg=exceptionMsgIn;;
+    }
+
+    public String toString(){
+       return  this.exceptionMsg;
+    }
+ }

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilI.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilI.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilI.java
new file mode 100644
index 0000000..7ba3fad
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilI.java
@@ -0,0 +1,9 @@
+package org.apache.airavata.cloud.aurora.utilities;
+
+import java.io.BufferedReader;
+
+import org.apache.airavata.cloud.aurora.exception.AuroraException;
+
+public interface AuroraUtilI{
+  public void printLog(BufferedReader stdout) throws AuroraException;
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilImpl.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilImpl.java
 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilImpl.java
new file mode 100644
index 0000000..e2ad948
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/AuroraIntegration/src/org/apache/airavata/cloud/aurora/utilities/AuroraUtilImpl.java
@@ -0,0 +1,25 @@
+
+package org.apache.airavata.cloud.aurora.utilities;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+import org.apache.airavata.cloud.aurora.exception.AuroraException;
+
+public class AuroraUtilImpl implements AuroraUtilI{
+  public void printLog(BufferedReader stdout) throws AuroraException
+  {
+    try{
+      String line;
+      line = stdout.readLine();
+      while (line != null) {
+          System.out.println(line);
+          line = stdout.readLine();
+        }
+      }
+      catch (IOException ex) {
+                       throw new AuroraException("IO Exception occured while 
passing the command.\n"+ex.toString());
+               }
+  }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/README.txt
----------------------------------------------------------------------
diff --git a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/README.txt 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/README.txt
new file mode 100644
index 0000000..d77fd91
--- /dev/null
+++ b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/README.txt
@@ -0,0 +1,16 @@
+
+
+## Temporarily using ANT compile the Aurora Management code.
+## TODO: integrate with maven build system, instead of using ANT
+
+#In the following directory run the compilation command:
+airavata/modules/cloud/MarathonIntegration/src
+
+#Compilation command
+ant all
+
+#Run command
+## TODO: add the command to run and test the code
+
+## Add sample output that shows the Marathon code working
+

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/build.xml
----------------------------------------------------------------------
diff --git a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/build.xml 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/build.xml
new file mode 100644
index 0000000..5533336
--- /dev/null
+++ b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/build.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project name="aurora" default="compile_all" basedir="..">
+
+  <property name="BUILD.compiler"       value="modern"/>
+  <property name="src"                  value="src"/>
+  <property name="BUILD"                value="BUILD"/>
+  <property name="classes"              value="${BUILD}/classes"/>
+
+
+  <target name="all" depends="compile_all"/>
+
+  <target name="compile_all"
+          depends="org"/>
+
+  <target name="clean">
+       <delete dir="${BUILD}"/>
+  </target>
+
+  <!-- Prepare target directories -->
+  <target name="prepare">
+        <mkdir dir="${BUILD}"/>
+        <mkdir dir="${classes}"/>
+  </target>
+
+
+ <target name="jar">
+        <mkdir dir="${BUILD}/jar"/>
+        <jar destfile="${BUILD}/jar/auroraDriverl.jar" 
basedir="${BUILD}/classes">
+            <manifest>
+                <attribute name="Main-Class" 
value="org.apache.airavata.cloud.aurora.driver.AuroraAdminDriver"/>
+            </manifest>
+        </jar>
+    </target>
+
+
+
+  <!-- ** means all subdirectories as well -->
+  <!-- * means all files in the current directory -->
+  <!-- for just java files use *.java -->
+
+  <target name="org" depends="prepare">
+    <javac srcdir="${src}"
+           includes="org/**"
+           excludes="**/package.html"
+           destdir="${classes}"
+           classpath="${classes}"
+           debug="on"
+           optimize="on"
+           deprecation="off"/>
+  </target>
+
+
+</project>

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/BigDataInjectorI.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/BigDataInjectorI.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/BigDataInjectorI.java
new file mode 100644
index 0000000..9fe41a1
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/BigDataInjectorI.java
@@ -0,0 +1,12 @@
+
+package org.apache.airavata.cloud.marathon.bigDataInjections;
+
+import java.util.Map;
+import java.util.List;
+
+
+public interface BigDataInjectorI {
+
+    // TODO: this interface should throw an exception
+    public void executeTheBigDataClientSideCommand(Map<String, List<String>> 
commandLineOptions);
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/MarathonInjectorImpl.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/MarathonInjectorImpl.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/MarathonInjectorImpl.java
new file mode 100644
index 0000000..c4a3978
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/bigDataInjections/MarathonInjectorImpl.java
@@ -0,0 +1,52 @@
+
+package org.apache.airavata.cloud.marathon.bigDataInjections;
+
+import java.util.Map;
+import java.util.List;
+
+
+import org.apache.airavata.cloud.marathon.marathonClient.MarathonJobSchedulerI;
+import 
org.apache.airavata.cloud.marathon.marathonClient.MarathonJobSchedulerImpl;
+import org.apache.airavata.cloud.marathon.exception.MarathonException;
+
+
+public class MarathonInjectorImpl implements BigDataInjectorI {
+    private MarathonJobSchedulerI marathonJS = null;
+    
+    public MarathonInjectorImpl(MarathonJobSchedulerI marathonJSIn) {
+       marathonJS = marathonJSIn;
+    }
+
+
+    public void executeTheBigDataClientSideCommand(Map<String, List<String>> 
commandLineOptions) {
+
+       
+       String commandName = commandLineOptions.get("o").get(0);
+       String RamSize, JobName, CpuCount, DiskSize, Image, Command;
+
+               switch(commandName)
+               {
+                       case "kill" :
+                               try {
+                                       
marathonJS.jobKill(commandLineOptions.get("n").get(0),commandLineOptions.get("a").get(0));
+                               } catch(MarathonException ex){
+                               } break;
+                       case "create" :
+                               JobName = commandLineOptions.get("n").get(0);
+                               RamSize = commandLineOptions.get("r").get(0);
+                               CpuCount = commandLineOptions.get("c").get(0);
+                               DiskSize = commandLineOptions.get("d").get(0);
+                               Image = commandLineOptions.get("i").get(0);
+                               Command = commandLineOptions.get("a").get(0);
+                               try {
+                                       
marathonJS.configCreate(JobName,RamSize,CpuCount,DiskSize,Image, Command);
+                               } catch (MarathonException ex) {}
+                               try {
+                                       
marathonJS.jobLaunch(JobName,commandLineOptions.get("a").get(0));
+                               } catch (MarathonException ex) {
+                               } break;
+                       default :
+                               System.out.println("Improper option\nOptions 
available:\n1) create\n2) kill\n");
+               }
+    } // end of public void executeTheBigDataCommand
+} // end of public class AuroraInjectorImpl

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/driver/MarathonAdminDriver.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/driver/MarathonAdminDriver.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/driver/MarathonAdminDriver.java
new file mode 100644
index 0000000..67fdde8
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/driver/MarathonAdminDriver.java
@@ -0,0 +1,61 @@
+package org.apache.airavata.cloud.marathon.driver;
+
+// TODO: need javadoc documentation at the top of each method
+
+// TODO: individually import the types
+import java.util.*;
+
+import org.apache.airavata.cloud.marathon.exception.MarathonException;
+import 
org.apache.airavata.cloud.marathon.marathonClient.MarathonJobSchedulerImpl;
+import org.apache.airavata.cloud.marathon.marathonClient.MarathonJobSchedulerI;
+import 
org.apache.airavata.cloud.marathon.bigDataInjections.MarathonInjectorImpl;
+import org.apache.airavata.cloud.marathon.bigDataInjections.BigDataInjectorI;
+
+public class MarathonAdminDriver{
+       public static void main(String[] args) {
+
+           // TODO: do command line validation
+
+           // Processing of the command line arguments should be moved to a 
different method
+
+
+
+           // This code to add command line arguments is based on Apache 
Commons
+
+           // TODO: explain why this Map data structure is needed
+               Map<String, List<String>> params = new HashMap<>();
+               
+               // TODO: explain what is the purpose of this List
+               List<String> options = null;
+               for (int i = 0; i < args.length; i++) {
+                       final String a = args[i];
+                       if (a.charAt(0) == '-') {
+                               if (a.length() < 2) {
+                                   // TOOD: need more details in the error 
statement
+                                   System.err.println("Error at argument " + 
a);
+                                   return;
+                               }
+                               // TODO: explain the purpose of this ArrayList
+                               options = new ArrayList<>();
+                               params.put(a.substring(1), options);
+                       }
+                       // TODO: explain when this "else" branch is taken
+                       else if (options != null) {
+                               options.add(a);
+                       }
+                       else {
+
+                               System.err.println("Illegal parameter 
\n[USAGE]\nOptions:\n1) -o\tcreate, kill, restart, update, update-info, 
update-pause\n2) -n\tname of the job\n 3) -r\tamount of RAM\n 4) -c\tCPU 
count\n 5) -d\tdisk space\n 6) -k\tname of the task to be killed\n 7) 
-i\texecutable/image\n ");
+                               return;
+                       }
+
+                       
+               }// end of for (int i=0; ...
+               
+               MarathonJobSchedulerI marathonJS = new 
MarathonJobSchedulerImpl();
+               BigDataInjectorI marathonInjector = new 
MarathonInjectorImpl(marathonJS);
+               marathonInjector.executeTheBigDataClientSideCommand(params); 
+
+
+       } // end of public static void main
+} // end of class

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/exception/MarathonException.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/exception/MarathonException.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/exception/MarathonException.java
new file mode 100644
index 0000000..bef09f2
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/exception/MarathonException.java
@@ -0,0 +1,15 @@
+package org.apache.airavata.cloud.marathon.exception;
+
+public class MarathonException extends Exception {
+    private String exceptionMsg;
+    public MarathonException(){
+       exceptionMsg="";
+    }
+    public MarathonException(String exceptionMsgIn){
+       exceptionMsg=exceptionMsgIn;;
+    }
+
+    public String toString(){
+       return  this.exceptionMsg;
+    }
+ }

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerI.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerI.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerI.java
new file mode 100644
index 0000000..423a7c4
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerI.java
@@ -0,0 +1,28 @@
+package org.apache.airavata.cloud.marathon.marathonClient;
+
+import org.apache.airavata.cloud.marathon.exception.MarathonException;
+
+public interface MarathonJobSchedulerI {
+
+       public void deleteMarathonLeader(String address) throws 
MarathonException;
+       public void marathonLeader(String address) throws MarathonException;
+       public void marathonInfo(String address) throws MarathonException;
+       public void launchQueue(String address) throws MarathonException;
+       public void eventSubscriptionList(String address) throws 
MarathonException;
+       public void eventsList(String address) throws MarathonException;
+       public void deleteDeployment(String address, String id) throws 
MarathonException;
+       public void deploymentList(String address) throws MarathonException;
+       public void deleteGroups(String address, String id) throws 
MarathonException;
+       public void createGroups(String address, String json) throws 
MarathonException;
+       public void groups(String address) throws MarathonException;
+       public void groupsId(String address, String groupid) throws 
MarathonException;
+       public void jobDeleteId(String address, String appid, String taskid) 
throws MarathonException;
+       public void jobDelete(String address, String appid) throws 
MarathonException;
+       public void runningJobs(String address, String appid) throws 
MarathonException;
+       public void jobListById(String address, String id) throws 
MarathonException;
+       public void jobListByName(String address, String name) throws 
MarathonException;
+       public void jobList(String address) throws MarathonException;
+       public void jobKill(String kill, String address) throws 
MarathonException;
+       public void jobLaunch(String name, String address) throws 
MarathonException;
+       public void configCreate(String name, String ram, String cpu, String 
disk, String image, String command) throws MarathonException;
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerImpl.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerImpl.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerImpl.java
new file mode 100644
index 0000000..0f7fdb4
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/marathonClient/MarathonJobSchedulerImpl.java
@@ -0,0 +1,296 @@
+package org.apache.airavata.cloud.marathon.marathonClient;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.airavata.cloud.marathon.exception.MarathonException;
+import org.apache.airavata.cloud.marathon.utilities.MarathonUtilImpl;
+import org.apache.airavata.cloud.marathon.utilities.MarathonUtilI;
+
+public class MarathonJobSchedulerImpl implements MarathonJobSchedulerI {
+       MarathonUtilI util = new MarathonUtilImpl();
+       public void deleteMarathonLeader(String address) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
-X DELETE "+address+"/v2/leader");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the launch queue.\n"+ex.toString());
+               }
+       }
+       public void marathonLeader(String address) throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/leader");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the leader information.\n"+ex.toString());
+               }
+       }
+       public void marathonInfo(String address) throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/info");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the marathon information.\n"+ex.toString());
+               }
+       }
+       public void launchQueue(String address) throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/queue");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the launch queue.\n"+ex.toString());
+               }
+       }
+       public void eventSubscriptionList(String address) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/eventSubscriptions");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list of event subscriptions.\n"+ex.toString());
+               }
+       }
+       public void eventsList(String address) throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/events");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list of events.\n"+ex.toString());
+               }
+       }
+       public void deleteDeployment(String address, String id) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
-X DELETE "+address+"/v2/deployments/"+id);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
deleting the deployment.\n"+ex.toString());
+               }
+       }
+       public void deploymentList(String address) throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/deployments");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list of deployment.\n"+ex.toString());
+               }
+       }
+       public void deleteGroups(String address, String id) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
-X DELETE "+address+"/v2/groups/"+id);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
deleting the group.\n"+ex.toString());
+               }
+       }
+       public void createGroups(String address, String json) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
-X POST -H \"Content-type: application/json\" "+address+"/v2/groups/"+json);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
creating the group.\n"+ex.toString());
+               }
+       }
+       public void groups(String address) throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/groups/");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list of groups.\n"+ex.toString());
+               }
+       }
+       public void groupsId(String address, String groupid) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/groups/"+groupid);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list of groups.\n"+ex.toString());
+               }
+       }
+       public void jobDeleteId(String address, String appid, String taskid) 
throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
DELETE "+address+"/v2/apps/"+appid+"/"+taskid);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list jobs.\n"+ex.toString());
+               }
+       }
+       public void jobDelete(String address, String appid) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
DELETE "+address+"/v2/apps/"+appid+"/tasks");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list jobs.\n"+ex.toString());
+               }
+       }
+       public void runningJobs(String address, String appid) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/apps/"+appid+"/tasks");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list jobs.\n"+ex.toString());
+               }
+       }
+       public void jobListById(String address, String id) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/apps/"+id);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list jobs.\n"+ex.toString());
+               }
+       }
+       public void jobListByName(String address, String name) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/apps/"+name);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list jobs.\n"+ex.toString());
+               }
+       }
+       public void jobList(String address) throws MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
GET "+address+"/v2/apps");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
retrieving the list jobs.\n"+ex.toString());
+               }
+       }
+       public void jobKill(String name, String address) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
-X DELETE "+address+""+name);
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
killing the job.\n"+ex.toString());
+               }
+       }
+       public void jobLaunch(String name, String address) throws 
MarathonException{
+               try{
+                       String line;
+                       Process marathonJob = Runtime.getRuntime().exec("curl 
-X POST "+address+"/v2/apps -d @"+name+" -H Content-type: application/json");
+                       BufferedReader stdout = new BufferedReader(new 
InputStreamReader(marathonJob.getInputStream()));
+                       util.printLog(stdout);
+                       marathonJob.waitFor();
+               }
+
+               catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
launching the job.\n"+ex.toString());
+               }
+       }
+       public void configCreate(String name, String ram, String cpu, String 
disk, String image, String command) throws MarathonException{
+       try {
+               String config = "'id': "+name+",'cmd': \""+command+"\", 
\"container\": {\"type\": \"DOCKER\", \"docker\": {\"image\": \""+image+"\", 
\"forcePullImage\": 
bool(1)}},\"constraints\":[[\"hostname\",\"UNIQUE\"]],\"cpus\": float("+cpu+"), 
\"mem\": "+ram+"), \"disk\": "+disk+", \"instances\": 1";
+               File file = new File(name+".json");
+
+               if (!file.exists()) {
+                       file.createNewFile();
+               }
+
+               FileWriter fw = new FileWriter(file.getAbsoluteFile());
+               BufferedWriter bw = new BufferedWriter(fw);
+               bw.write(config);
+               bw.close();
+
+               }catch (IOException ex) {
+                       throw new MarathonException("IO Exception occured while 
creating the configuration file.\n"+ex.toString());
+               }catch (Exception ex) {
+                       throw new MarathonException("Exception occured while 
creating the configuration file.\n"+ex.toString());
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilI.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilI.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilI.java
new file mode 100644
index 0000000..492399e
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilI.java
@@ -0,0 +1,9 @@
+package org.apache.airavata.cloud.marathon.utilities;
+
+import java.io.BufferedReader;
+
+import org.apache.airavata.cloud.marathon.exception.MarathonException;
+
+public interface MarathonUtilI{
+  public void printLog(BufferedReader stdout) throws MarathonException;
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/be595299/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilImpl.java
----------------------------------------------------------------------
diff --git 
a/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilImpl.java
 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilImpl.java
new file mode 100644
index 0000000..15e4f9c
--- /dev/null
+++ 
b/gsoc2016/Big-Data-Integration/MarathonIntegration/src/org/apache/airavata/cloud/marathon/utilities/MarathonUtilImpl.java
@@ -0,0 +1,25 @@
+
+package org.apache.airavata.cloud.marathon.utilities;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+import org.apache.airavata.cloud.marathon.exception.MarathonException;
+
+public class MarathonUtilImpl implements MarathonUtilI{
+  public void printLog(BufferedReader stdout) throws MarathonException
+  {
+    try{
+      String line;
+      line = stdout.readLine();
+      while (line != null) {
+          System.out.println(line);
+          line = stdout.readLine();
+        }
+      }
+      catch (IOException ex) {
+                       throw new MarathonException("IO Exception occured while 
passing the command.\n"+ex.toString());
+               }
+  }
+}

Reply via email to