From 43c4be524993504f05254447b80079f0161dbce8 Mon Sep 17 00:00:00 2001 From: Nunzio Andrea Galante Date: Mon, 31 Jul 2017 11:21:47 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@151456 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../service/DataminerPoolManager.java | 4 +- .../poolmanager/service/StagingJob.java | 3 + .../poolmanager/util/CheckMethod.java | 88 ++++++++++++++++--- 3 files changed, 82 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java index 326886e..ad90c0d 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java @@ -28,14 +28,14 @@ public class DataminerPoolManager ***REMOVED*** ***REMOVED*** -***REMOVED***Algorithm algo, String env) throws IOException, InterruptedException ***REMOVED*** +***REMOVED***Algorithm algo, String env, String targetVRE) throws IOException, InterruptedException ***REMOVED*** Cluster stagingCluster = ClusterBuilder.getStagingDataminerCluster(env); ***REMOVED***Cluster rProtoCluster = ClusterBuilder.getRProtoCluster(); - DMPMJob job = new StagingJob(this.svnUpdater, algo, stagingCluster, /*rProtoCluster,*/ ScopeProvider.instance.get(), env); + DMPMJob job = new StagingJob(this.svnUpdater, algo, stagingCluster, /*rProtoCluster,*/ targetVRE, env); String id = job.start(); return id; ***REMOVED*** diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java index cae3b65..3a9b0e9 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java @@ -77,6 +77,9 @@ public class StagingJob extends DMPMJob ***REMOVED*** return; ***REMOVED*** + ***REMOVED***before the installation to check if the files exist + b.deleteFiles(this.algorithm, env);; + int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.stagingCluster, false, "root")); diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java index 73c1f32..455cfb1 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java @@ -11,6 +11,7 @@ import java.util.Vector; import javax.jms.ServerSession; +import org.apache.activemq.transport.tcp.ExceededMaximumConnectionsException; ***REMOVED*** import com.jcraft.jsch.Channel; @@ -90,7 +91,7 @@ public class CheckMethod ***REMOVED*** File file = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+".jar"); File file2 = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+"_interface.jar"); - + System.out.println("First file is located to: "+file.getPath()); System.out.println("Second file is located to: "+file2.getPath()); @@ -108,7 +109,62 @@ public class CheckMethod ***REMOVED*** return false; ***REMOVED*** + + public void deleteFiles(Algorithm a,String env) throws Exception***REMOVED*** + JSch jsch = new JSch(); + Session session = null; + Channel channel = null; + ChannelSftp c = null; + ServiceConfiguration p = new ServiceConfiguration(); + System.out.println("checking existing in env: "+ env + " " + p.getHost(env)); + File file = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+".jar"); + File file2 = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+"_interface.jar"); + + + System.out.println("First file is located to: "+file.getPath()); + System.out.println("Second file is located to: "+file2.getPath()); + + + jsch.setKnownHosts("~/.ssh/known_hosts"); + String privateKey = "~/.ssh/id_rsa"; + + jsch.addIdentity(privateKey); + System.out.println("Private Key Added."); + + session = jsch.getSession("root", p.getHost(env)); + System.out.println("session created."); + + java.util.Properties config = new java.util.Properties(); + config.put("StrictHostKeyChecking", "no"); + + session.setConfig(config); + session.connect(); + + channel = session.openChannel("sftp"); + channel.connect(); + System.out.println("shell channel connected...."); + + c = (ChannelSftp) channel; + + if(doesExist(file.getPath(),env)&&(doesExist(file2.getPath(),env)))***REMOVED*** + + c.rm(file.getPath()); + c.rm(file2.getPath()); + System.out.println("Both the files have been deleted"); + ***REMOVED*** + else System.out.println("Files not found"); + channel.disconnect(); + c.disconnect(); + session.disconnect(); + +***REMOVED*** + + + + + + public boolean doesExist(String path, String env) throws Exception ***REMOVED*** JSch jsch = new JSch(); Session session = null; @@ -233,18 +289,28 @@ public class CheckMethod ***REMOVED*** ***REMOVED***a.copyFromDmToSVN(aa); - if (a.checkMethod("dataminer1-devnext.d4science.org", "***REMOVED***"))***REMOVED*** - System.out.println("AAA");***REMOVED*** - - if (a.doesExist("/home/gcube/wps_algorithms/algorithms/RBLACKBOX.jar","Dev"))***REMOVED*** - System.out.println("BBBB"); +***REMOVED*** if (a.checkMethod("dataminer1-devnext.d4science.org", "***REMOVED***"))***REMOVED*** +***REMOVED*** System.out.println("AAA");***REMOVED*** +***REMOVED*** +***REMOVED*** if (a.doesExist("/home/gcube/wps_algorithms/algorithms/RBLACKBOX.jar","Dev"))***REMOVED*** +***REMOVED*** System.out.println("BBBB"); +***REMOVED*** +***REMOVED******REMOVED*** +***REMOVED*** if (a.doesExist("/home/gcube/wps_algorithms/algorithms/RBLACKBOX_interface.jar","Dev"))***REMOVED*** +***REMOVED*** System.out.println("CCCC");***REMOVED*** +***REMOVED*** +***REMOVED*** File aa = new File("/home/gcube/wps_algorithms/algorithms/RBLACKBOX_interface.jar"); +***REMOVED*** a.copyFromDmToSVN(aa, "Dev"); + + + + Algorithm al = new Algorithm(); + al.setName("RBLACKBOX"); + a.deleteFiles(al, "Dev"); + + -***REMOVED*** - if (a.doesExist("/home/gcube/wps_algorithms/algorithms/RBLACKBOX_interface.jar","Dev"))***REMOVED*** - System.out.println("CCCC");***REMOVED*** - File aa = new File("/home/gcube/wps_algorithms/algorithms/RBLACKBOX_interface.jar"); - a.copyFromDmToSVN(aa, "Dev"); ***REMOVED***