dataminer-pool-manager/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/clients/ISClient.java

181 lines
6.3 KiB
Java

***REMOVED***
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
***REMOVED***
import java.io.ByteArrayOutputStream;
import java.io.File;
***REMOVED***
import java.io.InputStream;
***REMOVED***
import java.io.PrintStream;
import java.net.MalformedURLException;
***REMOVED***
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
***REMOVED***
***REMOVED***
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
import org.gcube.common.resources.gcore.ServiceEndpoint;
***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Domain;
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.comparator.HostComparator;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.ISVNOptions;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
***REMOVED***
public class ISClient {
public Host getDataminer(String hostname) {
Host h = new Host();
boolean remote2 = true;
if (!remote2) {
h.setName("dataminer1-devnext.d4science.org");
return h;
***REMOVED*** else {
***REMOVED***SimpleQuery query = queryFor(ServiceEndpoint.class);
***REMOVED***query.addCondition("$resource/Profile/RunTime/HostedOn/text() eq '" + hostname + "'");
***REMOVED***DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
***REMOVED***List<ServiceEndpoint> resources = client.submit(query);
***REMOVED***ServiceEndpoint a = resources.get(0);
***REMOVED***h.setName(a.profile().runtime().hostedOn());
h.setName(hostname);
***REMOVED***
return h;
***REMOVED***
***REMOVED*** return the HProxy hostname in the VRE
public static String getHProxy() {
Host h = new Host();
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq 'DataMiner'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
h.setName(resources.get(0).profile().runtime().hostedOn());
return h.getName();
***REMOVED***
***REMOVED*** return the Cluster hostname from the IS
***REMOVED*** to develop
***REMOVED*** public Cluster getCluster(){
***REMOVED*** Cluster cl = new Cluster();
***REMOVED*** String HProxy = this.getHProxy();
***REMOVED*** SimpleQuery query = queryFor(ServiceEndpoint.class);
***REMOVED*** query.addCondition("$resource/Profile/Platform/Name/text() eq
***REMOVED*** 'DataMiner'");
***REMOVED*** DiscoveryClient<ServiceEndpoint> client =
***REMOVED*** clientFor(ServiceEndpoint.class);
***REMOVED*** List<ServiceEndpoint> resources = client.submit(query);
***REMOVED*** cl.setName(resources.get(0).profile().runtime().hostedOn());
***REMOVED*** return null;
***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** return the dataminer hostnames from the IS
***REMOVED*** to develop
***REMOVED*** public List<Host> getDM(){
***REMOVED*** Cluster cl = new Cluster();
***REMOVED*** String HProxy = this.getHProxy();
***REMOVED*** SimpleQuery query = queryFor(ServiceEndpoint.class);
***REMOVED*** query.addCondition("$resource/Profile/Platform/Name/text() eq
***REMOVED*** 'DataMiner'");
***REMOVED*** DiscoveryClient<ServiceEndpoint> client =
***REMOVED*** clientFor(ServiceEndpoint.class);
***REMOVED*** List<ServiceEndpoint> resources = client.submit(query);
***REMOVED*** cl.setName(resources.get(0).profile().runtime().hostedOn());
***REMOVED*** return null;
***REMOVED***
***REMOVED*** ***REMOVED***
/**
* Return the list of hosts (dataminers) in a given VRE
*
* @param vreName
* @return
*/
public Collection<Host> listDataminersInVRE() {
boolean remote = false;
if (!remote) {
Collection<Host> out = new Vector<>();
Host h = new Host();
***REMOVED*** h.setName("bb-dataminer.res.eng.it");
***REMOVED*** h.setName("vm101.ui.savba.sk");
h.setName("dataminer1-devnext.d4science.org");
out.add(h);
***REMOVED***
***REMOVED*** else {
SimpleQuery query = queryFor(ServiceEndpoint.class);
***REMOVED*** old version
***REMOVED*** query.addCondition("$resource/Profile/Category/text() eq
***REMOVED*** 'DataAnalysis'")
***REMOVED*** .addCondition("$resource/Profile/Name/text() eq 'DataMiner'");
query.addCondition("$resource/Profile/Platform/Name/text() eq 'DataMiner'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
Collection<Host> out = new Vector<>();
for (ServiceEndpoint r : resources) {
Host h = new Host();
h.setName(r.profile().runtime().hostedOn());
out.add(h);
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
public static void main(String[] args) throws IOException, SVNException {
ISClient a = new ISClient();
ScopeProvider.instance.set("/gcube/devNext/NextNext");
***REMOVED*** System.out.println(a.getHProxy());
***REMOVED*** System.out.println(a.MapCluster());
***REMOVED*** System.out.println(a.listDataMinersByCluster());
***REMOVED*** System.out.println(a.listDataMinersByCluster());
***REMOVED*** List<Dependency> list = new LinkedList<Dependency>();
***REMOVED*** Dependency aa = new Dependency();
***REMOVED*** aa.setName("testnunzio");
***REMOVED*** aa.setType("cran:");
***REMOVED*** list.add(aa);
***REMOVED*** a.checkSVNdep();
System.out.println(a.getDataminer("dataminer1-d-d4s.d4science.org").getDomain());
***REMOVED*** System.out.println(a.listDataminersInVRE());
***REMOVED***
***REMOVED***