433 lines
15 KiB
Java
433 lines
15 KiB
Java
***REMOVED***package org.gcube.dataanalysis.dataminer.poolmanager.rest;
|
|
***REMOVED***
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***import java.net.MalformedURLException;
|
|
***REMOVED***import java.net.ProxySelector;
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***import java.net.UnknownHostException;
|
|
***REMOVED***
|
|
***REMOVED***import javax.ws.rs.GET;
|
|
***REMOVED***import javax.ws.rs.Path;
|
|
***REMOVED***import javax.ws.rs.Produces;
|
|
***REMOVED***import javax.ws.rs.QueryParam;
|
|
***REMOVED***
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
|
|
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.service.DataminerPoolManager;
|
|
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.util.PropertiesBasedProxySelector;
|
|
***REMOVED******REMOVED***
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***@Path("/")
|
|
***REMOVED***public class RestPoolManager implements PoolManager {
|
|
***REMOVED***
|
|
***REMOVED*** private static final Logger LOGGER = LoggerFactory.getLogger(RestPoolManager.class);
|
|
***REMOVED***
|
|
***REMOVED*** private PoolManager service = new DataminerPoolManager();
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** @GET
|
|
***REMOVED*** @Path("/add")
|
|
***REMOVED*** @Produces("text/plain")
|
|
***REMOVED*** public String addAlgorithmToVRE(
|
|
***REMOVED*** @QueryParam("algorithm") String algorithm,
|
|
***REMOVED*** @QueryParam("vre") String vre,
|
|
***REMOVED*** @QueryParam("name") String name,
|
|
***REMOVED*** @QueryParam("description") String description,
|
|
***REMOVED*** @QueryParam("category") String category,
|
|
***REMOVED*** @QueryParam("algorithmType") String algorithmType,
|
|
***REMOVED*** @QueryParam("skipJava") String skipJava) throws IOException, InterruptedException {
|
|
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
|
|
***REMOVED*** LOGGER.debug("Adding algorithm =" + algorithm + " to VRE =" + vre);
|
|
***REMOVED*** Algorithm algo = service.extractAlgorithm(algorithm);
|
|
***REMOVED***
|
|
***REMOVED*** if (algo.getCategory() == null){
|
|
***REMOVED*** algo.setCategory(category);
|
|
***REMOVED*** ***REMOVED*** else category = algo.getCategory();
|
|
***REMOVED***
|
|
***REMOVED*** if (algo.getAlgorithmType() == null){
|
|
***REMOVED*** algo.setAlgorithmType(algorithmType);
|
|
***REMOVED*** ***REMOVED*** else algorithmType = algo.getCategory();
|
|
***REMOVED***
|
|
***REMOVED*** if (algo.getSkipJava() == null){
|
|
***REMOVED*** algo.setSkipJava(skipJava);
|
|
***REMOVED*** ***REMOVED*** else skipJava = algo.getSkipJava();
|
|
***REMOVED***
|
|
***REMOVED*** if (algo.getName() == null){
|
|
***REMOVED*** algo.setCategory(name);
|
|
***REMOVED*** ***REMOVED*** else name = algo.getName();
|
|
***REMOVED***
|
|
***REMOVED*** if (algo.getDescription() == null){
|
|
***REMOVED*** algo.setDescription(description);;
|
|
***REMOVED*** ***REMOVED*** else description = algo.getDescription();
|
|
***REMOVED***
|
|
***REMOVED*** return service.addAlgorithmToVRE(algo, vre);
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** @GET
|
|
***REMOVED*** @Path("/log")
|
|
***REMOVED*** @Produces("text/plain")
|
|
***REMOVED*** public String getLogById(@QueryParam("logUrl") String logUrl) throws IOException {
|
|
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
|
|
***REMOVED*** LOGGER.debug("Returning Log =" + logUrl);
|
|
***REMOVED*** return service.getScriptFromURL(service.getURLfromWorkerLog(logUrl));
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** @Override
|
|
***REMOVED*** public Algorithm extractAlgorithm(String url) throws IOException {
|
|
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
|
|
***REMOVED*** return null;
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** public static void main(String[] args) throws IOException, InterruptedException {
|
|
***REMOVED*** RestPoolManager a = new RestPoolManager();
|
|
***REMOVED*** ***REMOVED***System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** ***REMOVED***ProxySelector.setDefault(new PropertiesBasedProxySelector("/home/ngalante/.proxy-settings"));
|
|
***REMOVED***
|
|
***REMOVED*** ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
|
***REMOVED*** a.addAlgorithmToVRE(
|
|
***REMOVED*** "http:***REMOVED***data.d4science.org/S2h1RHZGd0JpWnBjZk9qTytQTndqcDRLVHNrQUt6QjhHbWJQNStIS0N6Yz0",
|
|
***REMOVED*** "/gcube/devNext/NextNext",
|
|
***REMOVED*** null, null, "test", "transducerers", "N");
|
|
***REMOVED***
|
|
***REMOVED*** ***REMOVED***System.out.println(a.getLogById("34ac474d-b9df-4929-87e1-2a0ae26cf898"));
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** @Override
|
|
***REMOVED*** public void getLogId(Algorithm algo, String vre) {
|
|
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
|
|
***REMOVED***
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** @Override
|
|
***REMOVED*** public String getScriptFromURL(URL logId) throws IOException {
|
|
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
|
|
***REMOVED*** return null;
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** @Override
|
|
***REMOVED*** public String addAlgorithmToVRE(Algorithm algo, String vre) throws IOException, InterruptedException {
|
|
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
|
|
***REMOVED*** return null;
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED*** @Override
|
|
***REMOVED*** public URL getURLfromWorkerLog(String logUrl) throws MalformedURLException, UnknownHostException {
|
|
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
|
|
***REMOVED*** return null;
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED***
|
|
***REMOVED******REMOVED***
|
|
package org.gcube.dataanalysis.dataminer.poolmanager.rest;
|
|
|
|
import java.awt.color.ICC_ColorSpace;
|
|
***REMOVED***
|
|
import java.net.MalformedURLException;
|
|
import java.net.ProxySelector;
|
|
***REMOVED***
|
|
import java.net.UnknownHostException;
|
|
***REMOVED***
|
|
***REMOVED***
|
|
import java.util.Random;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
|
|
import javax.ws.rs.DefaultValue;
|
|
import javax.ws.rs.GET;
|
|
import javax.ws.rs.Path;
|
|
import javax.ws.rs.Produces;
|
|
import javax.ws.rs.QueryParam;
|
|
|
|
import org.apache.commons.lang.math.RandomUtils;
|
|
***REMOVED***
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.clients.ISClient;
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.service.DataminerPoolManager;
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.PropertiesBasedProxySelector;
|
|
***REMOVED***
|
|
***REMOVED***
|
|
import org.tmatesoft.svn.core.SVNException;
|
|
|
|
|
|
|
|
|
|
@Path("/")
|
|
public class RestPoolManager implements PoolManager {
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(RestPoolManager.class);
|
|
|
|
private PoolManager service = new DataminerPoolManager();
|
|
|
|
/*
|
|
/scopes/<scope> POST ***REMOVED*** add an algorithm to all dataminers in the scope
|
|
/hosts/<hostname> POST ***REMOVED*** add an algorithm to the given host
|
|
*/
|
|
|
|
@GET
|
|
@Path("/scopes/add")
|
|
@Produces("text/plain")
|
|
public String addAlgorithmToVRE(
|
|
@QueryParam("algorithm") String algorithm,
|
|
@QueryParam("vre") String vre,
|
|
@QueryParam("name") String name,
|
|
@QueryParam("description") String description,
|
|
@QueryParam("category") String category,
|
|
@DefaultValue("transducerers") @QueryParam("algorithmType") String algorithmType,
|
|
@DefaultValue("N") @QueryParam("skipJava") String skipJava,
|
|
@DefaultValue("false") @QueryParam("publish") boolean publish) throws IOException, InterruptedException, SVNException {
|
|
Algorithm algo= this.getAlgorithm(algorithm, vre, null, name, description, category, algorithmType, skipJava);
|
|
|
|
***REMOVED***publish algo
|
|
if (publish){
|
|
service.addAlgToIs(algo);
|
|
***REMOVED***
|
|
|
|
***REMOVED***update svn
|
|
for (Dependency d : algo.getDependencies()){
|
|
|
|
if (d.getType().equals("os")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_deb_pkgs.txt", ls);
|
|
***REMOVED***
|
|
if (d.getType().equals("cran")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_cran_pkgs.txt", ls);
|
|
***REMOVED***
|
|
if (d.getType().equals("custom")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_github_pkgs.txt", ls);
|
|
***REMOVED***
|
|
if (d.getType().equals("")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_deb_pkgs.txt", ls);
|
|
***REMOVED***
|
|
***REMOVED***
|
|
|
|
return service.addAlgorithmToVRE(algo, vre);
|
|
***REMOVED***
|
|
|
|
@GET
|
|
@Path("/hosts/add")
|
|
@Produces("text/plain")
|
|
public String addAlgorithmToHost(
|
|
@QueryParam("algorithm") String algorithm,
|
|
@QueryParam("hostname") String hostname,
|
|
@QueryParam("name") String name,
|
|
@QueryParam("description") String description,
|
|
@QueryParam("category") String category,
|
|
@DefaultValue("transducerers") @QueryParam("algorithmType") String algorithmType,
|
|
@DefaultValue("N") @QueryParam("skipJava") String skipJava,
|
|
@DefaultValue("false") @QueryParam("publish") boolean publish) throws IOException, InterruptedException, SVNException {
|
|
Algorithm algo= this.getAlgorithm(algorithm, null, hostname, name, description, category, algorithmType, skipJava);
|
|
***REMOVED***publish algo
|
|
if (publish){
|
|
service.addAlgToIs(algo);
|
|
***REMOVED***
|
|
|
|
***REMOVED***update svn
|
|
for (Dependency d : algo.getDependencies()){
|
|
|
|
if (d.getType().equals("os")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_deb_pkgs.txt", ls);
|
|
***REMOVED***
|
|
if (d.getType().equals("cran")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_cran_pkgs.txt", ls);
|
|
***REMOVED***
|
|
if (d.getType().equals("custom")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_github_pkgs.txt", ls);
|
|
***REMOVED***
|
|
if (d.getType().equals("")){
|
|
List<String> ls = new LinkedList<String>();
|
|
ls.add(d.getName());
|
|
service.getOriginalContents("r_deb_pkgs.txt", ls);
|
|
***REMOVED***
|
|
***REMOVED***
|
|
return service.addAlgorithmToHost(algo, hostname);
|
|
***REMOVED***
|
|
|
|
|
|
private Algorithm getAlgorithm(
|
|
String algorithm,
|
|
String vre,
|
|
String hostname,
|
|
String name,
|
|
String description,
|
|
String category,
|
|
String algorithmType,
|
|
String skipJava) throws IOException, InterruptedException {
|
|
LOGGER.debug("Adding algorithm =" + algorithm + " to VRE =" + vre);
|
|
Algorithm algo = service.extractAlgorithm(algorithm);
|
|
|
|
|
|
if (algo.getCategory() == null){
|
|
algo.setCategory(category);
|
|
***REMOVED*** else algo.setCategory(algo.getCategory());
|
|
|
|
if (algo.getAlgorithmType() == null){
|
|
algo.setAlgorithmType(algorithmType);
|
|
***REMOVED*** else algo.setAlgorithmType(algo.getCategory());
|
|
|
|
if (algo.getSkipJava() == null){
|
|
algo.setSkipJava(skipJava);
|
|
***REMOVED*** else algo.setSkipJava(algo.getSkipJava());
|
|
|
|
if (algo.getName() == null){
|
|
algo.setName(name);
|
|
***REMOVED*** else algo.setName(algo.getName());
|
|
|
|
if (algo.getDescription() == null){
|
|
algo.setDescription(description);;
|
|
***REMOVED*** else algo.setDescription(algo.getDescription());
|
|
|
|
return algo;
|
|
***REMOVED***
|
|
|
|
|
|
|
|
@GET
|
|
@Path("/log")
|
|
@Produces("text/plain")
|
|
public String getLogById(@QueryParam("logUrl") String logUrl) throws IOException {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
LOGGER.debug("Returning Log =" + logUrl);
|
|
return service.getScriptFromURL(service.getURLfromWorkerLog(logUrl));
|
|
***REMOVED***
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
public Algorithm extractAlgorithm(String url) throws IOException {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
return null;
|
|
***REMOVED***
|
|
|
|
|
|
public static void main(String[] args) throws IOException, InterruptedException, SVNException {
|
|
***REMOVED***System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
|
|
***REMOVED***ProxySelector.setDefault(new PropertiesBasedProxySelector("/home/ngalante/.proxy-settings"));
|
|
|
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
|
|
|
***REMOVED***PoolManager aa = new DataminerPoolManager();
|
|
***REMOVED***System.out.println(aa.getAlgoById("ICHTHYOP_MODEL_ONE_BY_ONE@3141d3aa-5f93-409f-b6f8-9fae0a6c0ee3"));
|
|
***REMOVED***System.out.println(aa.getAlgoFromIs());
|
|
|
|
|
|
***REMOVED***RestPoolManager a = new RestPoolManager();
|
|
***REMOVED***a.addAlgorithmToVRE(
|
|
***REMOVED***"http:***REMOVED***data.d4science.org/S2h1RHZGd0JpWnBjZk9qTytQTndqcDRLVHNrQUt6QjhHbWJQNStIS0N6Yz0",
|
|
***REMOVED***"/gcube/devNext/NextNext",
|
|
***REMOVED***null, null, "test", "transducerers", "N");
|
|
|
|
***REMOVED*** a.addAlgorithmToHost(
|
|
***REMOVED*** "http:***REMOVED***data.d4science.org/dENQTTMxdjNZcGRpK0NHd2pvU0owMFFzN0VWemw3Zy9HbWJQNStIS0N6Yz0",
|
|
***REMOVED*** "dataminer1-devnext.d4science.org",
|
|
***REMOVED*** "ICHTHYOP_MODEL_ONE_BY_ONE", null, "ICHTHYOP_MODEL", "transducerers", "N",false);
|
|
***REMOVED***
|
|
***REMOVED***
|
|
|
|
PoolManager aa = new DataminerPoolManager();
|
|
List<String> ls = new LinkedList<String>();
|
|
String afa = "nunzio";
|
|
String b = "galante";
|
|
ls.add(b);
|
|
ls.add(afa);
|
|
|
|
System.out.println(aa.getOriginalContents("r_deb_pkgs.txt",ls));
|
|
***REMOVED***
|
|
|
|
|
|
|
|
@Override
|
|
public void getLogId(Algorithm algo, String vre) {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
|
|
***REMOVED***
|
|
|
|
|
|
@Override
|
|
public String getScriptFromURL(URL logId) throws IOException {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
return null;
|
|
***REMOVED***
|
|
|
|
|
|
@Override
|
|
public String addAlgorithmToVRE(Algorithm algo, String vre) throws IOException, InterruptedException {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
return null;
|
|
***REMOVED***
|
|
|
|
@Override
|
|
public String addAlgorithmToHost(Algorithm algo, String hostname)
|
|
throws IOException, InterruptedException {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
return null;
|
|
***REMOVED***
|
|
|
|
@Override
|
|
public URL getURLfromWorkerLog(String logUrl) throws MalformedURLException, UnknownHostException {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
return null;
|
|
***REMOVED***
|
|
|
|
@Override
|
|
public void addAlgToIs(Algorithm algo) {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
|
|
***REMOVED***
|
|
|
|
@Override
|
|
public Set<Algorithm> getAlgoFromIs() {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
return null;
|
|
***REMOVED***
|
|
|
|
@Override
|
|
public List<String> getOriginalContents(String file, List<String> ldep) throws SVNException {
|
|
***REMOVED*** TODO Auto-generated method stub
|
|
return null;
|
|
***REMOVED***
|
|
|
|
|
|
|
|
|
|
***REMOVED***
|
|
|
|
|