git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@151308 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8a35a0c831
commit
2c3e5c6964
|
@ -67,12 +67,12 @@ public class ProductionPublishingJob extends DMPMJob ***REMOVED***
|
||||||
String response = "";
|
String response = "";
|
||||||
|
|
||||||
if (exitstatus == 9) ***REMOVED***
|
if (exitstatus == 9) ***REMOVED***
|
||||||
response = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE" + targetVREName;
|
response = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE " + targetVREName;
|
||||||
writer.println(response);
|
writer.println(response);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
if (exitstatus == 0) ***REMOVED***
|
if (exitstatus == 0) ***REMOVED***
|
||||||
response = "SVN REPOSITORY UPDATE FAI; THE CRON JOB WILL NOT BE ABLE TO INSTALL THE ALGORITHM "+this.algorithm.getName()+" IN THE VRE" + targetVREName;;
|
response = "SVN REPOSITORY UPDATE FAI; THE CRON JOB WILL NOT BE ABLE TO INSTALL THE ALGORITHM "+this.algorithm.getName()+" IN THE VRE " + targetVREName;;
|
||||||
writer.println(response);
|
writer.println(response);
|
||||||
***REMOVED***writer.close();
|
***REMOVED***writer.close();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -21,9 +21,12 @@ import com.jcraft.jsch.SftpATTRS;
|
||||||
import com.jcraft.jsch.SftpException;
|
import com.jcraft.jsch.SftpException;
|
||||||
|
|
||||||
public class CheckMethod ***REMOVED***
|
public class CheckMethod ***REMOVED***
|
||||||
|
|
||||||
|
protected SVNUpdater svnUpdater;
|
||||||
|
|
||||||
public CheckMethod() ***REMOVED***
|
public CheckMethod() ***REMOVED***
|
||||||
|
this.svnUpdater = svnUpdater;
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
public boolean checkMethod(String machine, String token) throws Exception ***REMOVED***
|
public boolean checkMethod(String machine, String token) throws Exception ***REMOVED***
|
||||||
|
@ -83,14 +86,20 @@ public class CheckMethod ***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
public boolean algoExists(Algorithm a) throws Exception***REMOVED***
|
public boolean algoExists(Algorithm a) throws Exception***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
File file = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+".jar");
|
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");
|
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("First file is located to: "+file.getPath());
|
||||||
System.out.println("Second file is located to: "+file2.getPath());
|
System.out.println("Second file is located to: "+file2.getPath());
|
||||||
|
|
||||||
|
|
||||||
if ((this.doesExist(file.getPath())) && (this.doesExist(file2.getPath())))***REMOVED***
|
if ((this.doesExist(file.getPath())) && (this.doesExist(file2.getPath())))***REMOVED***
|
||||||
|
this.svnUpdater.updateAlgorithmFiles(file);
|
||||||
|
this.svnUpdater.updateAlgorithmFiles(file2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.tools.ant.FileScanner;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
||||||
|
import org.tmatesoft.sqljet.core.internal.lang.SqlParser.column_constraint_check_return;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
import org.tmatesoft.svn.core.SVNNodeKind;
|
||||||
import org.tmatesoft.svn.core.SVNURL;
|
import org.tmatesoft.svn.core.SVNURL;
|
||||||
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
|
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
|
||||||
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
|
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
|
||||||
|
@ -15,6 +19,7 @@ import org.tmatesoft.svn.core.wc.SVNWCUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -167,6 +172,122 @@ public class SVNUpdater ***REMOVED***
|
||||||
this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, user, env);
|
this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, user, env);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public void updateAlgorithmFiles(File a) throws SVNException***REMOVED***
|
||||||
|
this.updateAlgorithmList(this.configuration.getSVNMainAlgoRepo(), a);
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
private void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException ***REMOVED***
|
||||||
|
try ***REMOVED***
|
||||||
|
System.out.println("Adding .jar file: " + a + " to repository " + svnMainAlgoRepo);
|
||||||
|
|
||||||
|
if (fileExists(svnMainAlgoRepo+File.separator+a.getName(), -1))***REMOVED***
|
||||||
|
this.updateFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo, a.getName());
|
||||||
|
|
||||||
|
***REMOVED***
|
||||||
|
else this.putFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo,a.getName());
|
||||||
|
|
||||||
|
***REMOVED*** catch (Exception ex) ***REMOVED***
|
||||||
|
ex.printStackTrace();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
finally ***REMOVED***
|
||||||
|
svnRepository.closeSession();
|
||||||
|
***REMOVED***
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void putFile(ByteArrayInputStream byteArrayInputStream, String destinationFolder, String fileName)
|
||||||
|
throws SVNException ***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
final ISVNEditor commitEditor = svnRepository.getCommitEditor("Add algorithm to list", null);
|
||||||
|
commitEditor.openRoot(-1);
|
||||||
|
commitEditor.openDir(destinationFolder, -1);
|
||||||
|
|
||||||
|
|
||||||
|
String filePath = destinationFolder + "/" + fileName;
|
||||||
|
|
||||||
|
|
||||||
|
***REMOVED***commitEditor.openFile(filePath, -1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
commitEditor.addFile(filePath, null, -1);
|
||||||
|
|
||||||
|
commitEditor.applyTextDelta(filePath, null);
|
||||||
|
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
|
||||||
|
String checksum = deltaGenerator.sendDelta(filePath, byteArrayInputStream, commitEditor, true);
|
||||||
|
commitEditor.closeFile(filePath, checksum);
|
||||||
|
commitEditor.closeDir();
|
||||||
|
commitEditor.closeDir();
|
||||||
|
commitEditor.closeEdit();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public void updateFile(ByteArrayInputStream byteArrayInputStream, String destinationFolder, String fileName)
|
||||||
|
throws SVNException ***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
final ISVNEditor commitEditor = svnRepository.getCommitEditor("Add algorithm to list", null);
|
||||||
|
commitEditor.openRoot(-1);
|
||||||
|
commitEditor.openDir(destinationFolder, -1);
|
||||||
|
|
||||||
|
|
||||||
|
String filePath = destinationFolder + "/" + fileName;
|
||||||
|
|
||||||
|
***REMOVED*** if (fileExists(filePath, -1)) ***REMOVED*** ***REMOVED*** updating existing file
|
||||||
|
|
||||||
|
commitEditor.openFile(filePath, -1);
|
||||||
|
|
||||||
|
***REMOVED******REMOVED*** else ***REMOVED*** ***REMOVED*** creating new file
|
||||||
|
|
||||||
|
***REMOVED***commitEditor.addFile(filePath, null, -1);
|
||||||
|
***REMOVED******REMOVED***
|
||||||
|
commitEditor.applyTextDelta(filePath, null);
|
||||||
|
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
|
||||||
|
String checksum = deltaGenerator.sendDelta(filePath, byteArrayInputStream, commitEditor, true);
|
||||||
|
commitEditor.closeFile(filePath, checksum);
|
||||||
|
commitEditor.closeDir();
|
||||||
|
commitEditor.closeDir();
|
||||||
|
commitEditor.closeEdit();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean fileExists(String path, long revision) throws SVNException ***REMOVED***
|
||||||
|
SVNNodeKind kind = svnRepository.checkPath(path, revision);
|
||||||
|
if (kind == SVNNodeKind.FILE) ***REMOVED***
|
||||||
|
return true;
|
||||||
|
***REMOVED***
|
||||||
|
return false;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static ByteArrayInputStream reteriveByteArrayInputStream(File file) throws IOException ***REMOVED***
|
||||||
|
|
||||||
|
return new ByteArrayInputStream(FileUtils.readFileToByteArray(file));
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
public void updateSVNAlgorithmList(String file, Algorithm algorithm, String targetVRE, String user, String env) ***REMOVED***
|
public void updateSVNAlgorithmList(String file, Algorithm algorithm, String targetVRE, String user, String env) ***REMOVED***
|
||||||
try ***REMOVED***
|
try ***REMOVED***
|
||||||
System.out.println("Updating algorithm list: " + file);
|
System.out.println("Updating algorithm list: " + file);
|
||||||
|
@ -423,4 +544,28 @@ public class SVNUpdater ***REMOVED***
|
||||||
return new ArrayList<>(ss);
|
return new ArrayList<>(ss);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) throws SVNException ***REMOVED***
|
||||||
|
|
||||||
|
ServiceConfiguration sc = new ServiceConfiguration("/home/ngalante/workspace/dataminer-pool-manager/src/main/resources/service.properties");
|
||||||
|
|
||||||
|
SVNUpdater c = new SVNUpdater(sc);
|
||||||
|
|
||||||
|
***REMOVED***File a = new File("/home/ngalante/Desktop/testCiro");
|
||||||
|
File b = new File ("/home/ngalante/Desktop/testB");
|
||||||
|
|
||||||
|
***REMOVED***c.updateAlgorithmFiles(a);
|
||||||
|
c.updateAlgorithmFiles(b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -41,6 +41,12 @@ public class ServiceConfiguration ***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public String getSVNMainAlgoRepo()***REMOVED***
|
||||||
|
return props.getProperty("svn.algo.main.repo");
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
***REMOVED***RProto
|
***REMOVED***RProto
|
||||||
public String getSVNRProtoAlgorithmsList()***REMOVED***
|
public String getSVNRProtoAlgorithmsList()***REMOVED***
|
||||||
return props.getProperty("svn.rproto.algorithms-list");
|
return props.getProperty("svn.rproto.algorithms-list");
|
||||||
|
|
|
@ -4,8 +4,11 @@ STAGING_HOST: dataminer1-devnext.d4science.org
|
||||||
SVN_REPO: https:***REMOVED***svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/RConfiguration/RPackagesManagement/
|
SVN_REPO: https:***REMOVED***svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/RConfiguration/RPackagesManagement/
|
||||||
#HAPROXY_CSV: http:***REMOVED***data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0
|
#HAPROXY_CSV: http:***REMOVED***data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0
|
||||||
|
|
||||||
|
|
||||||
svn.repository = https:***REMOVED***svn.d4science.research-infrastructures.eu/gcube
|
svn.repository = https:***REMOVED***svn.d4science.research-infrastructures.eu/gcube
|
||||||
|
|
||||||
|
svn.algo.main.repo = /trunk/data-analysis/DataMinerConfiguration/algorithms
|
||||||
|
|
||||||
svn.rproto.algorithms-list = /trunk/data-analysis/DataMinerConfiguration/algorithms/proto/algorithms
|
svn.rproto.algorithms-list = /trunk/data-analysis/DataMinerConfiguration/algorithms/proto/algorithms
|
||||||
|
|
||||||
svn.rproto.deps-linux-compiled =
|
svn.rproto.deps-linux-compiled =
|
||||||
|
|
Loading…
Reference in New Issue