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
85c51c1f9a
commit
2bbfe69d3b
|
@ -67,12 +67,12 @@ public class ProductionPublishingJob extends DMPMJob {
|
|||
String response = "";
|
||||
|
||||
if (exitstatus == 9) {
|
||||
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);
|
||||
***REMOVED***
|
||||
|
||||
if (exitstatus == 0) {
|
||||
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);
|
||||
***REMOVED***writer.close();
|
||||
***REMOVED***
|
||||
|
|
|
@ -21,9 +21,12 @@ import com.jcraft.jsch.SftpATTRS;
|
|||
import com.jcraft.jsch.SftpException;
|
||||
|
||||
public class CheckMethod {
|
||||
|
||||
protected SVNUpdater svnUpdater;
|
||||
|
||||
public CheckMethod() {
|
||||
|
||||
this.svnUpdater = svnUpdater;
|
||||
|
||||
***REMOVED***
|
||||
|
||||
public boolean checkMethod(String machine, String token) throws Exception {
|
||||
|
@ -83,14 +86,20 @@ public class CheckMethod {
|
|||
|
||||
|
||||
public boolean algoExists(Algorithm a) throws Exception{
|
||||
|
||||
|
||||
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());
|
||||
|
||||
|
||||
if ((this.doesExist(file.getPath())) && (this.doesExist(file2.getPath()))){
|
||||
this.svnUpdater.updateAlgorithmFiles(file);
|
||||
this.svnUpdater.updateAlgorithmFiles(file2);
|
||||
|
||||
return true;
|
||||
***REMOVED***
|
||||
else
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.tools.ant.FileScanner;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
||||
import org.tmatesoft.sqljet.core.internal.lang.SqlParser.column_constraint_check_return;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNNodeKind;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
|
||||
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.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
***REMOVED***
|
||||
import java.util.*;
|
||||
|
||||
|
@ -167,6 +172,122 @@ public class SVNUpdater {
|
|||
this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, user, env);
|
||||
***REMOVED***
|
||||
|
||||
|
||||
public void updateAlgorithmFiles(File a) throws SVNException{
|
||||
this.updateAlgorithmList(this.configuration.getSVNMainAlgoRepo(), a);
|
||||
***REMOVED***
|
||||
|
||||
|
||||
private void updateAlgorithmList(String svnMainAlgoRepo, File a) throws SVNException {
|
||||
try {
|
||||
System.out.println("Adding .jar file: " + a + " to repository " + svnMainAlgoRepo);
|
||||
|
||||
if (fileExists(svnMainAlgoRepo+File.separator+a.getName(), -1)){
|
||||
this.updateFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo, a.getName());
|
||||
|
||||
***REMOVED***
|
||||
else this.putFile(reteriveByteArrayInputStream(a), svnMainAlgoRepo,a.getName());
|
||||
|
||||
***REMOVED*** catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
***REMOVED***
|
||||
|
||||
finally {
|
||||
svnRepository.closeSession();
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
public void putFile(ByteArrayInputStream byteArrayInputStream, String destinationFolder, String fileName)
|
||||
throws SVNException {
|
||||
|
||||
|
||||
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 {
|
||||
|
||||
|
||||
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*** updating existing file
|
||||
|
||||
commitEditor.openFile(filePath, -1);
|
||||
|
||||
***REMOVED******REMOVED*** else { ***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 {
|
||||
SVNNodeKind kind = svnRepository.checkPath(path, revision);
|
||||
if (kind == SVNNodeKind.FILE) {
|
||||
return true;
|
||||
***REMOVED***
|
||||
return false;
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static ByteArrayInputStream reteriveByteArrayInputStream(File file) throws IOException {
|
||||
|
||||
return new ByteArrayInputStream(FileUtils.readFileToByteArray(file));
|
||||
***REMOVED***
|
||||
|
||||
|
||||
public void updateSVNAlgorithmList(String file, Algorithm algorithm, String targetVRE, String user, String env) {
|
||||
try {
|
||||
System.out.println("Updating algorithm list: " + file);
|
||||
|
@ -423,4 +544,28 @@ public class SVNUpdater {
|
|||
return new ArrayList<>(ss);
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws SVNException {
|
||||
|
||||
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***
|
||||
|
|
|
@ -41,6 +41,12 @@ public class ServiceConfiguration {
|
|||
***REMOVED***
|
||||
|
||||
|
||||
public String getSVNMainAlgoRepo(){
|
||||
return props.getProperty("svn.algo.main.repo");
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
***REMOVED***RProto
|
||||
public String getSVNRProtoAlgorithmsList(){
|
||||
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/
|
||||
#HAPROXY_CSV: http:***REMOVED***data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0
|
||||
|
||||
|
||||
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.deps-linux-compiled =
|
||||
|
|
Loading…
Reference in New Issue