git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@169817 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e8e45abb36
commit
91ffb8e3b7
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<groupId>org.gcube.dataAnalysis</groupId>
|
<groupId>org.gcube.dataAnalysis</groupId>
|
||||||
<artifactId>dataminer-pool-manager</artifactId>
|
<artifactId>dataminer-pool-manager</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>2.5.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>dataminer-pool-manager</name>
|
<name>dataminer-pool-manager</name>
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -5,33 +5,35 @@ import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.GenericResource;
|
import org.gcube.common.resources.gcore.GenericResource;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.ConfigurationImpl.CONFIGURATIONS;
|
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.ConfigurationImpl.CONFIGURATIONS;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.ConfigurationImpl.REPOSITORIES;
|
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configurations.AbstractConfiguration;
|
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configurations.AbstractConfiguration;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
|
***REMOVED***
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
public class ClientConfigurationCache
|
public class ClientConfigurationCache
|
||||||
{
|
{
|
||||||
|
|
||||||
private Map<String, String> repositories;
|
***REMOVED***
|
||||||
|
private SVNRepository svnRepository;
|
||||||
private Map<String, AbstractConfiguration> configurations;
|
private Map<String, AbstractConfiguration> configurations;
|
||||||
|
private long svnRepositoryTimeout;
|
||||||
private Map<String, Long> repoTimeouts,
|
private Map<String, Long> configurationsTimeouts;
|
||||||
configurationsTimeouts;
|
|
||||||
|
|
||||||
private final long duration = 120000; ***REMOVED***2 minutes
|
private final long duration = 120000; ***REMOVED***2 minutes
|
||||||
|
|
||||||
public ClientConfigurationCache ()
|
ClientConfigurationCache ()
|
||||||
{
|
{
|
||||||
this.repositories = new HashMap<>();
|
this.logger = LoggerFactory.getLogger(ClientConfigurationCache.class);
|
||||||
|
this.svnRepository = null;
|
||||||
this.configurations = new HashMap<>();
|
this.configurations = new HashMap<>();
|
||||||
this.repoTimeouts = new HashMap<>();
|
this.svnRepositoryTimeout = 0;
|
||||||
this.configurationsTimeouts = new HashMap<>();
|
this.configurationsTimeouts = new HashMap<>();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
@ -50,40 +52,69 @@ public class ClientConfigurationCache
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
public String getRepository (REPOSITORIES repository)
|
public SVNRepository getSVNRepository ()
|
||||||
{
|
{
|
||||||
Long time = this.repoTimeouts.get(repository);
|
|
||||||
long currentTime = new Date().getTime();
|
long currentTime = new Date().getTime();
|
||||||
|
|
||||||
if (time == null || currentTime > time+this.duration)
|
if (this.svnRepositoryTimeout == 0 || currentTime > this.svnRepositoryTimeout+this.duration)
|
||||||
{
|
{
|
||||||
this.repositories.put(repository.toString(), getRepository (repository.toString()));
|
this.svnRepository = queryForRepository();
|
||||||
this.repoTimeouts.put(repository.toString(), currentTime);
|
this.svnRepositoryTimeout = currentTime;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
return this.repositories.get(repository.toString());
|
return this.svnRepository;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
private String getRepository(String type) {
|
private SVNRepository queryForRepository()
|
||||||
|
{
|
||||||
|
|
||||||
String ghost = "";
|
|
||||||
SimpleQuery query = queryFor(GenericResource.class);
|
SimpleQuery query = queryFor(GenericResource.class);
|
||||||
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource");
|
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DMPMConfigurator'").setResult("$resource");
|
||||||
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
|
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
|
||||||
List<GenericResource> ds = client.submit(query);
|
List<GenericResource> ds = client.submit(query);
|
||||||
for (GenericResource a : ds) {
|
Iterator<GenericResource> resourcesIterator = ds.iterator();
|
||||||
ghost = a.profile().body().getElementsByTagName(type).item(0).getTextContent();
|
SVNRepository response = null;
|
||||||
|
|
||||||
|
while (resourcesIterator.hasNext() && response == null)
|
||||||
|
{
|
||||||
|
GenericResource resource = resourcesIterator.next();
|
||||||
|
String repositoryURL = resource.profile().body().getElementsByTagName(SVNRepository.REPOSITORY_URL).item(0).getTextContent();
|
||||||
|
|
||||||
|
if (repositoryURL != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
String repositoryPath = resource.profile().body().getElementsByTagName(SVNRepository.REPOSITORY_PATH).item(0).getTextContent();
|
||||||
|
String repositoryUsername = null;
|
||||||
|
String repositoryPassword = null;
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
repositoryUsername = resource.profile().body().getElementsByTagName(SVNRepository.REPOSITORY_USERNAME).item(0).getTextContent();
|
||||||
|
repositoryPassword = resource.profile().body().getElementsByTagName(SVNRepository.REPOSITORY_PASSWORD).item(0).getTextContent();
|
||||||
|
|
||||||
|
if (repositoryUsername != null && repositoryUsername.trim() == "") repositoryUsername = null;
|
||||||
|
|
||||||
|
if (repositoryPassword != null && repositoryPassword.trim() == "") repositoryPassword = null;
|
||||||
|
|
||||||
|
this.logger.debug("Repository username "+repositoryUsername);
|
||||||
|
this.logger.debug("Repository password "+repositoryPassword);
|
||||||
|
|
||||||
|
***REMOVED*** catch (Exception e)
|
||||||
|
{
|
||||||
|
this.logger.debug("SVN Username and password not present");
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
this.logger.debug("SVN Repository URL: "+repositoryURL);
|
||||||
|
this.logger.debug("SVN Repository path: "+repositoryPath);
|
||||||
|
|
||||||
|
response = new SVNRepository(repositoryURL, repositoryPath,repositoryUsername, repositoryPassword);
|
||||||
|
|
||||||
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
return response;
|
||||||
return ghost.trim ();
|
|
||||||
|
|
||||||
***REMOVED*** TODO Auto-generated method stub
|
|
||||||
|
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
private AbstractConfiguration getConfiguration (AbstractConfiguration type)
|
private AbstractConfiguration getConfiguration (AbstractConfiguration type)
|
||||||
|
|
|
@ -27,9 +27,7 @@ public interface Configuration {
|
||||||
|
|
||||||
public String getSVNWCDepsList();
|
public String getSVNWCDepsList();
|
||||||
|
|
||||||
public String getSVNRepository();
|
public SVNRepository getSVNRepository();
|
||||||
|
|
||||||
public String getSVNMainAlgoRepo();
|
|
||||||
|
|
||||||
public String getGhostAlgoDirectory();
|
public String getGhostAlgoDirectory();
|
||||||
|
|
||||||
|
|
|
@ -30,21 +30,21 @@ public class ConfigurationImpl implements Configuration {
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
enum REPOSITORIES {
|
***REMOVED*** enum REPOSITORIES {
|
||||||
REPO ("svn.repository"),
|
***REMOVED*** REPO ("svn.repository"),
|
||||||
MAIN_ALGO ("svn.algo.main.repo");
|
***REMOVED*** MAIN_ALGO ("svn.algo.main.repo");
|
||||||
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
private REPOSITORIES(String type) {
|
|
||||||
this.type = type;
|
|
||||||
***REMOVED***
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.type;
|
|
||||||
***REMOVED***
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
***REMOVED*** private String type;
|
||||||
|
***REMOVED***
|
||||||
|
***REMOVED*** private REPOSITORIES(String type) {
|
||||||
|
***REMOVED*** this.type = type;
|
||||||
|
***REMOVED*** ***REMOVED***
|
||||||
|
***REMOVED***
|
||||||
|
***REMOVED*** @Override
|
||||||
|
***REMOVED*** public String toString() {
|
||||||
|
***REMOVED*** return this.type;
|
||||||
|
***REMOVED*** ***REMOVED***
|
||||||
|
***REMOVED******REMOVED***
|
||||||
|
|
||||||
|
|
||||||
private CONFIGURATIONS type;
|
private CONFIGURATIONS type;
|
||||||
|
@ -129,17 +129,12 @@ public class ConfigurationImpl implements Configuration {
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSVNRepository()
|
public SVNRepository getSVNRepository()
|
||||||
{
|
{
|
||||||
return this.cache.getRepository(REPOSITORIES.REPO);
|
return this.cache.getSVNRepository();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSVNMainAlgoRepo() {
|
|
||||||
|
|
||||||
return this.cache.getRepository(REPOSITORIES.MAIN_ALGO);
|
|
||||||
|
|
||||||
***REMOVED***
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGhostAlgoDirectory() {
|
public String getGhostAlgoDirectory() {
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class DMPMClientConfiguratorManager
|
||||||
|
|
||||||
System.out.println("RESULT 1"+a.getStagingConfiguration().getSVNCRANDepsList());
|
System.out.println("RESULT 1"+a.getStagingConfiguration().getSVNCRANDepsList());
|
||||||
System.out.println("RESULT 2"+a.getProductionConfiguration().getRepository());
|
System.out.println("RESULT 2"+a.getProductionConfiguration().getRepository());
|
||||||
System.out.println("RESULT 3"+a.getStagingConfiguration().getSVNMainAlgoRepo());
|
System.out.println("RESULT 3"+a.getStagingConfiguration().getSVNRepository().getPath());
|
||||||
***REMOVED***System.out.println(a.getRepo());
|
***REMOVED***System.out.println(a.getRepo());
|
||||||
***REMOVED***System.out.println(a.getAlgoRepo());
|
***REMOVED***System.out.println(a.getAlgoRepo());
|
||||||
***REMOVED***System.out.println(a.getSVNRepo());
|
***REMOVED***System.out.println(a.getSVNRepo());
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration;
|
||||||
|
|
||||||
|
public class SVNRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
static final String REPOSITORY_URL = "svn.repository",
|
||||||
|
REPOSITORY_PATH = "svn.algo.main.repo",
|
||||||
|
REPOSITORY_USERNAME = "svn.repository.username",
|
||||||
|
REPOSITORY_PASSWORD = "svn.repository.password";
|
||||||
|
|
||||||
|
private String baseUrl,
|
||||||
|
path,
|
||||||
|
username,
|
||||||
|
password;
|
||||||
|
|
||||||
|
SVNRepository(String baseUrl, String path, String username, String password) {
|
||||||
|
this.baseUrl = baseUrl;
|
||||||
|
this.path = path;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
SVNRepository(String baseUrl, String path) {
|
||||||
|
this (baseUrl, path, null, null);
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getBaseUrl() {
|
||||||
|
return baseUrl;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
***REMOVED***
|
|
@ -21,9 +21,6 @@ public abstract class AbstractConfiguration
|
||||||
private String depsWindowsCompiled;
|
private String depsWindowsCompiled;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@XmlElement (name="host")
|
@XmlElement (name="host")
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
|
@ -48,6 +45,7 @@ public abstract class AbstractConfiguration
|
||||||
this.softwareRepo = softwareRepo;
|
this.softwareRepo = softwareRepo;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
@XmlElement (name="ghost-repo")
|
@XmlElement (name="ghost-repo")
|
||||||
public String getGhostRepo() {
|
public String getGhostRepo() {
|
||||||
return ghostRepo;
|
return ghostRepo;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
||||||
|
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
|
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
|
||||||
|
***REMOVED***
|
||||||
|
***REMOVED***
|
||||||
import org.tmatesoft.svn.core.SVNException;
|
import org.tmatesoft.svn.core.SVNException;
|
||||||
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;
|
||||||
|
@ -12,11 +14,27 @@ public class SVNRepositoryManager {
|
||||||
|
|
||||||
private SVNRepository svnRepository;
|
private SVNRepository svnRepository;
|
||||||
private static SVNRepositoryManager instance;
|
private static SVNRepositoryManager instance;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
private SVNRepositoryManager (Configuration configuration) throws SVNException
|
private SVNRepositoryManager (Configuration configuration) throws SVNException
|
||||||
{
|
{
|
||||||
this.svnRepository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(configuration.getSVNRepository()));
|
this.logger = LoggerFactory.getLogger(SVNRepositoryManager.class);
|
||||||
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager();
|
org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.SVNRepository repository = configuration.getSVNRepository();
|
||||||
|
this.svnRepository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(repository.getBaseUrl()));
|
||||||
|
ISVNAuthenticationManager authManager = null;
|
||||||
|
|
||||||
|
if (repository.getUsername() == null)
|
||||||
|
{
|
||||||
|
this.logger.debug("Using SVN default credentials");
|
||||||
|
authManager = SVNWCUtil.createDefaultAuthenticationManager();
|
||||||
|
***REMOVED***
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.logger.debug("Using IS credentials");
|
||||||
|
authManager = SVNWCUtil.createDefaultAuthenticationManager(repository.getUsername(),repository.getPassword());
|
||||||
|
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
this.svnRepository.setAuthenticationManager(authManager);
|
this.svnRepository.setAuthenticationManager(authManager);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,6 @@ public class CheckMethodStaging extends CheckMethod{
|
||||||
super (DMPMClientConfiguratorManager.getInstance().getStagingConfiguration());
|
super (DMPMClientConfiguratorManager.getInstance().getStagingConfiguration());
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void copyFromDmToSVN(File a) throws Exception{
|
protected void copyFromDmToSVN(File a) throws Exception{
|
||||||
super.copyFromDmToSVN(a, new SVNUpdaterStaging());
|
super.copyFromDmToSVN(a, new SVNUpdaterStaging());
|
||||||
|
@ -31,9 +20,6 @@ public class CheckMethodStaging extends CheckMethod{
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
***REMOVED*** ServiceConfiguration a = new ServiceConfiguration();
|
***REMOVED*** ServiceConfiguration a = new ServiceConfiguration();
|
||||||
***REMOVED*** System.out.println(a.getStagingHost());
|
***REMOVED*** System.out.println(a.getStagingHost());
|
||||||
|
|
Loading…
Reference in New Issue