This commit is contained in:
Nunzio Andrea Galante 2017-07-31 11:21:47 +00:00
parent d2f5e9d963
commit 2c4ee18a2b
4 changed files with 92 additions and 15 deletions

View File

@ -50,11 +50,12 @@ public class RestPoolManager implements PoolManager {
@Path("/algorithm/stage")
@Produces("text/plain")
public String stageAlgorithm(
@QueryParam("algorithmPackageURL") String algorithmPackageURL
@QueryParam("algorithmPackageURL") String algorithmPackageURL,
@QueryParam("targetVRE") String targetVRE
/*@QueryParam("category") String category*/) throws IOException, InterruptedException {
Algorithm algo = AlgorithmBuilder.create(algorithmPackageURL);
String env = context.application().getInitParameter("Environment");
return this.service.stageAlgorithm(algo,env);
return this.service.stageAlgorithm(algo,env,targetVRE);
***REMOVED***
@ -217,6 +218,13 @@ public class RestPoolManager implements PoolManager {
***REMOVED***
@Override
public String stageAlgorithm(String algorithmPackageURL) throws IOException, InterruptedException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***

View File

@ -28,14 +28,14 @@ public class DataminerPoolManager {
***REMOVED***
public String stageAlgorithm(Algorithm algo, String env) throws IOException, InterruptedException {
public String stageAlgorithm(Algorithm algo, String env, String targetVRE) throws IOException, InterruptedException {
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***

View File

@ -77,6 +77,9 @@ public class StagingJob extends DMPMJob {
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"));

View File

@ -11,6 +11,7 @@ import java.util.Vector;
import javax.jms.ServerSession;
import org.apache.activemq.transport.tcp.ExceededMaximumConnectionsException;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
import com.jcraft.jsch.Channel;
@ -90,7 +91,7 @@ public class CheckMethod {
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 {
return false;
***REMOVED***
public void deleteFiles(Algorithm a,String env) throws Exception{
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))){
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 {
JSch jsch = new JSch();
Session session = null;
@ -233,18 +289,28 @@ public class CheckMethod {
***REMOVED***a.copyFromDmToSVN(aa);
if (a.checkMethod("dataminer1-devnext.d4science.org", "708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548")){
System.out.println("AAA");***REMOVED***
if (a.doesExist("/home/gcube/wps_algorithms/algorithms/RBLACKBOX.jar","Dev")){
System.out.println("BBBB");
***REMOVED*** if (a.checkMethod("dataminer1-devnext.d4science.org", "708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548")){
***REMOVED*** System.out.println("AAA");***REMOVED***
***REMOVED***
***REMOVED*** if (a.doesExist("/home/gcube/wps_algorithms/algorithms/RBLACKBOX.jar","Dev")){
***REMOVED*** System.out.println("BBBB");
***REMOVED***
***REMOVED******REMOVED***
***REMOVED*** if (a.doesExist("/home/gcube/wps_algorithms/algorithms/RBLACKBOX_interface.jar","Dev")){
***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")){
System.out.println("CCCC");***REMOVED***
File aa = new File("/home/gcube/wps_algorithms/algorithms/RBLACKBOX_interface.jar");
a.copyFromDmToSVN(aa, "Dev");
***REMOVED***