diff --git a/JSAGA_Package/GridEngine_dependencies.tar.gz b/JSAGA_Package/GridEngine_dependencies.tar.gz deleted file mode 100644 index 8e56d71..0000000 Binary files a/JSAGA_Package/GridEngine_dependencies.tar.gz and /dev/null differ diff --git a/JSAGA_Package/jsaga-installer-0.9.14-20110629.095919-1-bin.tar.gz b/JSAGA_Package/jsaga-installer-0.9.14-20110629.095919-1-bin.tar.gz deleted file mode 100644 index 8cd4443..0000000 Binary files a/JSAGA_Package/jsaga-installer-0.9.14-20110629.095919-1-bin.tar.gz and /dev/null differ diff --git a/build.xml b/build.xml deleted file mode 100644 index accd2f4..0000000 --- a/build.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/GridEngine.properties b/config/GridEngine.properties deleted file mode 100644 index c64c105..0000000 --- a/config/GridEngine.properties +++ /dev/null @@ -1,2 +0,0 @@ -usertracking_datasource = jdbc/UserTrackingPool -hibernate_datasource = jdbc/gehibernatepool diff --git a/config/GridEngineLogConfig.xml b/config/GridEngineLogConfig.xml deleted file mode 100644 index c7d0e99..0000000 --- a/config/GridEngineLogConfig.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/hibernate.cfg.xml b/config/hibernate.cfg.xml deleted file mode 100644 index 716ffa0..0000000 --- a/config/hibernate.cfg.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - jdbc/gehibernatepool - - - org.hibernate.dialect.MySQL5Dialect - - - - org.hibernate.transaction.JDBCTransactionFactory - - - org.hibernate.cache.HashtableCacheProvider - - - thread - - - - - - - - - - - - \ No newline at end of file diff --git a/config/hibernateStandAlone.cfg.xml b/config/hibernateStandAlone.cfg.xml deleted file mode 100644 index 28bf703..0000000 --- a/config/hibernateStandAlone.cfg.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - org.hibernate.dialect.MySQL5Dialect - - - com.mysql.jdbc.Driver - jdbc:mysql://localhost/userstracking - tracking_user - usertracking - - org.hibernate.transaction.JDBCTransactionFactory - - - org.hibernate.cache.HashtableCacheProvider - - - thread - - - - - - - - - - - - \ No newline at end of file diff --git a/external_lib/commons-io-2.0.1-bin.tar.gz b/external_lib/commons-io-2.0.1-bin.tar.gz deleted file mode 100644 index d65bb3b..0000000 Binary files a/external_lib/commons-io-2.0.1-bin.tar.gz and /dev/null differ diff --git a/external_lib/httpcomponents-client-4.1.1-bin.tar.gz b/external_lib/httpcomponents-client-4.1.1-bin.tar.gz deleted file mode 100644 index 3a984e1..0000000 Binary files a/external_lib/httpcomponents-client-4.1.1-bin.tar.gz and /dev/null differ diff --git a/external_lib/httpcomponents-core-4.1.2-bin.tar.gz b/external_lib/httpcomponents-core-4.1.2-bin.tar.gz deleted file mode 100644 index 4222b86..0000000 Binary files a/external_lib/httpcomponents-core-4.1.2-bin.tar.gz and /dev/null differ diff --git a/external_lib/mysql-connector-java-5.1.16-bin.jar b/external_lib/mysql-connector-java-5.1.16-bin.jar deleted file mode 100644 index e62f2cb..0000000 Binary files a/external_lib/mysql-connector-java-5.1.16-bin.jar and /dev/null differ diff --git a/it/infn/ct/GridEngine/Config/GridEngineConfig.java b/it/infn/ct/GridEngine/Config/GridEngineConfig.java deleted file mode 100644 index d4c1731..0000000 --- a/it/infn/ct/GridEngine/Config/GridEngineConfig.java +++ /dev/null @@ -1,91 +0,0 @@ -package it.infn.ct.GridEngine.Config; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.apache.log4j.Logger; - -public class GridEngineConfig { - - private static GridEngineConfig instance = null; - private static final Logger _log = Logger.getLogger(GridEngineConfig.class.getName()); - private final String gePropertiesFile = "GridEngine.properties"; - - private String userstrackingDatasource = "jdbc/UserTrackingPool"; - private String hibernateDatasource = "jdbc/gehibernatepool"; - - public static synchronized GridEngineConfig getInstance() { - if (instance == null) - instance = new GridEngineConfig(); - return instance; - } - - /** - * Load the given configuration file which overrides static settings - * - * @param configFile - */ - private GridEngineConfig() { - /* - * Load a configuration file containing GridEngineDaemon settings wich - * override the static settings defined in the class - */ - loadProperties(); - _log.info("GridEngine config:" + this.toString()); - } - - private void loadProperties() { - // - InputStream inputStream = null; - Properties prop = new Properties(); - try { - inputStream = this.getClass().getClassLoader().getResourceAsStream(gePropertiesFile); - - prop.load(inputStream); - - /* - * Retrieving configuration values - */ - - // APIServer DB settings - String prop_usertrackingDatasource = prop.getProperty("usertracking_datasource"); - String prop_hibernateDatasource = prop.getProperty("hibernate_datasource"); - - if (prop_usertrackingDatasource != null) { - this.userstrackingDatasource = prop_usertrackingDatasource; - } - if (prop_hibernateDatasource != null) { - this.hibernateDatasource = prop_hibernateDatasource; - } - } catch (NullPointerException e) { - _log.warn("Unable to load property file; using default settings"); - } catch (IOException e) { - _log.warn("Error reading file: " + e); - } catch (NumberFormatException e) { - _log.warn("Error while reading property file: " + e); - } finally { - try { - if (null != inputStream) - inputStream.close(); - } catch (IOException e) { - _log.error("Error closing configuration file input stream"); - } - } - } - - public String getUserstrackingDatasource() { - return userstrackingDatasource; - } - - public String getHibernateDatasource() { - return hibernateDatasource; - } - - @Override - public String toString() { - return "GridEngineConfig [gePropetiesFile=" + gePropertiesFile + ", userstrackingDatasource=" - + userstrackingDatasource + ", hibernateDatasource=" + hibernateDatasource + "]"; - } - -} diff --git a/it/infn/ct/GridEngine/Data/DataError.java b/it/infn/ct/GridEngine/Data/DataError.java deleted file mode 100644 index b72a462..0000000 --- a/it/infn/ct/GridEngine/Data/DataError.java +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: XXXXXXXXXXXXXXXXXX -****************************************************************************/ - -package it.infn.ct.GridEngine.Data; - -public class DataError extends Exception { - - /** - * - */ - private static final long serialVersionUID = 2342342321L; - - /** - * Creates a new instance of DataError without detail message. - */ - public DataError() { - } - - /** - * Constructs an instance of DataError with the specified detail message. - * @param msg the detail message. - */ - public DataError(String msg) { - super(msg); - } -} diff --git a/it/infn/ct/GridEngine/Data/JSagaDataManagement.java b/it/infn/ct/GridEngine/Data/JSagaDataManagement.java deleted file mode 100644 index 1cf5f5a..0000000 --- a/it/infn/ct/GridEngine/Data/JSagaDataManagement.java +++ /dev/null @@ -1,188 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: XXXXXXXXXXXXXXXXXX -****************************************************************************/ - -package it.infn.ct.GridEngine.Data; - -import it.infn.ct.GridEngine.InformationSystem.BDII; -import it.infn.ct.GridEngine.SessionManagement.SessionManager; -import it.infn.ct.GridEngine.UsersTracking.UsersTrackingDBInterface; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Random; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.ogf.saga.error.BadParameterException; -import org.ogf.saga.error.NoSuccessException; -import org.ogf.saga.namespace.NSEntry; -import org.ogf.saga.namespace.NSFactory; -import org.ogf.saga.session.Session; -import org.ogf.saga.url.URL; -import org.ogf.saga.url.URLFactory; - -public class JSagaDataManagement { - - private Log log =LogFactory.getLog(JSagaDataManagement.class); - - private SessionManager sessionM; - private BDII bdii; - private UsersTrackingDBInterface userTrackingDB; - - public JSagaDataManagement() { - System.setProperty("saga.factory", "fr.in2p3.jsaga.impl.SagaFactoryImpl"); - userTrackingDB = new UsersTrackingDBInterface(); - sessionM = new SessionManager(); - log.info("A new JSagaDataManagement object created"); - } - - public void useRobotProxy(String proxyId, String vo, String fqan, boolean proxyrenewal) { - sessionM.useRobotProxy(proxyId, vo, fqan, proxyrenewal); - log.info("Enabled the proxy robot with id='"+proxyId+"'," - + " vo='"+vo+"', " - + " fqan='"+fqan+"'," - + " proxyRenewal='"+proxyrenewal+"'"); - } - - public void setUserProxy(String value) { - sessionM.setUserProxy(value); - log.info("Using the proxy '"+value+"'"); - } - - public String getUserProxy() { - return sessionM.getUserProxy(); - } - - public String getBDII() { - return bdii.getLocation().toString(); - } - - public void setBDII(String value) { - try { - bdii = new BDII(new URI(value)); - } - catch (Exception exc) { - log.error(exc); - } - } - - public void upload(String sourceURL, String relativeLocation, String commonName, String tcpAddress, int GridInteractionId, String userDescription) throws DataError{ - try { - java.net.URL source = new java.net.URL(sourceURL); - upload(source, relativeLocation, commonName, tcpAddress, GridInteractionId, userDescription); - } catch (Exception ex) { - log.error(ex); - throw new DataError(ex.getMessage()); - } - } - - public URI upload(java.net.URL source, String relativeLocation, String commonName, String tcpAddress, int GridInteractionId, String userDescription) throws DataError { - ArrayList srms = null; - URI uriSrm = null; - - try { - srms = new java.util.ArrayList(bdii.querySRMURIs(sessionM.getUserVO())); - } catch (Exception e) { - log.error(e); - throw new DataError(e.getMessage()); - } - Random rdm = new Random(); - while(srms.size()>0){ - int idxSrm = rdm.nextInt(srms.size()); - try { - uriSrm = new URI(srms.get(idxSrm).toString().concat(relativeLocation)); - copyFile(URLFactory.createURL(source.toString()), URLFactory.createURL(uriSrm.toString()), commonName, tcpAddress, GridInteractionId, userDescription); - break; - } catch (BadParameterException e) { - log.error(e); - srms.remove(idxSrm); - } catch (NoSuccessException e) { - log.error(e); - srms.remove(idxSrm); - } catch (URISyntaxException e) { - log.error(e); - srms.remove(idxSrm); - } - - } - if(srms.size()==0) - throw new DataError("All available storage fails"); - - return uriSrm; - - } - - public void copyFile(String sourceURL, String destinationURL, String commonName, String tcpAddress, int GridInteractionId, String userDescription) throws DataError { - try { - URL source = URLFactory.createURL(sourceURL); - URL destination = URLFactory.createURL(destinationURL); - copyFile(source, destination, commonName, tcpAddress, GridInteractionId, userDescription); - } catch (Exception ex) { - log.error(ex); - throw new DataError(ex.getMessage()); - } - } - - public void copyFile(java.net.URL sourceURL, java.net.URL destinationURL, String commonName, String tcpAddress, int GridInteractionId, String userDescription) throws DataError { - try { - URL source = URLFactory.createURL(sourceURL.toString()); - URL destination = URLFactory.createURL(destinationURL.toString()); - copyFile(source, destination, commonName, tcpAddress, GridInteractionId, userDescription); - } catch (Exception ex) { - log.error(ex); - throw new DataError(ex.getMessage()); - } - - } - - private void copyFile(URL source, URL destination, String commonName, String tcpAddress, int GridInteractionId, String userDescription) throws DataError { - int gIntAct = userTrackingDB.InsertActiveGridInteraction( - commonName, - tcpAddress, - GridInteractionId, - "["+source+"]"+"-["+destination+"]", - sessionM.getUserDN(), - sessionM.getProxyId(), - sessionM.getUserVO(), - sessionM.getUserFQAN(), - userDescription); - Session session = sessionM.getSession(); - - try { - NSEntry entrySource = NSFactory.createNSEntry(session, source); - - entrySource.copy(destination); - entrySource.close(); - userTrackingDB.CloseGridInteraction(gIntAct); - sessionM.closeSession(); - } catch (Exception ex) { - log.error(ex); - userTrackingDB.CloseGridInteraction(gIntAct); - throw new DataError(ex.getMessage()); - } - - } - -} diff --git a/it/infn/ct/GridEngine/InformationSystem/BDII.java b/it/infn/ct/GridEngine/InformationSystem/BDII.java deleted file mode 100644 index 453f9a1..0000000 --- a/it/infn/ct/GridEngine/InformationSystem/BDII.java +++ /dev/null @@ -1,730 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) - ****************************************************************************/ - -package it.infn.ct.GridEngine.InformationSystem; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.naming.NamingException; -import javax.naming.directory.SearchResult; -//import java.util.logging.Level; -//import java.util.logging.Logger; -//import javax.naming.directory.Attributes; - -/** - * This class executes LDAP query to a BDII to get information about a gLite - * based infrastructure - * - * @author mario - */ -public class BDII { - - final static String[] srmServiceType = { "srm", "SRM" }; - final static String[] wmsServiceType = { "org.glite.wms.WMProxy" }; - final static String[] cesServiceType = { "org.glite.ce.CREAM" }; - - URI location; - - /** - * Constructs a new {@link BDII} object given a LDAP URI - * - * @param location - * the given URI (e.g. ldap://gridit-bdii-01.cnaf.infn.it:2170). - */ - public BDII(URI location) { - super(); - this.location = location; - } - - /** - * Returns the LDAP URI. - * - * @return LDAP URI. - */ - public URI getLocation() { - return location; - } - - private Set querySRMURIs(String vo) throws Exception { - - Set srmURIs = new HashSet(); - - BDIIQuery q = new BDIIQuery(location.toString()); - - ArrayList res = q - .query("(&(objectClass=GlueSA)(GlueSAAccessControlBaseRule=VO:" - + vo + "))"); - - Map ids = new HashMap(); - - for (SearchResult r : res) { - - try { - String id = r.getAttributes() - .get("GlueChunkKey").get().toString(); //$NON-NLS-1$; - id = id.substring(id.indexOf('=') + 1); - ArrayList resForPath = q - .query("(&(GlueChunkKey=GlueSEUniqueID=" + id - + ")(GlueVOInfoAccessControlBaseRule=VO:" + vo - + "))"); - if (!resForPath.isEmpty()) { - String path = resForPath.get(0).getAttributes() - .get("GlueVOInfoPath").get().toString(); - ids.put(id, path); - } - } catch (NamingException ex) { - // Logger.getLogger(BDII.class.getName()).log(Level.FINE, - // "Error when quering BDII", ex); - } - } - - String searchPhrase = "(&(objectClass=GlueService)(GlueServiceUniqueID=*)(GlueServiceAccessControlRule=" + vo + ")"; //$NON-NLS-1$ - - searchPhrase += "(|"; //$NON-NLS-1$ - for (String type : srmServiceType) { - searchPhrase += "(GlueServiceType=" + type + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - searchPhrase += "))"; - - // System.out.println(searchPhrase); - - res = q.query(searchPhrase); - - Set srmIds = new HashSet(); - - for (SearchResult r : res) { - - try { - String serviceEndPoint = GlueUtility.getStringAttribute( - "GlueServiceEndpoint", r.getAttributes()); - - URI httpgURI = new URI(serviceEndPoint); - - if (ids.containsKey(httpgURI.getHost())) { - - StringBuilder srmURI = new StringBuilder(); - - srmURI.append("srm"); - srmURI.append("://"); - srmURI.append(httpgURI.getHost()); - if (httpgURI.getPort() != -1) { - srmURI.append(':'); - srmURI.append(httpgURI.getPort()); - } - - // System.out.println(); - srmURI.append(ids.get(httpgURI.getHost())); - - String srmURIString = srmURI.toString(); - srmURIs.add(URI.create(srmURIString)); - - srmIds.add(httpgURI.getHost()); - } - // else - // Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING,"No path found in BDII for host " - // + httpgURI.getHost()); - - } catch (URISyntaxException e) { - // Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING,"Error creating URI for a storge element.", - // e); - } - } - - return srmURIs; - } - - /** - * Returns a WMS list for a specified virtual organization. - * - * @param vo - * the virtual organization name - * @return WMS list for a specified virtual organization. - * @throws NamingException - */ - public List queryWMSURIs(String vo) throws NamingException { - BDIIQuery q = new BDIIQuery(location.toString()); - - String searchPhrase = "(&(objectClass=GlueService)(GlueServiceUniqueID=*)(GlueServiceAccessControlRule=" - + vo + ")"; - searchPhrase += "(|"; //$NON-NLS-1$ - for (String type : wmsServiceType) { - searchPhrase += "(GlueServiceType=" + type + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - searchPhrase += "))"; - - ArrayList res = q.query(searchPhrase); - - List wmsURIs = new LinkedList(); - - for (SearchResult r : res) { - - try { - URI wmsURI = new URI(GlueUtility.getStringAttribute( - "GlueServiceEndpoint", r.getAttributes())); - wmsURIs.add(wmsURI); - } catch (URISyntaxException e) { - // Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, - // "Error creating URI for WMS.", e); - } - } - - return wmsURIs; - } - - /** - * Returns a randomly chosen WMS for a specified virtual organization. - * - * @param VO - * he virtual organization name - * @return randomly chosen WMS for a specified virtual organization. - */ - public String getRandomWMS(String VO) { - try { - List wmsList = queryWMSURIs(VO); - int index = (int) ((Math.random()) * (new Integer(wmsList.size()) - .doubleValue())); - - System.out.println("Index=" + index); - if (index == wmsList.size()) - index--; - - String wmsSelected = wmsList.get(index).toString() - .replaceFirst("https", "wms"); - return wmsSelected; - } catch (NamingException exc) { - System.out.println(exc.toString()); - } - return null; - } - - // ldapsearch -x -LLL -H ldap://bdii.eela.ufrj.br:2170 -b o=grid - // '(&(objectClass=GlueCE)(GlueCEAccessControlBaseRule=VO:prod.vo.eu-eela.eu))' - // GlueCEUniqueID - /** - * Returns a computing element list for a given virtual organization. - * - * @param vo - * virtual organization - * @return a computing element list for a given virtual organization. - * @throws NamingException - */ - public List queryCEQueues(String vo) throws NamingException { - BDIIQuery q = new BDIIQuery(location.toString()); - - String searchPhrase = "(&(objectClass=GlueCE)(GlueCEAccessControlBaseRule=VO:" - + vo + "))"; - q.setAttribute("GlueCEUniqueID"); - - ArrayList res = q.query(searchPhrase); - - List ceQueues = new LinkedList(); - - for (SearchResult r : res) { - String ce = GlueUtility.getStringAttribute("GlueCEUniqueID", - r.getAttributes()); - ceQueues.add(ce); - } - - return ceQueues; - } - - /** - * Returns a randomly chosen CE for a specified virtual organization. - * - * @param VO - * he virtual organization name - * @return randomly chosen CE for a specified virtual organization. - */ - public String getRandomCE(String VO) { - try { - List cesList = queryCEQueues(VO); - int index = (int) ((Math.random()) * (new Integer(cesList.size()) - .doubleValue())); - - System.out.println("Index=" + index); - if (index == cesList.size()) - index--; - - String ceSelected = cesList.get(index).toString(); - return ceSelected; - } catch (NamingException exc) { - System.out.println(exc.toString()); - } - return null; - } - - /** - * Returns the geographical coordinates for a given computing element. - * - * @param ce - * computing element name - * @return a String[] containing latitude and longitude for a given - * computing element. - * @throws NamingException - */ - public String[] queryCECoordinate(String ce) throws NamingException { - String coordinates[] = new String[2]; - BDIIQuery q = new BDIIQuery(ce.toString()); - - String searchPhrase = "(&(objectClass=GlueSite))"; - q.setAttribute("GlueSiteLatitude"); - q.setAttribute("GlueSiteLongitude"); - ArrayList res = q.query(searchPhrase); - - for (SearchResult r : res) { - coordinates[0] = GlueUtility.getStringAttribute("GlueSiteLatitude", - r.getAttributes()); - System.out.println("latitude" + coordinates[0]); - coordinates[1] = GlueUtility.getStringAttribute( - "GlueSiteLongitude", r.getAttributes()); - System.out.println("longitude=" + coordinates[1]); - - break; - } - ldap: // gridit-bdii-01.cnaf.infn.it:2170 - - if (coordinates[0] == null) - coordinates[0] = "0"; - if (coordinates[1] == null) - coordinates[1] = "0"; - return coordinates; - } - - // ldapsearch -x -H ldap://bdii.eumedgrid.eu:2170 -b o=grid - // "(&(objectclass=GlueSubCluster)(GlueHostApplicationSoftwareRunTimeEnvironment=VO-eumed-ASTRA))" - // GlueSubClusterName - /** - * Returns a computing element list for a given software tag. - * - * @param tag - * tag identifying software - * @return a computing element list for a given software tag. - * @throws NamingException - */ - public List queryCEForSWTag(String tag) throws NamingException { - BDIIQuery q = new BDIIQuery(location.toString()); - - String searchPhrase = "(&(objectClass=GlueSubCluster)(GlueHostApplicationSoftwareRunTimeEnvironment=" - + tag + "))"; - q.setAttribute("GlueSubClusterName"); - - ArrayList res = q.query(searchPhrase); - - List ceForSWTag = new LinkedList(); - - for (SearchResult r : res) { - String ce = GlueUtility.getStringAttribute("GlueSubClusterName", - r.getAttributes()); - ceForSWTag.add(ce); - } - return ceForSWTag; - } - - /** - * Returns a randomly chosen computing element for a given software tag. - * - * @param tag - * tag identifying software - * - * @return a randomly chosen computing element for a given software tag. - * @throws NamingException - */ - public String getRandomCEForSWTag(String tag) throws NamingException { - List ceForSWTag = queryCEForSWTag(tag); - - if (ceForSWTag.size() == 0) - return ""; - - int index = (int) ((Math.random()) * (new Integer(ceForSWTag.size()) - .doubleValue())); - - System.out.println("Index=" + index); - if (index == ceForSWTag.size()) - index--; - - return ceForSWTag.get(index).toString(); - } - - /** - * Returns a computing element list for a given SWTag, virtual organization - * and maximum CPU time. - * - * @param TAG - * tag identifying software - * @param VO - * virtual organization - * @param MaxCPUTime - * required maximum CPU time - * @return a computing element list for a given SWTag, virtual organization - * and maximum CPU time. - * @throws NamingException - */ - public List queryCEFromSWTag_MaxCPUTime(String TAG, String VO, - Integer MaxCPUTime) throws NamingException { - BDIIQuery q = new BDIIQuery(location.toString()); - - String searchPhrase = "(&(objectClass=GlueSubCluster)(GlueHostApplicationSoftwareRunTimeEnvironment=" - + TAG + "))"; - - q.setAttribute("GlueSubClusterName"); - - ArrayList res = q.query(searchPhrase); - List ceFromSWTag_MaxCPUTime = new LinkedList(); - - String ce = null; - for (SearchResult r : res) { - ce = GlueUtility.getStringAttribute("GlueSubClusterName", - r.getAttributes()); - searchPhrase = "(&(objectClass=GlueCE)(GlueCEAccessControlBaseRule=VO:" - + VO + ")(GlueCEPolicyMaxCPUTime>=" + MaxCPUTime + "))"; - q.setAttribute("GlueCEUniqueID"); - - ArrayList res2 = q.query(searchPhrase); - for (SearchResult response : res2) { - String queue = GlueUtility.getStringAttribute("GlueCEUniqueID", - response.getAttributes()); - // Check if the queue matches the ce... - if (queue.matches(ce + "(.*)")) - ceFromSWTag_MaxCPUTime.add(ce); - } - } - return ceFromSWTag_MaxCPUTime; - } - - /** - * Returns a randomly chosen computing element for a given SWTag, virtual - * organization. and maximum CPU time. - * - * @param TAG - * tag identifying software - * @param VO - * virtual organization - * @param MaxCPUTime - * required maximum CPU time - * @return a randomly chosen computing element for a given SWTag, virtual - * organization - * @throws NamingException - */ - public String getRandomCEFromSWTag_MaxCPUTime(String TAG, String VO, - Integer MaxCPUTime) throws NamingException { - List ceFromSWTag_MaxCPUTime = queryCEFromSWTag_MaxCPUTime(TAG, - VO, MaxCPUTime); - - if (ceFromSWTag_MaxCPUTime.size() == 0) - return ""; - - int index = (int) ((Math.random()) * (new Integer( - ceFromSWTag_MaxCPUTime.size()).doubleValue())); - if (index == ceFromSWTag_MaxCPUTime.size()) - index--; - return ceFromSWTag_MaxCPUTime.get(index).toString(); - } - - // Retrieve the GlueSEImplementationName for a given storage resource - // String SE_HOSTNAME = "ldap://iceage-se-01.ct.infn.it:2170"; - /** - * Retrieve the GlueSEImplementationName for a given storage resource - * - * @param SE_HOSTNAME - * storage element. (e.g. ldap://iceage-se-01.ct.infn.it:2170) - * @return the GlueSEImplementationName for a given storage resource - * @throws NamingException - */ - public String getGlueSEImplementationName(String SE_HOSTNAME) - throws NamingException { - String GlueSEImplementationName = ""; - - BDIIQuery q = new BDIIQuery(SE_HOSTNAME); - String searchPhrase = ("(&(objectClass=GlueSE))"); - q.setAttribute("GlueSEImplementationName"); - - ArrayList res = q.query(searchPhrase); - - for (SearchResult r : res) - GlueSEImplementationName = GlueUtility.getStringAttribute( - "GlueSEImplementationName", r.getAttributes()); - - return GlueSEImplementationName; - } - - // Retrieve the GlueVOInfoPath for a given storage resource and a VO - // String SE_HOST = "iceage-se-01.ct.infn.it"; - // String VO = "gridit"; - /** - * Retrieve the GlueVOInfoPath for a given storage resource and a VO. - * - * @param SE_HOST - * storage element host. (e.g. iceage-se-01.ct.infn.it) - * @param VO_NAME - * virtual organization name. - * @return the GlueVOInfoPath for a given storage resource and a VO. - * @throws NamingException - */ - public String getGlueVOInfoPath(String SE_HOST, String VO_NAME) - throws NamingException { - - String GlueVOInfoPath = ""; - - BDIIQuery q = new BDIIQuery(location.toString()); - String searchPhrase = ("(&(GlueVOInfoLocalID=" + VO_NAME - + "*)(GlueChunkKey=GlueSEUniqueID=" + SE_HOST + "))"); - q.setAttribute("GlueVOInfoPath"); - - ArrayList res = q.query(searchPhrase); - - for (SearchResult r : res) - GlueVOInfoPath = GlueUtility.getStringAttribute("GlueVOInfoPath", - r.getAttributes()); - - return GlueVOInfoPath; - } - - // Retrieve the list of GlueCEUniqueID for a given VO and a - // GlueCEPolicyMaxCPUTime - // String VO = "gridit"; - // Integer MAX_CPUTime = 30240; - /** - * Retrieve the list of GlueCEUniqueID for a given VO and a - * GlueCEPolicyMaxCPUTime - * - * @param VO_NAME - * virtual organization name - * @param MaxCPUTime - * required maximum CPU time - * @return the list of GlueCEUniqueID for a given VO and a - * GlueCEPolicyMaxCPUTime - * @throws NamingException - */ - public List getGlueCEUniqueIDs(String VO_NAME, Integer MaxCPUTime) - throws NamingException { - - BDIIQuery q = new BDIIQuery(location.toString()); - String searchPhrase = ("(&(objectClass=GlueCE)(GlueCEAccessControlBaseRule=VO:" - + VO_NAME + "(GlueCEPolicyMaxCPUTime>=" + MaxCPUTime + "))"); - q.setAttribute("GlueCEUniqueID"); - - ArrayList res = q.query(searchPhrase); - List GlueCEUniqueIDs = new LinkedList(); - - for (SearchResult r : res) { - String CE = GlueUtility.getStringAttribute("GlueCEUniqueID", - r.getAttributes()); - GlueCEUniqueIDs.add(CE); - } - - return GlueCEUniqueIDs; - } - - // Retrieve a full list of GlueCEInfoHostName for a given VO - // String VO = "gridit"; - /** - * Retrieve a full list of GlueCEInfoHostName for a given VO. - * - * @param VO_NAME - * virtual organization name. - * @return a full list of GlueCEInfoHostName for a given VO. - * @throws NamingException - */ - public List getGlueCEInfoHostNames(String VO_NAME) - throws NamingException { - - BDIIQuery q = new BDIIQuery(location.toString()); - String searchPhrase = ("(&(objectClass=GlueCE)(GlueCEAccessControlBaseRule=VO:" - + VO_NAME + "))"); - q.setAttribute("GlueCEInfoHostName"); - - ArrayList res = q.query(searchPhrase); - List GlueCEInfoHostNames = new LinkedList(); - - for (SearchResult r : res) { - String CE = GlueUtility.getStringAttribute("GlueCEInfoHostName", - r.getAttributes()); - GlueCEInfoHostNames.add(CE); - } - - return GlueCEInfoHostNames; - } - - // Retrieve the defaultSE for a given CE - // String CE_HOST = "grid012.ct.infn.it"; - /** - * Retrieve the defaultSE for a given computing element. - * - * @param CE_HOST - * computing element host.(e.g. grid012.ct.infn.it). - * @return the defaultSE for a given computing element. - * @throws NamingException - */ - public String getGlueCEInfoDefaultSE(String CE_HOST) throws NamingException { - String GlueCEInfoDefaultSE = ""; - - BDIIQuery q = new BDIIQuery(location.toString()); - String searchPhrase = ("(&(objectClass=GlueCE)(GlueCEUniqueID=" - + CE_HOST + "*))"); - q.setAttribute("GlueCEInfoDefaultSE"); - - ArrayList res = q.query(searchPhrase); - - for (SearchResult r : res) - GlueCEInfoDefaultSE = GlueUtility.getStringAttribute( - "GlueCEInfoDefaultSE", r.getAttributes()); - - return GlueCEInfoDefaultSE; - } - - public String getRandomCEFromSWTag_MaxWallClockTime(String TAG, String VO, - Integer MaxWallClockTime) throws NamingException { - - List ceFromSWTag_MaxWallClockTime = queryCEFromSWTag_MaxWallClockTime( - TAG, VO, MaxWallClockTime); - if (ceFromSWTag_MaxWallClockTime.size() == 0) - return ""; - int index = (int) ((Math.random()) * (new Integer( - ceFromSWTag_MaxWallClockTime.size()).doubleValue())); - if (index == ceFromSWTag_MaxWallClockTime.size()) - index--; - return ceFromSWTag_MaxWallClockTime.get(index).toString(); - } - - public List queryCEFromSWTag_MaxWallClockTime(String TAG, - String VO, Integer MaxWallClockTime) throws NamingException { - BDIIQuery q = new BDIIQuery(location.toString()); - - String searchPhrase = "(&(objectClass=GlueSubCluster)(GlueHostApplicationSoftwareRunTimeEnvironment=" - + TAG + "))"; - - q.setAttribute("GlueSubClusterName"); - - List CE_LIST = new LinkedList(); - List QUEUE_LIST = new LinkedList(); - - ArrayList res = q.query(searchPhrase); - List ceFromSWTag_MaxWallClockTime = new LinkedList(); - - String ce = null; - for (SearchResult r : res) { - ce = GlueUtility.getStringAttribute("GlueSubClusterName", - r.getAttributes()); - CE_LIST.add(ce); - } - - searchPhrase = "(&(objectClass=GlueCE)(GlueCEAccessControlBaseRule=VO:" - + VO + ")(GlueCEPolicyMaxWallClockTime>=" + MaxWallClockTime - + "))"; - - q.setAttribute("GlueCEUniqueID"); - - ArrayList res2 = q.query(searchPhrase); - for (SearchResult response : res2) { - String queue = GlueUtility.getStringAttribute("GlueCEUniqueID", - response.getAttributes()); - QUEUE_LIST.add(queue); - } - - // Check if the queue matches the ce - for (int i = 0; i < QUEUE_LIST.size(); i++) - for (int j = 0; j < CE_LIST.size(); j++) - if ((QUEUE_LIST.get(i)).contains(CE_LIST.get(j))) - ceFromSWTag_MaxWallClockTime.add(CE_LIST.get(j)); - - return ceFromSWTag_MaxWallClockTime; - } - - public static void main(String[] args) { - BDII bdii = null; - String bdiiCometa = "ldap://gridit-bdii-01.cnaf.infn.it:2170"; - String VO = "gridit"; - String tag = "VO-gridit-GEANT4-09-05-patch-01"; - Integer MAX_CPUTime = 30240; - String cequeue = ""; - - try { - bdii = new BDII(new URI(bdiiCometa)); - } catch (Exception exc) { - System.out.println(exc.toString()); - } - - try { - cequeue = bdii - .getRandomCEFromSWTag_MaxCPUTime(tag, VO, MAX_CPUTime); - } catch (NamingException e) { - e.printStackTrace(); - } - - System.out.println("cequeue=" + cequeue); - /* - * String bdiiCometa = "ldap://gridit-bdii-01.cnaf.infn.it:2170"; - * //String bdiiGisela = "ldap://bdii.eela.ufrj.br:2170"; //String - * bdiiEumed = "ldap://topbdii.junet.edu.jo:2170"; //String VO = - * "eumed"; String VO = "prod.vo.eu-eela.eu"; String tag = - * "VO-gridit-POVRAY-3.6"; //String CE = "ldap://ce01.unlp.edu.ar:2170"; - * BDII bdii = null; - * - * try { bdii = new BDII(new URI(bdiiCometa)); } catch (Exception exc) { - * System.out.println(exc.toString()); } - * - * List cequeues = null; String cequeue = null; - * - * // try { // cequeues = bdii.queryCEQueues(VO); // } catch - * (NamingException e) { // // TODO Auto-generated catch block // - * e.printStackTrace(); // } - * - * // try { // cequeues = bdii.queryCEForSWTag(tag); // } catch - * (NamingException e) { // // TODO Auto-generated catch block // - * e.printStackTrace(); // } - * - * try { cequeue = bdii.getRandomCEForSWTag(tag); } catch - * (NamingException e) { // TODO Auto-generated catch block - * e.printStackTrace(); } - * - * System.out.println("cequeue="+cequeue); - * - * // String CECoordinate[] = null; // Iterator iterator = - * cequeues.iterator(); // try { // while (iterator.hasNext()) { // - * String ce = iterator.next(); // System.out.println(ce); // - * CECoordinate = bdii.queryCECoordinate("ldap://"+ce+":2170"); // if - * (CECoordinate!=null) { // - * System.out.println("latitude="+CECoordinate[0]); // - * System.out.println("longitude="+CECoordinate[1]); // // } // } // } - * catch (NamingException e) { // // TODO Auto-generated catch block // - * e.printStackTrace(); // } - * - * // String CECoordinate[] = null; // try { // CECoordinate = - * bdii.queryCECoordinate(CE); // } catch (NamingException e) { // // - * TODO Auto-generated catch block // e.printStackTrace(); // } // // if - * (CECoordinate!=null) { // - * System.out.println("latitude"+CECoordinate[0]); // - * System.out.println("longitude="+CECoordinate[1]); // // } - */ - } - -} diff --git a/it/infn/ct/GridEngine/InformationSystem/BDIIQuery.java b/it/infn/ct/GridEngine/InformationSystem/BDIIQuery.java deleted file mode 100644 index a978947..0000000 --- a/it/infn/ct/GridEngine/InformationSystem/BDIIQuery.java +++ /dev/null @@ -1,99 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2008 g-Eclipse consortium - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial development of the original code was made for - * project g-Eclipse founded by European Union - * project number: FP6-IST-034327 http://www.geclipse.eu/ - * - * Contributor(s): - * Nikolaos Tsioutsias - implementation - *****************************************************************************/ -package it.infn.ct.GridEngine.InformationSystem; - -import java.util.ArrayList; -import java.util.Hashtable; - -import javax.naming.Context; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.DirContext; -import javax.naming.directory.InitialDirContext; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - - -/** - * @author tnikos - * - */ -public class BDIIQuery { - - private String bdii = ""; //$NON-NLS-1$ - private ArrayList attributeList = new ArrayList(); - /** - * @param bdii the end poing of the bdii to query - */ - public BDIIQuery(final String bdii) - { - this.bdii = bdii; - } - - /** - * Sets the specific attributes of the element that we want to return - * @param attribute a valid - */ - public void setAttribute(final String attribute) - { - if (attribute!=null && attribute.length() > 0 ) - { - this.attributeList.add( attribute ); - } - } - - private ArrayList getAttributes() - { - return this.attributeList; - } - /** - * This method queries the bdii set in the constructor - * @param searchPhrase the search phrase - * @return an array list of SearchResult objects. - * @throws InternalProcessingError - */ - public ArrayList query(final String searchPhrase) throws NamingException - { - boolean hasError= false; - ArrayList resultsList = new ArrayList(); - String bindDN = "o=grid"; //$NON-NLS-1$ - Hashtable env = new Hashtable(); - - env.put( Context.INITIAL_CONTEXT_FACTORY, - "com.sun.jndi.ldap.LdapCtxFactory" ); //$NON-NLS-1$ - env.put( Context.PROVIDER_URL, this.bdii); - - if ( ! hasError ) { - /* get a handle to an Initial DirContext */ - DirContext dirContext = new InitialDirContext( env ); - - /* specify search constraints to search subtree */ - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); - - // specify the elements to return - if (this.getAttributes().size()> 0) - constraints.setReturningAttributes( this.getAttributes().toArray( new String[this.getAttributes().size()] )); - - // Perform the search - NamingEnumeration results = dirContext.search( bindDN, - searchPhrase, - constraints ); - resultsList = java.util.Collections.list( results ); - - } - return resultsList; - } -} \ No newline at end of file diff --git a/it/infn/ct/GridEngine/InformationSystem/GlueUtility.java b/it/infn/ct/GridEngine/InformationSystem/GlueUtility.java deleted file mode 100644 index 65e6866..0000000 --- a/it/infn/ct/GridEngine/InformationSystem/GlueUtility.java +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2006, 2007 g-Eclipse Consortium - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial development of the original code was made for the - * g-Eclipse project founded by European Union - * project number: FP6-IST-034327 http://www.geclipse.eu/ - * - * Contributors: - * Nikolaos Tsioutsias - initial API and implementation - * - *****************************************************************************/ -package it.infn.ct.GridEngine.InformationSystem; - - -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; - - -/** - * @author Nikolaos Tsioutsias - * - */ -public class GlueUtility { - - /** - * - * @param attribute The name of the attribute - * @param attributes The list of attributes - * @return returns an empty String if a wrong attribute name is passed or - * a String with the value of the attribute. - */ - public static String getStringAttribute( final String attribute, - final Attributes attributes ) - { - String result = ""; //$NON-NLS-1$ - Attribute attr = attributes.get( attribute ); - if( attr != null ) { - try { - result = attr.get().toString(); - } catch( NamingException e ) { - // ignore missing fields - } - } - return result; - } - - /** - * @param attribute The name of the attribute - * @param attributes The list of attributes - * @return returns an Integer object with value of -1 if the wrong name is passed or the - * value of the attribute. - */ - public static Integer getIntegerAttribute( final String attribute, - final Attributes attributes ) - { - Integer result = Integer.valueOf(-1); - Attribute attr = attributes.get( attribute ); - if( attr != null ) { - try { - result = Integer.parseInt( attr.get().toString() ); - } catch( NamingException e ) { - // ignore missing fields - } catch( NumberFormatException e ) { - // Ignore Exception - } - } - return result; - } - - /** - * @param attribute The name of the attribute - * @param attributes The list of attributes - * @return returns a Long object with value of -1 if the wrong name is passed or the - * value of the attribute. - */ - public static Long getLongAttribute( final String attribute, - final Attributes attributes ) - { - Long result = Long.valueOf(-1); - Attribute attr = attributes.get( attribute ); - if( attr != null ) { - try { - result = Long.parseLong( attr.get().toString() ); - } catch( NamingException e ) { - // ignore missing fields - } catch( NumberFormatException e ) { - // Ignore Exception - } - } - return result; - } -} \ No newline at end of file diff --git a/it/infn/ct/GridEngine/Job/InfrastructureInfo.java b/it/infn/ct/GridEngine/Job/InfrastructureInfo.java deleted file mode 100644 index d251802..0000000 --- a/it/infn/ct/GridEngine/Job/InfrastructureInfo.java +++ /dev/null @@ -1,722 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) - ****************************************************************************/ - -package it.infn.ct.GridEngine.Job; - -/** - * This class contains the information needed to access an e-Infrastructure: - * middleware, resource managers, credential, etc. - * @author mario - * - */ -public class InfrastructureInfo { - - private String Name = ""; - private String Middleware = "glite"; - private String BDII = ""; - private String ResourcemanagerList[] = null; - private String ETokenServer = ""; - private String ETokenServerPort = ""; - private String ProxyId = ""; - private String VO = ""; - private String FQAN = ""; - private String SWTag = ""; - // boolean proxyRenewal = true; - private String UserProxy = ""; // for example /tmp/x509up_u500 - private String Keystore = ""; - private String UserName = ""; - private String Password = ""; - private String CEList[] = null; - private boolean RFC = false; - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param proxy - * path to a user proxy certificate - */ - public InfrastructureInfo(String name, String bdii, - String resourcemanagerlist[], String proxy) { - Name = name; - BDII = bdii; - ResourcemanagerList = resourcemanagerlist; - UserProxy = proxy; - } - - public InfrastructureInfo(String name, String middleware, - String authparam1, String resourcemanagerlist[]) { - Name = name; - Middleware = middleware; - UserName = authparam1; - ResourcemanagerList = resourcemanagerlist; - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param middleware - * middleware name - * @param authparam1 - * first authentication parameter. This parameter can have more - * meanings depending on middleware type, if middleware is: - *
    - *
  • glite, it is the BDII host;
  • - *
  • wsgram, is ignored;
  • - *
  • unicore or bes-genesis2, it is the keystore name;
  • - *
  • ourgrid or ssh, it is the user name;
  • - *
- * @param authparam2 - * second authentication parameter. This parameter can have more - * meanings depending on middleware type, if middleware is: - *
    - *
  • glite or wsgram, it is the path to a user proxy - * certificate;
  • - *
  • unicore or bes-genesis2, it is the keystore password;
  • - *
  • ourgrid or ssh, it is the user password;
  • - *
- * @param resourcemanagerlist - * resourcemanagerlist String[] that contains list of enabled - * WMSes - */ - public InfrastructureInfo(String name, String middleware, - String authparam1, String authparam2, String resourcemanagerlist[]) { - Name = name; - Middleware = middleware; - if (Middleware.equals("glite")) { - BDII = authparam1; - UserProxy = authparam2; - } else if (Middleware.equals("wsgram") || Middleware.equals("gatekeeper")) { - UserProxy = authparam2; - } else if ((Middleware.equals("unicore")) - || (Middleware.equals("bes-genesis2"))) { - Keystore = authparam1; - Password = authparam2; - } else if (Middleware.equals("ourgrid") || Middleware.equals("ssh")) { - UserName = authparam1; - Password = authparam2; - } - - ResourcemanagerList = resourcemanagerlist; - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param proxy - * path to a user proxy certificate - * @param swtag - * infrastructure software tag - */ - public InfrastructureInfo(String name, String bdii, - String resourcemanagerlist[], String proxy, String swtag) { - Name = name; - BDII = bdii; - ResourcemanagerList = resourcemanagerlist; - SWTag = swtag; - UserProxy = proxy; - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param proxy - * path to a user proxy certificate - * @param swtag - * infrastructure software tag - * @param CEs - * a String[] of possible CEs - */ - public InfrastructureInfo(String name, String resourcemanagerlist[], - String proxy, String swtag, String[] CEs) { - Name = name; - ResourcemanagerList = resourcemanagerlist; - SWTag = swtag; - UserProxy = proxy; - CEList = CEs; - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param CEs - * a String[] of possible CEs - */ - public InfrastructureInfo(String name, String resourcemanagerlist[], - String etokenserver, String etokenserverport, String proxyid, - String vo, String fqan, String[] CEs) { -// Name = name; -// CEList = CEs; -// ResourcemanagerList = resourcemanagerlist; -// ETokenServer = etokenserver; -// ETokenServerPort = etokenserverport; -// ProxyId = proxyid; -// VO = vo; -// FQAN = fqan; - - this(name,resourcemanagerlist,etokenserver,etokenserverport,proxyid,vo,fqan,false,CEs); - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - * @param CEs - * a String[] of possible CEs - */ - public InfrastructureInfo(String name, String resourcemanagerlist[], - String etokenserver, String etokenserverport, String proxyid, - String vo, String fqan, boolean rfc, String[] CEs) { - Name = name; - CEList = CEs; - ResourcemanagerList = resourcemanagerlist; - ETokenServer = etokenserver; - ETokenServerPort = etokenserverport; - ProxyId = proxyid; - VO = vo; - FQAN = fqan; - RFC = rfc; - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles. - */ - public InfrastructureInfo(String name, String bdii, - String resourcemanagerlist[], String etokenserver, - String etokenserverport, String proxyid, String vo, String fqan) { -// Name = name; -// BDII = bdii; -// ResourcemanagerList = resourcemanagerlist; -// ETokenServer = etokenserver; -// ETokenServerPort = etokenserverport; -// ProxyId = proxyid; -// VO = vo; -// FQAN = fqan; - - this(name,bdii,resourcemanagerlist,etokenserver,etokenserverport,proxyid,vo,fqan,false); - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - */ - public InfrastructureInfo(String name, String bdii, - String resourcemanagerlist[], String etokenserver, - String etokenserverport, String proxyid, String vo, String fqan, boolean rfc) { - Name = name; - BDII = bdii; - ResourcemanagerList = resourcemanagerlist; - ETokenServer = etokenserver; - ETokenServerPort = etokenserverport; - ProxyId = proxyid; - VO = vo; - FQAN = fqan; - RFC = rfc; - } - - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param middleware - * middleware name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles. - */ - public InfrastructureInfo(String name, String middleware, String bdii, - String resourcemanagerlist[], String etokenserver, - String etokenserverport, String proxyid, String vo, String fqan) { -// Name = name; -// Middleware = middleware; -// BDII = bdii; -// ResourcemanagerList = resourcemanagerlist; -// ETokenServer = etokenserver; -// ETokenServerPort = etokenserverport; -// ProxyId = proxyid; -// VO = vo; -// FQAN = fqan; - - this(name,middleware,bdii,resourcemanagerlist,etokenserver,etokenserverport,proxyid,vo,fqan,false); - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param middleware - * middleware name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - */ - public InfrastructureInfo(String name, String middleware, String bdii, - String resourcemanagerlist[], String etokenserver, - String etokenserverport, String proxyid, String vo, String fqan, boolean rfc) { - Name = name; - Middleware = middleware; - BDII = bdii; - ResourcemanagerList = resourcemanagerlist; - ETokenServer = etokenserver; - ETokenServerPort = etokenserverport; - ProxyId = proxyid; - VO = vo; - FQAN = fqan; - RFC = rfc; - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles. - * @param swtag - * infrastructure software tag - */ - public InfrastructureInfo(String name, String bdii, - String resourcemanagerlist[], String etokenserver, - String etokenserverport, String proxyid, String vo, String fqan, - String swtag) { -// Name = name; -// BDII = bdii; -// ResourcemanagerList = resourcemanagerlist; -// ETokenServer = etokenserver; -// ETokenServerPort = etokenserverport; -// ProxyId = proxyid; -// VO = vo; -// FQAN = fqan; -// SWTag = swtag; - - this(name,bdii,resourcemanagerlist,etokenserver,etokenserverport,proxyid,vo,fqan,false,swtag); - } - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param bdii - * BDII host - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles. - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - * @param swtag - * infrastructure software tag - */ - public InfrastructureInfo(String name, String bdii, - String resourcemanagerlist[], String etokenserver, - String etokenserverport, String proxyid, String vo, String fqan, - boolean rfc, String swtag) { - Name = name; - BDII = bdii; - ResourcemanagerList = resourcemanagerlist; - ETokenServer = etokenserver; - ETokenServerPort = etokenserverport; - ProxyId = proxyid; - VO = vo; - FQAN = fqan; - SWTag = swtag; - RFC = rfc; - } - - - /** - * Constructs a {@link InfrastructureInfo} object initializing its attribute - * with the given data. - * - * @param name - * infrastructure name - * @param middleware - * middlewarename - * @param resourcemanagerlist - * String[] that contains list of enabled WMSes - */ - public InfrastructureInfo(String name, String middleware, - String resourcemanagerlist[]) { - Name = name; - Middleware = middleware; - ResourcemanagerList = resourcemanagerlist; - } - - /** - * Returns the infrastructure full name - * - * @return infrastructure full name - */ - public String getName() { - return Name; - } - - public void setName(String name) { - Name = name; - } - - /** - * Returns the BDII host. - * - * @return BDII host. - */ - public String getBDII() { - return BDII; - } - - public void setBDII(String bDII) { - BDII = bDII; - } - - /** - * Returns the list of enabled WMSes. - * @deprecated - * @return list of enabled WMSes. - */ - public String[] getWmsList() { - return ResourcemanagerList; - } - public String[] getResourcemanagerList() { - return ResourcemanagerList; - } - - public void setResourcemanagerList(String[] resourcemanagerList) { - ResourcemanagerList = resourcemanagerList; - } - - /** - * Returns the path to a user proxy certificate. - * - * @return path to a user proxy certificate. - */ - public String getUserProxy() { - return UserProxy; - } - - public void setUserProxy(String userProxy) { - UserProxy = userProxy; - } - - /** - * Returns the robot proxy host. - * - * @return robot proxy host. - */ - public String getETokenServer() { - return ETokenServer; - } - - public void setETokenServer(String eTokenServer) { - ETokenServer = eTokenServer; - } - - /** - * Returns the robot proxy port. - * - * @return robot proxy port. - */ - public String getETokenServerPort() { - return ETokenServerPort; - } - - public void setETokenServerPort(String eTokenServerPort) { - ETokenServerPort = eTokenServerPort; - } - - /** - * Returns the robot proxy identifier. - * - * @return robot proxy identifier. - */ - public String getProxyId() { - return ProxyId; - } - - public void setProxyId(String proxyId) { - ProxyId = proxyId; - } - - /** - * Returns the robot proxy robot proxy virtual organization. - * - * @return robot proxy virtual organization. - */ - public String getVO() { - return VO; - } - - public void setVO(String vO) { - VO = vO; - } - - /** - * Returns the robot proxy roles. - * - * @return robot proxy roles. - */ - public String getFQAN() { - return FQAN; - } - - public void setFQAN(String fQAN) { - FQAN = fQAN; - } - - /** - * Returns the infrastructure software tag. - * - * @return infrastructure software tag. - */ - public String getSWTag() { - return SWTag; - } - - public void setSWTag(String sWTag) { - SWTag = sWTag; - } - - /** - * Returns the infrastructure middleware name. - * - * @return infrastructure middleware name. - */ - public String getMiddleware() { - return Middleware; - } - - public void setMiddleware(String middleware) { - Middleware = middleware; - } - - /** - * Returns the keystore. - * - * @return keystore. - */ - public String getKeystore() { - return Keystore; - } - - public void setKeystore(String keystore) { - Keystore = keystore; - } - - /** - * Returns the username. - * - * @return username. - */ - public String getUserName() { - return UserName; - } - - public void setUserName(String userName) { - UserName = userName; - } - - /** - * Returns the password. - * - * @return password. - */ - public String getPassword() { - return Password; - } - - public void setPassword(String password) { - Password = password; - } - - /** - * Returns the list possible CEs. - * - * @return list possible CEs. - */ - public String[] getCEList() { - return CEList; - } - - public void setCEList(String[] cEList) { - CEList = cEList; - } - - /** - * Returns the RFC flag. - * - * @return RFC flag. - */ - public boolean getRFC() { - return RFC; - } - - public void setRFC(boolean rFC) { - RFC = rFC; - } - -} diff --git a/it/infn/ct/GridEngine/Job/JSagaJobSubmission.java b/it/infn/ct/GridEngine/Job/JSagaJobSubmission.java deleted file mode 100644 index 823d260..0000000 --- a/it/infn/ct/GridEngine/Job/JSagaJobSubmission.java +++ /dev/null @@ -1,3029 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) -****************************************************************************/ - - -package it.infn.ct.GridEngine.Job; - -import fr.in2p3.jsaga.impl.job.instance.JobImpl; -import it.infn.ct.GridEngine.InformationSystem.BDII; -import it.infn.ct.GridEngine.JobCollection.JobCollection; -import it.infn.ct.GridEngine.JobResubmission.GEActiveGridInteraction; -import it.infn.ct.GridEngine.JobResubmission.GEJobDescription; -import it.infn.ct.GridEngine.JobService.JobCheckStatusService; -import it.infn.ct.GridEngine.SendMail.MailUtility; -import it.infn.ct.GridEngine.UsersTracking.ActiveInteractions; -import it.infn.ct.GridEngine.UsersTracking.UsersTrackingDBInterface; - -import java.io.File; -import java.net.URI; -import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.concurrent.Semaphore; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import org.apache.log4j.Logger; -import org.apache.log4j.xml.DOMConfigurator; -import org.ogf.saga.context.Context; -import org.ogf.saga.context.ContextFactory; -import org.ogf.saga.error.IncorrectStateException; -import org.ogf.saga.error.NotImplementedException; -import org.ogf.saga.file.FileFactory; -import org.ogf.saga.job.Job; -import org.ogf.saga.job.JobDescription; -import org.ogf.saga.job.JobFactory; -import org.ogf.saga.job.JobService; -import org.ogf.saga.namespace.Flags; -import org.ogf.saga.session.Session; -import org.ogf.saga.session.SessionFactory; -import org.ogf.saga.task.State; -import org.ogf.saga.url.URL; -import org.ogf.saga.url.URLFactory; -//to be deleted only 4 genesis -//import org.ogf.saga.session.SessionFactory; -//import fr.in2p3.jsaga.impl.context.ContextImpl; - -//import org.apache.commons.logging.Log; -//import org.apache.commons.logging.LogFactory; - -/** - * This class is responsible for submission of a job to an e-Infrastructure - * @author mario - * - */ -public class JSagaJobSubmission { - /** - * List of possibles Adaptor - */ - public enum Adaptor { - /** - * WMS adaptor - */ - wms, - /** - * WSGRAM adaptor - */ - wsgram, - /** - * GATEKEEPER adaptor - */ - gatekeeper, - /** - * SSH adaptor - */ - ssh, - /** - * OURGRID adaptor - */ - ourgrid, - /** - * UNICORE adaptor - */ - unicore, - /** - * GOS adaptor - */ - gos, - /** - * GENESIS Adaptor - */ - besGenesis2, - /** - * ROCCI Adaptor - */ - rocci - } - - - private JobServiceManager jobServiceManager = null; - private BDII bdii = null; - private String WMSList[] = null; - private String resourceManagerlist[] = null; - - //*********MARIO************ - private String CEList[] = null; - private String userEmail = ""; - private static final Logger logger = Logger.getLogger(JSagaJobSubmission.class); -// private static final Logger logger = Logger.getRootLogger(); - private GEJobDescription description; - //************************** - -// private String executable = ""; -// private String arguments = ""; -// private String jobQueue = ""; -// private String outputPath = ""; - private String outputPathPrefix = ""; -// private String jobOutput = ""; -// private String jobError = ""; - private String jobSandbox = ""; -// private String inputFiles[] = null; - private String outputFiles[] = null; - private String jobPortletId = ""; - -// private String SPMDVariation = ""; -// private String NumberOfProcesses = ""; -// private String totalCPUCount = ""; -// private String JDLRequirements[] = null; - - private UsersTrackingDBInterface DBInterface; - - private ThreadPoolExecutor threadPool; - - private String URL = ""; - private String userName = ""; - private String password = ""; - - private int shallowRetry = 5; - private int allowResub = -1; - - private boolean checkJobsStatus = true; - //private static Log _log = LogFactory.getLog(JSagaJobSubmission.class); - //private static Logger _log = Logger.getLogger(JSagaJobSubmission.class); - private boolean randomCE = false; - - private String jksPath = ""; - private String jksPassword = ""; - - private String ourgridUserName = ""; - private String ourgridPassword = ""; - - private String genesisJksPath = ""; - private String genesisJksPassword = ""; - - private String SSHUserName = ""; - private String SSHPassword = ""; - - private boolean resubmitting = false; - private Semaphore waitForResubmission = new Semaphore(0); - - /** - * Constructs a {@link JSagaJobSubmission} object specifying - * connection parameters to users tracking database. - * - * @param db database name - * @param dbUser database username - * @param dbUserPwd database password. - */ - public JSagaJobSubmission(String db, String dbUser, String dbUserPwd) { - //System.setProperty("JSAGA_HOME", "/opt/jsaga-0.9.15-SNAPSHOT/"); -// System.setProperty("JSAGA_HOME", "/home/mario/JSAGA/"); - System.setProperty("saga.factory", "fr.in2p3.jsaga.impl.SagaFactoryImpl"); -// PropertyConfigurator.configure("log4j.properties"); -// DOMConfigurator.configure("GridEngineLogConfig.xml"); - DOMConfigurator.configure((System.getProperty("GridEngineLogConfig.path")!=null ? System.getProperty("GridEngineLogConfig.path") : "GridEngineLogConfig.xml")); - - URL = db; - userName = dbUser; - password = dbUserPwd; - - DBInterface = new UsersTrackingDBInterface(db,dbUser,dbUserPwd); - //DBInterface = new UsersTrackingDBInterface("jdbc:mysql://lrt01.ct.infn.it/userstracking","tracking_user","usertracking"); - - jobServiceManager = new JobServiceManager(); - - try { - threadPool = InitialContext.doLookup("GridEngine-Pool"); - } - catch ( NamingException ex ) { - //System.out.println("Cannot get thread-pool: " + ex); - logger.error("Cannot get thread-pool: " + ex); - } - catch(Exception ex){ - //System.out.println("Cannot get thread-pool: " + ex); - logger.error("Cannot get thread-pool: " + ex); - } - - //DELME - String test1 = System.getProperty("JSAGA_HOME"); - String test3 = System.getProperty("saga.factory", "fr.in2p3.jsaga.impl.SagaFactoryImpl"); - if(logger.isDebugEnabled()){ - logger.debug("JSAGA_HOME:"+test1); - logger.debug("saga.factory:"+test3); -// System.out.println("JSAGA_HOME:"+test1); -// System.out.println("saga.factory:"+test3); - } - description = new GEJobDescription(); - } - - /** - * Constructs a {@link JSagaJobSubmission} object without specify - * connection parameters to users tracking database. - * - */ - public JSagaJobSubmission() { - //System.setProperty("JSAGA_HOME", "/opt/jsaga-0.9.15-SNAPSHOT/"); -// System.setProperty("JSAGA_HOME", "/home/mario/JSAGA/"); - System.setProperty("saga.factory", "fr.in2p3.jsaga.impl.SagaFactoryImpl"); - //PropertyConfigurator.configure("log4j.properties"); -// DOMConfigurator.configure("GridEngineLogConfig.xml"); - DOMConfigurator.configure((System.getProperty("GridEngineLogConfig.path")!=null ? System.getProperty("GridEngineLogConfig.path") : "GridEngineLogConfig.xml")); - DBInterface = new UsersTrackingDBInterface(); - - jobServiceManager = new JobServiceManager(); - - try { - threadPool = InitialContext.doLookup("GridEngine-Pool"); - } - catch ( NamingException ex ) { - logger.error("Cannot get thread-pool: " + ex); -// System.out.println("Cannot get thread-pool: " + ex); - } - catch(Exception ex){ - logger.error("Cannot get thread-pool: " + ex); -// System.out.println("Cannot get thread-pool: " + ex); - } - - //DELME - String test1 = System.getProperty("JSAGA_HOME"); - String test3 = System.getProperty("saga.factory", "fr.in2p3.jsaga.impl.SagaFactoryImpl"); - if(logger.isDebugEnabled()){ - logger.debug("JSAGA_HOME:"+test1); - logger.debug("saga.factory:"+test3); -// System.out.println("JSAGA_HOME:"+test1); -// System.out.println("saga.factory:"+test3); - } - description = new GEJobDescription(); - } - - /** - * Constructs a {@link JSagaJobSubmission} specifying a connection - * interface to users tracking database. - * - * @param dbInt users tracking database connection interface. - */ - public JSagaJobSubmission(UsersTrackingDBInterface dbInt) { - - logger.info("NEW CONSTRUCTOR"); - DBInterface = dbInt; - - jobServiceManager = new JobServiceManager(); - - try { - threadPool = InitialContext.doLookup("GridEngine-Pool"); - } - catch ( NamingException ex ) { - logger.error("Cannot get thread-pool: " + ex); - } - catch(Exception ex){ - logger.error("Cannot get thread-pool: " + ex); - } - - //DELME - String test1 = System.getProperty("JSAGA_HOME"); - String test3 = System.getProperty("saga.factory", "fr.in2p3.jsaga.impl.SagaFactoryImpl"); - if(logger.isDebugEnabled()){ - logger.debug("JSAGA_HOME:"+test1); - logger.debug("saga.factory:"+test3); - - } - } - - /** - * Constructs a {@link JSagaJobSubmission} object specifying - * connection parameters to users tracking database and and the description - * of submitting job. - * - * @param db database name - * @param dbUser database username - * @param dbUserPwd database password - * @param description a {@link GEJobDescription} object contains description - * of the submitting job. - */ - public JSagaJobSubmission(String db, String dbUser, String dbUserPwd, GEJobDescription description) { - - this(db, dbUser, dbUserPwd); - this.description = description; - this.description.saveJobDescription(); - - } - - /** - * Constructs a {@link JSagaJobSubmission} object specifying the description - * for the submitting job. - * - * @param description a {@link GEJobDescription} object contains description - * of the submitting job. - */ - public JSagaJobSubmission(GEJobDescription description) { - - this(); - this.description = description; - this.description.saveJobDescription(); - - } - - /** - * Constructs a {@link JSagaJobSubmission} specifying a connection - * interface to users tracking database and the grid job identifier to retrieve - * its description. - * - * @param dbInt users tracking database connection interface - * @param jobId grid job identifier. - */ - public JSagaJobSubmission(UsersTrackingDBInterface dbInt, String jobId) { - - DBInterface = dbInt; - description = new GEJobDescription(); - description = GEJobDescription.findJobDescriptionByJobId(jobId); - jobServiceManager = new JobServiceManager(); - - try { - threadPool = InitialContext.doLookup("GridEngine-Pool"); - } - catch ( NamingException ex ) { - logger.error("Cannot get thread-pool: " + ex); - - } - catch(Exception ex){ - logger.error("Cannot get thread-pool: " + ex); - - } - - //DELME - String test1 = System.getProperty("JSAGA_HOME"); - String test3 = System.getProperty("saga.factory", "fr.in2p3.jsaga.impl.SagaFactoryImpl"); - if(logger.isDebugEnabled()){ - logger.debug("JSAGA_HOME:"+test1); - logger.debug("saga.factory:"+test3); - - } - } - - /** - * Sets java keystore file path and password. - * - * @param jkspath keystore file path - * @param jkspassword keystore password. - */ - public void setJKS(String jkspath, String jkspassword) { - jksPath = jkspath; - jksPassword = jkspassword; - } - - public void setGenesisJKS(String jkspath, String jkspassword) { - genesisJksPath = jkspath; - genesisJksPassword = jkspassword; - } - - /** - * Sets OurGrid user credentials. - * - * @param username OurGrid username - * @param password OurGrid password. - */ - public void setOurGridCredential(String username, String password) { - ourgridUserName = username; - ourgridPassword = password; - } - - /** - * Sets SSH credentials. - * - * @param username SSH username - * @param password SSH password. - */ - public void setSSHCredential(String username, String password) { - SSHUserName = username; - SSHPassword = password; - } - - /** - * Sets the maximum attempts submission numbers. - * - * @param value the maximum attempts submission numbers. - */ - public void setShallowRetry(int value) { - shallowRetry = value; - } - - /** - * Returns the maximum attempts submission numbers. - * - * @return the maximum attempts submission numbers. - */ - public int getShallowRetry() { - return shallowRetry; - } - - /** - * If true starts after job submission starts a thread that checks - * job status. By default it is true. - * - * @param value if true starts a check job status thread, else not - * starts thread. - */ - public void setCheckJobsStatus(boolean value) { - checkJobsStatus = value; - } - - /** - * Returns true if a check job status thread was started - * after job submission, false otherwise. - * - * @return true if a check job status thread was started after job submission, false otherwise. - */ - public boolean getCheckJobsStatus() { - return checkJobsStatus; - } - - /** - * Sets if a random CE will be chosen from given CEs list or from a - * bdii service. - * - * @param value true if a random CE will be chosen, false otherwise. - * By default it is false. - */ - public void setRandomCE(boolean value) { - randomCE = value; - } - - /** - * Returns true if a random CE will be chosen from given CEs list or from a - * bdii service, false otherwise. - * - * @return true if a random CE will be chosen from given CEs list or from a - * bdii service, false otherwise - */ - public boolean getRandomCE() { - return randomCE; - } - - /** - * Sets the BDII URI service. - * - * @param value URI service. - */ - public void setBDII(String value) { - try { - bdii = new BDII(new URI(value)); - } - catch (Exception exc) { - logger.error(exc.toString()); -// System.out.println(exc.toString()); - } - } - - /** - * Returns a string representing BDII URI. - * - * @return a string representing BDII URI. - */ - public String getBDII() { - return bdii.getLocation().toString(); - } - - /** - * Sets WMS addresses list. - * - * @param list a String[] consisting of WMS address. - */ - public void setWMSList(String list[]) { - WMSList = list; - if(logger.isDebugEnabled()) - for (int i=0;i" + inputFiles[i].substring(inputFiles[i].lastIndexOf('/')+1) + ","; -// } -// } - - if ((description.getInputFiles()!=null) && (!description.getInputFiles().equals(""))) { - String[] inputFiles = description.getInputFiles().split(","); - for (int i=0;i" + inputFiles[i].substring(inputFiles[i].lastIndexOf('/')+1) + ","; - } - } -// if (!jobOutput.equals("")) -// jobSandbox = jobSandbox + outputPath + jobPortletId + "/<" + jobOutput + ","; -// //jobSandbox = jobSandbox + outputPath + jobPortletId + "/"+ jobOutput + "<" + jobOutput + ","; - - if ((description.getOutput()!=null) && (!description.getOutput().equals(""))) - jobSandbox = jobSandbox + description.getOutputPath() + jobPortletId + "/<" + description.getOutput() + ","; - -// if (!jobError.equals("")) -// jobSandbox = jobSandbox + outputPath + jobPortletId + "/<" + jobError + ","; -// //jobSandbox = jobSandbox + outputPath + jobPortletId + "/"+ jobError + "<" + jobError + ","; - - if ((description.getError()!=null) && (!description.getError().equals(""))) - jobSandbox = jobSandbox + description.getOutputPath() + jobPortletId + "/<" + description.getError() + ","; - -// if (outputFiles!=null) { -// for (int i=0;i0) - jobSandbox = jobSandbox.substring(0,jobSandbox.length()-1); - - logger.info("jobSandbox:"+jobSandbox); -// System.out.println("jobSandbox:"+jobSandbox); - return jobSandbox; - } - - public JobId submitJob(String commonName, String tcpAddress, int GridInteractionId, String userDescription) { - return submitJob(commonName, tcpAddress, GridInteractionId, "", userDescription); - } - - /** - * This method allows to submit a job of a collection in an asynchronous way. It starts a - * separated thread responsible for the submission of this job. - * - * @param commonName a String representing user name - * @param tcpAddress user's IP address - * @param GridInteractionId an identifier of application in a specified portal - * @param userDescription a description for this job - * @param jobCollectionId job collection identifier. - */ - //TO SUBMIT COLLECTIONS - public void submitJobAsync(String commonName, String tcpAddress, int GridInteractionId, String userDescription, int jobCollectionId) { - submitJobAsync(commonName, tcpAddress, GridInteractionId, "", userDescription, jobCollectionId ); - } - - /** - * This method allows to submit a job in an asynchronous way to a specified resource manager. - * It starts a separated thread responsible for the submission of this job. - * - * @param commonName a String representing user name - * @param tcpAddress user's IP address - * @param GridInteractionId an identifier of application in a specified portal - * @param resourceManager to which are submitting this job - * @param userDescription a description for this job. - */ - //TO SUBMIT Simple Jobs - public void submitJobAsync(String commonName, String tcpAddress, int GridInteractionId, String resourceManager, String userDescription) { - submitJobAsync(commonName, tcpAddress, GridInteractionId, resourceManager, userDescription, null ); - } - - /** - * This method allows to submit a job in an asynchronous way. - * It starts a separated thread responsible for the submission of this job. - * - * @param commonName a String representing user name - * @param tcpAddress user's IP address - * @param GridInteractionId an identifier of application in a specified portal - * @param userDescription a description for this job. - */ - //TO SUBMIT A JOB WITHOUT SPECIFYING A DETERMINATE RESOURCE MANAGER - public void submitJobAsync(String commonName, String tcpAddress, int GridInteractionId, String userDescription) { - submitJobAsync(commonName, tcpAddress, GridInteractionId, "", userDescription, null ); - } - - private JobId submitJob(String commonName, String tcpAddress, int GridInteractionId, String resourceManager, String userDescription) { - try { - - URL serviceURL; - boolean getRandomWMS = false; - - if (resourceManager.equals("")) { - getRandomWMS = true; - if ( (WMSList==null) && (bdii==null)) { - System.out.println("Error: you have to specify a WMS list or a BDII"); - return null; //TODO manage error - } - } - - if (getRandomWMS) { - String selectedResourceManager = ""; - if (WMSList!=null) - selectedResourceManager = getRandomWMS(); - else - selectedResourceManager = bdii.getRandomWMS(jobServiceManager.getUserVO()); - System.out.println("Resource Manager selected: " + selectedResourceManager); - serviceURL = URLFactory.createURL(selectedResourceManager); - } - else - serviceURL = URLFactory.createURL(resourceManager); - - System.out.println("resourceManager:"+resourceManager); - - Job job = null; - JobDescription desc = JobFactory.createJobDescription(); - - if (getExecutable().equals("")) { - return null; //TODO manage error - } - - int count = 0; - - System.out.println("getting jobService..."); - JobService service = jobServiceManager.getJobService(serviceURL); - while ((service==null) && (count < shallowRetry)) { - count++; - //sleep 1 sec between each re-submission - try { - Thread.sleep(1000); - } - catch (Exception e) {} - if (getRandomWMS) { - String selectedResourceManager = ""; - if (WMSList!=null) - selectedResourceManager = getRandomWMS(); - else - selectedResourceManager = bdii.getRandomWMS(jobServiceManager.getUserVO()); - System.out.println("Resource Manager selected: " + selectedResourceManager); - - serviceURL = URLFactory.createURL(selectedResourceManager); - } - service = jobServiceManager.getJobService(serviceURL); - } - - if (service==null) - return null; - - //creating db entry... - //int dbId = DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), jobServiceManager.getProxyId(), jobServiceManager.getUserVO(), jobServiceManager.getUserFQAN(), userDescription); - int dbId = 0; - if (jobServiceManager.getUserProxy().equals("")) - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), jobServiceManager.getProxyId(), jobServiceManager.getUserVO(), jobServiceManager.getUserFQAN(), userDescription, null); - else - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), jobServiceManager.getUserProxy(), jobServiceManager.getUserVO(), jobServiceManager.getUserFQAN(), userDescription, null); - - setJobPortletId(removeNotAllowedCharacter(userDescription) + "_" + (new Integer(dbId).toString())); - //setJobPortletId(userDescription.replaceAll(" ", "") + "_" + (new Integer(dbId).toString())); - - desc.setAttribute(JobDescription.EXECUTABLE, getExecutable()); - - - if ((getArguments()!=null) && (!getArguments().equals(""))) - desc.setVectorAttribute(JobDescription.ARGUMENTS, getArguments().split(",")); - - if ((getJobOutput()!=null) && (!getJobOutput().equals(""))) - desc.setAttribute(JobDescription.OUTPUT, getJobOutput()); - - if ((getJobError()!=null) && (!getJobError().equals(""))) - desc.setAttribute(JobDescription.ERROR, getJobError()); - - if ((getJobQueue()!=null) && (!getJobQueue().equals(""))) - desc.setAttribute(JobDescription.QUEUE, getJobQueue()); - else if (randomCE) { - if (bdii!=null) { - String randomQueue = bdii.getRandomCE(jobServiceManager.getUserVO()); - System.out.println("CE selected:"+randomQueue); - desc.setAttribute(JobDescription.QUEUE, randomQueue); - } - } - - desc.setVectorAttribute(JobDescription.FILETRANSFER, createJobSandbox().split(",")); - - //MPI - if ((getTotalCPUCount()!=null) && (!getTotalCPUCount().equals(""))) - desc.setAttribute(JobDescription.TOTALCPUCOUNT,getTotalCPUCount()); - -//FUTURE USE -// if (!(SPMDVariation.equals(""))) -// desc.setAttribute(JobDescription.SPMDVARIATION,SPMDVariation); -// -// if (!(NumberOfProcesses.equals(""))) -// desc.setAttribute(JobDescription.NUMBEROFPROCESSES, NumberOfProcesses); - - //Requirements - if (getJDLRequirements()!=null) - desc.setVectorAttribute("Extension", getJDLRequirements()); - - System.out.println("JobDescription Created..."); - - job = service.createJob(desc); - - // create the job - boolean jobSubmitted = false; - while ( (!jobSubmitted) && (count < shallowRetry)) { - try { - // submit - System.out.println("Job submitting..."); - - job.run(); - - jobSubmitted = true; - } - catch(Exception exc) { - System.out.println(exc.toString()); - count ++; - //sleep 1 sec between each re-submission - try { - Thread.sleep(1000); - } - catch (Exception e) {} - - if (randomCE) { - if (bdii!=null) { - String randomQueue = bdii.getRandomCE(jobServiceManager.getUserVO()); - System.out.println("CE selected:"+randomQueue); - desc.setAttribute(JobDescription.QUEUE, randomQueue); - job = service.createJob(desc); - } - } - - if (getRandomWMS) { - String selectedResourceManager = ""; - if (WMSList!=null) - selectedResourceManager = getRandomWMS(); - else - selectedResourceManager = bdii.getRandomWMS(jobServiceManager.getUserVO()); - System.out.println("Resource Manager selected: " + selectedResourceManager); - - URL newServiceURL = URLFactory.createURL(selectedResourceManager); - if (newServiceURL != serviceURL) { - serviceURL = newServiceURL; - jobServiceManager.closeSession(); - service = jobServiceManager.getJobService(serviceURL); - job = service.createJob(desc); - } - } - - } - } - - if (!jobSubmitted) { - //TODO deleting line from DB - jobServiceManager.closeSession(); - return null; - } - - String jobId = job.getAttribute(Job.JOBID); - System.out.println(jobId); - - int err = DBInterface.updateGridInteraction(jobId, dbId); - - if (err!=0) System.out.println("Error in update grid interaction"); - - jobServiceManager.closeSession(); - - return new JobId(jobId, dbId); - } - catch (Exception e) { - jobServiceManager.closeSession(); - System.out.println(e.toString()); - } - - return null; - - } - -// public void submitJobAsync(final String commonName, final String tcpAddress, final int GridInteractionId, final String resourceManager, final String userDescription, final Integer jobCollectionId, final Long descriptionToUpdate) { - private void submitJobAsync(final String commonName, final String tcpAddress, final int GridInteractionId, final String resourceManager, final String userDescription, final Integer jobCollectionId) { - Thread t; - t = new Thread("submitJob") { - public void run() { - try { - - logger.info("Submitting job in Thread : " + Thread.currentThread()); -// System.out.println("Submitting job in Thread : " + Thread.currentThread()); - - URL serviceURL; - boolean getRandomWMS = false; - String adaptor = ""; - logger.info("random resource manager error check"); -// System.out.println("random resource manager error check"); - if (resourceManager.equals("")) { - getRandomWMS = true; - if ( (WMSList==null) && (bdii==null)) { - logger.warn("You have to specify a WMS list or a BDII"); - //System.out.println("Error: you have to specify a WMS list or a BDII"); - if (resubmitting) waitForResubmission.release(); - return; //TODO manage error - } - } - - if (getRandomWMS) { - logger.info("Getting random resource manager..."); -// System.out.println("getting random resource manager..."); - String selectedResourceManager = ""; - if (WMSList!=null) - selectedResourceManager = getRandomWMS(); - else - selectedResourceManager = bdii.getRandomWMS(jobServiceManager.getUserVO()); - logger.info("Resource Manager selected: " + selectedResourceManager); -// System.out.println("Resource Manager selected: " + selectedResourceManager); - - serviceURL = URLFactory.createURL(selectedResourceManager); - } - else { - logger.info("creating serviceurl..."); -// System.out.println("creating serviceurl..."); - serviceURL = URLFactory.createURL(resourceManager); - } -// logger.debug("Service URL: "+serviceURL); - logger.info("Getting adaptor name..."); -// System.out.println("getting adaptor name..."); - - //System.out.println("resourceManager:"+resourceManager); - adaptor = serviceURL.toString().substring(0, serviceURL.toString().indexOf(":")); - logger.info("Using adaptor: " + adaptor); -// System.out.println("Using adaptor:"+adaptor); - - Job job = null; - JobDescription desc = JobFactory.createJobDescription(); -// GEJobDescription jobDesc=null; -// if(descriptionToUpdate==null){ -// jobDesc = new GEJobDescription(); -// } else { -// jobDesc = GEJobDescription.findJobDescriptionById(descriptionToUpdate); -// } - -// if (executable.equals("")) { -// return; //TODO manage error -// } - if(getExecutable().equals("")) { - if (resubmitting) waitForResubmission.release(); - return; - } - - int count = 0; - - logger.info("Getting jobService..."); -// System.out.println("getting jobService..."); - - JobService service = null; - if ( (adaptor.equals("wms")) || (adaptor.equals("wsgram")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("rocci"))) { - service = jobServiceManager.getJobService(serviceURL); - } - else if (adaptor.equals("unicore")) { - service = jobServiceManager.getJobService(jksPath,jksPassword,serviceURL); - } - else if (adaptor.equals("ourgrid")) { - service = jobServiceManager.getOurGridJobService(ourgridUserName,ourgridPassword,serviceURL); - } - else if (adaptor.equals("bes-genesis2")) { - service = jobServiceManager.getGenesisJobService(genesisJksPath,genesisJksPassword,serviceURL); - } - else if (adaptor.equals("gos")) { - service = jobServiceManager.getGOSJobService(serviceURL); - } - else if (adaptor.equals("ssh")) { - service = jobServiceManager.getSSHJobService(SSHUserName,SSHPassword,serviceURL); - } - - while ((service==null) && (count < shallowRetry)) { - count++; - //sleep 1 sec between each re-submission - try { - Thread.sleep(1000); - } - catch (Exception e) {} - if (getRandomWMS) { - String selectedResourceManager = ""; - if (WMSList!=null) - selectedResourceManager = getRandomWMS(); - else - selectedResourceManager = bdii.getRandomWMS(jobServiceManager.getUserVO()); - logger.info("Resource Manager selected: " + selectedResourceManager); -// System.out.println("Resource Manager selected: " + selectedResourceManager); - - adaptor = selectedResourceManager.substring(0, selectedResourceManager.indexOf(":")); - logger.info("Using adaptor: " + adaptor); -// System.out.println("Using adaptor:"+adaptor); - - serviceURL = URLFactory.createURL(selectedResourceManager); - } - - if ( (adaptor.equals("wms")) || (adaptor.equals("wsgram")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("rocci"))) { - service = jobServiceManager.getJobService(serviceURL); - } - else if (adaptor.equals("unicore")) { - service = jobServiceManager.getJobService(jksPath,jksPassword,serviceURL); - } - else if (adaptor.equals("ourgrid")) { - service = jobServiceManager.getOurGridJobService(ourgridUserName,ourgridPassword,serviceURL); - } - else if (adaptor.equals("bes-genesis2")) { - service = jobServiceManager.getGenesisJobService(genesisJksPath,genesisJksPassword,serviceURL); - } - else if (adaptor.equals("gos")) { - service = jobServiceManager.getGOSJobService(serviceURL); - } - else if (adaptor.equals("ssh")) { - service = jobServiceManager.getSSHJobService(SSHUserName,SSHPassword,serviceURL); - } - } - - if (service==null){ - deleteSubmittingDescription(userDescription, 0); - if (resubmitting) waitForResubmission.release(); - return; - } - - - //creating db entry... - int dbId = 0; - - if ( (adaptor.equals("wms")) || (adaptor.equals("wsgram")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("rocci"))) { - if (jobServiceManager.getUserProxy().isEmpty()){ - //dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), jobServiceManager.getProxyId(), jobServiceManager.getUserVO(), jobServiceManager.getUserFQAN(), userDescription); - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), jobServiceManager.getProxyId(), jobServiceManager.getUserVO(), jobServiceManager.getUserFQAN(), userDescription, userEmail, jobServiceManager.etokenServer+":"+jobServiceManager.etokenServerPort, jobCollectionId); - } - else{ - //dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), jobServiceManager.getUserProxy(), jobServiceManager.getUserVO(), jobServiceManager.getUserFQAN(), userDescription); - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), jobServiceManager.getUserProxy(), jobServiceManager.getUserVO(), jobServiceManager.getUserFQAN(), userDescription, userEmail, jobCollectionId); - } -// jobDesc.setProxyRenewal(jobServiceManager.ProxyRenewal); - description.setProxyRenewal(jobServiceManager.ProxyRenewal); - } - else if (adaptor.equals("unicore")) { - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), (jobServiceManager.getJKSPath()+":"+jobServiceManager.getJKSPassword()), "", "", userDescription, userEmail, jobCollectionId); - } - else if (adaptor.equals("ourgrid")) { - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", "", (jobServiceManager.getOurGridUserName()+":"+jobServiceManager.getOurGridPassword()), "", "", userDescription, userEmail, jobCollectionId); - } - else if (adaptor.equals("bes-genesis2")) { - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", jobServiceManager.getUserDN(), (jobServiceManager.getGenesisJKSPath()+":"+jobServiceManager.getGenesisJKSPassword()), "", "", userDescription, userEmail, jobCollectionId); - } - else if (adaptor.equals("gos")) { - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", "gos", "", "", "", userDescription, userEmail, jobCollectionId); - } - else if (adaptor.equals("ssh")) { - dbId= DBInterface.InsertActiveGridInteraction(commonName, tcpAddress, GridInteractionId, "", "", (jobServiceManager.getSSHUserName()+":"+jobServiceManager.getSSHPassword()), "", "", userDescription, userEmail, jobCollectionId); - } - - - setJobPortletId(removeNotAllowedCharacter(userDescription) + "_" + (new Integer(dbId).toString())); - //setJobPortletId(userDescription.replaceAll(" ", "") + "_" + (new Integer(dbId).toString())); - - desc.setAttribute(JobDescription.EXECUTABLE, getExecutable()); -// jobDesc.setExecutable(executable); - - if ((getArguments()!=null) && (!getArguments().equals(""))){ - desc.setVectorAttribute(JobDescription.ARGUMENTS, getArguments().split(",")); -// jobDesc.setArguments(getArguments()); - } - - if ((getJobOutput()!=null) && (!getJobOutput().equals(""))){ - desc.setAttribute(JobDescription.OUTPUT, getJobOutput()); -// jobDesc.setOutput(jobOutput); - } - - if ((getJobError()!=null) && (!getJobError().equals(""))){ - desc.setAttribute(JobDescription.ERROR, getJobError()); -// jobDesc.setError(jobError); - } - - if ((getJobQueue()!=null) && (!getJobQueue().equals(""))){ - desc.setAttribute(JobDescription.QUEUE, getJobQueue()); -// jobDesc.setQueue(jobQueue); - } - else if ((randomCE) && (adaptor.equals("wms"))) { - if (bdii!=null) { - String randomQueue = bdii.getRandomCE(jobServiceManager.getUserVO()); - logger.info("CE selected:"+randomQueue); -// System.out.println("CE selected:"+randomQueue); - desc.setAttribute(JobDescription.QUEUE, randomQueue); - } - //************MARIO*************************** - else{ - String randomQueue=getRandomCEFromCElist(); - logger.info("CE selected:"+randomQueue); - desc.setAttribute(JobDescription.QUEUE, randomQueue); - } - //******************************************** -// jobDesc.setQueue(desc.getAttribute(JobDescription.QUEUE)); - setJobQueue(desc.getAttribute(JobDescription.QUEUE)); - } - - if (!adaptor.equals("bes-genesis2")) { - desc.setVectorAttribute(JobDescription.FILETRANSFER, createJobSandbox().split(",")); -// jobDesc.setFileTransfer(createJobSandbox()); - } - else { - desc.setVectorAttribute(JobDescription.FILETRANSFER, ("scp://vm20.ct.infn.it:4422/home/chaindemo/stdoutdoLookup("JobCheckStatusService"); - logger.info("Got JobCheckStatusService..."); -// System.out.println("Got JobCheckStatusService..."); - } - catch ( NamingException ex ) { - logger.error("Cannot get JobCheckStatusService: " + ex); -// System.out.println("Cannot get JobCheckStatusService: " + ex); - } - catch(Exception ex){ - logger.error("Cannot get JobCheckStatusService: " + ex); -// System.out.println("Cannot get JobCheckStatusService: " + ex); - } - - if (jobCheckStatusService==null) { - logger.info("Get local JobCheckStatusService"); -// System.out.println("get local JobCheckStatusService"); -// jobCheckStatusService = JobCheckStatusService.getInstance(URL, userName, password); - if(!DBInterface.inAppServer){ - logger.info("Creating JobCheckStatusService with local connection parameters."); - jobCheckStatusService = JobCheckStatusService.getInstance(URL, userName, password); - } - else { - logger.info("Creating JobCheckStatusService with datasource paramters."); - jobCheckStatusService = JobCheckStatusService.getInstance(); - } - } - - jobCheckStatusService.startJobCheckStatusThread(commonName, outputPathPrefix); - } - - if (resubmitting) waitForResubmission.release(); - - } - catch (Exception e) { - System.out.println("Exception serviceURL="+e.getMessage()); - e.printStackTrace(); - - jobServiceManager.closeSession(); - logger.error(e.toString()); -// System.out.println(e.toString()); - if (resubmitting) waitForResubmission.release(); - } - - } - - }; - if (threadPool != null) threadPool.execute(t); - else t.start(); - } - -// public String getJobStatus(JobId jobId) { -// return (getJobStatus(jobId,false))[0]; -// } - /** - * This method returns a String array consists of two elements in the following order: - *
    - *
  • return[0] current status for this job;
  • - *
  • return[1] compute element (CE) where job are running.
  • - *
- * - * @param jobId the grid job identifier for which want retrieve status - * @param getCE true if you want also retrieve the compute element, false othewise. - * @return a strings array consists of: status for this job and compute element in the above specified order. - */ - public String[] getJobStatus(JobId jobId, boolean getCE) { - - String[] output = new String[2]; - for (int i=0;i<2;i++) - output[i] = ""; - - String nativeJobId = getNativeJobId(jobId.getGridJobId()); - URL serviceURL = getServiceURL(jobId.getGridJobId()); - if ((nativeJobId==null) || (serviceURL==null)) return output; //TODO manage error - - String adaptor = (serviceURL.toString()).substring(0, (serviceURL.toString()).indexOf(":")); - logger.info("Using adaptor:"+adaptor); -// System.out.println("Using adaptor:"+adaptor); - - if ( (adaptor.equals("wms")) || (adaptor.equals("wsgram")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("gos")) || (adaptor.equals("rocci"))) { - } - else if (adaptor.equals("unicore")) { - if ( (jksPath.equals("")) || (jksPassword.equals("")) ) { - logger.error("Error in getJobStatus - No JKS defined."); -// System.out.println("Error in getJobStatus - No JKS defined."); - return output; - } - } - else if (adaptor.equals("ourgrid")) { - if ( (ourgridUserName.equals("")) || (ourgridPassword.equals("")) ) { - logger.error("Error in getJobStatus - No ourgrid credentials defined."); -// System.out.println("Error in getJobStatus - No ourgrid credentials defined."); - return output; - } - } - else if (adaptor.equals("bes-genesis2")) { - if ( (genesisJksPath.equals("")) || (genesisJksPassword.equals("")) ) { - logger.error("Error in getJobStatus - No Genesis JKS defined."); -// System.out.println("Error in getJobStatus - No Genesis JKS defined."); - return output; - } - } - else if (adaptor.equals("ssh")) { -// if ( (SSHUserName.equals("")) || (SSHPassword.equals("")) ) { - if ( (SSHUserName.equals(""))){ - logger.error("Error in getJobStatus - No SSH credentials defined."); - return output; - } - } - else { - logger.error("Error in getJobStatus - Adaptor not supported."); -// System.out.println("Error in getJobStatus - Adaptor not supported."); - return output; - } - - try { - logger.info("Getting JobService..."); -// System.out.println("Getting JobService..."); - - JobService service = null; - if ( (adaptor.equals("wms")) || (adaptor.equals("wsgram")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("rocci"))) { - service = jobServiceManager.getJobService(serviceURL); - } - else if (adaptor.equals("unicore")) { - service = jobServiceManager.getJobService(jksPath,jksPassword,serviceURL); - } - else if (adaptor.equals("ourgrid")) { - service = jobServiceManager.getOurGridJobService(ourgridUserName,ourgridPassword,serviceURL); - } - else if (adaptor.equals("bes-genesis2")) { - service = jobServiceManager.getGenesisJobService(genesisJksPath,genesisJksPassword,serviceURL); - System.setProperty("javax.net.ssl.keyStore","/tmp/genesis-robot-keys.jks"); - System.getProperty("javax.net.ssl.keyStorePassword","chaindemo"); - } - else if (adaptor.equals("gos")) { - service = jobServiceManager.getGOSJobService(serviceURL); - } - else if (adaptor.equals("ssh")) { - service = jobServiceManager.getSSHJobService(SSHUserName,SSHPassword,serviceURL); - } - - logger.info("Getting Job..."); -// System.out.println("Getting Job..."); - Job job = service.getJob(nativeJobId); -// System.out.println("Getting Job Description..."); -// JobDescription descr = null; -// try { -// descr = job.getJobDescription(); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// if (descr!=null) { -// System.out.println("EXECUTABLE="+descr.getAttribute(JobDescription.EXECUTABLE)); -// System.out.println("INPUT="+descr.getAttribute(JobDescription.INPUT)); -// System.out.println("OUTPUT="+descr.getAttribute(JobDescription.OUTPUT)); -// System.out.println("ARGUMENTS="+descr.getAttribute(JobDescription.ARGUMENTS)); -// System.out.println("QUEUE="+descr.getAttribute(JobDescription.QUEUE)); -// } - logger.info("Getting Job State..."); -// System.out.println("Getting Job State..."); - //State state = job.getState(); - State state; - - if ( (adaptor.equals("ssh")) || (adaptor.equals("rocci"))) { - synchronized (JSagaJobSubmission.class) {state = job.getState();} - } - else - state = job.getState(); - - if (getCE) { - // - // GET CE - // - logger.info("Getting CE..."); -// System.out.println("Getting CE..."); - - if ( (adaptor.equals("wms")) || (adaptor.equals("ourgrid")) || (adaptor.equals("ssh")) || (adaptor.equals("rocci"))) { - String executionHosts[]; - try { - executionHosts = job.getVectorAttribute(Job.EXECUTIONHOSTS); - if (!executionHosts[0].equals("")) { - if (adaptor.equals("wms")) { - logger.info("PRE CE ="+executionHosts[0]); -// System.out.println("PRE CE ="+executionHosts[0]); - //executionHosts[0] = executionHosts[0].substring(executionHosts[0].indexOf("/")+2); - executionHosts[0] = executionHosts[0].substring(0, executionHosts[0].indexOf(":")); - } - logger.info("CE ="+executionHosts[0]); -// System.out.println("CE ="+executionHosts[0]); - output[1] = executionHosts[0]; - -// String ceForBDII = "ldap://" + executionHosts[0] + ":2170"; -// System.out.println("CE for BDII="+ceForBDII); -// setBDII(executionHosts[0]); -// String CECoordinate[] = bdii.queryCECoordinate(ceForBDII); -// -// if (CECoordinate!=null) { -// output[2] = CECoordinate[0]; -// output[3] = CECoordinate[1]; -// } -// else { -// output[2] = "0"; -// output[3] = "0"; -// } - - } - } catch (IncorrectStateException e) { - executionHosts = new String[]{"[not initialized yet]"}; - } catch (NotImplementedException e) { - executionHosts = new String[]{"[not supported for this backend]"}; - } catch (Exception e) { - e.printStackTrace(); - } - } - else if ( (adaptor.equals("unicore")) || adaptor.equals("wsgram") || (adaptor.equals("gatekeeper")) || adaptor.equals("bes-genesis2")) { - // unicore://zam052v01.zam.kfa-juelich.de:8080 - // wsgram://xn03.ctsf.cdacb.in:8443/GW - // bes-genesis2://xcg-server1.uvacse.virginia.edu:20443/axis/services/GeniiBESPortType?genii-container-id=93B641B7-9422-EA4C-A90B-CA6A9D98E344 - output[1] = (serviceURL.toString()).substring((serviceURL.toString()).indexOf("/")+2); - output[1] = output[1].substring(0,output[1].indexOf(":")); - } - else if (adaptor.equals("gos")) { - // gos://124.205.18.242 - output[1] = (serviceURL.toString()).substring((serviceURL.toString()).indexOf("/")+2); - } -// else if (adaptor.equals("wsgram")) { -// //TODO temporary we have only a unique wsgram ce -// output[1] = "xn03.ctsf.cdacb.in"; -// } -// System.out.println("executionHosts.length="+executionHosts.length); -// for (int i=0;i= 0){ -// Prova.deleteActiveGridInteraction(jobId.getGridJobId()); -// GEActiveGridInteraction jobAborted = new GEActiveGridInteraction(); -// jobAborted = GEActiveGridInteraction.findActiveGridInteractionByJobId(jobId.getGridJobId()); - jobAborted = GEActiveGridInteraction.findActiveGridInteractionByJobId(Long.valueOf(jobId.getDbId())); - jobAborted.delete(); -// resubmitJob(jobAborted, abortedJobDesc); - resubmitJob(jobAborted); - } - else{ - logger.warn("Cannot resubmit job: "+ jobId.getGridJobId() +". Max resubmission count exceeded"); - description.delete(); -// jobAborted = GEActiveGridInteraction.findActiveGridInteractionByJobId(jobId.getGridJobId()); - jobAborted = GEActiveGridInteraction.findActiveGridInteractionByJobId(Long.valueOf(jobId.getDbId())); - if(jobAborted.getIdJobCollection() == null) - DBInterface.CloseGridInteraction(jobId.getDbId()); - } - output[0] = "Aborted"; - return output; - } catch(Exception e) { - logger.warn("Job failed: "+e.toString()); -// System.out.println("Job failed."); - - output[0] = "Aborted"; - return output; - } -// catch(NotImplementedException e) { -// logger.warn("Job failed: "+e.toString()); -//// System.out.println("Job failed."); -// -// output[0] = "Aborted"; -// return output; -// } - } else { - output[0] = "Unexpected state"; - return output; - } - } - - } - catch (Exception e) { - jobServiceManager.closeSession(); - logger.error(e.toString()); -// System.out.println(e.toString()); - } - - output[0] = "Error in getting job state"; - return output; - } - - private void resubmitJob(GEActiveGridInteraction jobAborted) { - //Preparo l'oggetto per la sottomissione - - logger.debug("RESUBMITTING JOB: " +jobAborted.getJobId()); - resubmitting = true; -// setExecutable(abortedJobDesc.getExecutable()); -// setArguments(abortedJobDesc.getArguments()); -// setJobOutput(abortedJobDesc.getOutput()); -// setJobError(abortedJobDesc.getError()); -// if(abortedJobDesc.getOutputPath().contains("/jobOutput/")); -// abortedJobDesc.setOutputPath(abortedJobDesc.getOutputPath().replace("/jobOutput/", "")); -// setOutputPath(abortedJobDesc.getOutputPath()); -// setInputFiles(abortedJobDesc.getInputFiles()); - setUserEmail(jobAborted.getEmail()); - - String tmp = description.getjobId().substring(1, description.getjobId().indexOf(']')); - String resourceManager=tmp.replace("[", ""); - resourceManager=resourceManager.replace("]", ""); - - String adaptor = resourceManager.toString().substring(0, resourceManager.toString().indexOf(":")); - - logger.debug("Switching Adaptor..."); - switch(Adaptor.valueOf(adaptor)){ - case wms: - case wsgram: - case gatekeeper: - case rocci: - logger.debug("Adaptor is WMS or WSGRAM or GATEKEEPER"); - if(!jobAborted.getProxyId().contains("/")){ - logger.debug("Using Robot Proxy..."); - if(!jobAborted.geteTokenServer().equals("")){ - String eTokenServerTmp = jobAborted.geteTokenServer(); - useRobotProxy(eTokenServerTmp.substring(0,eTokenServerTmp.indexOf(':')), eTokenServerTmp.substring(eTokenServerTmp.indexOf(':')+1), jobAborted.getProxyId(), jobAborted.getVO(), jobAborted.getFqan(), description.isProxyRenewal(), true, jobAborted.getCommonName()); - }else{ - useRobotProxy(jobAborted.getProxyId(), jobAborted.getVO(), jobAborted.getFqan(), description.isProxyRenewal(),true, jobAborted.getCommonName()); - } - }else{ - logger.debug("Using User Proxy..."); - setUserProxy(jobAborted.getProxyId()); - } - break; - case ssh: - logger.debug("Adaptor is SSH"); - String sshUserName = jobAborted.getProxyId().substring(0,jobAborted.getProxyId().indexOf(":")); - String sshPassword = jobAborted.getProxyId().substring(jobAborted.getProxyId().indexOf(":")+1); - logger.debug("sshUserName: " + sshUserName + " sshPassword: "+ sshPassword); - setSSHCredential(sshUserName, sshPassword); - break; - case ourgrid: - logger.debug("Adaptor is OURGRID"); - String ourgridUserName = jobAborted.getProxyId().substring(0,jobAborted.getProxyId().indexOf(":")); - String ourgridPassword = jobAborted.getProxyId().substring(jobAborted.getProxyId().indexOf(":")+1); - setOurGridCredential(ourgridUserName, ourgridPassword); - break; - case unicore: - logger.debug("Adaptor is UNICORE"); - String jksPath = jobAborted.getProxyId().substring(0,jobAborted.getProxyId().indexOf(":")); - String jksPassword = jobAborted.getProxyId().substring(jobAborted.getProxyId().indexOf(":")+1); - setJKS(jksPath, jksPassword); - break; - case gos: - logger.debug("Adaptor is GOS"); - break; - case besGenesis2: - logger.debug("Adaptor is BESGENESIS2"); - String genesisJksPath = jobAborted.getProxyId().substring(0,jobAborted.getProxyId().indexOf(":")); - String genesisjksPassword = jobAborted.getProxyId().substring(jobAborted.getProxyId().indexOf(":")+1); - setGenesisJKS(genesisJksPath, genesisjksPassword); - break; - default: - logger.error("Adaptor undefined."); - return; - } - - submitJobAsync(jobAborted.getCommonName(), jobAborted.getTcpAddress(), jobAborted.getGridInteraction(), resourceManager, jobAborted.getUserDescription(), jobAborted.getIdJobCollection()); - - try { - waitForResubmission.acquire(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - logger.error("Exception during waiting for re-submission"); - e.printStackTrace(); - } - - resubmitting = false; - } - - public void submitFinalJob(GEActiveGridInteraction finalJob, GEJobDescription finalJobDesc) { - //Preparo l'oggetto per la sottomissione - - logger.debug("SUBMITTING FINAL JOB FOR COLLECTION: " + finalJob.getIdJobCollection()); - - description = finalJobDesc; -// setExecutable(finalJobDesc.getExecutable()); -// setArguments(finalJobDesc.getArguments()); -// setJobOutput(finalJobDesc.getOutput()); -// setJobError(finalJobDesc.getError()); -// if(finalJobDesc.getOutputPath().contains("/jobOutput/")); -// finalJobDesc.setOutputPath(finalJobDesc.getOutputPath().replace("/jobOutput/", "")); -// setOutputPath(finalJobDesc.getOutputPath()); -// setInputFiles(finalJobDesc.getInputFiles()); - //setUserEmail(finalJob.getEmail()); NO uso email della collection - - String tmp = finalJob.getJobId().substring(1, finalJob.getJobId().indexOf(']')); - String resourceManager=tmp.replace("[", ""); - resourceManager=resourceManager.replace("]", ""); - - String adaptor = resourceManager.toString().substring(0, resourceManager.toString().indexOf(":")); - - logger.debug("Switching Adaptor..."); - switch(Adaptor.valueOf(adaptor)){ - case wms: - case wsgram: - case gatekeeper: - case rocci: - logger.debug("Adaptor is WMS or WSGRAM or GATEKEEPER"); - if(!finalJob.getProxyId().contains("/")){ - logger.debug("Using Robot Proxy..."); - if(!finalJob.geteTokenServer().equals("")){ - String eTokenServerTmp = finalJob.geteTokenServer(); - useRobotProxy(eTokenServerTmp.substring(0,eTokenServerTmp.indexOf(':')), eTokenServerTmp.substring(eTokenServerTmp.indexOf(':')+1), finalJob.getProxyId(), finalJob.getVO(), finalJob.getFqan(), finalJobDesc.isProxyRenewal(), true,finalJob.getCommonName()); - }else{ - useRobotProxy(finalJob.getProxyId(), finalJob.getVO(), finalJob.getFqan(), finalJobDesc.isProxyRenewal(), true, finalJob.getCommonName()); - } - }else{ - logger.debug("Using User Proxy..."); - setUserProxy(finalJob.getProxyId()); - } - break; - case ssh: - logger.debug("Adaptor is SSH"); - String sshUserName = finalJob.getProxyId().substring(0,finalJob.getProxyId().indexOf(":")); - String sshPassword = finalJob.getProxyId().substring(finalJob.getProxyId().indexOf(":")+1); - logger.debug("sshUserName: " + sshUserName + " sshPassword: "+ sshPassword); - setSSHCredential(sshUserName, sshPassword); - break; - case ourgrid: - logger.debug("Adaptor is OURGRID"); - String ourgridUserName = finalJob.getProxyId().substring(0,finalJob.getProxyId().indexOf(":")); - String ourgridPassword = finalJob.getProxyId().substring(finalJob.getProxyId().indexOf(":")+1); - setOurGridCredential(ourgridUserName, ourgridPassword); - break; - case unicore: - logger.debug("Adaptor is UNICORE"); - String jksPath = finalJob.getProxyId().substring(0,finalJob.getProxyId().indexOf(":")); - String jksPassword = finalJob.getProxyId().substring(finalJob.getProxyId().indexOf(":")+1); - setJKS(jksPath, jksPassword); - break; - case gos: - logger.debug("Adaptor is GOS"); - break; - case besGenesis2: - logger.debug("Adaptor is BESGENESIS2"); - String genesisJksPath = finalJob.getProxyId().substring(0,finalJob.getProxyId().indexOf(":")); - String genesisjksPassword = finalJob.getProxyId().substring(finalJob.getProxyId().indexOf(":")+1); - setGenesisJKS(genesisJksPath, genesisjksPassword); - break; - default: - logger.error("Adaptor undefined."); - return; - } - StringTokenizer st = new StringTokenizer(finalJob.getUserDescription(), "_"); - - submitJobAsync(finalJob.getCommonName(), finalJob.getTcpAddress(), finalJob.getGridInteraction(), resourceManager, st.nextToken()+"-FinalJob", finalJob.getIdJobCollection()); - } - - public String getJobOutput(int DbId) { - System.out.println("DbId = "+ DbId); - String outputPath = ""; - String gridJobId = DBInterface.getGridJobId(DbId); - System.out.println("gridJobId2 = "+ gridJobId); - - outputPath = getJobOutput(new JobId(gridJobId,DbId)); - - return outputPath; - } - - public String getCollectionOutput(int DbId) { - System.out.println("DbId = "+ DbId); - JobCollection jc = JobCollection.getJobCollection(DbId); - String outputPath = "/jobOutput/" + removeNotAllowedCharacter(jc.getDescription()) + "_" + jc.getId() + ".tgz"; - int doneCollectionId = jc.close(); - List subJobs = GEActiveGridInteraction.findActiveJobForJobCollection(DbId); - for (GEActiveGridInteraction geActiveGridInteraction : subJobs) { - DBInterface.CloseGridInteraction(geActiveGridInteraction.getId().intValue(), doneCollectionId); - } - - return outputPath; - } - - public String getJobOutput(JobId jobId) { //SPostare in UsertrackingDBInt - String jobOutputPath = "/jobOutput/" + removeNotAllowedCharacter(DBInterface.getJobUserDescription(jobId.getDbId())) + "_" + jobId.getDbId() + ".tgz"; - //String jobOutputPath = "/jobOutput/" + (DBInterface.getJobUserDescription(jobId.getDbId())).replaceAll(" ", "") + "_" + jobId.getDbId() + ".tgz"; - DBInterface.CloseGridInteraction(jobId.getDbId()); - System.out.println("getJobOutput=" + jobOutputPath); - return jobOutputPath; - //return "/jobOutput/" + (DBInterface.getJobUserDescription(jobId.getDbId())).replaceAll(" ", "") + "_" + jobId.getDbId() + ".tgz"; - } - - /** - * Performs the output download for the specified job. - * - * @param jobId the grid job identifier for which want download output - * @param description a string represent the user description for this job. - */ - public void downloadJobOutput(JobId jobId, String description) { - logger.info("Downloading Job output..."); - String nativeJobId = getNativeJobId(jobId.getGridJobId()); - URL serviceURL = getServiceURL(jobId.getGridJobId()); - if ((nativeJobId==null) || (serviceURL==null)) return; //TODO manage error - - String adaptor = (serviceURL.toString()).substring(0, (serviceURL.toString()).indexOf(":")); - logger.info("Using adaptor:"+adaptor); -// System.out.println("Using adaptor:"+adaptor); - - if ( (adaptor.equals("wms")) || (adaptor.equals("wsgram")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("gos")) || (adaptor.equals("rocci")) ) { - } - else if (adaptor.equals("unicore")) { - if ( (jksPath.equals("")) || (jksPassword.equals("")) ) { - logger.error("Error in getJobStatus - No JKS defined."); -// System.out.println("Error in getJobStatus - No JKS defined."); - return; - } - } - else if (adaptor.equals("ourgrid")) { - if ( (ourgridUserName.equals("")) || (ourgridPassword.equals("")) ) { - logger.error("Error in getJobStatus - No ourgrid credentials defined."); -// System.out.println("Error in getJobStatus - No ourgrid credentials defined."); - return; - } - } - else if (adaptor.equals("bes-genesis2")) { - if ( (genesisJksPath.equals("")) || (genesisJksPassword.equals("")) ) { - logger.error("Error in getJobStatus - No Genesis JKS defined."); -// System.out.println("Error in getJobStatus - No Genesis JKS defined."); - return; - } - } - else if (adaptor.equals("ssh")) { -// if ( (SSHUserName.equals("")) || (SSHPassword.equals("")) ) { - if ( (SSHUserName.equals(""))) { - logger.error("Error in getJobStatus - No SSH credentials defined."); - return; - } - } - else { - logger.error("Error in getJobStatus - Adaptor not supported."); -// System.out.println("Error in getJobStatus - Adaptor not supported."); - return; - } - - try{ - logger.info("Creating JobService..."); -// System.out.println("Creating JobService..."); - - JobService service = null; - if ( (adaptor.equals("wms")) || (adaptor.equals("wsgram")) || (adaptor.equals("gatekeeper")) || (adaptor.equals("rocci"))) { - service = jobServiceManager.getJobService(serviceURL); - } - else if (adaptor.equals("unicore")) { - service = jobServiceManager.getJobService(jksPath,jksPassword,serviceURL); - } - else if (adaptor.equals("ourgrid")) { - service = jobServiceManager.getOurGridJobService(ourgridUserName,ourgridPassword,serviceURL); - } - else if (adaptor.equals("bes-genesis2")) { - service = jobServiceManager.getGenesisJobService(genesisJksPath,genesisJksPassword,serviceURL); - } - else if (adaptor.equals("gos")) { - service = jobServiceManager.getGOSJobService(serviceURL); - } - else if (adaptor.equals("ssh")) { - service = jobServiceManager.getSSHJobService(SSHUserName,SSHPassword,serviceURL); - } - - logger.info("Getting Job..."); -// System.out.println("Getting Job..."); - Job job = service.getJob(nativeJobId); - -// JobDescription desc = job.getJobDescription(); -// if (desc==null) System.out.println("*** E' NULLO!***"); -// else desc.setVectorAttribute(JobDescription.FILETRANSFER,"/home/diego/mpitest/start.sh>start.sh,/home/diego/mpitest/output.txt tmp = GEActiveGridInteraction.findActiveJobForJobCollection(jobCollectionId.intValue()); -// System.out.println("AAAAAAAAAAAAAA"+tmp.size()); -// if(tmp.size() == 1){ -// if (jc instanceof WorkflowN1) { -// long idFinalJob = ((WorkflowN1) jc).getIdFinalJob(); -// GEJobDescription tmpDescr = new GEJobDescription(); -// tmpDescr = GEJobDescription.findJobDescriptionById(idFinalJob); -// if (tmpDescr.getId() != null) -// tmpDescr.delete(); -// } -// if(!jc.getUserEmail().equals("")) -// m = new MailUtility(jc.getUserEmail(), "", "", jc.getDescription(), MailUtility.ContentMessage.SUBMISSION_ERROR); -// jc.delete(); -// } -// } - - if(!getUserEmail().equals("")){ - String address = getUserEmail(); - if(!getSenderEmail().equals("")){ - address = getSenderEmail()+"|"+getUserEmail(); - } - m = new MailUtility(address, "", "", userDescription, MailUtility.ContentMessage.SUBMISSION_ERROR); - } - - if(m!=null) - m.sendMail(); - description.delete(); - - if(dbId!=0){ - GEActiveGridInteraction activeGridInteraction = GEActiveGridInteraction.findActiveGridInteractionByJobId((long)dbId); - activeGridInteraction.delete(); - } - - } - ///* - public static void main(String [] args) - { - //JSagaJobSubmission tmpJSaga1 = new JSagaJobSubmission("jdbc:mysql://localhost/userstracking","tracking_user","usertracking"); - //tmpJSaga1.removeNotAllowedCharacter("Job-1"); - //tmpJSaga1.removeNotAllowedCharacter("Stre:ss:: te%st job n. 1"); - - int num_job = 1; - //String bdiiCometa = "ldap://infn-bdii-01.ct.pi2s2.it:2170"; - String bdiiCometa = "ldap://gridit-bdii-01.cnaf.infn.it:2170"; - //String bdiiCometa = "ldap://bdii.eela.ufrj.br:2170"; - String wmsList[] = {"wms://wms-4.dir.garr.it:7443/glite_wms_wmproxy_server"//, - //"wms://wms005.cnaf.infn.it:7443/glite_wms_wmproxy_server"//, -// "wms://gridit-wms-01.cnaf.infn.it:7443/glite_wms_wmproxy_server", -// "wms://egee-rb-09.cnaf.infn.it:7443/glite_wms_wmproxy_server"};//, -// "wms://egee-wms-01.cnaf.infn.it:7443/glite_wms_wmproxy_server", -// /*"wms://wms013.cnaf.infn.it:7443/glite_wms_wmproxy_server",*/ -// "wms://egee-wms-01.cnaf.infn.it:7443/glite_wms_wmproxy_server" - }; - String EUMEDwmsList[] = {"wms://wms.ulakbim.gov.tr:7443/glite_wms_wmproxy_server"}; - String bdiiEumed = "ldap://bdii.eumedgrid.eu:2170"; - String sshList[] = {"ssh://api.ct.infn.it"}; - //String CEs[] = {"grisuce.scope.unina.it", "ce-02.roma3.infn.it", "gridce3.pi.infn.it"}; - String CEs[] = {//"ce-02.roma3.infn.it:8443/cream-pbs-grid" - //"grisuce.scope.unina.it:8443/cream-pbs-grisu_short", - //"cccreamceli09.in2p3.fr:8443/cream-sge-long" - "ce-01.roma3.infn.it:8443/cream-pbs-grid" - }; - -// String OCCI_ENDPOINT_HOST = "rocci://carach5.ics.muni.cz"; -// String OCCI_ENDPOINT_PORT = "11443"; -// String OCCI_AUTH = "x509"; - - // Possible RESOURCE values: 'os_tpl', 'resource_tpl', 'compute' -// String OCCI_RESOURCE = "compute"; - //String OCCI_RESOURCE_ID = "https://carach5.ics.muni.cz:11443/compute/a0ad539e-ad17-4309-bc9c-4f9f91aecbaa"; -// String OCCI_VM_TITLE = "MyDebianROCCITest"; - - // Possible OCCI_OS values: 'debianvm', 'octave', 'r' and 'generic_www' -// String OCCI_OS = "debianvm"; -// String OCCI_FLAVOUR = "small"; - - // Possible ACTION values: 'list', 'describe', 'create' and 'delete' -// String OCCI_ACTION = "create"; -// String OCCI_PUBLIC_KEY = "/home/diego/.ssh/id_rsa.pub"; -// String OCCI_PRIVATE_KEY = "/home/diego/.ssh/id_rsa"; -// -// String rOCCIURL = OCCI_ENDPOINT_HOST + ":" + -// OCCI_ENDPOINT_PORT + -// System.getProperty("file.separator") + "?" + -// "action=" + OCCI_ACTION + -// "&resource=" + OCCI_RESOURCE + -// "&attributes_title=" + OCCI_VM_TITLE + -// "&mixin_os_tpl=" + OCCI_OS + -// "&mixin_resource_tpl=" + OCCI_FLAVOUR + -// "&auth=" + OCCI_AUTH + -// "&publickey_file=" + OCCI_PUBLIC_KEY + -// "&privatekey_file=" + OCCI_PRIVATE_KEY; -// -// String rOCCIResourcesList[] = {rOCCIURL}; - //String wmsList[] = {"wms://infn-wms-01.ct.pi2s2.it:7443/glite_wms_wmproxy_server"//, - // "unicore://zam052v01.zam.kfa-juelich.de:8080/?Target=EMI-UNICOREX" - //}; - - //JSagaJobSubmission tmpJSaga = new JSagaJobSubmission(); - //JSagaJobSubmission tmpJSaga = new JSagaJobSubmission("jdbc:mysql://10.70.1.99/userstracking","tracking_user","usertracking"); - //String bdiiGilda = "ldap://egee-bdii.cnaf.infn.it:2170"; - //tmpJSaga.setBDII(bdiiGilda); - //tmpJSaga.useRobotProxy("101", "gilda", "gilda", true); -// tmpJSga.setJobOutput("myOutput.txt"); -// tmpJSaga.setJobError("myError.txt"); - System.out.println("#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#"); -// JobId[] newJobsId = new JobId[num_job]; - -// /*SUBMISSION SPECIFYING JOB DESCRIPTION - for(int i = 0; i jobList = null; -// Vector cesListwithCoord = null; - - -// if (!DBInterface.isUpdateJobsStatusAsyncRunning("ViralGrid", "scardaci")) { -// System.out.println("1- Running checking thread..."); -// DBInterface.updateJobsStatusAsync2("ViralGrid","scardaci","/tmp"); -// } -// -// if (!DBInterface.isUpdateJobsStatusAsyncRunning("ViralGrid", "scardaci")) { -// System.out.println("2- Running checking thread..."); -// DBInterface.updateJobsStatusAsync2("ViralGrid","scardaci","/tmp"); -// } - - while(status.equals("RUNNING")) { - - - //DBInterface.updateJobsStatus("ViralGrid","scardaci"); - - try { - Thread.sleep(15000); - } - catch (Exception e) {} - - status = "DONE"; - jobList = DBInterface.getActiveInteractionsByName("test"); - - if (jobList != null) { - for (int i = 0; i < jobList.size(); i++) { - - if(jobList.get(i).getSubJobs()==null){ - - System.out.println("DBID = " + jobList.elementAt(i).getInteractionInfos()[0] - + " Portal = " + jobList.elementAt(i).getInteractionInfos()[1] - + " - Application = " + jobList.elementAt(i).getInteractionInfos()[2] - + " - Description = " +jobList.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " + jobList.elementAt(i).getInteractionInfos()[4] - + " - Status = " + jobList.elementAt(i).getInteractionInfos()[5]); - - } else { - System.out.println("***COLLECTION INFOS*** DBID = " + jobList.elementAt(i).getInteractionInfos()[0] - + " Portal = " + jobList.elementAt(i).getInteractionInfos()[1] - + " - Application = " + jobList.elementAt(i).getInteractionInfos()[2] - + " - Description = " +jobList.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " + jobList.elementAt(i).getInteractionInfos()[4] - + " - Status = " + jobList.elementAt(i).getInteractionInfos()[5]); - Vector subJobs = jobList.get(i).getSubJobs(); - for(String[] subJobInfos : subJobs) - System.out.println("\t|_***SUBJOB INFOS*** DBID = " + subJobInfos[0] - + " Portal = " + subJobInfos[1] - + " - Application = " + subJobInfos[2] - + " - Description = " + subJobInfos[3] - + " - Timestamp = " + subJobInfos[4] - + " - Status = " + subJobInfos[5]); - } - if (!jobList.elementAt(i).getInteractionInfos()[5].equals("DONE")) - status = "RUNNING"; - } - } - -// cesListwithCoord = DBInterface.getCEsGeographicDistribution("ViralGrid","scardaci"); -// -// if (cesListwithCoord!=null) { -// for (int i=0;i jobList2 = null; -// jobList2 = DBInterface.getDoneJobsListByName("scardaci"); -// for (int i=0;i doLookup("JobServices-Dispatcher"); - logger.info("Got JobServices-Dispatcher..."); - - } catch (NamingException ex) { - logger.info("Cannot get JobServices-Dispatcher: " + ex); - - } catch (Exception ex) { - logger.info("Cannot get JobServices-Dispatcher: " + ex); - - } - - if (jobServicesDispatcher == null) { - logger.info("Get local JobServicesDispatcher"); - - jobServicesDispatcher = JobServicesDispatcher.getInstance(); - } - - setResubNumber(jobServicesDispatcher.getResubNumber()); - } - - /** - * Returns the maximum attempts re-submission numbers. - * - * @return the maximum attempts re-submission numbers. - */ - protected int getResubNumber() { - return resubNumber; - } - - /** - * Sets the maximum attempts re-submission numbers. - * - * @param value - * the maximum attempts re-submission numbers. - */ - protected void setResubNumber(int resubNumber) { - this.resubNumber = resubNumber; - } - - /** - * This method specifies that for interaction will be used the specified - * robot proxy. - * - * @param etokenserver - * proxy robot host - * @param etokenserverport - * proxy robot port - * @param proxyId - * proxy robot identifier - * @param vo - * proxy robot virtual organization - * @param fqan - * proxy robot roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - */ - protected void useRobotProxy(String etokenserver, String etokenserverport, - String proxyId, String vo, String fqan, boolean proxyrenewal, boolean rfc) { - usingRobotProxy = true; - - useRobotProxy(etokenserver,etokenserverport,proxyId,vo,fqan,proxyrenewal, rfc, "Empty"); - } - - /** - * This method specifies that for interaction will be used the specified - * robot proxy. - * - * @param etokenserver - * proxy robot host - * @param etokenserverport - * proxy robot port - * @param proxyId - * proxy robot identifier - * @param vo - * proxy robot virtual organization - * @param fqan - * proxy robot roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - */ - protected void useRobotProxy(String etokenserver, String etokenserverport, - String proxyId, String vo, String fqan, boolean proxyrenewal) { - usingRobotProxy = true; - - useRobotProxy(etokenserver,etokenserverport,proxyId,vo,fqan,proxyrenewal,false, "Empty"); - } - - /** - * This method specifies that for interaction will be used the specified - * robot proxy. - * - * @param etokenserver - * proxy robot host - * @param etokenserverport - * proxy robot port - * @param proxyId - * proxy robot identifier - * @param vo - * proxy robot virtual organization - * @param fqan - * proxy robot roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - */ - protected void useRobotProxy(String etokenserver, String etokenserverport, - String proxyId, String vo, String fqan, boolean proxyrenewal, boolean rfc, String cnLabel) { - usingRobotProxy = true; - - etokenServer = etokenserver; - etokenServerPort = etokenserverport; - ProxyId = proxyId; - VO = vo; - FQAN = fqan; - ProxyRenewal = proxyrenewal; - RFC = rfc; - this.cnLabel = "eToken:" + cnLabel; - } - - /** - * This method specifies that for interaction will be used the specified - * robot proxy. - * - * @param proxyId - * proxy robot identifier - * @param vo - * proxy robot virtual organization - * @param fqan - * proxy robot roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - */ - protected void useRobotProxy(String proxyId, String vo, String fqan, - boolean proxyrenewal) { - usingRobotProxy = true; - - useRobotProxy(proxyId,vo,fqan,proxyrenewal,false, "Empty"); - } - - /** - * This method specifies that for interaction will be used the specified - * robot proxy. - * - * @param proxyId - * proxy robot identifier - * @param vo - * proxy robot virtual organization - * @param fqan - * proxy robot roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - */ - protected void useRobotProxy(String proxyId, String vo, String fqan, - boolean proxyrenewal, boolean rfc, String cnLabel) { - usingRobotProxy = true; - - ProxyId = proxyId; - VO = vo; - FQAN = fqan; - ProxyRenewal = proxyrenewal; - RFC = rfc; - this.cnLabel = "eToken:" + cnLabel; - } - - /** - * This method specifies that for interaction will be used the specified - * User proxy. - * - * @param value - * path to a user proxy certificate - */ - protected void setUserProxy(String value) { - userProxy = value; - - if ((!usingRobotProxy) && (!value.equals(""))) { - Session session_temp; - Context context; - try { - logger.info("Creating session...."); - - session_temp = SessionFactory.createSession(false); - logger.info(ContextImpl.URL_PREFIX); - - context = ContextFactory.createContext("VOMS"); - context.setAttribute(Context.USERPROXY, userProxy); - session_temp.addContext(context); - - DN = context.getAttribute(Context.USERID); - logger.info("DN=" + DN); - - // if (!usingRobotProxy) { - VO = context.getAttribute(Context.USERVO); - logger.info("VO=" + VO); - // System.out.println("VO="+VO); - FQAN = context.getAttribute("UserFQAN"); - logger.info("FQAN" + FQAN); - // System.out.println("FQAN"+FQAN); - // } - - session_temp.close(); - } catch (Exception e) { - logger.error("Error in reading user proxy..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - - } - } - - } - - /** - * Returns the user proxy path used for this interaction. - * - * @return user proxy path used for this interaction. - */ - protected String getUserProxy() { - return userProxy; - } - - /** - * Returns a {@link JobService} for the specified resource manager. - * - * @param resourceManager - * resource manager host - * @return {@link JobService} for the specified resource manager. - */ - protected JobService getJobService(URL resourceManager) { - if ((!usingRobotProxy) && (userProxy.equals(""))) - return null; - - JobService jobservice = null; - ResourceManager = resourceManager; - - try { - if (!usingRobotProxy) { - jobservice = jobServicesDispatcher.getJobService(userProxy, DN, - VO, FQAN, resourceManager.toString()); - // session = jobservice.getSession(); - } else { - jobservice = jobServicesDispatcher.getJobService(etokenServer, - etokenServerPort, ProxyId, VO, FQAN, ProxyRenewal, RFC, cnLabel, - resourceManager.toString()); - DN = jobServicesDispatcher.getDN(jobservice); - } - - } catch (Exception e) { - logger.error("Error in getting job service:" + e.toString()); - - } - return jobservice; - } - - /** - * Returns a {@link JobService} for the specified resource manager using - * UNICORE middleware. - * - * @param jksPath - * keystore path - * @param jskPassword - * keystore password - * @param resourceManager - * resource manager host - * @return a JobService object that allows job creation, submission and - * status monitoring using UNICORE middleware. - */ - protected JobService getJobService(String jksPath, String jskPassword, - URL resourceManager) { - - usingJKS = true; - JKSPath = jksPath; - JKSPassword = jskPassword; - - JobService jobservice = null; - ResourceManager = resourceManager; - - try { - jobservice = jobServicesDispatcher.getJKSJobService(jksPath, - jskPassword, resourceManager.toString()); - DN = jobServicesDispatcher.getDN(jobservice); - } catch (Exception e) { - logger.error("Error in getting job service:" + e.toString()); - - } - return jobservice; - } - - /** - * Returns a {@link JobService} for the specified resource manager using - * OURGRID middleware. - * - * @param username - * username parameter - * @param password - * password parameter - * @param resourceManager - * resource manager host - * @return a JobService object for OURGRID middleware - * - */ - protected JobService getOurGridJobService(String username, String password, - URL resourceManager) { - - usingOurGrid = true; - OurGridUserName = username; - OurGridPassword = password; - - JobService jobservice = null; - ResourceManager = resourceManager; - - try { - jobservice = jobServicesDispatcher.getOurGridJobService(username, - password, resourceManager.toString()); - // DN = jobServicesDispatcher.getDN(jobservice); - } catch (Exception e) { - logger.error("Error in getting job service:" + e.toString()); - - } - return jobservice; - } - - /** - * Returns a {@link JobService} for the specified resource manager using - * BESGENESIS middleware. - * - * @param jksPath - * keystore path - * @param jskPassword - * keystore password - * @param resourceManager - * resource manager host - * @return a JobService object for BESGENESIS middleware - */ - protected JobService getGenesisJobService(String jksPath, String jskPassword, - URL resourceManager) { - - usingGenesisJKS = true; - genesisJKSPath = jksPath; - genesisJKSPassword = jskPassword; - - JobService jobservice = null; - ResourceManager = resourceManager; - - try { - jobservice = jobServicesDispatcher.getGenesisJobService(jksPath, - jskPassword, resourceManager.toString()); - DN = jobServicesDispatcher.getDN(jobservice); - } catch (Exception e) { - logger.error("Error in getting job service:" + e.toString()); - - } - return jobservice; - } - - /** - * Returns a {@link JobService} for the specified resource manager using GOS - * middleware. - * - * @param resourceManager - * resource manager host - * @return a JobService object for GOS middleware - */ - protected JobService getGOSJobService(URL resourceManager) { - - usingGOS = true; - - JobService jobservice = null; - ResourceManager = resourceManager; - - try { - jobservice = jobServicesDispatcher.getGOSJobService(resourceManager - .toString()); - // DN = jobServicesDispatcher.getDN(jobservice); - } catch (Exception e) { - logger.error("Error in getting job service:" + e.toString()); - - } - return jobservice; - } - - /** - * Returns a {@link JobService} for the specified resource manager using SSH - * middleware. - * - * @param username - * username parameter - * @param password - * password parameter - * @param resourceManager - * resource manager host - * @return a JobService object for SSH middleware - */ - protected JobService getSSHJobService(String username, String password, - URL resourceManager) { - - usingSSH = true; - SSHUserName = username; - SSHPassword = password; - - JobService jobservice = null; - ResourceManager = resourceManager; - - try { - jobservice = jobServicesDispatcher.getSSHJobService(username, - password, resourceManager.toString()); - } catch (Exception e) { - logger.error("Error in getting job service:" + e.toString()); - } - return jobservice; - } - - /** - * This method closes - */ - protected void closeSession() { - if (usingJKS) { - jobServicesDispatcher.closeJKSJobService(JKSPath, - ResourceManager.toString()); - return; - } else if (usingOurGrid) { - jobServicesDispatcher.closeOurGridJobService(OurGridUserName, - ResourceManager.toString()); - return; - } else if (usingGenesisJKS) { - jobServicesDispatcher.closeGenesisJobService(genesisJKSPath, - ResourceManager.toString()); - return; - } else if (usingGOS) { - jobServicesDispatcher - .closeGOSJobService(ResourceManager.toString()); - return; - } else if (usingSSH) { - jobServicesDispatcher.closeSSHJobService(SSHUserName, - ResourceManager.toString()); - return; - } - - if (usingRobotProxy) - jobServicesDispatcher.closeJobService(usingRobotProxy, ProxyId, VO, - FQAN, ResourceManager.toString()); - else - jobServicesDispatcher.closeJobService(usingRobotProxy, DN, VO, - FQAN, ResourceManager.toString()); - } - - protected String getUserDN() { - // if (userProxy.equals("")) return ""; - - return DN; - } - - protected String getUserVO() { - return VO; - } - - protected String getUserFQAN() { - return FQAN; - } - - protected String getProxyId() { - // if (session==null) return ""; //TODO manage error - - if (usingRobotProxy) { - return ProxyId; - } - - return ""; - } - - protected String getJKSPath() { - return JKSPath; - } - - protected String getJKSPassword() { - return JKSPassword; - } - - protected String getOurGridUserName() { - return OurGridUserName; - } - - protected String getOurGridPassword() { - return OurGridPassword; - } - - protected String getGenesisJKSPath() { - return genesisJKSPath; - } - - protected String getGenesisJKSPassword() { - return genesisJKSPassword; - } - - protected String getSSHUserName() { - return SSHUserName; - } - - protected String getSSHPassword() { - return SSHPassword; - } - - protected String getProxyRequestOptions() { - String requestOptions = ""; - //disable-voms-proxy=false&proxy-renewal=true&rfc-proxy=true&cn-label=eToken:Empty - if(ProxyRenewal){ - requestOptions = "proxy-renewal=true&"; - } - - if(RFC){ - requestOptions += "rfc-proxy=true&"; - } - - requestOptions += "cn-label=" + cnLabel; - return requestOptions; - } - -} diff --git a/it/infn/ct/GridEngine/Job/MultiInfrastructureJobSubmission.java b/it/infn/ct/GridEngine/Job/MultiInfrastructureJobSubmission.java deleted file mode 100644 index ecf2cff..0000000 --- a/it/infn/ct/GridEngine/Job/MultiInfrastructureJobSubmission.java +++ /dev/null @@ -1,1034 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) -****************************************************************************/ - -package it.infn.ct.GridEngine.Job; - -import it.infn.ct.GridEngine.JobResubmission.GEJobDescription; -import it.infn.ct.GridEngine.UsersTracking.ActiveInteractions; -import it.infn.ct.GridEngine.UsersTracking.UsersTrackingDBInterface; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.Vector; - -import org.apache.log4j.Logger; - -public class MultiInfrastructureJobSubmission { - - private List infrastructureInfo; - -// private String executable = ""; -// private String arguments = ""; -// private String jobQueue = ""; -// private String outputPath = ""; -// private String jobOutput = ""; -// private String jobError = ""; -// private String inputFiles = ""; - private String outputFiles = ""; -// private String totalCPUCount = ""; -// private String SPMDVariation = ""; -// private String NumberOfProcesses = ""; -// private String JDLRequirements[] = null; - private boolean checkJobsStatus = true; - private boolean randomCE = false; - - - private boolean inAppServer = true; - private String DB = ""; - private String DBUser = ""; - private String DBUserPwd = ""; - - //********MARIO*************** - private String userEmail = ""; - private static final Logger logger = Logger.getLogger(MultiInfrastructureJobSubmission.class); - private GEJobDescription description; - //**************************** - - /** - * Constructs a {@link MultiInfrastructureJobSubmission} object without specify - * connection parameters to users tracking database. - */ - public MultiInfrastructureJobSubmission() { - infrastructureInfo = new LinkedList(); - description = new GEJobDescription(); - } - /** - * Constructs a {@link MultiInfrastructureJobSubmission} object specifying the description for - * the submitting job. - * - * @param description a {@link GEJobDescription} object contains description - * of the submitting job. - */ - public MultiInfrastructureJobSubmission(GEJobDescription description) { - this(); - - this.description = description; - } - - /** - * Constructs a {@link MultiInfrastructureJobSubmission} object specifying - * connection parameters to users tracking database. - * - * @param db database name - * @param dbUser database username - * @param dbUserPwd database password. - */ - public MultiInfrastructureJobSubmission(String db, String dbUser, String dbUserPwd) { - infrastructureInfo = new LinkedList(); - - DB = db; - DBUser = dbUser; - DBUserPwd = dbUserPwd; - inAppServer = false; - - description = new GEJobDescription(); - } - - /** - * Constructs a {@link MultiInfrastructureJobSubmission} object specifying - * connection parameters to users tracking database and and the description - * of submitting job. - * - * @param db database name - * @param dbUser database username - * @param dbUserPwd database password - * @param description a {@link GEJobDescription} object contains description - * of the submitting job. - */ - public MultiInfrastructureJobSubmission(String db, String dbUser, String dbUserPwd, GEJobDescription description) { - this(db, dbUser, dbUserPwd); - - this.description = description; - } - - /** - * Constructs a {@link MultiInfrastructureJobSubmission} object specifying - * connection parameters to users tracking database, the list of enabled infrastructures and and the description - * of submitting job. - * - * @param db database name - * @param dbUser database username - * @param dbUserPwd database password - * @param infrastructures list of enabled infrastructures - * @param description a {@link GEJobDescription} object contains description - * of the submitting job. - */ - public MultiInfrastructureJobSubmission(String db, String dbUser, String dbUserPwd, ArrayList infrastructures, GEJobDescription description){ - this(db, dbUser, dbUserPwd); - this.infrastructureInfo = infrastructures; - this.description = description; - } - - /** - * Constructs a {@link MultiInfrastructureJobSubmission} specifying a list of possible infrastructures - * to which submit job. - * - * @param infrastructures list of possible infrastructures to which submit job. - */ - public MultiInfrastructureJobSubmission(InfrastructureInfo infrastructures[]) { - infrastructureInfo = new LinkedList(); - - for (int i=0;i cesListwithCoord = null; -// -// System.out.println("Vado in sleep..."); -// while(true) { -// try { -// Thread.sleep(120000); -// -// cesListwithCoord = DBInterface.getCEsGeographicDistribution("ViralGrid","scardaci"); -// -// if (cesListwithCoord!=null) { -// for (int i=0;i jobList = null; - - while(status.equals("RUNNING")) { - try { - Thread.sleep(15000); - } - catch (Exception e) {} - - System.out.println("Users running jobs = " + DBInterface.getTotalNumberOfUsersWithRunningJobs()); - status = "DONE"; -// jobList = DBInterface.getActiveJobsListByName("mtorrisi"); - jobList = DBInterface.getActiveInteractionsByName("test"); - - if (jobList != null) { - for (int i = 0; i < jobList.size(); i++) { - - if(jobList.get(i).getSubJobs()==null){ - - System.out.println("DBID = " + jobList.elementAt(i).getInteractionInfos()[0] - + " Portal = " + jobList.elementAt(i).getInteractionInfos()[1] - + " - Application = " + jobList.elementAt(i).getInteractionInfos()[2] - + " - Description = " +jobList.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " + jobList.elementAt(i).getInteractionInfos()[4] - + " - Status = " + jobList.elementAt(i).getInteractionInfos()[5]); - - } else { - System.out.println("***COLLECTION INFOS*** DBID = " + jobList.elementAt(i).getInteractionInfos()[0] - + " Portal = " + jobList.elementAt(i).getInteractionInfos()[1] - + " - Application = " + jobList.elementAt(i).getInteractionInfos()[2] - + " - Description = " +jobList.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " + jobList.elementAt(i).getInteractionInfos()[4] - + " - Status = " + jobList.elementAt(i).getInteractionInfos()[5]); - Vector subJobs = jobList.get(i).getSubJobs(); - for(String[] subJobInfos : subJobs) - System.out.println("\t|_***SUBJOB INFOS*** DBID = " + subJobInfos[0] - + " Portal = " + subJobInfos[1] - + " - Application = " + subJobInfos[2] - + " - Description = " + subJobInfos[3] - + " - Timestamp = " + subJobInfos[4] - + " - Status = " + subJobInfos[5]); - } - if (!jobList.elementAt(i).getInteractionInfos()[5].equals("DONE")) - status = "RUNNING"; - } - } - - if (status.equals("RUNNING")) { - try { - Thread.sleep(15000); - } - catch (Exception e) {} - } - - } - -// String allTarPath = DBInterface.createAllJobsFromDescriptionArchive("mtorrisi", "J o b -", "/tmp"); - String allTarPath = DBInterface - .createAllJobsArchive("test", "/tmp"); - System.out.println("allTarPath=" + allTarPath); - // - Vector jobList1 = null; - jobList1 = DBInterface.getDoneInteractionsByName("test"); - - if (jobList1.size() == 0) - System.out.println("No jobs for user test"); - for (int i = 0; i < jobList1.size(); i++) { - if (jobList1.get(i).getSubJobs() == null) { - - System.out.println("DBID = " - + jobList1.elementAt(i).getInteractionInfos()[0] - + " Portal = " - + jobList1.elementAt(i).getInteractionInfos()[1] - + " - Application = " - + jobList1.elementAt(i).getInteractionInfos()[2] - + " - Description = " - + jobList1.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " - + jobList1.elementAt(i).getInteractionInfos()[4] - + " - Status = " - + jobList1.elementAt(i).getInteractionInfos()[5]); - - } else { - System.out.println("***COLLECTION INFOS*** DBID = " - + jobList1.elementAt(i).getInteractionInfos()[0] - + " Portal = " - + jobList1.elementAt(i).getInteractionInfos()[1] - + " - Application = " - + jobList1.elementAt(i).getInteractionInfos()[2] - + " - Description = " - + jobList1.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " - + jobList1.elementAt(i).getInteractionInfos()[4] - + " - Status = " - + jobList1.elementAt(i).getInteractionInfos()[5]); - Vector subJobs = jobList1.get(i).getSubJobs(); - for (String[] subJobInfos : subJobs) - System.out.println("\t|_***SUBJOB INFOS*** DBID = " - + subJobInfos[0] + " Portal = " + subJobInfos[1] - + " - Application = " + subJobInfos[2] - + " - Description = " + subJobInfos[3] - + " - Timestamp = " + subJobInfos[4] - + " - Status = " + subJobInfos[5]); - } - } - } - - private void setDescription(GEJobDescription description) { - this.description = description; - - } - -} diff --git a/it/infn/ct/GridEngine/JobCollection/ClosedJobCollection.hbm.xml b/it/infn/ct/GridEngine/JobCollection/ClosedJobCollection.hbm.xml deleted file mode 100644 index 194f641..0000000 --- a/it/infn/ct/GridEngine/JobCollection/ClosedJobCollection.hbm.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/it/infn/ct/GridEngine/JobCollection/ClosedJobCollection.java b/it/infn/ct/GridEngine/JobCollection/ClosedJobCollection.java deleted file mode 100644 index f75b597..0000000 --- a/it/infn/ct/GridEngine/JobCollection/ClosedJobCollection.java +++ /dev/null @@ -1,247 +0,0 @@ -package it.infn.ct.GridEngine.JobCollection; - -import it.infn.ct.GridEngine.JobResubmission.GESessionFactoryUtil; - -import java.sql.Timestamp; -import java.util.List; - -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.Transaction; - -/** - * - * @author mario - * - */ -public class ClosedJobCollection { - - // @Id - // @GeneratedValue - // @Column (name="id") - private int id; // primary key - - // @Column (name="common_name") - private String commonName; - - // @Column (name="description") - private String description; - - // @Column (name="task_counter") - private int taskCounter; - - // @Column (name="collection_status") - private String collectionStatus; - - // @Column (name="start_timestamp") - private Timestamp startTimestamp; - - // @Column (name="end_timestamp") - private Timestamp endTimestamp; - - // @Column (name="collection_type") - private String collectionType; - - protected ClosedJobCollection() { - - } - - protected ClosedJobCollection(String commonName, String description, - int taskCounter, String collectionStatus, Timestamp startTimestamp, - Timestamp endTimestamp, String collectionType) { - super(); - - this.commonName = commonName; - this.description = description; - this.taskCounter = taskCounter; - this.collectionStatus = collectionStatus; - this.startTimestamp = startTimestamp; - this.endTimestamp = endTimestamp; - this.collectionType = collectionType; - } - - /** - * Returns database id of this closed collection. - * - * @return database id of this closed collection. - */ - public int getId() { - return id; - } - - protected void setId(int id) { - this.id = id; - } - - /** - * Returns description for this closed collection. - * - * @return description for this closed collection. - */ - public String getDescription() { - return description; - } - - protected void setDescription(String description) { - this.description = description; - } - - /** - * Returns the parallel tasks number. - * - * @return parallel tasks number. - */ - public int getTaskCounter() { - return taskCounter; - } - - protected void setTaskCounter(int taskCounter) { - // this.taskCounter = getSubJobDescriptions().size(); - this.taskCounter = taskCounter; - } - - /** - * Returns closed collection status. - * - * @return closed collection status. - */ - public String getCollectionStatus() { - return collectionStatus; - } - - protected void setCollectionStatus(String collectionStatus) { - this.collectionStatus = collectionStatus; - } - - /** - * Returns the JobCollection submission Timestamp. - * - * @return submission Timestamp - */ - public Timestamp getStartTimestamp() { - return startTimestamp; - } - - protected void setStartTimestamp(Timestamp startTimestamp) { - this.startTimestamp = startTimestamp; - } - - /** - * Returns the timestamp when this collection has been successfully - * completed. - * - * @return timestamp when this collection has been successfully completed. - */ - public Timestamp getEndTimestamp() { - return endTimestamp; - } - - protected void setEndTimestamp(Timestamp endTimestamp) { - this.endTimestamp = endTimestamp; - } - - /** - * Returns the user common-name who submitted this collection. - * - * @return the user common-name who submitted this collection. - */ - public String getCommonName() { - return commonName; - } - - protected void setCommonName(String commonName) { - this.commonName = commonName; - } - - /** - * Returns a String that represent the collection type. - * - * @return a String that represent the collection type. - */ - public String getCollectionType() { - return collectionType; - } - - protected void setCollectionType(String collectionType) { - this.collectionType = collectionType; - } - - protected void saveClosedJobCollection() { - - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - session.save(this); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - throw he; - } finally { - session.close(); - } - } - - @Override - public String toString() { - return "ClosedJobCollection [id=" + id + ", commonName=" + commonName - + ", description=" + description + ", collectionStatus=" - + collectionStatus + "]"; - } - - /** - * Returns ClosedCollection object for the specified key. - * - * @param key - * that uniquely identifies the closed collection in the - * database. - * @return a {@link ClosedJobCollection} for the specified key. - */ - public static ClosedJobCollection getClosedCollections(Integer key) { - ClosedJobCollection result = new ClosedJobCollection(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Query q = session - .createQuery("from ClosedJobCollection where id = :id "); - q.setParameter("id", key.intValue()); - List closedCollections = q.list(); - - try { - if (closedCollections.size() == 1) { - result = closedCollections.get(0); - } else - // Gestire - System.out.println("Multiple row in ClosedCollection"); - } catch (HibernateException he) { - he.printStackTrace(); - } finally { - session.close(); - } - return result; - } - - /** - * Returns a String[] with some ClosedCollection information. - * - * @return a String[] with some ClosedCollection information. - */ - public String[] getCollectionInfos() { - - String[] collectionInfos = new String[6]; - - collectionInfos[0] = "" + this.getId(); - collectionInfos[3] = this.description; - collectionInfos[4] = "" + this.startTimestamp; - collectionInfos[5] = this.collectionStatus; - - return collectionInfos; - - } - -} diff --git a/it/infn/ct/GridEngine/JobCollection/JobCollection.hbm.xml b/it/infn/ct/GridEngine/JobCollection/JobCollection.hbm.xml deleted file mode 100644 index d5bd6c2..0000000 --- a/it/infn/ct/GridEngine/JobCollection/JobCollection.hbm.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/it/infn/ct/GridEngine/JobCollection/JobCollection.java b/it/infn/ct/GridEngine/JobCollection/JobCollection.java deleted file mode 100644 index 56570c5..0000000 --- a/it/infn/ct/GridEngine/JobCollection/JobCollection.java +++ /dev/null @@ -1,752 +0,0 @@ -package it.infn.ct.GridEngine.JobCollection; - -import it.infn.ct.GridEngine.Job.JSagaJobSubmission; -import it.infn.ct.GridEngine.JobResubmission.GEActiveGridInteraction; -import it.infn.ct.GridEngine.JobResubmission.GEJobDescription; -import it.infn.ct.GridEngine.JobResubmission.GESessionFactoryUtil; -import it.infn.ct.GridEngine.SendMail.MailUtility; -import it.infn.ct.GridEngine.SendMail.MailUtility.ContentMessage; -import it.infn.ct.GridEngine.UsersTracking.UsersTrackingDBInterface; - -import java.io.IOException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; -import java.util.TimeZone; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.Transaction; - - -//@Entity -//@Table(name = "ActiveJobCollections") -//@Inheritance(strategy=InheritanceType.SINGLE_TABLE) -//@DiscriminatorColumn( -// name="collection_type", -// discriminatorType=DiscriminatorType.STRING -//) -//@DiscriminatorValue(value="JOB_COLLECTION") -/** - * This class is a simple collection of parallel running jobs. When you create a - * new JobCollection objects, this handles all behavior. It is responsible for - * the creation, updating collection state and complete collection when all jobs - * have gone DONE. - * - * @author mario - * - */ -public class JobCollection { - - private static final String OUTPUT_DIR = "/jobOutput/"; - protected static final Logger logger = Logger - .getLogger(JobCollection.class); - -// @Id -// @GeneratedValue -// @Column (name="id") - private int id; // primary key - -// @Column (name="common_name") - private String commonName; - -// @Column (name="description") - private String description; - -// @Column (name="task_counter") - private int taskCounter; - -// @Column (name="user_email") - private String userEmail; - -// @Column (name="status") - private String collectionStatus; - -// @Column (name="start_timestamp") - private Timestamp startTimestamp; - -// @Column (name="end_timestamp") - private Timestamp endTimestamp; - -// @Column (name="output_path") - private String outputPath; - -// @Transient - private ArrayList subJobDescriptions; - - /** - * Constructs a JobCollection object without a user email. - * - * @param commonName - * a string that identifies the user - * @param description - * a string that gives a collection description - * @param outputPath - * a string that specifies the path where the output file for the - * collection are stored - * @param subJobDescriptions - * an {@link ArrayList} of {@link GEJobDescription} that - * represents the entire sub-job descriptions. - */ - public JobCollection(String commonName, String description, - String outputPath, ArrayList subJobDescriptions) { - this(commonName, description, null, outputPath, subJobDescriptions); - } - - /** - * Constructs a JobCollection object with the specified user email to notify - * that this job collection is completed. - * - * @param commonName - * a string that identifies the user - * @param description - * a string that gives a collection description - * @param userEmail - * email address to notify completed collection - * @param outputPath - * a string that specifies the path where the output file for the - * collection are stored - * @param subJobDescriptions - * an {@link ArrayList} of {@link GEJobDescription} that - * represents the entire sub-job descriptions. - */ - public JobCollection(String commonName, String description, - String userEmail, String outputPath, - ArrayList subJobDescriptions) { - // this(commonName, description, outputPath, subJobDescriptions); - this.commonName = commonName; - this.description = description; - this.outputPath = outputPath + OUTPUT_DIR; - this.setSubJobDescriptions(subJobDescriptions); - this.taskCounter = subJobDescriptions.size(); - this.userEmail = userEmail; - - saveJobCollection(); - } - - protected JobCollection() { - - } - - /** - * Returns the JobCollection id. - * - * @return an integer that is the JobCollection id. - */ - public int getId() { - return id; - } - - protected void setId(int id) { - this.id = id; - } - - /** - * Returns the JobCollection user description. - * - * @return JobCollection user description. - */ - public String getDescription() { - return description; - } - - /** - * Sets JobCollection user description - * - * @param description - * user description - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Returns the parallel tasks number. - * - * @return parallel tasks number. - */ - public int getTaskCounter() { - return taskCounter; - } - - protected void setTaskCounter(int taskCounter) { - // this.taskCounter = getSubJobDescriptions().size(); - this.taskCounter = taskCounter; - } - - /** - * Returns the user email, if it was specified in JobCollection constructor. - * - * @return the user email. - */ - public String getUserEmail() { - return userEmail; - } - - protected void setUserEmail(String userEmail) { - this.userEmail = userEmail; - } - - /** - * Returns the user email, if it was specified in JobCollection constructor. - * - * @return the user email. - */ - public String getCollectionStatus() { - return collectionStatus; - } - - protected void setCollectionStatus(String collectionStatus) { - this.collectionStatus = collectionStatus; - } - - /** - * Returns the JobCollection submission Timestamp. - * - * @return submission Timestamp - */ - public Timestamp getStartTimestamp() { - return startTimestamp; - } - - protected void setStartTimestamp(Timestamp startTimestamp) { - this.startTimestamp = startTimestamp; - } - - /** - * Returns the timestamp when this JobCollection has been successfully - * completed. - * - * @return timestamp when this JobCollection has been successfully - * completed. - */ - public Timestamp getEndTimestamp() { - return endTimestamp; - } - - protected void setEndTimestamp(Timestamp endTimestamp) { - this.endTimestamp = endTimestamp; - } - - /** - * Returns the user common-name who submitted this JobCollection. - * - * @return the user common-name who submitted this JobCollection. - */ - public String getCommonName() { - return commonName; - } - - protected void setCommonName(String commonName) { - this.commonName = commonName; - } - - /** - * Returns the path where output files of this JobCollection are stored. - * - * @return the path where output files of this JobCollection are stored. - */ - public String getOutputPath() { - return outputPath; - } - - protected void setOutputPath(String outputPath) { - if (!outputPath.contains(OUTPUT_DIR)) - this.outputPath = outputPath + OUTPUT_DIR; - else - this.outputPath = outputPath; - } - - /** - * Returns a list of GEJobDescription objects that represent descriptions - * for all sub-jobs of this job collection. - * - * @return a list of {@link GEJobDescription} objects that represent - * descriptions for all sub-jobs of this job collection. - */ - public ArrayList getSubJobDescriptions() { - return subJobDescriptions; - } - - protected void setSubJobDescriptions( - ArrayList subJobDescriptions) { - this.subJobDescriptions = subJobDescriptions; - } - - protected void saveJobCollection() { - - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - this.setCollectionStatus("CREATED"); - this.setStartTimestamp(getCurrentUTCTimestamp()); - session.save(this); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - throw he; - } finally { - session.close(); - } - } - - protected void delete() { - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - session.delete(this); - - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - } - - /** - * This method retrieves all running JobCollections for the specified user. - * A running JobCollection is a collection whose state can be in one of the - * following possibilities: - *
    - *
  • CREATED: when the collection was just created and none of its - * sub-jobs was still submitted;
  • - *
  • RUNNING: when at least one of its sub-jobs aren't in a final status;
  • - *
  • SUBMITTING_FINAL_JOB: when the collection is an instance of - * {@link WorkflowN1} and its final job was just submitted;
  • - *
  • RUNNING_FINAL_JOB: when the final job of a {@link WorkflowN1} are - * still running.
  • - *
- * - * @param commonName - * for which you want to retrieve running JobCollections. - * @return list of all running JobCollections for the specified common name. - */ - public static Vector getRunningJobCollections( - String commonName) { - - Vector result = new Vector(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - Query q = session - .createQuery("from JobCollection where commonName = :commonName and collectionStatus <> 'DONE' and collectionStatus <> 'Aborted' "); - q.setParameter("commonName", commonName); - List activeJobCollections = q.list(); - for (JobCollection jobCollection : activeJobCollections) - result.add(jobCollection); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - - } finally { - session.close(); - } - return result; - - } - - /** - * This method retrieves all successfully completed JobCollections for the - * specified user. - * - * @param commonName - * for which you want to retrieve all successfully completed - * JobCollections. - * @return list of all successfully completed JobCollections for the - * specified common name. - */ - public static Vector getDoneJobCollections(String commonName) { - Vector result = new Vector(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - Query q = session - .createQuery("from JobCollection where commonName = :commonName and collectionStatus = 'DONE'"); - q.setParameter("commonName", commonName); - List activeJobCollections = q.list(); - for (JobCollection jobCollection : activeJobCollections) - result.add(jobCollection); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - - } finally { - session.close(); - } - return result; - } - - /** - * This method retrieves all JobCollections for a specified user. - * - * @param commonName - * of the user for which you want retrieve active JobCollectios. - * @return a {@link Vector} of active JobCollections for the spicified user. - */ - public static Vector getActiveJobCollectionsByName( - String commonName) { - - Vector result = new Vector(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - Query q = session - .createQuery("from JobCollection where commonName = :commonName "); - q.setParameter("commonName", commonName); - List activeJobCollections = q.list(); - for (JobCollection jobCollection : activeJobCollections) - result.add(jobCollection); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - - } finally { - session.close(); - } - return result; - - } - - /** - * Returns the JobCollection with the specified id. - * - * @param jobCollectionId - * JobCollection id. - * @return the {@link JobCollection} with the specified id - */ - public static JobCollection getJobCollection(int jobCollectionId) { - - JobCollection result = new JobCollection(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Query q = session.createQuery("from JobCollection where id = :id "); - q.setParameter("id", jobCollectionId); - List activeJobCollections = q.list(); - - try { - if (activeJobCollections.size() == 1) { - result = activeJobCollections.get(0); - } else - // Gestire - System.out.println("Multiple row in JobCollections"); - } catch (HibernateException he) { - he.printStackTrace(); - } finally { - session.close(); - } - return result; - } - - /** - * Returns a boolean that represent if this collection is in final status or - * not. A JobCollection is in final status if all its sub-jobs aren't in - * RUNING or in SUBMITTED state. - * - * @return true if JobCollection is in final status, false otherwise. - */ - public boolean isInFinalStatus() { - boolean result = false; - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - - Query q = session - .createSQLQuery("SELECT count(*) FROM ActiveGridInteractions WHERE id_job_collection = :jobCollectionId AND (status <> 'RUNNING' AND status <> 'SUBMITTED')"); - q.setParameter("jobCollectionId", this.getId()); - java.math.BigInteger tmp = (java.math.BigInteger) q.uniqueResult(); - int activeJobCont = tmp.intValue(); -// q = session -// .createSQLQuery("SELECT count(*) FROM ActiveGridInteractions WHERE id_job_collection = :jobCollectionId"); -// q.setParameter("jobCollectionId", this.getId()); -// java.math.BigInteger tmp1 = (java.math.BigInteger) q.uniqueResult(); -// int totalJobCont = tmp1.intValue(); -// if (activeJobCont == this.getTaskCounter() || totalJobCont < this.getTaskCounter()) - if (activeJobCont == this.getTaskCounter()) - result = true; - else - result = false; - - // Query q = session - // .createQuery("from GEActiveGridInteraction where id_job_collection = :jobCollectionId AND (status = 'RUNNING' OR status = 'SUBMITTED')"); - // q.setParameter("jobCollectionId", this.getId()); - - // List activeJobInCollections = q.list(); - // if (activeJobInCollections.size() == 0) - // // La collection è in uno stato finale - // result = true; - // else - // result = false; - - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - - } finally { - session.close(); - } - return result; - } - - /** - * This method handles state updating for this JobCollection. - * - * @param inFinalStatus - */ - public void updateJobCollectionStatus(boolean inFinalStatus) { - - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - String newStatus = ""; - - tx = session.beginTransaction(); - - if (inFinalStatus) { - Query q = session - .createSQLQuery("SELECT count(*) FROM ActiveGridInteractions WHERE id_job_collection = :jobCollectionId AND status = 'DONE'"); - q.setParameter("jobCollectionId", this.getId()); - java.math.BigInteger tmp = (java.math.BigInteger) q - .uniqueResult(); - int result = tmp.intValue(); - - if (result == this.getTaskCounter()) - // this.setCollectionStatus("DONE"); - newStatus = "DONE"; - else - // this.setCollectionStatus("Aborted"); - newStatus = "Aborted"; - this.setEndTimestamp(getCurrentUTCTimestamp()); - - // session.update(this); - } else if (!this.getCollectionStatus().equals("RUNNING")) { - // this.setCollectionStatus("RUNNING"); - newStatus = "RUNNING"; - } else - newStatus = this.getCollectionStatus(); - - if (!newStatus.equals(this.getCollectionStatus())) { - this.setCollectionStatus(newStatus); - session.update(this); - } - - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - - } finally { - session.close(); - } - - } - - @Override - public String toString() { - return "JobCollection [id=" + id + ", description=" + description - + ", commonName=" + commonName + ", taskCounter=" + taskCounter - + "]"; - } - - protected Timestamp getCurrentUTCTimestamp() { - Calendar calendar = Calendar.getInstance(); - java.util.Date date = calendar.getTime(); - TimeZone tz = calendar.getTimeZone(); - - long msFromEpochGMT = date.getTime(); - - int offsetFromUTC = tz.getOffset(msFromEpochGMT); - - Calendar UTCCalendar = Calendar - .getInstance(TimeZone.getTimeZone("GMT")); - UTCCalendar.setTime(date); - UTCCalendar.add(Calendar.MILLISECOND, -offsetFromUTC); - - Timestamp currentTimestamp = new Timestamp( - UTCCalendar.getTimeInMillis()); - return currentTimestamp; - } - - /** - * This method closes a JobCollection with "Aborted" state because at least - * one of its sub-job has been unsucessfully completed for a number of times - * greater than maximum re-submission attempts allowed. - * - * @param dbInt - * an interface to the database where make persistent this - * information. - */ - public void abortCollection(UsersTrackingDBInterface dbInt) { - ClosedJobCollection abortedCollection = new ClosedJobCollection( - this.commonName, this.description, this.taskCounter, - this.collectionStatus, this.startTimestamp, this.endTimestamp, - this.getClass().getSimpleName()); - abortedCollection.saveClosedJobCollection(); - logger.info("Aborted Collection inserted: " - + abortedCollection.toString()); - - this.delete(); - - List listOfActiveGridInteractions = GEActiveGridInteraction.findActiveJobForJobCollection(this.getId()); - - for (GEActiveGridInteraction activeGridInteraction : listOfActiveGridInteractions){ -// if(!activeGridInteraction.getStatus().equals("DONE")){ -// GEJobDescription descr = GEJobDescription.findJobDescriptionByJobId(activeGridInteraction.getJobId()); -// if(descr.getId()!=0) -// descr.delete(); -// } - dbInt.CloseGridInteraction(activeGridInteraction.getId().intValue(), abortedCollection.getId() ); - } - - // TODO rimovere eventuali directory di job DONE - -// if(!this.getUserEmail().equals("")){ -// MailUtility m = new MailUtility(this.getUserEmail(), this.getDescription(), MailUtility.ContentMessage.SUBMISSION_ERROR); -// m.sendMail(); -// } - - } - - /** - * This method moves a successfully completed JobCollection from the - * ActiveJobJollections database table to the completed one. - * - * @return the auto-generated id for the completed JobCollection, just added - * in JobCollections table. - */ - public int close() { - ClosedJobCollection doneCollection = new ClosedJobCollection( - this.commonName, this.description, this.taskCounter, - this.collectionStatus, this.startTimestamp, this.endTimestamp, - this.getClass().getSimpleName()); - doneCollection.saveClosedJobCollection(); - logger.info("Done Collection inserted: " + doneCollection.toString()); - this.delete(); - return doneCollection.getId(); - } - - /** - * This method completes a JobCollection by making an archive of the output - * directory of this collection. Furthermore, it sends an email to the user - * to notify the JobCollection completed. - * - * @param jobData - * a String[] with job information used in the notification email - * sent to the user. - */ - public void completeCollection(String[] jobData) { - - logger.info("creating a tgz archive containing output files..."); - - String collectionOutputDirectory = JSagaJobSubmission - .removeNotAllowedCharacter(this.getDescription()); - - // logger.info("tar czvf "+this.getOutputPath()+ - // collectionOutputDirectory + "_" + this.getId()+".tgz "+ - // this.getOutputPath() + collectionOutputDirectory + "_" + - // this.getId()); - logger.info("tar czvf " + this.getOutputPath() - + collectionOutputDirectory + "_" + this.getId() - + ".tgz --directory=" + this.getOutputPath() + " " - + collectionOutputDirectory + "_" + this.getId()); - - Process process; - try { - // process = Runtime.getRuntime().exec("tar czvf " - // +this.getOutputPath()+ collectionOutputDirectory + "_" - // +this.getId()+".tgz "+this.getOutputPath() + - // collectionOutputDirectory + "_" +this.getId()); - process = Runtime.getRuntime().exec( - "tar czvf " + this.getOutputPath() - + collectionOutputDirectory + "_" + this.getId() - + ".tgz --directory=" + this.getOutputPath() + " " - + collectionOutputDirectory + "_" + this.getId()); - process.waitFor(); - // deleting folder... - String command = "rm -Rf " + this.getOutputPath() - + collectionOutputDirectory + "_" + this.getId(); - logger.info(command); - process = Runtime.getRuntime().exec(command); - process.waitFor(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - if (this.getUserEmail() != null && !this.getUserEmail().equals("")) { - - if (!jobData[11].equals("")) { - logger.debug("Sending email for completed job collection: " - + this.toString()); - ContentMessage cm; - if (this instanceof WorkflowN1) - cm = ContentMessage.WORKFLOW_N1; - else - cm = ContentMessage.JOB_COLLECTION; - MailUtility m = new MailUtility(this.getUserEmail(), - jobData[9], jobData[10], this.getDescription(), cm); - m.sendMail(); - } - - } - - } - - /** - * Returns a String[] with some JobCollection information. - * - * @return a String[] with some JobCollection information - */ - public String[] getCollectionInfos() { - - String[] collectionInfos = new String[6]; - - collectionInfos[0] = "" + this.getId(); - collectionInfos[3] = this.description; - collectionInfos[4] = "" + this.startTimestamp; - collectionInfos[5] = this.collectionStatus; - - return collectionInfos; - } -} diff --git a/it/infn/ct/GridEngine/JobCollection/JobCollectionSubmission.java b/it/infn/ct/GridEngine/JobCollection/JobCollectionSubmission.java deleted file mode 100644 index ddf6cdf..0000000 --- a/it/infn/ct/GridEngine/JobCollection/JobCollectionSubmission.java +++ /dev/null @@ -1,566 +0,0 @@ -package it.infn.ct.GridEngine.JobCollection; - -import it.infn.ct.GridEngine.Job.InfrastructureInfo; -import it.infn.ct.GridEngine.Job.JSagaJobSubmission; -import it.infn.ct.GridEngine.JobResubmission.GEJobDescription; -import it.infn.ct.GridEngine.UsersTracking.ActiveInteractions; -import it.infn.ct.GridEngine.UsersTracking.UsersTrackingDBInterface; - -import java.util.ArrayList; -import java.util.Vector; - -import org.apache.log4j.Logger; - -/** - * This class allow to submit a collection of job to the Grid Infrastructure A - * collection can be: - *
    - *
  • an instance of {@link JobCollection}: that represent a set of jobs - * running parallel; - *
  • an instance of {@link WorkflowN1}: that represent a simple work flow - * where the first level output file are input file for a final job. - *
- * - * @author mario - * - */ -public class JobCollectionSubmission { - - // oggetto che rappresenta la collezione da sottomettere - private JobCollection jobCollection; - - private boolean inAppServer = true; - private String DB = ""; - private String DBUser = ""; - private String DBUserPwd = ""; - - private static final Logger logger = Logger - .getLogger(JobCollectionSubmission.class); - - /** - * Constructs a JobCollectionSubmission object that can be used for - * submission, accepts a {@link JobCollection} object that is the submitting - * collection. - * - * @param jobCollection - * the submitting collection. - */ - public JobCollectionSubmission(JobCollection jobCollection) { - // Costruttore richiamato se ci troviamo su application server. - setJobCollection(jobCollection); - } - - /** - * Constructs a JobCollectionSubmission object that can be used for - * submission, accepts the local database connection parameters and a - * {@link JobCollection} object that is the submitting collection. - * - * @param dB - * database name - * @param dBUser - * database username - * @param dBUserPwd - * database password - * @param jobCollection - * the submitting collection. - */ - public JobCollectionSubmission(String dB, String dBUser, String dBUserPwd, - JobCollection jobCollection) { - - this(jobCollection); // Chiamo il costruttore di default - // Setto i parametri di connessione locali - this.DB = dB; - this.DBUser = dBUser; - this.DBUserPwd = dBUserPwd; - - this.inAppServer = false; - - } - - /** - * Returns the submitting {@link JobCollection} object. - * - * @return the submitting collection. - */ - public JobCollection getJobCollection() { - return jobCollection; - } - - /** - * Sets the submitting {@link JobCollection} object. - * - * @param jobCollection - * the submitting collection. - */ - public void setJobCollection(JobCollection jobCollection) { - this.jobCollection = jobCollection; - } - - /** - * Returns true if the application is running on a application - * server. - * - * @return true if the application is running on a application - * server, false otherwise. - */ - public boolean isInAppServer() { - return inAppServer; - } - - // public void setInAppServer(boolean inAppServer) { - // this.inAppServer = inAppServer; - // } - - public void submitJobCollection(InfrastructureInfo[] infrastructures, - String tcpAddress, int gridInteractionId) {// array di infra e - // scegiere random a - // aqual submit - - for (int i = 0; i < jobCollection.getSubJobDescriptions().size(); i++) { - GEJobDescription descr = jobCollection.getSubJobDescriptions().get( - i); - JSagaJobSubmission jobSubmission = createJobSubmissionObject( - getRandomInfrastructure(infrastructures), descr); - - jobSubmission.submitJobAsync(jobCollection.getCommonName(), - tcpAddress, gridInteractionId, - jobCollection.getDescription() + "_" + i, - jobCollection.getId()); - } - - } - - private InfrastructureInfo getRandomInfrastructure( - InfrastructureInfo[] infrastructures) { - if (infrastructures == null) - return null; - - int index = (int) ((Math.random()) * (new Integer( - infrastructures.length).doubleValue())); - if (index == infrastructures.length) - index--; - if (logger.isDebugEnabled()) - logger.debug("Infrastructure selected = " + infrastructures[index]); - - return infrastructures[index]; - } - - private JSagaJobSubmission createJobSubmissionObject( - InfrastructureInfo infrastructure, GEJobDescription descr) { - - JSagaJobSubmission jobSubmission = null; - - if (inAppServer) - jobSubmission = new JSagaJobSubmission(descr); - else - jobSubmission = new JSagaJobSubmission(DB, DBUser, DBUserPwd, descr); - - if (infrastructure.getMiddleware().equals("glite")) { - if (!(infrastructure.getBDII().equals(""))) - jobSubmission.setBDII(infrastructure.getBDII()); - // ******MARIO***** - else - jobSubmission.setCEList(infrastructure.getCEList()); - // **************** - } - - if (infrastructure.getResourcemanagerList() != null) - jobSubmission.setWMSList(infrastructure.getResourcemanagerList()); - - if ((infrastructure.getMiddleware().equals("glite")) - || (infrastructure.getMiddleware().equals("wsgram"))) { - if (infrastructure.getUserProxy().equals("")) - jobSubmission.useRobotProxy(infrastructure.getETokenServer(), - infrastructure.getETokenServerPort(), - infrastructure.getProxyId(), infrastructure.getVO(), - infrastructure.getFQAN(), true, true, jobCollection.getCommonName()); - else - jobSubmission.setUserProxy(infrastructure.getUserProxy()); - } else if (infrastructure.getMiddleware().equals("unicore")) { - jobSubmission.setJKS(infrastructure.getKeystore(), - infrastructure.getPassword()); - } else if (infrastructure.getMiddleware().equals("ourgrid")) { - jobSubmission.setOurGridCredential(infrastructure.getUserName(), - infrastructure.getPassword()); - } else if (infrastructure.getMiddleware().equals("bes-genesis2")) { - jobSubmission.setGenesisJKS(infrastructure.getKeystore(), - infrastructure.getPassword()); - } else if (infrastructure.getMiddleware().equals("ssh")) { - jobSubmission.setSSHCredential(infrastructure.getUserName(), - infrastructure.getPassword()); - } - - if ((infrastructure.getMiddleware().equals("ourgrid")) - && (!(descr.getExecutable().equals("/bin/sh")))) { - jobSubmission.setExecutable("/bin/sh"); - - if (!(descr.getArguments().equals(""))) - descr.setExecutable(descr.getExecutable() + " " - + descr.getArguments()); - - jobSubmission.setArguments(descr.getArguments()); - } else { - if (!(descr.getExecutable().equals(""))) - jobSubmission.setExecutable(descr.getExecutable()); - - if (!(descr.getArguments().equals(""))) - jobSubmission.setArguments(descr.getArguments()); - } - - if (descr.getQueue() != null && !(descr.getQueue().equals(""))) - jobSubmission.setJobQueue(descr.getQueue()); - - if (!(descr.getOutputPath().equals(""))) - jobSubmission.setOutputPath(descr.getOutputPath()); - - if (!(descr.getOutput().equals(""))) - jobSubmission.setJobOutput(descr.getOutput()); - - if (!(descr.getError().equals(""))) - jobSubmission.setJobError(descr.getError()); - - if (!descr.getInputFiles().equals("")) - jobSubmission.setInputFiles(descr.getInputFiles()); - // TODO DA FARE - // if (!(outputFiles.equals(""))) - // jobSubmission.setOutputFiles(descr.get); - - if (descr.getTotalCPUCount() != null - && !(descr.getTotalCPUCount().equals(""))) - jobSubmission.setTotalCPUCount(descr.getTotalCPUCount()); - - if (descr.getSPDMVariation() != null - && !(descr.getSPDMVariation().equals(""))) - jobSubmission.setSPMDVariation(descr.getSPDMVariation()); - - if (descr.getNumberOfProcesses() != null - && !(descr.getNumberOfProcesses().equals(""))) - jobSubmission.setNumberOfProcesses(descr.getNumberOfProcesses()); - - // if (infrastructure.getMiddleware().equals("glite")) { - // if (infrastructure.getSWTag().equals("")) { - // if (descr.getJDLRequirements() != null) - // jobSubmission.setJDLRequirements(descr.getJDLRequirements()); - // } else { - // // - // Member("VO-prod.vo.eu-eela.eu-OCTAVE-3.2.4",other.GlueHostApplicationSoftwareRunTimeEnvironment); - // String requirements[] = null; - // if (JDLRequirements != null) { - // requirements = new String[JDLRequirements.length + 1]; - // requirements[0] = "JDLRequirements=(Member(\"" - // + infrastructure.getSWTag() - // + "\", other.GlueHostApplicationSoftwareRunTimeEnvironment))"; - // for (int i = 0; i < JDLRequirements.length; i++) - // requirements[i + 1] = JDLRequirements[i]; - // } else { - // requirements = new String[1]; - // requirements[0] = "JDLRequirements=(Member(\"" - // + infrastructure.getSWTag() - // + "\", other.GlueHostApplicationSoftwareRunTimeEnvironment))"; - // } - // jobSubmission.setJDLRequirements(requirements); - // } - // } - - return jobSubmission; - } - - public static void main(String[] args) { - logger.info("Submitting Collection"); - - InfrastructureInfo infrastructures[] = new InfrastructureInfo[1]; - - String collectionDescr = "Collection"; - - String sshList[] = { "ssh://gilda-liferay-vm-06.ct.infn.it:5000" }; - String sshList1[] = { "ssh://gilda-liferay-vm-15.ct.infn.it:5000" }; - String sshList2[] = { "ssh://api.ct.infn.it" }; - String sshList3[] = {"ssh://90.147.74.95"}; //jobtest - String wmsList[] = {"wms://wmsdecide.dir.garr.it:7443/glite_wms_wmproxy_server"}; - String wmsListSEEGRID[] = {"wms://wms01.afroditi.hellasgrid.gr:7443/glite_wms_wmproxy_server"}; -// "wms://wms.magrid.ma:7443/glite_wms_wmproxy_server"}; -// "wms://wmsdecide.dir.garr.it:7443/glite_wms_wmproxy_server" }; - // wms://wms-4.dir.garr.it:7443/glite_wms_wmproxy_server - // infrastructures[0] = new InfrastructureInfo("SSH Infrastructure", - // "ssh", "liferayadmin", "liferayadmin", sshList); - // infrastructures[1] = new InfrastructureInfo("SSH Infrastructure", - // "ssh", "liferayadmin", "CiematANDInfn2013", sshList1); -// infrastructures[0] = new InfrastructureInfo("SSH Infrastructure", -// "ssh", "root", "Passw0rd!", sshList2); -//// - infrastructures[0] = new InfrastructureInfo("SSH Infrastructure", - "ssh", "jobtest", sshList3); - - -// infrastructures[0] = new InfrastructureInfo("EUMEDGRID", -// "ldap://bdii.eumedgrid.eu:2170", wmsListSEEGRID, -// "etokenserver.ct.infn.it", "8082", -// "bc681e2bd4c3ace2a4c54907ea0c379b", "see", "see"); -// infrastructures[0] = new InfrastructureInfo("gridit", -// "ldap://gridit-bdii-01.cnaf.infn.it:2170", wmsList, -// "etokenserver.ct.infn.it", "8082", -// "332576f78a4fe70a52048043e90cd11f", "gridit", "gridit"); - - // String wmsListUnicore[] = { - // "unicore://zam052v01.zam.kfa-juelich.de:8080/?Target=EMI-UNICOREX" }; - // InfrastructureInfo infrastructure = new InfrastructureInfo("Unicore", - // "unicore", "/tmp/robot2012.jks", "robot2012", wmsListUnicore); - - ArrayList descriptions = new ArrayList(); - - for (int i = 0; i < 2; i++) { - GEJobDescription description = new GEJobDescription(); - description.setExecutable("/bin/sh"); - switch (i) { - case 0: -// description.setExecutable("/bin/hostname"); - description.setArguments("-f"); -// description.setInputFiles("./hostname.sh"); -// description.setOutputFiles("output.README"); - break; - case 1: -// description.setExecutable("/bin/ls"); - description.setArguments("-a"); -// description.setArguments("ls.sh"); -// description.setInputFiles("./ls.sh"); - break; - case 2: -// description.setExecutable("/bin/pwd"); -// description.setArguments("pwd.sh"); -// description.setInputFiles("./pwd.sh"); - break; - default: - if ((i % 2) != 0) { -// description.setExecutable("ifconfig"); - description.setArguments("ifconfig.sh"); - description - .setInputFiles("./ifconfig.sh"); - } else { -// description.setExecutable("/bin/ps"); - description.setArguments("ps.sh"); - description.setInputFiles("./ps.sh"); - } - break; - } - - description.setOutputPath("/tmp"); - if ((i % 2) != 0) - description.setOutput("myOutput-" + i + ".txt"); - else - description.setOutput("PippomyOutput-" + i + ".txt"); - description.setError("myError-" + i + ".txt"); - - descriptions.add(description); - } - - GEJobDescription finalJobDescription = new GEJobDescription(); -// finalJobDescription.setExecutable("/bin/ls"); - finalJobDescription.setExecutable("ls.sh"); - finalJobDescription.setArguments("./ls.sh"); - - String tmp = ""; - for (int i = 0; i < descriptions.size(); i++) { - if (tmp.equals("")) - tmp = descriptions.get(i).getOutput(); - else - tmp += "," + descriptions.get(i).getOutput(); - } - - finalJobDescription - .setInputFiles(tmp - + ",./ls.sh"); - - finalJobDescription.setOutputPath("/tmp"); - finalJobDescription.setOutput("myOutput-FinalJob.txt"); - finalJobDescription.setError("myError-FinalJob.txt"); - -// JobCollection wf1 = new WorkflowN1("test", "Workflow N-1 ALL", -// "mario.torrisi@ct.infn.it", "/tmp", descriptions, -// finalJobDescription); -// JobCollectionSubmission tmpJobCollectionSubmission1 = new -// JobCollectionSubmission( -// "jdbc:mysql://localhost/userstracking", "tracking_user", -// "usertracking", wf1); -// tmpJobCollectionSubmission1.submitJobCollection(infrastructures, -// "193.206.208.183:8162", 81); - -// JobCollection wf = new WorkflowN1("mtorrisi", "Workflow N-1","mario.torrisi@ct.infn.it|mario.torrisi@ct.infn.it", "/tmp", -// descriptions, -// finalJobDescription, new String[] { "Pippo","3" }); -// // -// JobCollectionSubmission tmpJobCollectionSubmission = new -// JobCollectionSubmission( -// "jdbc:mysql://localhost/userstracking", "tracking_user", -// "usertracking", wf); -// tmpJobCollectionSubmission.submitJobCollection(infrastructures, -// "193.206.208.183:8162", 1); - - /*SOTTOMETTO UNA NUOVA COLLEZIONE - JobCollection collection = new JobCollection("test", - "Collection - TEST - ", "/tmp", descriptions); - JobCollectionSubmission tmpJobCollectionSubmission = new JobCollectionSubmission( - "jdbc:mysql://localhost/userstracking", "tracking_user", - "usertracking", collection); - - tmpJobCollectionSubmission.submitJobCollection(infrastructures, - "193.206.208.183:8162", 1); - // Fine sottomissione nuova collezione*/ - JobParametric p = new JobParametric("test", - "Parametric Job - mtorrisi", "mario.torrisi@ct.infn.it", - "/tmp", descriptions, "hostname.sh"); - - JobCollectionSubmission tmpJobCollectionSubmission = new - JobCollectionSubmission( - "jdbc:mysql://localhost/userstracking", "tracking_user", - "usertracking", p); - - tmpJobCollectionSubmission.submitJobCollection(infrastructures, - "193.206.208.183:8162", 81); - System.out.println("Vado in sleep..."); - try { - Thread.sleep(60000); - } catch (Exception e) { - } - - System.out.println("Checking jobs..."); - - UsersTrackingDBInterface DBInterface = new UsersTrackingDBInterface( - "jdbc:mysql://localhost/userstracking", "tracking_user", - "usertracking"); - String status = "RUNNING"; - Vector jobList = null; - - while (status.equals("RUNNING")) { - try { - Thread.sleep(15000); - } catch (Exception e) { - } - - System.out.println("Users running jobs = " - + DBInterface.getTotalNumberOfUsersWithRunningJobs()); - status = "DONE"; - // jobList = DBInterface.getActiveJobsListByName("mtorrisi"); - jobList = DBInterface.getActiveInteractionsByName("mtorrisi"); - - if (jobList != null) { - for (int i = 0; i < jobList.size(); i++) { - - if (jobList.get(i).getSubJobs() == null) { - - System.out - .println("DBID = " - + jobList.elementAt(i) - .getInteractionInfos()[0] - + " Portal = " - + jobList.elementAt(i) - .getInteractionInfos()[1] - + " - Application = " - + jobList.elementAt(i) - .getInteractionInfos()[2] - + " - Description = " - + jobList.elementAt(i) - .getInteractionInfos()[3] - + " - Timestamp = " - + jobList.elementAt(i) - .getInteractionInfos()[4] - + " - Status = " - + jobList.elementAt(i) - .getInteractionInfos()[5]); - - } else { - System.out - .println("***COLLECTION INFOS*** DBID = " - + jobList.elementAt(i) - .getInteractionInfos()[0] - + " Portal = " - + jobList.elementAt(i) - .getInteractionInfos()[1] - + " - Application = " - + jobList.elementAt(i) - .getInteractionInfos()[2] - + " - Description = " - + jobList.elementAt(i) - .getInteractionInfos()[3] - + " - Timestamp = " - + jobList.elementAt(i) - .getInteractionInfos()[4] - + " - Status = " - + jobList.elementAt(i) - .getInteractionInfos()[5]); - Vector subJobs = jobList.get(i).getSubJobs(); - for (String[] subJobInfos : subJobs) - System.out.println("\t|_***SUBJOB INFOS*** DBID = " - + subJobInfos[0] + " Portal = " - + subJobInfos[1] + " - Application = " - + subJobInfos[2] + " - Description = " - + subJobInfos[3] + " - Timestamp = " - + subJobInfos[4] + " - Status = " - + subJobInfos[5]); - } - if (!jobList.elementAt(i).getInteractionInfos()[5] - .equals("DONE")) - status = "RUNNING"; - } - } - - if (status.equals("RUNNING")) { - try { - Thread.sleep(15000); - } catch (Exception e) { - } - } - - } - - String allTarPath = DBInterface - .createAllJobsArchive("test", "/tmp"); - System.out.println("allTarPath=" + allTarPath); - // - Vector jobList1 = null; - jobList1 = DBInterface.getDoneInteractionsByName("test"); - - if (jobList1.size() == 0) - System.out.println("No jobs for user test"); - for (int i = 0; i < jobList1.size(); i++) { - if (jobList1.get(i).getSubJobs() == null) { - - System.out.println("DBID = " - + jobList1.elementAt(i).getInteractionInfos()[0] - + " Portal = " - + jobList1.elementAt(i).getInteractionInfos()[1] - + " - Application = " - + jobList1.elementAt(i).getInteractionInfos()[2] - + " - Description = " - + jobList1.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " - + jobList1.elementAt(i).getInteractionInfos()[4] - + " - Status = " - + jobList1.elementAt(i).getInteractionInfos()[5]); - - } else { - System.out.println("***COLLECTION INFOS*** DBID = " - + jobList1.elementAt(i).getInteractionInfos()[0] - + " Portal = " - + jobList1.elementAt(i).getInteractionInfos()[1] - + " - Application = " - + jobList1.elementAt(i).getInteractionInfos()[2] - + " - Description = " - + jobList1.elementAt(i).getInteractionInfos()[3] - + " - Timestamp = " - + jobList1.elementAt(i).getInteractionInfos()[4] - + " - Status = " - + jobList1.elementAt(i).getInteractionInfos()[5]); - Vector subJobs = jobList1.get(i).getSubJobs(); - for (String[] subJobInfos : subJobs) - System.out.println("\t|_***SUBJOB INFOS*** DBID = " - + subJobInfos[0] + " Portal = " + subJobInfos[1] - + " - Application = " + subJobInfos[2] - + " - Description = " + subJobInfos[3] - + " - Timestamp = " + subJobInfos[4] - + " - Status = " + subJobInfos[5]); - } - } - - } - -} diff --git a/it/infn/ct/GridEngine/JobCollection/JobParametric.java b/it/infn/ct/GridEngine/JobCollection/JobParametric.java deleted file mode 100644 index 5463906..0000000 --- a/it/infn/ct/GridEngine/JobCollection/JobParametric.java +++ /dev/null @@ -1,47 +0,0 @@ -package it.infn.ct.GridEngine.JobCollection; - -import it.infn.ct.GridEngine.JobResubmission.GEJobDescription; - -import java.io.File; -import java.util.ArrayList; - -public class JobParametric extends JobCollection { - - private String executable; - - public JobParametric(String commonName, String description, - String outputPath, ArrayList subJobDescriptions, - String executable) { - this(commonName, description, null, outputPath, subJobDescriptions, executable); - } - - public JobParametric(String commonName, String description, - String userEmail, String outputPath, - ArrayList subJobDescriptions, String executable) { - File f = new File(executable); - this.executable=f.getName(); - - super.setCommonName(commonName); - super.setDescription(description); - super.setUserEmail(userEmail); - super.setOutputPath(outputPath); - for (GEJobDescription geJobDescription : subJobDescriptions) { - geJobDescription.setExecutable(this.getExecutable()); - if(!geJobDescription.getInputFiles().contains(executable)) - geJobDescription.setInputFiles(geJobDescription.getInputFiles()+","+executable); - } - super.setSubJobDescriptions(subJobDescriptions); - super.setTaskCounter(subJobDescriptions.size()); - - saveJobCollection(); - } - - protected JobParametric(){ - super(); - } - - public String getExecutable() { - return executable; - } - -} diff --git a/it/infn/ct/GridEngine/JobCollection/WorkflowN1.java b/it/infn/ct/GridEngine/JobCollection/WorkflowN1.java deleted file mode 100644 index 6f0bc3d..0000000 --- a/it/infn/ct/GridEngine/JobCollection/WorkflowN1.java +++ /dev/null @@ -1,474 +0,0 @@ -package it.infn.ct.GridEngine.JobCollection; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.Transaction; - -import it.infn.ct.GridEngine.Job.JSagaJobSubmission; -import it.infn.ct.GridEngine.JobResubmission.GEActiveGridInteraction; -import it.infn.ct.GridEngine.JobResubmission.GEJobDescription; -import it.infn.ct.GridEngine.JobResubmission.GESessionFactoryUtil; -import it.infn.ct.GridEngine.UsersTracking.UsersTrackingDBInterface; - -//@Entity -//@Table(name="ActiveJobCollections") -//@DiscriminatorValue("WORKFLOW_N1") -/** - * This class represent a simple work flow which performs a number of parallel - * jobs, the outputs of this jobs are inputs for the final job. When final job - * has been successfully completed the work flow goes in DONE state. - * - * @author mario - * - */ -public class WorkflowN1 extends JobCollection { - -// @Column (name="id_final_job") - private Long idFinalJob; - -// @Transient - private GEJobDescription finalJobDescription; -// @Transient - private String[] inputFilePrefixes; - - /** - * Constructs a WorkFlowN1 object without a specified user email and in - * which all first level jobs outputs are inputs for final job. - * - * @param commonName - * a string that identifies the user - * @param description - * a string that gives a work flow description - * @param outputPath - * a string that specifies the path where the output file for the - * work flow are stored - * @param subJobDescriptions - * an ArrayList of GEJobDescription that represents the entire - * sub-job descriptions - * @param finalJobDescription - * description of the work flow final job. - */ - public WorkflowN1(String commonName, String description, - String outputPath, ArrayList subJobDescriptions, - GEJobDescription finalJobDescription) { - // super(commonName, description, outputPath, subJobDescriptions); - this(commonName, description, null, outputPath, subJobDescriptions, - finalJobDescription, null); - // this.finalJobDescription = finalJobDescription; - } - - /** - * Constructs a WorkFlowN1 object without a specified user email and in - * which all first level jobs outputs are inputs for final job. - * - * @param commonName - * a string that identifies the user - * @param description - * a string that gives a work flow description - * @param outputPath - * a string that specifies the path where the output file for the - * work flow are stored - * @param subJobDescriptions - * an ArrayList of GEJobDescription that represents the entire - * sub-job descriptions - * @param finalJobDescription - * description of the work flow final job. - * @param finalJobInputFilePrefixes - * a String[] with the first level output file names must have to - * become input file for the final job. - */ - public WorkflowN1(String commonName, String description, - String outputPath, ArrayList subJobDescriptions, - GEJobDescription finalJobDescription,String[] finalJobInputFilePrefixes) { - // super(commonName, description, outputPath, subJobDescriptions); - this(commonName, description, null, outputPath, subJobDescriptions, - finalJobDescription, finalJobInputFilePrefixes); - // this.finalJobDescription = finalJobDescription; - } - - /** - * Constructs a WorkFlowN1 object with with the specified user email to - * notify that this work flow is completed. Using this constructor all first - * level jobs outputs are inputs for final job. - * - * @param commonName - * a string that identifies the user - * @param description - * a string that gives a work flow description - * @param userEmail - * email address to notify completed work flow - * @param outputPath - * a string that specifies the path where the output file for the - * work flow are stored - * @param subJobDescriptions - * an ArrayList of GEJobDescription that represents the entire - * sub-job descriptions - * @param finalJobDescription - * description of the work flow final job. - */ - public WorkflowN1(String commonName, String description, - String userEmail, String outputPath, - ArrayList subJobDescriptions, - GEJobDescription finalJobDescription) { - - this(commonName, description, userEmail, outputPath, - subJobDescriptions, finalJobDescription, null); - } - - /** - * Constructs a WorkFlowN1 object with the specified user email to notify - * that this work flow has been completed and a list of prefixes that output - * file names of the first level job must have to become input file of the - * final job. - * - * @param commonName - * a string that identifies the user - * @param description - * a string that gives a work flow description - * @param userEmail - * email address to notify completed work flow - * @param outputPath - * a string that specifies the path where the output file for the - * work flow are stored - * @param subJobDescriptions - * an ArrayList of GEJobDescription that represents the entire - * sub-job descriptions - * @param finalJobDescription - * description of the work flow final job. - * @param finalJobInputFilePrefixes - * a String[] with the first level output file names must have to - * become input file for the final job. - */ - public WorkflowN1(String commonName, String description, - String userEmail, String outputPath, - ArrayList subJobDescriptions, - GEJobDescription finalJobDescription, - String[] finalJobInputFilePrefixes) { - - super.setCommonName(commonName); - super.setDescription(description); - super.setOutputPath(outputPath); - super.setSubJobDescriptions(subJobDescriptions); - super.setTaskCounter(subJobDescriptions.size()); - super.setUserEmail(userEmail); - this.inputFilePrefixes = finalJobInputFilePrefixes; - this.finalJobDescription = finalJobDescription; - - saveJobCollection(); - } - - protected WorkflowN1() { - super(); - } - - /** - * Returns final Job description. - * - * @return final Job description. - */ - public GEJobDescription getFinalJobDescription() { - return finalJobDescription; - } - - protected void setFinalJobDescription(GEJobDescription finalJobDescription) { - this.finalJobDescription = finalJobDescription; - } - - /** - * Returns final job database id. - * - * @return final job database id. - */ - public Long getIdFinalJob() { - return idFinalJob; - } - - private void setIdFinalJob(Long idFinalJob) { - this.idFinalJob = idFinalJob; - } - - /** - * Returns a list of input file prefixes for final job of this work flow. - * - * @return a list of input file prefixes for final job of this work flow. - */ - public String[] getInputFilePrefixes() { - return inputFilePrefixes; - } - - protected void setInputFilePrefixes(String[] inputFilePrefixes) { - this.inputFilePrefixes = inputFilePrefixes; - } - - @Override - protected void saveJobCollection() { - - if (this.inputFilePrefixes != null) { - StringTokenizer tmp = new StringTokenizer( - this.finalJobDescription.getInputFiles(), ","); - String[] oldFinalJobInputFiles = new String[tmp.countTokens()]; - String[] newFinalJobInputFiles = new String[tmp.countTokens()]; - for (int i = 0; tmp.hasMoreTokens(); i++) { - oldFinalJobInputFiles[i] = tmp.nextToken(); - newFinalJobInputFiles[i] = " "; - } - - for (String inputFilePrefix : this.inputFilePrefixes) { - for (int i = 0; i < this.getSubJobDescriptions().size(); i++) - - if (this.getSubJobDescriptions().get(i).getOutput() - .contains(inputFilePrefix)) { - newFinalJobInputFiles[i] = oldFinalJobInputFiles[i]; - } - } - for (int i = 0; i < oldFinalJobInputFiles.length; i++) { - if (oldFinalJobInputFiles[i].contains("/")) - newFinalJobInputFiles[i] = oldFinalJobInputFiles[i]; - } - - this.finalJobDescription.setInputFiles(""); - for (String s : newFinalJobInputFiles) { - - if (this.finalJobDescription.getInputFiles().equals("")) - this.finalJobDescription.setInputFiles(s); - else - this.finalJobDescription - .setInputFiles(this.finalJobDescription - .getInputFiles() + "," + s); - } - - } - - this.finalJobDescription.saveJobDescription(); - this.setIdFinalJob(this.finalJobDescription.getId()); - - super.saveJobCollection(); - } - - // @Override - // public void saveJobCollection() { - // - // this.finalJobDescription.saveJobDescription(); - // this.setIdFinalJob(this.finalJobDescription.getId()); - // - // super.saveJobCollection(); - // } - - /** - * Returns a boolean that represent if this work flow is in final status or - * not. A WorkFlowN1 is in final status if all its sub-jobs (first level sub-jobs and final job) aren't in - * RUNING or in SUBMITTED state. - * - * @return true if WorkFlowN1 is in final status, false otherwise. - */ - @Override - public boolean isInFinalStatus() { - if (!this.getCollectionStatus().equals("SUBMITTING_FINAL_JOB") - && !this.getCollectionStatus().equals("RUNNING_FINAL_JOB")) - return super.isInFinalStatus(); - else { - boolean result = false; - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - - Query q = session - .createSQLQuery("SELECT count(*) FROM ActiveGridInteractions WHERE id_job_collection = :jobCollectionId AND (status <> 'RUNNING' AND status <> 'SUBMITTED')"); - q.setParameter("jobCollectionId", this.getId()); - java.math.BigInteger tmp = (java.math.BigInteger) q - .uniqueResult(); - int activeJobCont = tmp.intValue(); - - if (activeJobCont == this.getTaskCounter() + 1) - result = true; - else - result = false; - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - - } finally { - session.close(); - } - return result; - } - } - - /** - * This method handles state updating for this WorkFlowN1. - * - * @param inFinalStatus - */ - @Override - public void updateJobCollectionStatus(boolean inFinalStatus) { - - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - String newStatus = ""; - - tx = session.beginTransaction(); - - if (inFinalStatus) { - - Query q = session - .createSQLQuery("SELECT count(*) FROM ActiveGridInteractions WHERE id_job_collection = :jobCollectionId AND status = 'DONE'"); - q.setParameter("jobCollectionId", this.getId()); - java.math.BigInteger tmp = (java.math.BigInteger) q - .uniqueResult(); - int result = tmp.intValue(); - - if (this.getCollectionStatus().equals("SUBMITTING_FINAL_JOB") - || this.getCollectionStatus().equals( - "RUNNING_FINAL_JOB")) { - if (result == this.getTaskCounter() + 1) { - newStatus = "DONE"; - this.setEndTimestamp(getCurrentUTCTimestamp()); - } else { - newStatus = "Aborted"; - this.setEndTimestamp(getCurrentUTCTimestamp()); - } - } else if (result == this.getTaskCounter()) { - if (!this.getCollectionStatus().equals( - "SUBMITTING_FINAL_JOB") - && !this.getCollectionStatus().equals( - "RUNNING_FINAL_JOB")) { - // this.setCollectionStatus("SUBMITTING_FINAL_JOB"); - newStatus = "SUBMITTING_FINAL_JOB"; - // this.setTaskCounter(this.getTaskCounter()+1); - } else { - // this.setCollectionStatus("DONE"); - newStatus = "DONE"; - this.setEndTimestamp(getCurrentUTCTimestamp()); - } - } else { - // this.setCollectionStatus("Aborted"); - newStatus = "Aborted"; - this.setEndTimestamp(getCurrentUTCTimestamp()); - } - } else if (this.getCollectionStatus().equalsIgnoreCase( - "SUBMITTING_FINAL_JOB")) { - // this.setCollectionStatus("RUNNING_FINAL_JOB"); - newStatus = "RUNNING_FINAL_JOB"; - } else if (!this.getCollectionStatus().equalsIgnoreCase( - "RUNNING_FINAL_JOB")) { - // this.setCollectionStatus("RUNNING"); - newStatus = "RUNNING"; - } else - newStatus = this.getCollectionStatus(); - - if (!newStatus.equals(this.getCollectionStatus())) { - this.setCollectionStatus(newStatus); - session.update(this); - } - - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - - } finally { - session.close(); - } - - } - - /** - * This method closes a WorkFlowN1 with "Aborted" state because at least - * one of its sub-job or its fina job has been unsucessfully completed for a number of times - * greater than maximum re-submission attempts allowed. - * - * @param dbInt - * an interface to the database where make persistent this - * information. - */ - @Override - public void abortCollection(UsersTrackingDBInterface dbInt) { - super.abortCollection(dbInt); - - GEJobDescription jobDescr = GEJobDescription - .findJobDescriptionById(this.getIdFinalJob()); - if (jobDescr != null) - jobDescr.delete(); - } - - /** - * This method is responsible for the final job submission for this work flow. - * - * @param dbInt an interface to user tracking database. - */ - public void submitFinalJob(UsersTrackingDBInterface dbInt) { - // logger.info("Closing Active sub-jobs..."); - - List doneSubJobs = GEActiveGridInteraction.findActiveJobForJobCollection(this.getId()); - List specialDoneSubJobs = new ArrayList(); - - logger.info("Submitting Final Job collection: " + this.toString()); - JSagaJobSubmission tmpJSaga = new JSagaJobSubmission(dbInt); - - GEJobDescription finalJobDescription = GEJobDescription - .findJobDescriptionById(this.getIdFinalJob()); - StringTokenizer tmp = new StringTokenizer( - finalJobDescription.getInputFiles(), ","); - String[] outpuFilesSuffix = new String[tmp.countTokens()]; - for (int i = 0; tmp.hasMoreTokens(); i++) { - outpuFilesSuffix[i] = tmp.nextToken(); - } - - // for (int i = 0; i 0) { - for (int i = doneSubJobs.size(); i < outpuFilesSuffix.length; i++) - inputFilesPath += "," + outpuFilesSuffix[i]; - } - logger.debug("Final Job inputFilesPath: " + inputFilesPath); - finalJobDescription.setInputFiles(inputFilesPath); - - finalJobDescription.saveJobDescription(); - - tmpJSaga.submitFinalJob(doneSubJobs.get(0), finalJobDescription); - } - -} diff --git a/it/infn/ct/GridEngine/JobResubmission/GEActiveGridInteraction.hbm.xml b/it/infn/ct/GridEngine/JobResubmission/GEActiveGridInteraction.hbm.xml deleted file mode 100644 index cbbaace..0000000 --- a/it/infn/ct/GridEngine/JobResubmission/GEActiveGridInteraction.hbm.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/it/infn/ct/GridEngine/JobResubmission/GEActiveGridInteraction.java b/it/infn/ct/GridEngine/JobResubmission/GEActiveGridInteraction.java deleted file mode 100644 index 5ad7216..0000000 --- a/it/infn/ct/GridEngine/JobResubmission/GEActiveGridInteraction.java +++ /dev/null @@ -1,557 +0,0 @@ -package it.infn.ct.GridEngine.JobResubmission; - -import it.infn.ct.GridEngine.JobCollection.JobCollection; - -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.TimeZone; - -import org.apache.log4j.Logger; -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.Transaction; - -/** - * This class is a persistence class used to mapping an active grid interaction - * in database, with an object. - * - * @author mario - * - */ -public class GEActiveGridInteraction { - - private static final Logger logger = Logger.getLogger(GEActiveGridInteraction.class); - // @Id - // @GeneratedValue - // @Column (name="id") - private Long id; // primary key - - // @Column (name="commonName") - private String commonName; - - // @Column (name="tcpAddress") - private String tcpAddress; - - // @Column (name="timestamp") - private Date timestamp; - - // @Column (name="grid_interaction") - private int gridInteraction; - - // @Column (name="grid_id") - private String jobId; - - // @Column (name="robot_certficate") - private String robotCertificate; - - // @Column (name="proxy_id") - private String proxyId; - - // @Column (name="virtual_organization") - private String VO; - - // @Column (name="fqan") - private String fqan; - - // @Column (name="user_description") - private String userDescription; - - // @Column (name="status") - private String status; - - // @Column (name="grid_ce") - private String CE; - - // @Column (name="latitude") - private float latitude; - - // @Column (name="longitude") - private float longitude; - - // @Column (name="timestamp_endjob") - private Date timestampEndJob; - - // @Column (name="email") - private String email; - - // @Column (name="e_token_eserver") - private String eTokenServer; - - // @Column (name="id_job_collection") - private Integer idJobCollection; - - public GEActiveGridInteraction() { - } - - /** - * Returns the database id for this interaction. - * - * @return the database id for this interaction. - */ - public Long getId() { - return id; - } - - protected void setId(Long id) { - this.id = id; - } - - /** - * Returns the common name of the user who did this interaction. - * - * @return the common name of the user who did this interaction. - */ - public String getCommonName() { - return commonName; - } - - protected void setCommonName(String commonName) { - this.commonName = commonName; - } - - /** - * Returns the IP address where this interaction originated. - * - * @return the IP address where this interaction originated. - */ - public String getTcpAddress() { - return tcpAddress; - } - - protected void setTcpAddress(String tcpAddress) { - this.tcpAddress = tcpAddress; - } - - /** - * Returns the start time stamp for this interaction. - * - * @return the start time stamp for this interaction. - */ - public Date getTimestamp() { - return timestamp; - } - - protected void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - /** - * Returns an identifier of application in a specified portal. - * - * @return an identifier of application in a specified portal. - */ - public int getGridInteraction() { - return gridInteraction; - } - - protected void setGridInteraction(int gridInteraction) { - this.gridInteraction = gridInteraction; - } - - /** - * Returns the grid job identifier. - * - * @return the grid job identifier. - */ - public String getJobId() { - return jobId; - } - - protected void setJobId(String jobId) { - this.jobId = jobId; - } - - /** - * Returns the Robot Certficate. - * - * @return the Robot Certficate. - */ - public String getRobotCertificate() { - return robotCertificate; - } - - protected void setRobotCertificate(String robotCertificate) { - this.robotCertificate = robotCertificate; - } - - /** - * Returns the Proxy identifier. - * - * @return the Proxy identifier. - */ - public String getProxyId() { - return proxyId; - } - - protected void setProxyId(String proxyId) { - this.proxyId = proxyId; - } - - /** - * Returns the Virtual Organization. - * - * @return the Virtual Organization. - */ - public String getVO() { - return VO; - } - - protected void setVO(String vO) { - VO = vO; - } - - /** - * Returns the FQAN. - * - * @return the FQAN - */ - public String getFqan() { - return fqan; - } - - protected void setFqan(String fqan) { - this.fqan = fqan; - } - - /** - * Returns a description for this job. - * - * @return a description for this job. - */ - public String getUserDescription() { - return userDescription; - } - - protected void setUserDescription(String userDescription) { - this.userDescription = userDescription; - } - - /** - * Returns status for this job. - * - * @return status for this job. - */ - public String getStatus() { - return status; - } - - protected void setStatus(String status) { - this.status = status; - } - - /** - * Returns the Compute Element. - * - * @return the Compute Element. - */ - public String getCE() { - return CE; - } - - protected void setCE(String cE) { - CE = cE; - } - - /** - * Returns latitude of the Compute element. - * - * @return latitude of the Compute element. - */ - public float getLatitude() { - return latitude; - } - - protected void setLatitude(float latitude) { - this.latitude = latitude; - } - - /** - * Returns longitude of the Compute element. - * - * @return longitude of the Compute element. - */ - public float getLongitude() { - return longitude; - } - - protected void setLongitude(float longitude) { - this.longitude = longitude; - } - - /** - * Returns the end time stamp for this interaction. - * - * @return the end time stamp for this interaction. - */ - public Date getTimestampEndJob() { - return timestampEndJob; - } - - protected void setTimestampEndJob(Date timestampEndJob) { - this.timestampEndJob = timestampEndJob; - } - - /** - * Returns the user email address. - * - * @return the user email address. - */ - public String getEmail() { - return email; - } - - protected void setEmail(String email) { - this.email = email; - } - - /** - * Returns the eTokenServer address. - * - * @return the eTokenServer address. - */ - public String geteTokenServer() { - return eTokenServer; - } - - protected void seteTokenServer(String eTokenServer) { - this.eTokenServer = eTokenServer; - } - - /** - * Returns the job collection identifier which this job belongs to, null - * otherwise. - * - * @return the job collection identifier which this job belongs to, null - * otherwise. - */ - public Integer getIdJobCollection() { - return idJobCollection; - } - - protected void setIdJobCollection(Integer idJobCollection) { - this.idJobCollection = idJobCollection; - } - - /** - * This method persists an active grid interaction into the - * ActiveGridInterctions table. - */ - public void save() { - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - session.save(this); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - - } - - /** - * This method updates the active grid interaction specified by the - * identifier. - * - * @param jobId - * ActiveGridInteractions identifier of the record that will be - * updated - */ - public void updateJobId(String jobId) { - this.jobId = jobId; - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - session.update(this); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - - } - - /** - * Retrieves the active grid interactions with a specified database identifier. - * - * @param dbId - * identifier for which you want to retrieve active grid - * interactions information. - * @return a {@link GEActiveGridInteraction} object with the grid - * interactions information. - */ - public static GEActiveGridInteraction findActiveGridInteractionByJobId( - Long dbId) { - GEActiveGridInteraction result = new GEActiveGridInteraction(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - - try { - tx=session.beginTransaction(); - Query q = session - .createQuery("from GEActiveGridInteraction where id = :dbId "); - q.setParameter("dbId", dbId); - List activeGridInteractions = q.list(); - - if (activeGridInteractions.size() == 1) { - result = activeGridInteractions.get(0); - } else if (activeGridInteractions.size() == 0) { - logger.debug("None row in ActiveGridInteractions for jobId:" - + dbId); -// System.out -// .println("None row in ActiveGridInteractions for jobId:" -// + jobId); - } else - // Gestire - logger.debug("Multiple rows in ActiveGridInteractions for jobId:" - + dbId); -// System.out -// .println("Multiple row in ActiveGridInteractions for jobId:" -// + jobId); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - return result; - } -// public static GEActiveGridInteraction findActiveGridInteractionByJobId( -// String jobId) { -// GEActiveGridInteraction result = new GEActiveGridInteraction(); -// Session session = GESessionFactoryUtil.getSessionfactory() -// .openSession(); -// -// Transaction tx = null; -// -// try { -// tx=session.beginTransaction(); -// Query q = session -// .createQuery("from GEActiveGridInteraction where jobId = :jobId "); -// q.setParameter("jobId", jobId); -// List activeGridInteractions = q.list(); -// -// if (activeGridInteractions.size() == 1) { -// result = activeGridInteractions.get(0); -// } else if (activeGridInteractions.size() == 0) { -// logger.debug("None row in ActiveGridInteractions for jobId:" -// + jobId); -//// System.out -//// .println("None row in ActiveGridInteractions for jobId:" -//// + jobId); -// } else -// // Gestire -// logger.debug("Multiple rows in ActiveGridInteractions for jobId:" -// + jobId); -//// System.out -//// .println("Multiple row in ActiveGridInteractions for jobId:" -//// + jobId); -// tx.commit(); -// } catch (HibernateException he) { -// if (tx != null) -// tx.rollback(); -// he.printStackTrace(); -// } finally { -// session.close(); -// } -// return result; -// } - - /** - * Removes the corresponding record from the database for this active - * interactions. - */ - public void delete() { - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - session.delete(this); - - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - } - - /** - * Retrieves all active interactions belong to a specified - * {@link JobCollection}. - * - * @param idJobCollection - * {@link JobCollection} identifier for which you want to - * retrieve all active sub-jobs. - * - * @return a {@link List} of {@link GEActiveGridInteraction} representing - * all active grid interactions for the specified - * {@link JobCollection} - */ - public static List findActiveJobForJobCollection( - int idJobCollection) { - List result = null; - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - Query q = session - .createQuery("from GEActiveGridInteraction where idJobCollection = :idJobCollection "); - q.setParameter("idJobCollection", idJobCollection); - result = q.list(); - - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - return result; - } - - private Timestamp getCurrentUTCTimestamp() { - Calendar calendar = Calendar.getInstance(); - java.util.Date date = calendar.getTime(); - TimeZone tz = calendar.getTimeZone(); - - long msFromEpochGMT = date.getTime(); - - int offsetFromUTC = tz.getOffset(msFromEpochGMT); - - Calendar UTCCalendar = Calendar - .getInstance(TimeZone.getTimeZone("GMT")); - UTCCalendar.setTime(date); - UTCCalendar.add(Calendar.MILLISECOND, -offsetFromUTC); - - Timestamp currentTimestamp = new Timestamp( - UTCCalendar.getTimeInMillis()); - return currentTimestamp; - } - -} diff --git a/it/infn/ct/GridEngine/JobResubmission/GEJobDescription.hbm.xml b/it/infn/ct/GridEngine/JobResubmission/GEJobDescription.hbm.xml deleted file mode 100644 index ab1c65d..0000000 --- a/it/infn/ct/GridEngine/JobResubmission/GEJobDescription.hbm.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/it/infn/ct/GridEngine/JobResubmission/GEJobDescription.java b/it/infn/ct/GridEngine/JobResubmission/GEJobDescription.java deleted file mode 100644 index fd72553..0000000 --- a/it/infn/ct/GridEngine/JobResubmission/GEJobDescription.java +++ /dev/null @@ -1,521 +0,0 @@ -package it.infn.ct.GridEngine.JobResubmission; - -import it.infn.ct.GridEngine.JobCollection.WorkflowN1; - -import java.util.List; - -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.Transaction; - -//import javax.persistence.Column; -//import javax.persistence.Entity; -//import javax.persistence.GeneratedValue; -//import javax.persistence.Id; -//import javax.persistence.Table; - -//@Entity -//@Table (name="JobDescription") -/** - * This class is a persistence class used to mapping a job description in - * database, with an object. - * - * @author mario - * - */ -public class GEJobDescription { - - // private static final Session session = - // GESessionFactoryUtil.getSessionfactory().getCurrentSession();//.openSession(); - // @Id - // @GeneratedValue - // @Column (name="id") - private Long id; // primary key - - // @Column - private String jobId; - - // @Column (name="executable") - private String executable; // JobDescription executable attribute - - // @Column (name="arguments") - private String arguments; - - // @Column (name="output") - private String output; - - // @Column (name="error") - private String error; - - // @Column (name="queue") - private String queue; - - // @Column (name="file_transfer") - private String fileTransfer; - - // @Column (name="total_cpu") - private String totalCPUCount; - - // @Column (name="SPDM_variation") - private String SPDMVariation; - - // @Column (name="number_of_processes") - private String numberOfProcesses; - - // @Column (name="JDL_requirements") - private String JDLRequirements; - - // @Column (name="output_path") - private String outputPath; - - // @Column (name="input_files") - private String inputFiles; - - // @Column (name="output_files") - private String outputFiles; - - // @Column (name="proxy_renewal") - private boolean proxyRenewal; - - // @Column (name="maxResubmitCount") - private int resubmitCount; - - public GEJobDescription() { - } - - /** - * Returns the database id for this description. - * - * @return the database id for this description. - */ - public Long getId() { - return id; - } - - private void setId(Long id) { - this.id = id; - } - - /** - * Returns the specified executable for this description. - * - * @return the specified executable for this description. - */ - public String getExecutable() { - if (executable != null) - return executable; - else - return ""; - } - - /** - * Sets the executable in this description. - * - * @param executable - * a string that represents the executable file name. - */ - public void setExecutable(String executable) { - this.executable = executable; - } - - /** - * Returns a comma separated string represents the list of the arguments for - * this description. - * - * @return comma separated string represents the list of the arguments for - * this description. - */ - public String getArguments() { - if (arguments != null) - return arguments; - else - return ""; - } - - /** - * Sets the arguments for this description. - * - * @param arguments - * a comma separated string containing the list of arguments. - */ - public void setArguments(String arguments) { - this.arguments = arguments; - } - - /** - * Returns the grid job identifier. - * - * @return the grid job identifier. - */ - public String getjobId() { - return jobId; - } - - /** - * Sets the grid job identifier for the job specified by this description. - * - * @param activeJobId - * string containing grid job identifier for the job specified by - * this description. - */ - public void setjobId(String activeJobId) { - this.jobId = activeJobId; - } - - /** - * Returns the output file name specified in this description. - * - * @return the output file name specified in this description. - */ - public String getOutput() { - return output; - } - - /** - * Sets the output file name. - * - * @param output - * the output file name. - */ - public void setOutput(String output) { - this.output = output; - } - - /** - * Returns the error file name specified in this description. - * - * @return the error file name specified in this description. - */ - public String getError() { - return error; - } - - /** - * Sets the error file name. - * - * @param error - * the error file name. - */ - public void setError(String error) { - this.error = error; - } - - /** - * Returns queue name for this description. - * - * @return queue Queue name. - */ - public String getQueue() { - return queue; - } - - /** - * Sets the queue name for the job specified by this description. - * - * @param queue - * Queue name. - */ - public void setQueue(String queue) { - this.queue = queue; - } - - public String getFileTransfer() { - return fileTransfer; - } - - public void setFileTransfer(String fileTransfer) { - this.fileTransfer = fileTransfer; - } - - /** - * Returns the total number of CPUs required to execute the job specified by - * this description. - * - * @return total number of CPUs required to execute the job specified by - * this description. - */ - public String getTotalCPUCount() { - return totalCPUCount; - } - - /** - * Sets the total number of CPUs required to execute the job specified by - * this description. - * - * @param totalCPUCount - * total number of CPUs required to execute the job. - */ - public void setTotalCPUCount(String totalCPUCount) { - this.totalCPUCount = totalCPUCount; - } - - public String getSPDMVariation() { - return SPDMVariation; - } - - public void setSPDMVariation(String sPDMVariation) { - SPDMVariation = sPDMVariation; - } - - /** - * Returns the total number of processes required by the job specified by - * this description. - * - * @return the total number of processes required by the job specified by - * this description. - */ - public String getNumberOfProcesses() { - return numberOfProcesses; - } - - /** - * Sets the total number of processes required by the job specified by this - * description. - * - * @param numberOfProcess - * total number of processes required by the job. - */ - public void setNumberOfProcesses(String numberOfProcess) { - this.numberOfProcesses = numberOfProcess; - } - - public String getJDLRequirements() { - return JDLRequirements; - } - - public void setJDLRequirements(String jDLRequirements) { - JDLRequirements = jDLRequirements; - } - - /** - * Returns output path where output files of the job specified by this - * description are stored. - * - * @return output path where output files of the job specified by this - * description are stored. - */ - public String getOutputPath() { - return outputPath; - } - - /** - * Sets output path where output files of the job specified by this - * description are stored. This method appends jobOutput folder to the - * specified path where files are really stored. - * - * @param outputPath - * prefix of the path of the folder followed by /jobOuput/ - * folder where output files are located.. - */ - public void setOutputPath(String outputPath) { - // this.outputPath = outputPath; - if (!outputPath.contains("/jobOutput/")) - this.outputPath = outputPath + "/jobOutput/"; - else - this.outputPath = outputPath; - } - - /** - * Returns a comma separated string representing the input files list for - * the the job specified by this description. - * - * @return a comma separated string representing the input files list. - */ - public String getInputFiles() { - if (inputFiles != null) - return inputFiles; - else - return ""; - } - - /** - * Sets the input files list for the job specified by this description. - * - * @param inputFiles - * a comma separated string representing the input files list. - */ - public void setInputFiles(String inputFiles) { - this.inputFiles = inputFiles; - } - - public void setOutputFiles(String value) { - this.outputFiles = value; - - } - - public String getOutputFiles() { - if (outputFiles != null) - return outputFiles; - else - return ""; - } - - /** - * Returns true if the robot proxy is renewable false otherwise. - * - * @return true if the robot proxy is renewable false otherwise - */ - public boolean isProxyRenewal() { - return proxyRenewal; - } - - /** - * Sets true if the robot proxy is renewable false otherwise. - * - * @param proxyRenewal - * true if the robot proxy is renewable false otherwise - */ - public void setProxyRenewal(boolean proxyRenewal) { - this.proxyRenewal = proxyRenewal; - } - - /** - * Returns the remaining re-submission attempts for the job represented by - * this description. - * - * @return the remaining re-submission attempts for the job represented by - * this description. - */ - public int getResubmitCount() { - return resubmitCount; - } - - /** - * Sets the remaining re-submission attempts for the job represented by this - * description - * - * @param resubmitCount - * the remaining re-submission attempts. - */ - public void setResubmitCount(int resubmitCount) { - this.resubmitCount = resubmitCount; - } - - /** - * Makes this description persistent in the database. - */ - public void saveJobDescription() { - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - // session.save(this); - session.saveOrUpdate(this); - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - } - - /** - * Retrieves the previously saved final job description for a - * {@link WorkflowN1} by its own database identifier. - * - * @param idFinalJob - * final job description database identifier. - * - * @return a {@link GEJobDescription} representing the final final job - * description for a {@link WorkflowN1} - */ - public static GEJobDescription findJobDescriptionById(Long idFinalJob) { - GEJobDescription result = new GEJobDescription(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Query q = session.createQuery("from GEJobDescription where id = :id "); - q.setParameter("id", idFinalJob); - List jobDescriptions = q.list(); - - try { - if (jobDescriptions.size() == 1) { - result = jobDescriptions.get(0); - } else if (jobDescriptions.size() == 0) { - - } else - // Gestire - System.out - .println("Multiple row in JobDescription for idFinalJob:" - + idFinalJob); - } catch (HibernateException he) { - he.printStackTrace(); - } finally { - session.close(); - } - return result; - } - - /** - * Retrieves the description for a specific job by its own grid job - * identifier. - * - * @param jobId - * grid job identifier of the job for which you want retrieve the - * description. - * @return a {@link GEJobDescription} object containing the specified job - * description. - */ - public static GEJobDescription findJobDescriptionByJobId(String jobId) { - GEJobDescription result = new GEJobDescription(); - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Query q = session - .createQuery("from GEJobDescription where jobId = :jobId "); - q.setParameter("jobId", jobId); - List jobDescriptions = q.list(); - - try { - if (jobDescriptions.size() == 1) { - result = jobDescriptions.get(0); - } else if (jobDescriptions.size() == 0) { - - } else - // Gestire - System.out - .println("Multiple row in JobDescription for idFinalJob:" - + jobId); - } catch (HibernateException he) { - he.printStackTrace(); - } finally { - session.close(); - } - return result; - } - - /** - * Removes the corresponding record from the database for this description. - */ - public void delete() { - Session session = GESessionFactoryUtil.getSessionfactory() - .openSession(); - - Transaction tx = null; - try { - tx = session.beginTransaction(); - session.delete(this); - - tx.commit(); - } catch (HibernateException he) { - if (tx != null) - tx.rollback(); - he.printStackTrace(); - } finally { - session.close(); - } - } - - @Override - public String toString() { - return "GEJobDescription [id=" + id + ", executable=" + executable - + ", arguments=" + arguments + ", output=" + output - + ", error=" + error + "]"; - } - -} diff --git a/it/infn/ct/GridEngine/JobResubmission/GESessionFactoryUtil.java b/it/infn/ct/GridEngine/JobResubmission/GESessionFactoryUtil.java deleted file mode 100644 index ec9d724..0000000 --- a/it/infn/ct/GridEngine/JobResubmission/GESessionFactoryUtil.java +++ /dev/null @@ -1,32 +0,0 @@ -package it.infn.ct.GridEngine.JobResubmission; - -import org.apache.log4j.Logger; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; - -import it.infn.ct.GridEngine.Config.GridEngineConfig; - - -public class GESessionFactoryUtil { - - private static SessionFactory sessionFactory; - private static final Logger logger = Logger.getLogger(GESessionFactoryUtil.class); - - static{ - try{ - GridEngineConfig gec = GridEngineConfig.getInstance(); - sessionFactory = new Configuration().setProperty("hibernate.connection.datasource", gec.getUserstrackingDatasource()).configure().buildSessionFactory(); - logger.info("Using hibernate datasource: " + gec.toString()); - } - catch(Throwable ex){ - logger.info("Could not find hibernate datasource, using local connection parameters ..."); - sessionFactory = new Configuration().configure("hibernateStandAlone.cfg.xml").buildSessionFactory(); - logger.info("Configured Hibernate local datasource"); - } - } - - public static SessionFactory getSessionfactory() { - return sessionFactory; - } - -} diff --git a/it/infn/ct/GridEngine/JobService/JobCheckStatusService.java b/it/infn/ct/GridEngine/JobService/JobCheckStatusService.java deleted file mode 100644 index c6ea343..0000000 --- a/it/infn/ct/GridEngine/JobService/JobCheckStatusService.java +++ /dev/null @@ -1,133 +0,0 @@ -package it.infn.ct.GridEngine.JobService; - -import it.infn.ct.GridEngine.UsersTracking.UsersTrackingDBInterface; - -import java.util.Vector; - -import org.apache.log4j.Logger; - -public class JobCheckStatusService { - - private static final Vector jobsCheckStatusThread = new Vector(); - private static JobCheckStatusService instance; - private static int jobsUpdatingInterval = 60; - private String URL = ""; - private String userName = ""; - private String password = ""; - boolean inAppServer; - - private static final Logger logger = Logger - .getLogger(JobCheckStatusService.class); - - private JobCheckStatusService() { - inAppServer = true; - } - - private JobCheckStatusService(String url, String username, String pwd) { - inAppServer = false; - URL = url; - userName = username; - password = pwd; - } - - /** - * Returns the unique instance of this class if it isn't null otherwise - * creates a new instance. - * - * @return the unique instance of this class. - */ - public synchronized static JobCheckStatusService getInstance() { - if (instance == null) { - instance = new JobCheckStatusService(); - } - - return instance; - } - - /** - * Returns the unique instance of this class if it isn't null otherwise - * creates a new instance with the specified database connection parameters. - * - * @param url - * database url - * @param username - * database username - * @param pwd - * database password - * @return the unique instance of this class. - */ - public synchronized static JobCheckStatusService getInstance(String url, - String username, String pwd) { - if (instance == null) { - instance = new JobCheckStatusService(url, username, pwd); - } - - return instance; - } - - /** - * Sets the time interval between two consecutively job updating. - * - * @param value - * time interval between two consecutively job updating. - */ - public synchronized void setJobsUpdatingInterval(int value) { - jobsUpdatingInterval = value; - } - - /** - * Starts a thread responsible for check of the status of the jobs for a - * specified user, if it not exists. - * - * @param commonName - * name of the user for who to start the check job status thread - * @param outputPathPrefix - * path file prefix where output files are located. - * - */ - public synchronized void startJobCheckStatusThread(String commonName, - String outputPathPrefix) { -// logger.info("########## jobsCheckStatusThread.size(): "+ jobsCheckStatusThread.size() +" ##########"); -// for (String s : jobsCheckStatusThread) { -// logger.info("########## COMMON NAME: "+ s +" ##########"); -// } - - if (jobsCheckStatusThread.contains(commonName)){ - logger.info("Check Status Thread for " + commonName + " already started"); - return; - } - - logger.info("Starting new check jobs status thread for user " - + commonName); - // System.out.println("Starting new check jobs status thread for user " - // + commonName); - - jobsCheckStatusThread.add(commonName); - - UsersTrackingDBInterface dbInterface; - if (inAppServer) - dbInterface = new UsersTrackingDBInterface(); - else - dbInterface = new UsersTrackingDBInterface(URL, userName, password); - - dbInterface.updateJobsStatusAsync(commonName, outputPathPrefix, - jobsUpdatingInterval); - } - - /** - * Stops the thread responsible for check of the status of the jobs for a - * specified user, - * - * @param commonName - * name of the user for who to stop the check job status thread - */ - public synchronized void stopJobCheckStatusThread(String commonName) { - if (jobsCheckStatusThread.contains(commonName)) { - logger.info("Deleting " + commonName - + " from the list of active users"); - // System.out.println("Deleting " + commonName + - // " from the list of active users"); - jobsCheckStatusThread.removeElement(commonName); - } - } -} diff --git a/it/infn/ct/GridEngine/JobService/JobCheckStatusServiceFactory.java b/it/infn/ct/GridEngine/JobService/JobCheckStatusServiceFactory.java deleted file mode 100644 index e80fb34..0000000 --- a/it/infn/ct/GridEngine/JobService/JobCheckStatusServiceFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) -****************************************************************************/ - -package it.infn.ct.GridEngine.JobService; - -import java.util.Enumeration; -import java.util.Hashtable; - -import javax.naming.Context; -import javax.naming.Name; -import javax.naming.NamingException; -import javax.naming.RefAddr; -import javax.naming.Reference; - - -public class JobCheckStatusServiceFactory implements javax.naming.spi.ObjectFactory, java.io.Serializable { - - @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable environment) throws Exception { - JobCheckStatusService jobCheckStatusService = JobCheckStatusService.getInstance(); - - try { - Reference reference = (Reference) obj; - Enumeration enumeration = reference.getAll(); - while (enumeration.hasMoreElements()) { - RefAddr refAddr = (RefAddr) enumeration.nextElement(); - String pname = refAddr.getType(); - String pvalue = (String) refAddr.getContent(); - if ("jobsupdatinginterval".equalsIgnoreCase(pname)) { - jobCheckStatusService.setJobsUpdatingInterval(Integer.parseInt(pvalue)); - } else { - throw new IllegalArgumentException("Unrecognized property name: " + pname); - } - } - } catch (Exception e) { - throw (NamingException) (new NamingException()).initCause(e); - } - return jobCheckStatusService; - } -}; diff --git a/it/infn/ct/GridEngine/JobService/JobServicesDispatcher.java b/it/infn/ct/GridEngine/JobService/JobServicesDispatcher.java deleted file mode 100644 index 810564a..0000000 --- a/it/infn/ct/GridEngine/JobService/JobServicesDispatcher.java +++ /dev/null @@ -1,1308 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) - ****************************************************************************/ - -package it.infn.ct.GridEngine.JobService; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Calendar; -import java.util.Hashtable; - -import org.apache.log4j.Logger; -import org.gridforum.jgss.ExtendedGSSCredential; -import org.gridforum.jgss.ExtendedGSSManager; -import org.ietf.jgss.GSSCredential; -import org.ogf.saga.context.Context; -import org.ogf.saga.context.ContextFactory; -import org.ogf.saga.error.NoSuccessException; -import org.ogf.saga.job.JobFactory; -import org.ogf.saga.job.JobService; -import org.ogf.saga.session.Session; -import org.ogf.saga.session.SessionFactory; -import org.ogf.saga.url.URL; -import org.ogf.saga.url.URLFactory; - -import fr.in2p3.jsaga.impl.context.ContextImpl; -import fr.in2p3.jsaga.impl.job.service.JobServiceImpl; - -public class JobServicesDispatcher { - - static final Hashtable jobServices = new Hashtable(); - static final Hashtable jobServicesCounter = new Hashtable(); - static final Hashtable sessionsTime = new Hashtable(); - - static final Hashtable jksJobServices = new Hashtable(); - static final Hashtable jksJobServicesCounter = new Hashtable(); - - static final Hashtable ourgridJobServices = new Hashtable(); - static final Hashtable ourgridJobServicesCounter = new Hashtable(); - - static final Hashtable genesisJobServices = new Hashtable(); - static final Hashtable genesisJobServicesCounter = new Hashtable(); - - static final Hashtable gosJobServices = new Hashtable(); - static final Hashtable gosJobServicesCounter = new Hashtable(); - - static final Hashtable sshJobServices = new Hashtable(); - static final Hashtable sshJobServicesCounter = new Hashtable(); - - private static JobServicesDispatcher instance; - private static int retryCount = 3; - private static int resubNumber = 10; - private static String myproxyServers = "gridit=myproxy.ct.infn.it"; - private static String trustStorePath = "/tmp/EMI-truststore.jks"; - private static String trustStorePassword = "goodpass"; - - private static String genesisTrustStorePath = "/opt/glassfish3/glassfish/domains/liferay/config/trust-genesis.jks"; - private static String genesisTrustStorePassword = "chaindemo"; - - private static String smtpServer = "mbox.ct.infn.it"; - private static String senderAddress = "sg-licence@ct.infn.it"; - - private static final Logger logger = Logger - .getLogger(JobServicesDispatcher.class); - - private JobServicesDispatcher() { - - } - - /** - * Returns the unique instance of this class if it isn't null otherwise - * creates a new instance. - * - * @return the unique instance of this class. - */ - public synchronized static JobServicesDispatcher getInstance() { - if (instance == null) { - instance = new JobServicesDispatcher(); - } - - return instance; - } - - public synchronized void setSmtpServer(String smtpserver) { - smtpServer = smtpserver; - } - - public String getSmtpServer() { - return smtpServer; - } - - public String getSenderAddress() { - return senderAddress; - } - - public synchronized void setSenderAddress(String senderaddress) { - senderAddress = senderaddress; - } - - protected synchronized void setRetryCount(int retrycount) { - retryCount = retrycount; - } - - protected synchronized void setMyproxyServers(String myproxyservers) { - myproxyServers = myproxyservers; - } - - protected synchronized void setTrustStorePath(String truststorepath) { - trustStorePath = truststorepath; - } - - protected synchronized void setTrustStorePassword(String truststorepassword) { - trustStorePassword = truststorepassword; - } - - protected synchronized void setGenesisTrustStorePath(String truststorepath) { - genesisTrustStorePath = truststorepath; - } - - protected synchronized void setGenesisTrustStorePassword( - String truststorepassword) { - genesisTrustStorePassword = truststorepassword; - } - - protected void setResubmissionNumber(int pvalue) { - resubNumber = pvalue; - } - - /** - * Returns the maximum attempts re-submission numbers. - * - * @return the maximum attempts re-submission numbers. - */ - public int getResubNumber() { - return resubNumber; - } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using an user proxy. - * - * @param proxyPath - * path to a user proxy certificate - * @param DN - * User ID or user name to use - * @param vo - * proxy virtual organization - * @param fqan - * proxy roles - * @param resourceManager - * resource manager host - * @return JobService that allows job creation, submission and status - * monitoring using a user proxy. - */ - public synchronized JobService getJobService(String proxyPath, String DN, - String vo, String fqan, String resourceManager) { - logger.info("GetJobService Local Proxy..."); - - String proxyInfo = DN + "-" + vo + "-" + fqan + "-" + resourceManager; - JobService service = jobServices.get(proxyInfo); - - String adaptor = (resourceManager.toString()).substring(0, - (resourceManager.toString()).indexOf(":")); - logger.info("JobServiceDispatcher: Using adaptor:" + adaptor); - - if (service == null) { - logger.info("Creating a new Session..."); - - Session session = null; - Context context = null; - try { - logger.info(("Initialize the security context for the adaptor " + adaptor)); - session = SessionFactory.createSession(false); - logger.info(ContextImpl.URL_PREFIX); - - context = ContextFactory.createContext("VOMS"); - context.setAttribute(Context.USERPROXY, proxyPath); - //if (adaptor.equals("rocci")) context.setVectorAttribute("BaseUrlIncludes", new String[]{"rocci://"}); - - if (adaptor.equals("wms")) { - // context.setVectorAttribute("JobServiceAttributes", new - // String[]{"wms.RetryCount="+retryCount}); - // context.setVectorAttribute("JobServiceAttributes", new - // String[]{"wms.RetryCount="+retryCount,"wms.rank=other.GlueCEStateFreeCPUs"}); - context.setVectorAttribute("JobServiceAttributes", - new String[] { - "wms.RetryCount=" + retryCount, - "wms.rank=other.GlueCEStateFreeCPUs", - "wms.myproxyserver=" - + getMyproxyServerForVO(vo) }); - } else if(adaptor.equals("rocci")) { - context = ContextFactory.createContext("SSH"); - context.setAttribute(Context.USERID,"root"); - //context.setAttribute(Context.USERPASS,""); - context.setAttribute(Context.USERCERT, - System.getProperty("user.home") + - System.getProperty("file.separator") + - ".ssh/id_rsa.pub"); - //Put here your private key file path - context.setAttribute(Context.USERKEY, - System.getProperty("user.home") + - System.getProperty("file.separator") + - ".ssh/id_rsa"); - //context.setAttribute("UrlPrefix","sftp"); - context.setVectorAttribute("BaseUrlIncludes", new String[]{"sftp://"}); - context.setVectorAttribute("DataServiceAttributes", new String[]{"sftp.KnownHosts="}); - //session.addContext(context); - } else if(adaptor.equals("gatekeeper")){ - - //Modifiy this section according to the A&A schema of your middleware - //In this example the VOMS A&A schema is used - context = ContextFactory.createContext("VOMS"); - context.setAttribute(Context.USERPROXY, proxyPath); - logger.info(("PROXY PATH: " + proxyPath)); - logger.info(("PROXY PATH CONTEXT: " + context.getAttribute(Context.USERPROXY))); - // example code to get a GSSCredential object -// File proxyFile = new File(proxyPath); -// byte [] proxyBytes = new byte[(int) proxyFile.length()]; -// FileInputStream in = new FileInputStream(proxyFile); -// in.read(proxyBytes); -// in.close(); -// -// ExtendedGSSManager manager = -// (ExtendedGSSManager) ExtendedGSSManager.getInstance(); -// -// GSSCredential cred = -// manager.createCredential( -// proxyBytes, -// ExtendedGSSCredential.IMPEXP_OPAQUE, -// GSSCredential.DEFAULT_LIFETIME, -// null, // use default mechanism: GSI -// GSSCredential.INITIATE_AND_ACCEPT); - - // code to pass the GSSCredential object to JSAGA -// context.setAttribute("UserProxyObject", fr.in2p3.jsaga.adaptor.security.impl.InMemoryProxySecurityCredential.toBase64(cred)); - - } - - session.addContext(context); - - } catch (Exception e) { - logger.error("Error in reading user proxy..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - try { - logger.info("Creating a new JobService..."); - URL serviceURL = null; - if (adaptor.equals("rocci")) - serviceURL = URLFactory.createURL(resourceManager+"&proxy_path="+proxyPath); - else - serviceURL = URLFactory.createURL(resourceManager); - - service = JobFactory.createJobService(session, serviceURL); - } catch (Exception e) { - logger.error("Error in creating jobService..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - jobServices.put(proxyInfo, service); - jobServicesCounter.put(service, new Integer(1)); - } else { - logger.info("JobService already exists!"); - Integer counter = jobServicesCounter.get(service); - if (counter == null) - logger.warn("ERROR! JobServicesCounter disaligned!"); - - jobServicesCounter.put(service, counter + 1); - logger.info("New counter=" + jobServicesCounter.get(service)); - logger.info("Number of elements in jobServicesCounter=" - + jobServicesCounter.size()); - } - - return service; - } - - /** - * Returns user ID or user name used in a specified service. - * - * @param service - * for which you want to retrieve user ID or user name. - * @return user ID or user name used in a specified service. - */ - public synchronized String getDN(JobService service) { - Session session_temp = null; - String DN = ""; - try { - session_temp = service.getSession(); - Context[] contexts = session_temp.listContexts(); - DN = contexts[0].getAttribute(Context.USERID); - logger.info("DN=" + DN); - - } catch (Exception e) { - logger.error("Error in reading user proxy..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - } - return DN; - } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using a robot proxy. - * - * @param etokenserver - * robot proxy host - * @param etokenserverport - * robot proxy port - * @param proxyId - * robot proxy identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - * @param resourceManager - * resource manager host - * @return JobService that allows job creation, submission and status - * monitoring using a user proxy. - */ -// public synchronized JobService getJobService(String etokenserver, -// String etokenserverport, String proxyId, String vo, String fqan, -// boolean proxyrenewal, String resourceManager) { -// return getJobService(etokenserver,etokenserverport,proxyId,vo,fqan,proxyrenewal,false,resourceManager); -// } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using a robot proxy. - * - * @param etokenserver - * robot proxy host - * @param etokenserverport - * robot proxy port - * @param proxyId - * robot proxy identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - * @param resourceManager - * resource manager host - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - * @return JobService that allows job creation, submission and status - * monitoring using a user proxy. - */ - public synchronized JobService getJobService(String etokenserver, - String etokenserverport, String proxyId, String vo, String fqan, - boolean proxyrenewal, boolean rfc, String cnLabel, String resourceManager) { - logger.info("GetJobService RobotProxy..."); - int oldCounter = 0; - String proxyInfo = proxyId + "-" + vo + "-" + fqan + "-" - + resourceManager; - JobService service = jobServices.get(proxyInfo); - - String adaptor = (resourceManager.toString()).substring(0, - (resourceManager.toString()).indexOf(":")); - logger.info("JobServiceDispatcher: Using adaptor:" + adaptor); - - if (service != null) { - boolean proxyIsExpired = false; - - try { - proxyIsExpired = checkProxyLifetime(service.getSession()); - } catch (Exception e) { - proxyIsExpired = true; - } - - if (proxyIsExpired) { - logger.warn("Proxy is expired! Getting a new proxy..."); - logger.info("Deleting old job service..."); - - oldCounter = jobServicesCounter.get(service); - logger.info("Old counter = " + oldCounter); - - jobServices.remove(proxyInfo); - jobServicesCounter.remove(service); - - Context[] contexts; - String proxyToBeDeleted = ""; - Session session = null; - try { - session = service.getSession(); - contexts = session.listContexts(); - proxyToBeDeleted = contexts[0] - .getAttribute(Context.USERPROXY); - session.close(); - } catch (Exception e) { - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - deleteProxy(proxyToBeDeleted); - - sessionsTime.remove(session); - - service = null; - - // - // - // RobotProxy robotProxy = null; - // if ( (!etokenserver.equals("")) || - // (!etokenserverport.equals("")) ) - // robotProxy = new RobotProxy(etokenserver, etokenserverport, - // proxyId, vo, fqan, proxyrenewal); - // else - // robotProxy = new RobotProxy(proxyId, vo, fqan, proxyrenewal); - // - // String proxyPath = robotProxy.getRobotProxy(); - // System.out.println("proxyPath2="+proxyPath); - // - // Context context = null; - // try { - // //contexts[0].setAttribute(Context.USERPROXY,proxyPath); - // session = SessionFactory.createSession(false); - // context = ContextFactory.createContext("VOMS"); - // context.setAttribute(Context.USERPROXY,proxyPath); - // - // context.setVectorAttribute("JobServiceAttributes", new - // String[]{"wms.RetryCount="+retryCount}); - // session.addContext(context); - // System.out.println("Added new security context in session."); - // } catch (Exception e) { - // System.out.println(e.toString()); - // System.out.println("Cause :"+e.getCause()); - // return null; - // } - // - // try { - // sessionsTime.put(session, - // Calendar.getInstance().getTimeInMillis()); - // } - // catch (Exception e) { - // System.out.println(e.toString()); - // System.out.println("Cause :"+e.getCause()); - // return null; - // } - - // deleteProxy(proxyToBeDeleted); - - } - } - - if (service == null) { - logger.info("Getting a new proxy..."); - - RobotProxy robotProxy = null; - if ((!etokenserver.equals("")) || (!etokenserverport.equals(""))) - robotProxy = new RobotProxy(etokenserver, etokenserverport, - proxyId, vo, fqan, proxyrenewal, rfc, cnLabel); - else - robotProxy = new RobotProxy(proxyId, vo, fqan, proxyrenewal, rfc); - - String proxyPath = robotProxy.getRobotProxy(); - logger.info("Creating a new Session..."); - Session session = null; - Context context = null; -// Context context_rocci = null; - try { - session = SessionFactory.createSession(false); - logger.info(ContextImpl.URL_PREFIX); - - context = ContextFactory.createContext("VOMS"); - context.setAttribute(Context.USERPROXY, proxyPath); - //if (adaptor.equals("rocci")) context.setVectorAttribute("BaseUrlIncludes", new String[]{"rocci://"}); - - if (adaptor.equals("wms")) { - context = ContextFactory.createContext("VOMS"); - context.setAttribute(Context.USERPROXY, proxyPath); - // context.setVectorAttribute("JobServiceAttributes", new - // String[]{"wms.RetryCount="+retryCount}); - // context.setVectorAttribute("JobServiceAttributes", new - // String[]{"wms.RetryCount="+retryCount,"wms.rank=other.GlueCEStateFreeCPUs"}); - context.setVectorAttribute("JobServiceAttributes", - new String[] { - "wms.RetryCount=" + retryCount, - "wms.rank=other.GlueCEStateFreeCPUs", - "wms.MyProxyServer=" - + getMyproxyServerForVO(vo) }); - } else if(adaptor.equals("rocci")) { - context = ContextFactory.createContext("rocci"); - context.setAttribute(Context.USERPROXY, proxyPath); - context.setAttribute(Context.USERID,"root"); - //context.setAttribute(Context.USERPASS,""); - context.setAttribute(Context.USERCERT, - System.getProperty("user.home") + - System.getProperty("file.separator") + - ".ssh/id_rsa.pub"); - //Put here your private key file path - context.setAttribute(Context.USERKEY, - System.getProperty("user.home") + - System.getProperty("file.separator") + - ".ssh/id_rsa"); - //context.setAttribute("UrlPrefix","sftp"); -// context.setVectorAttribute("BaseUrlIncludes", new String[]{"sftp://"}); -// context.setVectorAttribute("DataServiceAttributes", new String[]{"sftp.KnownHosts="}); - } - - session.addContext(context); - - logger.info("DN=" + context.getAttribute(Context.USERID)); - logger.info("VO=" + context.getAttribute(Context.USERVO)); - logger.info("FQAN=" + context.getAttribute("UserFQAN")); - - session.addContext(context); -// if (adaptor.equals("rocci")) { -// context = ContextFactory.createContext("SSH"); -// context.setAttribute(Context.USERID,"root"); -// //context.setAttribute(Context.USERPASS,""); -// context.setAttribute(Context.USERCERT, -// System.getProperty("user.home") + -// System.getProperty("file.separator") + -// ".ssh/id_rsa.pub"); -// //Put here your private key file path -// context.setAttribute(Context.USERKEY, -// System.getProperty("user.home") + -// System.getProperty("file.separator") + -// ".ssh/id_rsa"); -// //context.setAttribute("UrlPrefix","sftp"); -// context.setVectorAttribute("BaseUrlIncludes", new String[]{"sftp://"}); -// context.setVectorAttribute("DataServiceAttributes", new String[]{"sftp.KnownHosts="}); -// session.addContext(context); -// } - - } catch (Exception e) { - logger.error("Error in reading user proxy..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - try { - logger.info("Creating a new JobService..."); - - URL serviceURL = null; - if (adaptor.equals("rocci")) - serviceURL = URLFactory.createURL(resourceManager+"&proxy_path="+proxyPath); - else - serviceURL = URLFactory.createURL(resourceManager); - - service = JobFactory.createJobService(session, serviceURL); - } catch (Exception e) { - e.printStackTrace(); - logger.error("Error in creating jobService..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - sessionsTime.put(session, Calendar.getInstance().getTimeInMillis()); - jobServices.put(proxyInfo, service); - jobServicesCounter.put(service, new Integer(oldCounter + 1)); - } else { - logger.info("JobService already exists!"); - - Integer counter = jobServicesCounter.get(service); - if (counter == null) - logger.warn("ERROR! JobServicesCounter disaligned!"); - - jobServicesCounter.put(service, counter + 1); - logger.info("New counter=" + jobServicesCounter.get(service)); - logger.info("Number of elements in jobServicesCounter=" - + jobServicesCounter.size()); - } - - return service; - } - - private synchronized boolean checkProxyLifetime(Session session) { - try { - Context[] contexts = session.listContexts(); - String lifetime = contexts[0].getAttribute(Context.LIFETIME); - logger.info("LIFETIME=" + lifetime); - - // if (lifetime.charAt(0)!='P') return false; - - // lifetime = lifetime.substring(lifetime.indexOf('T')+1); - - long time = sessionsTime.get(session); - - long interval = Calendar.getInstance().getTimeInMillis() - time; - - logger.info("Interval=" + interval); - - // se sono passate + di 6 ore - // if (interval>1000) - if (interval > (6 * 60 * 60 * 1000)) - return true; - - // int hour = 0; - // if (lifetime.indexOf('H') != -1) - // hour = new - // Integer(lifetime.substring(0,lifetime.indexOf('H'))).intValue(); - // - // System.out.println("hour="+hour); - // - // if (hour<2) - // return true; - - } catch (Exception e) { - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return false; - } - - return false; - } - - /** - * Closes the JobService with the specified parameters. - * - * @param usingRobotProxy - * true if JobService uses a robot proxy, false otherwise - * @param proxyId - * robot proxy user identifier - * @param vo - * proxyId robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param resourceManager - * resource manager host - */ - public synchronized void closeJobService(boolean usingRobotProxy, - String proxyId, String vo, String fqan, String resourceManager) { - String proxyInfo = proxyId + "-" + vo + "-" + fqan + "-" - + resourceManager; - JobService service = jobServices.get(proxyInfo); - - if (service == null) { - logger.warn("Error: Job Service not available.."); - return; - } - - Integer counter = jobServicesCounter.get(service); - if (counter == null) { - logger.warn("ERROR! JobServicesCounter disaligned!"); - return; - } - - if (counter.intValue() > 1) { - jobServicesCounter.put(service, counter - 1); - logger.info("New counter=" + jobServicesCounter.get(service)); - logger.info("Number of elements in jobServicesCounter=" - + jobServicesCounter.size()); - } else if (counter.intValue() == 1) { - jobServices.remove(proxyInfo); - jobServicesCounter.remove(service); - - try { - Session session = service.getSession(); - String proxyToBeDeleted = ""; - if (usingRobotProxy) { - Context[] contexts = session.listContexts(); - proxyToBeDeleted = contexts[0] - .getAttribute(Context.USERPROXY); - } - - session.close(); - - if (usingRobotProxy) { - sessionsTime.remove(session); - deleteProxy(proxyToBeDeleted); - // File f = new File(proxyToBeDeleted); - // if (!f.exists()) - // return; - // - // // Attempt to delete it - // boolean success = f.delete(); - // - // if (!success) - // System.out.println("Error in deleting proxy = " + - // proxyToBeDeleted); - } - } catch (Exception e) { - logger.error("Error in closing session!"); - // System.out.println("Error in closing session!"); - } - logger.info("Job service removed..."); - // System.out.println("Job service removed..."); - - } - } - - private synchronized void deleteProxy(String proxyToBeDeleted) { - logger.info("Deleting proxy = " + proxyToBeDeleted); - File f = new File(proxyToBeDeleted); - if (!f.exists()) - return; - - // Attempt to delete it - boolean success = f.delete(); - - if (!success) - logger.warn("Error in deleting proxy = " + proxyToBeDeleted); - else - logger.info("Deleted proxy = " + proxyToBeDeleted); - - } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using UNICORE middleware. - * - * @param jksPath - * keystore path - * @param jskPassword - * keystore password - * @param resourceManager - * resource manager host - * @return a JobService object that allows job creation, submission and - * status monitoring using UNICORE middleware. - */ - public synchronized JobService getJKSJobService(String jksPath, - String jskPassword, String resourceManager) { - logger.info("getJKSJobService..."); - String jksInfo = jksPath + "-" + resourceManager; - JobService service = jksJobServices.get(jksInfo); - - if (service == null) { - logger.info("Creating a new Session..."); - - System.setProperty("javax.net.ssl.trustStore", trustStorePath); - System.setProperty("javax.net.ssl.trustStorePassword", - trustStorePassword); - - Session session = null; - Context context = null; - try { - session = SessionFactory.createSession(false); - context = ContextFactory.createContext("JKS"); - context.setAttribute("Keystore", jksPath); - context.setAttribute("KeystorePass", jskPassword); - - session.addContext(context); - logger.info("DN=" + context.getAttribute(Context.USERID)); - } catch (Exception e) { - logger.error("Error in reading user proxy..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - try { - logger.info("Creating a new JobService..."); - URL serviceURL = URLFactory.createURL(resourceManager); - service = JobFactory.createJobService(session, serviceURL); - } catch (Exception e) { - logger.error("Error in creating jobService..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - jksJobServices.put(jksInfo, service); - jksJobServicesCounter.put(service, new Integer(1)); - } else { - logger.info("JobService already exists!"); - Integer counter = jksJobServicesCounter.get(service); - if (counter == null) - logger.warn("ERROR! jksJobServicesCounter disaligned!"); - - jksJobServicesCounter.put(service, counter + 1); - logger.info("New counter=" + jksJobServicesCounter.get(service)); - logger.info("Number of elements in jobServicesCounter=" - + jksJobServicesCounter.size()); - } - - return service; - } - - /** - * Closes the JobService with the specified parameters. - * - * @param jksPath - * keystore path - * @param resourceManager - * resource manager host - */ - public synchronized void closeJKSJobService(String jksPath, - String resourceManager) { - logger.info("getJKSJobService..."); - String jksInfo = jksPath + "-" + resourceManager; - JobService service = jksJobServices.get(jksInfo); - - if (service == null) { - logger.warn("Error: Job Service not available.."); - return; - } - - Integer counter = jksJobServicesCounter.get(service); - if (counter == null) { - logger.error("ERROR! JobServicesCounter disaligned!"); - return; - } - - if (counter.intValue() > 1) { - jksJobServicesCounter.put(service, counter - 1); - logger.info("New counter=" + jksJobServicesCounter.get(service)); - logger.info("Number of elements in jobServicesCounter=" - + jksJobServicesCounter.size()); - } else if (counter.intValue() == 1) { - jksJobServices.remove(jksInfo); - jksJobServicesCounter.remove(service); - - try { - Session session = service.getSession(); - session.close(); - } catch (Exception e) { - logger.error("Error in closing session!"); - } - logger.info("Job service removed..."); - - } - } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using OURGRID middleware. - * - * @param username - * username parameter - * @param password - * password parameter - * @param resourceManager - * resource manager host - * @return a JobService object for OURGRID middleware - */ - public synchronized JobService getOurGridJobService(String username, - String password, String resourceManager) { - logger.info("getPWDJobService..."); - String ourgridInfo = username + "-" + resourceManager; - JobService service = ourgridJobServices.get(ourgridInfo); - - if (service == null) { - logger.info("Creating a new Session..."); - - Session session = null; - Context context = null; - try { - session = SessionFactory.createSession(false); - context = ContextFactory.createContext("ourgrid"); - context.setAttribute("UserID", username); - context.setAttribute("UserPass", password); - - session.addContext(context); - - } catch (Exception e) { - logger.error("Error in creating session"); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - try { - logger.info("Creating a new JobService..."); - URL serviceURL = URLFactory.createURL(resourceManager); - service = JobFactory.createJobService(session, serviceURL); - } catch (Exception e) { - logger.error("Error in creating jobService..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - ourgridJobServices.put(ourgridInfo, service); - ourgridJobServicesCounter.put(service, new Integer(1)); - } else { - logger.info("JobService already exists!"); - Integer counter = ourgridJobServicesCounter.get(service); - if (counter == null) - logger.warn("ERROR! ourgridJobServicesCounter disaligned!"); - - ourgridJobServicesCounter.put(service, counter + 1); - logger.info("New counter=" + ourgridJobServicesCounter.get(service)); - logger.info("Number of elements in ourgridJobServicesCounter=" - + ourgridJobServicesCounter.size()); - } - - return service; - } - - /** - * Closes a JobService used for OURGRID middleware. - * - * @param username - * username parameter - * @param resourceManager - * resource manager host - */ - public synchronized void closeOurGridJobService(String username, - String resourceManager) { - logger.info("closeOurGridJobService..."); - String ourgridInfo = username + "-" + resourceManager; - JobService service = ourgridJobServices.get(ourgridInfo); - - if (service == null) { - logger.warn("Error: Job Service not available.."); - return; - } - - Integer counter = ourgridJobServicesCounter.get(service); - if (counter == null) { - logger.warn("ERROR! ourgridJobServicesCounter disaligned!"); - return; - } - - if (counter.intValue() > 1) { - ourgridJobServicesCounter.put(service, counter - 1); - logger.info("New counter=" + ourgridJobServicesCounter.get(service)); - logger.info("NUmber of elements in ourgridJobServicesCounter=" - + ourgridJobServicesCounter.size()); - } else if (counter.intValue() == 1) { - ourgridJobServices.remove(ourgridInfo); - ourgridJobServicesCounter.remove(service); - - try { - Session session = service.getSession(); - session.close(); - } catch (Exception e) { - logger.error("Error in closing session!"); - } - logger.info("Job service removed..."); - - } - } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using BESGENESIS middleware. - * - * @param jksPath - * keystore path - * @param jskPassword - * keystore password - * @param resourceManager - * resource manager host - * @return a JobService object for BESGENESIS middleware - */ - public synchronized JobService getGenesisJobService(String jksPath, - String jskPassword, String resourceManager) { - logger.info("getGenesisJobService..."); - String jksInfo = jksPath + "-" + resourceManager; - JobService service = genesisJobServices.get(jksInfo); - - if (service == null) { - logger.info("Creating a new Session..."); - - System.setProperty("javax.net.ssl.trustStore", - genesisTrustStorePath); - System.setProperty("javax.net.ssl.trustStorePassword", - genesisTrustStorePassword); - System.setProperty("javax.net.ssl.keyStore", jksPath); - System.setProperty("javax.net.ssl.keyStorePassword", jskPassword); - System.setProperty("genesis.ssh.username", "chaindemo"); - System.setProperty("genesis.ssh.password", "chaindemo"); - - Session session = null; - Context context = null; - try { - session = SessionFactory.createSession(false); - context = ContextFactory.createContext("AxisJKS"); - // context.setAttribute("Keystore",jksPath); - // context.setAttribute("KeystorePass",jskPassword); - - String[] attributes = new String[] { - "ReferenceParameterNS=http://edu.virginia.vcgr.genii/ref-params", - "ReferenceParameterName=resource-key", - "bes-genesis2.ReferenceParameterValue=10543AFE-56A7-6A27-E017-ADA51BFFAD47" }; - context.setVectorAttribute("JobServiceAttributes", attributes); - - session.addContext(context); - logger.info("DN=" + context.getAttribute(Context.USERID)); - } catch (Exception e) { - logger.error("Error in reading user proxy..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - try { - logger.info("Creating a new JobService..."); - URL serviceURL = URLFactory.createURL(resourceManager); - service = JobFactory.createJobService(session, serviceURL); - } catch (Exception e) { - logger.error("Error in creating jobService..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - genesisJobServices.put(jksInfo, service); - genesisJobServicesCounter.put(service, new Integer(1)); - } else { - logger.info("JobService already exists!"); - Integer counter = genesisJobServicesCounter.get(service); - if (counter == null) - logger.warn("ERROR! genesisJobServicesCounter disaligned!"); - - genesisJobServicesCounter.put(service, counter + 1); - logger.info("New counter=" + genesisJobServicesCounter.get(service)); - logger.info("Number of elements in jobServicesCounter=" - + genesisJobServicesCounter.size()); - } - - return service; - } - - /** - * Closes the JobService with the specified parameters. - * - * @param jksPath - * keystore path - * @param resourceManager - * resource manager host - */ - public synchronized void closeGenesisJobService(String jksPath, - String resourceManager) { - logger.info("closeGenesisJobService..."); - String jksInfo = jksPath + "-" + resourceManager; - JobService service = genesisJobServices.get(jksInfo); - - if (service == null) { - logger.warn("Error: Job Service not available.."); - return; - } - - Integer counter = genesisJobServicesCounter.get(service); - if (counter == null) { - logger.warn("ERROR! genesisJobServicesCounter disaligned!"); - return; - } - - if (counter.intValue() > 1) { - genesisJobServicesCounter.put(service, counter - 1); - logger.info("New counter=" + genesisJobServicesCounter.get(service)); - logger.info("NUmber of elements in jobServicesCounter=" - + genesisJobServicesCounter.size()); - } else if (counter.intValue() == 1) { - genesisJobServices.remove(jksInfo); - genesisJobServicesCounter.remove(service); - - try { - Session session = service.getSession(); - session.close(); - } catch (Exception e) { - logger.error("Error in closing session!"); - } - logger.info("Job service removed..."); - - } - } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using GOS middleware. - * - * @param resourceManager - * resource manager host - * @return a JobService object for GOS middleware - */ - public synchronized JobService getGOSJobService(String resourceManager) { - logger.info("getGOSJobService..."); - String gosInfo = resourceManager; - JobService service = gosJobServices.get(gosInfo); - - if (service == null) { - try { - logger.info("Creating a new JobService..."); - URL serviceURL = URLFactory.createURL(resourceManager); - service = JobFactory.createJobService(serviceURL); - } catch (Exception e) { - logger.error("Error in creating jobService..."); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - gosJobServices.put(gosInfo, service); - gosJobServicesCounter.put(service, new Integer(1)); - } else { - logger.info("JobService already exists!"); - Integer counter = gosJobServicesCounter.get(service); - if (counter == null) - logger.warn("ERROR! gosJobServicesCounter disaligned!"); - - gosJobServicesCounter.put(service, counter + 1); - logger.info("New counter=" + gosJobServicesCounter.get(service)); - logger.info("NUmber of elements in gosJobServicesCounter=" - + gosJobServicesCounter.size()); - } - - return service; - } - - /** - * Closes the JobService with the specified parameters. - * - * @param resourceManager - * resource manager host - */ - public synchronized void closeGOSJobService(String resourceManager) { - logger.info("closeGOSJobService..."); - String gosInfo = resourceManager; - JobService service = gosJobServices.get(gosInfo); - - if (service == null) { - logger.warn("Error: Job Service not available.."); - return; - } - - Integer counter = gosJobServicesCounter.get(service); - if (counter == null) { - logger.warn("ERROR! gosJobServicesCounter disaligned!"); - return; - } - - if (counter.intValue() > 1) { - gosJobServicesCounter.put(service, counter - 1); - logger.info("New counter=" + gosJobServicesCounter.get(service)); - logger.info("NUmber of elements in gosJobServicesCounter=" - + gosJobServicesCounter.size()); - } else if (counter.intValue() == 1) { - gosJobServices.remove(gosInfo); - gosJobServicesCounter.remove(service); - logger.info("Job service removed..."); - - } - } - - /** - * Returns a JobService object that allows job creation, submission and - * status monitoring using SSH middleware. - * - * @param username - * username parameter - * @param password - * password parameter - * @param resourceManager - * resource manager host - * @return a JobService object for SSH middleware - */ - public synchronized JobService getSSHJobService(String username, - String password, String resourceManager) { - logger.info("getSSHJobService..."); - String sshInfo = username + "-" + resourceManager; - JobService service = sshJobServices.get(sshInfo); - - if (service == null) { - logger.info("Creating a new Session..."); - - Session session = null; - Context context = null; - try { - session = SessionFactory.createSession(false); - if (!password.equals("")) { - context = ContextFactory.createContext("UserPass"); - context.setAttribute("UserID", username); - context.setAttribute("UserPass", password); - } else { - context = ContextFactory.createContext("SSH"); - context.setAttribute(Context.USERID, username); - } - context.setVectorAttribute("BaseUrlIncludes", new String[]{"sftp://"}); - context.setVectorAttribute("DataServiceAttributes", new String[]{"sftp.KnownHosts="}); - session.addContext(context); - - } catch (Exception e) { - logger.error("Error in creating session"); - logger.error(e.toString()); - logger.error("Cause :" + e.getCause()); - return null; - } - - try { - logger.info("Creating a new JobService..."); - URL serviceURL = URLFactory.createURL(resourceManager); - service = JobFactory.createJobService(session, serviceURL); - } catch (Exception e) { - e.printStackTrace(); - logger.error("Error in creating jobService..."); - logger.error(e.toString()); -// logger.error("Cause :" + e.getCause()); - return null; - } - - sshJobServices.put(sshInfo, service); - sshJobServicesCounter.put(service, new Integer(1)); - } else { - logger.info("JobService already exists!"); - - Integer counter = sshJobServicesCounter.get(service); - if (counter == null) - logger.warn("ERROR! sshJobServicesCounter disaligned!"); - - sshJobServicesCounter.put(service, counter + 1); - logger.info("New counter=" + sshJobServicesCounter.get(service)); - logger.info("Number of elements in sshJobServicesCounter=" - + sshJobServicesCounter.size()); - } - - return service; - } - - /** - * Closes a JobService used for SSH middleware. - * - * @param username - * username parameter - * @param resourceManager - * resource manager host - */ - public synchronized void closeSSHJobService(String username, - String resourceManager) { - logger.info("closeSSHJobService..."); - String sshInfo = username + "-" + resourceManager; - JobService service = sshJobServices.get(sshInfo); - - if (service == null) { - logger.warn("Error: Job Service not available.."); - return; - } - - Integer counter = sshJobServicesCounter.get(service); - if (counter == null) { - logger.warn("ERROR! sshJobServicesCounter disaligned!"); - return; - } - - if (counter.intValue() > 1) { - sshJobServicesCounter.put(service, counter - 1); - logger.info("New counter=" + sshJobServicesCounter.get(service)); - logger.info("NUmber of elements in sshJobServicesCounter=" - + sshJobServicesCounter.size()); - } else if (counter.intValue() == 1) { - sshJobServices.remove(sshInfo); - sshJobServicesCounter.remove(service); - - try { - Session session = service.getSession(); - - try { - ((JobServiceImpl) service).disconnect(); - } catch (NoSuccessException e2) { - logger.error("ERROR! SSH service not disconnected"); - e2.printStackTrace(); - } - - session.close(); - } catch (Exception e) { - logger.error("Error in closing session!"); - } - logger.info("Job service removed..."); - - } - } - - private synchronized String getMyproxyServerForVO(String vo) { - logger.info("getMyproxyServerForVO=" + vo); - - String myproxyserver = ""; - int startIndex = myproxyServers.indexOf(vo); - - if (startIndex != -1) { - int endIndex = myproxyServers.indexOf(";", startIndex); - - if (endIndex != -1) - myproxyserver = myproxyServers.substring( - startIndex + vo.length() + 1, endIndex); - else - myproxyserver = myproxyServers.substring(startIndex - + vo.length() + 1); - } - logger.info("myproxyserver=" + myproxyserver); - - return myproxyserver; - } -} diff --git a/it/infn/ct/GridEngine/JobService/JobServicesDispatcherFactory.java b/it/infn/ct/GridEngine/JobService/JobServicesDispatcherFactory.java deleted file mode 100644 index a4626aa..0000000 --- a/it/infn/ct/GridEngine/JobService/JobServicesDispatcherFactory.java +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) -****************************************************************************/ - -package it.infn.ct.GridEngine.JobService; - -import java.util.Enumeration; -import java.util.Hashtable; - -import javax.naming.Context; -import javax.naming.Name; -import javax.naming.NamingException; -import javax.naming.RefAddr; -import javax.naming.Reference; - - -public class JobServicesDispatcherFactory implements javax.naming.spi.ObjectFactory, java.io.Serializable { - - @Override - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable environment) throws Exception { - JobServicesDispatcher jobServiceDispatcher = JobServicesDispatcher.getInstance(); - - try { - Reference reference = (Reference) obj; - Enumeration enumeration = reference.getAll(); - while (enumeration.hasMoreElements()) { - RefAddr refAddr = (RefAddr) enumeration.nextElement(); - String pname = refAddr.getType(); - String pvalue = (String) refAddr.getContent(); - if ("retrycount".equalsIgnoreCase(pname)) { - jobServiceDispatcher.setRetryCount(Integer.parseInt(pvalue)); - } - else if ("myproxyservers".equalsIgnoreCase(pname)) { - jobServiceDispatcher.setMyproxyServers(pvalue); - } - else if ("truststorepath".equalsIgnoreCase(pname)) { - jobServiceDispatcher.setTrustStorePath(pvalue); - } - else if ("truststorepassword".equalsIgnoreCase(pname)) { - jobServiceDispatcher.setTrustStorePassword(pvalue); - } - else if ("genesistruststorepath".equalsIgnoreCase(pname)) { - jobServiceDispatcher.setGenesisTrustStorePath(pvalue); - } - else if ("genesistruststorepassword".equalsIgnoreCase(pname)) { - jobServiceDispatcher.setGenesisTrustStorePassword(pvalue); - } - else if("resubnumber".equalsIgnoreCase(pname)){ - jobServiceDispatcher.setResubmissionNumber(Integer.parseInt(pvalue)); - } - else if("smtpserver".equalsIgnoreCase(pname)){ - jobServiceDispatcher.setSmtpServer(pvalue); - } - else if("senderaddress".equalsIgnoreCase(pname)){ - jobServiceDispatcher.setSenderAddress(pvalue); - } - else { - throw new IllegalArgumentException("Unrecognized property name: " + pname); - } - } - } catch (Exception e) { - throw (NamingException) (new NamingException()).initCause(e); - } - return jobServiceDispatcher; - } -}; \ No newline at end of file diff --git a/it/infn/ct/GridEngine/JobService/RobotProxy.java b/it/infn/ct/GridEngine/JobService/RobotProxy.java deleted file mode 100644 index 1163ccb..0000000 --- a/it/infn/ct/GridEngine/JobService/RobotProxy.java +++ /dev/null @@ -1,323 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) - ****************************************************************************/ - -package it.infn.ct.GridEngine.JobService; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.UUID; - -import org.apache.commons.io.FileUtils; -import org.apache.log4j.Logger; - -public class RobotProxy { - - String folderPath = "/tmp/"; - String proxyPath = ""; - String proxyId = ""; - String VO = ""; - boolean proxyRenewal = false; - String FQAN = ""; - boolean RFC = false; - String cnLabel = "eToken:Empty"; - - String eTokenServer = "myproxy.ct.infn.it"; - String eTokenServerPort = "8082"; - - private static final Logger logger = Logger.getLogger(RobotProxy.class); - - /** - * Constructs a {@link RobotProxy} object with given parameters. - * - * @param proxyid - * robot proxy identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - */ - public RobotProxy(String proxyid, String vo, String fqan, - boolean proxyrenewal) { - proxyId = proxyid; - VO = vo; - FQAN = fqan; - proxyRenewal = proxyrenewal; - } - - /** - * Constructs a {@link RobotProxy} object with given parameters. - * - * @param proxyid - * robot proxy identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - */ - public RobotProxy(String proxyid, String vo, String fqan, - boolean proxyrenewal, boolean rfc) { - proxyId = proxyid; - VO = vo; - FQAN = fqan; - proxyRenewal = proxyrenewal; - RFC = rfc; - } - - - /** - * Constructs a {@link RobotProxy} object with given parameters. - * - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - */ - public RobotProxy(String etokenserver, String etokenserverport, - String proxyid, String vo, String fqan, boolean proxyrenewal) { - eTokenServer = etokenserver; - eTokenServerPort = etokenserverport; - proxyId = proxyid; - VO = vo; - FQAN = fqan; - proxyRenewal = proxyrenewal; - } - - /** - * Constructs a {@link RobotProxy} object with given parameters. - * - * @param etokenserver - * robot proxy server host - * @param etokenserverport - * robot proxy server port - * @param proxyid - * robot proxy server identifier - * @param vo - * robot proxy virtual organization - * @param fqan - * robot proxy roles - * @param proxyrenewal - * a boolean value that says if the robot proxy is renewable or - * not - * @param rfc - * a boolean value that says if the robot proxy is in RFC format or - * not - */ - public RobotProxy(String etokenserver, String etokenserverport, - String proxyid, String vo, String fqan, boolean proxyrenewal, boolean rfc, String cnLabel) { - eTokenServer = etokenserver; - eTokenServerPort = etokenserverport; - proxyId = proxyid; - VO = vo; - FQAN = fqan; - proxyRenewal = proxyrenewal; - RFC = rfc; - this.cnLabel = cnLabel; - } - - /** - * Returns the folder path where user proxy is stored. - * - * @return folder path where user proxy is stored. - */ - public String getFolderPath() { - return folderPath; - } - - /** - * Sets folder path where user proxy is stored. - * - * @param path - * folder path where user proxy is stored. - */ - public void setFolderPath(String path) { - folderPath = path; - } - - /** - * Returns the path where user proxy is stored. - * - * @return path where user proxy is stored. - */ - public String getProxyPath() { - return proxyPath; - } - - /** - * Sets the path where user proxy is stored. - * - * @param path - * path where user proxy is stored. - */ - public void setProxyPath(String path) { - proxyPath = path; - } - - /** - * Returns the robot proxy identifier. - * - * @return robot proxy identifier. - */ - public String getproxyId() { - return proxyId; - } - - /** - * Sets the robot proxy identifier. - * - * @param proxyid - * the robot proxy identifier. - */ - public void setproxyId(String proxyid) { - proxyId = proxyid; - } - - /** - * Returns the robot proxy virtual organization. - * - * @return robot proxy virtual organization. - */ - public String getVO() { - return VO; - } - - /** - * Sets the robot proxy virtual organization. - * - * @param vo - * robot proxy virtual organization. - */ - public void setVO(String vo) { - VO = vo; - } - - /** - * Returns the robot proxy roles. - * - * @return robot proxy roles. - */ - public String getFQAN() { - return FQAN; - } - - /** - * Sets the robot proxy roles. - * - * @param fqan - * robot proxy roles. - */ - public void setFQAN(String fqan) { - FQAN = fqan; - } - - /** - * Returns a string representing robot proxy information. - * - * @return string representing robot proxy information. - */ - public String getRobotProxy() { - File proxyFile; - - if (!proxyPath.equals("")) - deleteRobotProxy(); - - logger.info("----->New GET HTTP<--------"); - - proxyPath = folderPath + UUID.randomUUID(); - proxyFile = new File(proxyPath); - logger.info("proxyPath=" + proxyPath); - - String proxyContent = ""; - URL proxyURL = null; - try { - if (RFC) { - proxyURL = new URL("http://" + eTokenServer + ":" - + eTokenServerPort + "/eTokenServer/eToken/" + proxyId - + "?voms=" + VO + ":" + FQAN + "&disable-voms-proxy=false&proxy-renewal=" - + proxyRenewal + "&rfc-proxy=" + RFC + "&cn-label=" + cnLabel); - } - else { - proxyURL = new URL("http://" + eTokenServer + ":" - + eTokenServerPort + "/eTokenServer/eToken/" + proxyId - + "?voms=" + VO + ":" + FQAN + "&proxy-renewal=" - + proxyRenewal + "&cn-label=" + cnLabel); - } - logger.info("get proxy: " + proxyURL.toString()); - URLConnection proxyConnection = proxyURL.openConnection(); - proxyConnection.setDoInput(true); - InputStream proxyStream = proxyConnection.getInputStream(); - BufferedReader input = new BufferedReader(new InputStreamReader( - proxyStream)); - String line = ""; - while ((line = input.readLine()) != null) { - proxyContent += line + "\n"; - } - FileUtils.writeStringToFile(proxyFile, proxyContent); - } catch (Exception e) { - if (proxyURL != null) - logger.error("Error in getting proxy: " + proxyURL.toString()); - return ""; - } - - return proxyPath; - } - - /** - * This method tries to remove the user proxy file. - */ - public void deleteRobotProxy() { - File f = new File(proxyPath); - if (!f.exists()) - return; - - // Attempt to delete it - boolean success = f.delete(); - - if (!success) - logger.warn("Error in deleting proxy = " + proxyPath); - else - proxyPath = ""; - } -} diff --git a/it/infn/ct/GridEngine/SendMail/MailUtility.java b/it/infn/ct/GridEngine/SendMail/MailUtility.java deleted file mode 100644 index 42082e2..0000000 --- a/it/infn/ct/GridEngine/SendMail/MailUtility.java +++ /dev/null @@ -1,303 +0,0 @@ -package it.infn.ct.GridEngine.SendMail; - -import it.infn.ct.GridEngine.JobService.JobServicesDispatcher; - -import java.util.Date; - -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; - -import org.apache.log4j.Logger; - -/** - * An utility class used to send an email to notify an user for a successfully - * completed interaction. - * - * @author mario - * - */ -public class MailUtility { - - public enum ContentMessage { - SIMPLE_JOB, JOB_COLLECTION, WORKFLOW_N1, SUBMISSION_ERROR; - } - - /** - * Logger for this class - */ - private static final Logger logger = Logger.getLogger(MailUtility.class); - // - private String from = JobServicesDispatcher.getInstance().getSenderAddress();// = "sg-licence@ct.infn.it"; - private String portal; - private String application; - private String description; - private String messageContent; - private String to;// = "mario.torrisi@ct.infn.it"; - // private String smtp = "mbox.ct.infn.it"; - private String smtp = JobServicesDispatcher.getInstance().getSmtpServer(); - - /** - * Prepares an {@link MailUtility} object to send to a specified user email - * address. - * - * @param to - * user email address - * @param portal - * the portal where the interaction was generated - * @param application - * the application used by the user - * @param description - * the description for this interaction - * @param cm - * interaction type. - * @see ContentMessage - */ - public MailUtility(String to, String portal, String application, - String description, ContentMessage cm) { - super(); - if(to.contains("|")){ - this.from = to.substring(0,to.indexOf('|')); - this.to = to.substring(to.indexOf('|')+1); - } else - this.to = to; - - this.application = application; - this.portal = portal; - this.description = description; - setMessageContent(cm); - } - - /** - * Prepares an {@link MailUtility} object to send to a specified user email - * address. - * - * @param to - * to user email address - * @param description - * the description for this interaction - * @param cm - * interaction type. see {@link ContentMessage}. - */ - public MailUtility(String to, String description, ContentMessage cm) { - super(); - if(to.contains("|")){ - this.from = to.substring(0,to.indexOf('|')); - this.to = to.substring(to.indexOf('|')+1); - } else - this.to = to; - - this.description = description; - setMessageContent(cm); - } - - // public String getApplication() { - // return application; - // } - // - // public void setApplication(String application) { - // this.application = application; - // } - // - // public String getPortal() { - // return portal; - // } - // - // public void setPortal(String portal) { - // this.portal = portal; - // } - // - // public String getDescription() { - // return description; - // } - // - // public void setDescription(String description) { - // this.description = description; - // } - // - // public String getTo() { - // return to; - // } - // - // public void setTo(String to) { - // this.to = to; - // } - - /** - * Sends the email. - */ - public void sendMail() { - // Creazione di una mail session - java.util.Properties props = new java.util.Properties(); - props.put("mail.smtp.host", smtp); - Session session = Session.getDefaultInstance(props); - - // Creazione del messaggio da inviare - MimeMessage message = new MimeMessage(session); - try { - message.setSubject(" [" + this.from + "] - [ " + this.application - + " ] "); - - java.util.Date currentDate = new java.util.Date(); - currentDate.setTime(currentDate.getTime()); - - message.setContent(this.messageContent, "text/html"); - // Aggiunta degli indirizzi del mittente e del destinatario - InternetAddress fromAddress = new InternetAddress(from); - InternetAddress toAddress = new InternetAddress(this.to); - message.setFrom(fromAddress); - message.setRecipient(Message.RecipientType.TO, toAddress); - - // Invio del messaggio - Transport.send(message); - - } catch (MessagingException e) { - // TODO Auto-generated catch block - logger.fatal(e.getLocalizedMessage()); - e.printStackTrace(); - } catch (Exception e) { - logger.fatal(e.getLocalizedMessage()); - } - } - - private void setMessageContent(ContentMessage cm) { - switch (cm) { - case SIMPLE_JOB: - this.messageContent = "

" - + "Science Gateway " - + this.portal - + "



" - + "Notification for completed job, Description: [ " - + this.description - + " ]
" - + "The job identified by: " - + this.description - + " has been successfully completed.

" - + "TimeStamp: " - + new Date(System.currentTimeMillis()) - + "

" - + "Disclaimer:
" - + "This is an automatic message sent by the Science Gateway based on Liferay technology.
" - + "If you did not submit any jobs through the Science Gateway, please " - + "contact us
"; - break; - - case JOB_COLLECTION: - this.messageContent = "

" - + "Science Gateway " - + this.portal - + "



" - + "Notification for completed job collection, Description: [ " - + this.description - + " ]
" - + "The job collection identified by: " - + this.description - + " has been successfully completed.

" - + "TimeStamp: " - + new Date(System.currentTimeMillis()) - + "

" - + "Disclaimer:
" - + "This is an automatic message sent by the Science Gateway based on Liferay technology.
" - + "If you did not submit any jobs through the Science Gateway, please " - + "contact us
"; - break; - - case WORKFLOW_N1: - this.messageContent = "

" - + "Science Gateway " - + this.portal - + "



" - + "Notification for completed workflow, Description: [ " - + this.description - + " ]
" - + "The workflow identified by: " - + this.description - + " has been successfully completed.

" - + "TimeStamp: " - + new Date(System.currentTimeMillis()) - + "

" - + "Disclaimer:
" - + "This is an automatic message sent by the Science Gateway based on Liferay technology.
" - + "If you did not submit any jobs through the Science Gateway, please " - + "contact us
"; - break; - case SUBMISSION_ERROR: - this.messageContent = "

" - + "Science Gateway " - + this.portal - + "



" - + "Notification for submission error
" - + "The interaction identified by: " - + this.description - + " hasn't been submitted for uncorrect portlet configuration parameters. Please, contact the Science Gateway support team to fix the problem.

" - + "TimeStamp: " - + new Date(System.currentTimeMillis()) - + "

" - + "Disclaimer:
" - + "This is an automatic message sent by the Science Gateway based on Liferay technology.
" - + "If you did not submit any jobs through the Science Gateway, please " - + "contact us
"; - break; - } - } -} - -// public void sendMail (String[] jobData){ -// if (!jobData[7].equals("")){ -// to = jobData[7]; -// if (logger.isDebugEnabled()) -// logger.debug("Send email, FROM: ["+ from +"] TO: ["+ to +"]"); -// // Creazione di una mail session -// java.util.Properties props = new java.util.Properties(); -// props.put("mail.smtp.host", smtp); -// Session session = Session.getDefaultInstance(props); -// -// // Creazione del messaggio da inviare -// MimeMessage message = new MimeMessage(session); -// try { -// message.setSubject(" [liferay-sg-gateway] - [ " + jobData[10] + " ] "); -// -// java.util.Date currentDate = new java.util.Date(); -// currentDate.setTime (currentDate.getTime()); -// -// message.setContent("

" -// + -// "Science Gateway " -// + jobData[9] -// + "



" -// + "Notification for completed job, Description: [ " + jobData[6] + -// " ]
" -// + "The job identified by: "+ jobData[6] -// +" has been successfully completed.

" -// + "TimeStamp: " + currentDate + "

" -// + "Disclaimer:
" -// + -// "This is an automatic message sent by the Science Gateway based on Liferay technology.
" -// + "If you did not submit any jobs through the Science Gateway, please " -// + "contact us
", -// "text/html"); -// // Aggiunta degli indirizzi del mittente e del destinatario -// InternetAddress fromAddress = new InternetAddress(from); -// InternetAddress toAddress = new InternetAddress(jobData[7]); -// message.setFrom(fromAddress); -// message.setRecipient(Message.RecipientType.TO, toAddress); -// -// // Invio del messaggio -// Transport.send(message); -// -// } catch (MessagingException e) { -// // TODO Auto-generated catch block -// logger.fatal(e.getLocalizedMessage()); -// //e.printStackTrace(); -// } catch (Exception e){ -// logger.fatal(e.getLocalizedMessage()); -// } -// } -// else -// logger.info("No 'TO' mail address is set"); -// return; -// } - diff --git a/it/infn/ct/GridEngine/SessionManagement/RobotProxy.java b/it/infn/ct/GridEngine/SessionManagement/RobotProxy.java deleted file mode 100644 index 4ba4782..0000000 --- a/it/infn/ct/GridEngine/SessionManagement/RobotProxy.java +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) -****************************************************************************/ - -package it.infn.ct.GridEngine.SessionManagement; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.UUID; - -import org.apache.commons.io.FileUtils; - -public class RobotProxy { - - String folderPath = "/tmp/"; - String proxyPath = ""; - String proxyId = ""; - String VO = ""; - boolean proxyRenewal = false; - String FQAN = ""; - String eTokenServer = "myproxy.ct.infn.it"; - String eTokenServerPort = "8082"; - - public RobotProxy(String proxyid, String vo, String fqan, boolean proxyrenewal) { - proxyId = proxyid; - VO = vo; - FQAN = fqan; - proxyRenewal = proxyrenewal; - } - - public RobotProxy(String etokenserver, String etokenserverport, String proxyid, String vo, String fqan, boolean proxyrenewal) { - eTokenServer = etokenserver; - eTokenServerPort = etokenserverport; - proxyId = proxyid; - VO = vo; - FQAN = fqan; - proxyRenewal = proxyrenewal; - } - - public String getFolderPath() { - return folderPath; - } - - public void setFolderPath(String path) { - folderPath = path; - } - - public String getProxyPath() { - return proxyPath; - } - - public void setProxyPath(String path) { - proxyPath = path; - } - - public String getproxyId() { - return proxyId; - } - - public void setproxyId(String proxyid) { - proxyId = proxyid; - } - - public String getVO() { - return VO; - } - - public void setVO(String vo) { - VO = vo; - } - - public String getFQAN() { - return FQAN; - } - - public void setFQAN(String fqan) { - FQAN = fqan; - } - - public String getRobotProxy() { - File proxyFile; - - if (!proxyPath.equals("")) - deleteRobotProxy(); - - System.out.println("----->New GET HTTP<--------"); - - proxyPath = folderPath + UUID.randomUUID(); - proxyFile = new File(proxyPath); - System.out.println("proxyPath="+proxyPath); - String proxyContent=""; - try { - URL proxyURL=new URL("http://"+eTokenServer+":"+eTokenServerPort+"/eTokenServer/eToken/" + proxyId + "?voms=" + VO + ":" + FQAN + "&proxy-renewal=" + proxyRenewal); - URLConnection proxyConnection = proxyURL.openConnection(); - proxyConnection.setDoInput(true); - InputStream proxyStream = proxyConnection.getInputStream(); - BufferedReader input = new BufferedReader(new InputStreamReader(proxyStream)); - String line = ""; - while ((line = input.readLine()) != null) { - //System.out.println(line); - proxyContent+=line+"\n"; - } - FileUtils.writeStringToFile(proxyFile, proxyContent); - } - catch (Exception e) { - return ""; - } - - return proxyPath; - } - - - public void deleteRobotProxy() { - File f = new File(proxyPath); - if (!f.exists()) - return; - - // Attempt to delete it - boolean success = f.delete(); - - if (!success) - System.out.println("Error in deleting proxy = " + proxyPath); - else - proxyPath = ""; - } -} diff --git a/it/infn/ct/GridEngine/SessionManagement/SessionManager.java b/it/infn/ct/GridEngine/SessionManagement/SessionManager.java deleted file mode 100644 index d6274ab..0000000 --- a/it/infn/ct/GridEngine/SessionManagement/SessionManager.java +++ /dev/null @@ -1,166 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) -****************************************************************************/ - -package it.infn.ct.GridEngine.SessionManagement; - - -import org.ogf.saga.context.Context; -import org.ogf.saga.context.ContextFactory; -import org.ogf.saga.session.Session; -import org.ogf.saga.session.SessionFactory; - -import fr.in2p3.jsaga.impl.context.ContextImpl; - -public class SessionManager { - - Session session = null; - private boolean usingRobotProxy = false; - private RobotProxy robotProxy = null; - private String userProxy = ""; //for example /tmp/x509up_u500 - private String retryCount = "3"; - - public void useRobotProxy(String etokenserver, String etokenserverport, String proxyId, String vo, String fqan, boolean proxyrenewal) { - robotProxy = new RobotProxy(etokenserver, etokenserverport, proxyId, vo, fqan, proxyrenewal); - usingRobotProxy = true; - } - - public void useRobotProxy(String proxyId, String vo, String fqan, boolean proxyrenewal) { - robotProxy = new RobotProxy(proxyId, vo, fqan, proxyrenewal); - usingRobotProxy = true; - } - - public void setUserProxy(String value) { - userProxy = value; - } - - public String getUserProxy() { - return userProxy; - } - - public void setRetryCount(String value) { - retryCount = value; - } - - public String getRetryCount() { - return retryCount; - } - - public Session getSession() { - - if (usingRobotProxy) - setUserProxy(robotProxy.getRobotProxy()); - - if (userProxy.equals("")) return null; - - session = null; - - try { - System.out.println("Creating session...."); - session = SessionFactory.createSession(false); - System.out.println(ContextImpl.URL_PREFIX); - - Context context = ContextFactory.createContext("VOMS"); - context.setAttribute(Context.USERPROXY,userProxy); - context.setVectorAttribute("JobServiceAttributes", new String[]{"wms.RetryCount="+retryCount}); - session.addContext(context); - context.getAttribute(Context.USERID); - - System.out.println("VO="+context.getAttribute(Context.USERVO)); - System.out.println("DN="+context.getAttribute(Context.USERID)); - - - } catch (Exception e) { - System.out.println("Error in Session recovery..."); - System.out.println(e.toString()); - System.out.println("Cause :"+e.getCause()); - return null; - } - - System.out.println("Session recovered..."); - - return session; - } - - public void closeSession() { - if (usingRobotProxy) { - robotProxy.deleteRobotProxy(); - setUserProxy(""); - } - session.close(); - session = null; - } - - public String getUserDN() { - if (session==null) - getSession(); - if (session==null) return ""; //TODO manage error - - try { - Context[] contexts = session.listContexts(); - return contexts[0].getAttribute(Context.USERID); - } - catch (Exception e) {System.out.println("Error in getting User DN");} - - return ""; - } - - public String getUserVO() { - if (session==null) - getSession(); - if (session==null) return ""; //TODO manage error - - try { - Context[] contexts = session.listContexts(); - return contexts[0].getAttribute(Context.USERVO); - } - catch (Exception e) {System.out.println("Error in getting User DN");} - - return ""; - } - - public String getUserFQAN() { - if (session==null) - getSession(); - if (session==null) return null; //TODO manage error - - if (usingRobotProxy) { - return robotProxy.getFQAN(); - } - - return getUserVO(); //TODO using VOMS Java API to get FQAN from a proxy - } - - public String getProxyId() { - if (session==null) - getSession(); - if (session==null) return null; //TODO manage error - - if (usingRobotProxy) { - return robotProxy.getproxyId(); - } - - return ""; - } - -} diff --git a/it/infn/ct/GridEngine/UsersTracking/ActiveInteractions.java b/it/infn/ct/GridEngine/UsersTracking/ActiveInteractions.java deleted file mode 100644 index 6fcd1be..0000000 --- a/it/infn/ct/GridEngine/UsersTracking/ActiveInteractions.java +++ /dev/null @@ -1,58 +0,0 @@ -package it.infn.ct.GridEngine.UsersTracking; - -import java.util.Vector; - -/** - * This class represent an active grid interaction. An active grid interaction can - * be a simple job or a JobCollection still active on the infrastructure. - * - * @author mario - * - */ -public class ActiveInteractions { - - private String[] interactionInfos; - private Vector subJobs; - - public ActiveInteractions() { - super(); - } - - public ActiveInteractions(String[] interactionInfos, - Vector subJobs) { - super(); - this.interactionInfos = interactionInfos; - this.subJobs = subJobs; - } - - /** - * Returns a string array that contains information of this active grid interaction. - * If this active interactions not belongs to a collection getSubJobs() method return null. - * - * @return a string array that contains information of this active grid interaction. - * @see #getSubJobs() - */ - public String[] getInteractionInfos() { - return interactionInfos; - } - - protected void setInteractionInfos(String[] interactionInfos) { - this.interactionInfos = interactionInfos; - } - - /** - * Returns a {@link Vector} of string array that contains informations - * of the sub-jobs belonging to a collection. - * - * @return a {@link Vector} of string array that contains informations - * of the sub-jobs belonging to a collection. - */ - public Vector getSubJobs() { - return subJobs; - } - - protected void setSubJobs(Vector subJobs) { - this.subJobs = subJobs; - } - -} diff --git a/it/infn/ct/GridEngine/UsersTracking/UsersTrackingDBInterface.java b/it/infn/ct/GridEngine/UsersTracking/UsersTrackingDBInterface.java deleted file mode 100644 index 1714f4f..0000000 --- a/it/infn/ct/GridEngine/UsersTracking/UsersTrackingDBInterface.java +++ /dev/null @@ -1,2020 +0,0 @@ -/************************************************************************** -Copyright (c) 2011: -Istituto Nazionale di Fisica Nucleare (INFN), Italy -Consorzio COMETA (COMETA), Italy - -See http://www.infn.it and and http://www.consorzio-cometa.it for details on -the -copyright holders. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Author: Diego Scardaci (INFN) -****************************************************************************/ - - -package it.infn.ct.GridEngine.UsersTracking; - -import it.infn.ct.GridEngine.Config.GridEngineConfig; -import it.infn.ct.GridEngine.Job.JSagaJobSubmission; -import it.infn.ct.GridEngine.Job.JobId; -import it.infn.ct.GridEngine.JobCollection.ClosedJobCollection; -import it.infn.ct.GridEngine.JobCollection.JobCollection; -import it.infn.ct.GridEngine.JobCollection.WorkflowN1; -import it.infn.ct.GridEngine.JobResubmission.GEJobDescription; -import it.infn.ct.GridEngine.JobService.JobCheckStatusService; -import it.infn.ct.GridEngine.SendMail.MailUtility; -import it.infn.ct.GridEngine.SendMail.MailUtility.ContentMessage; -import it.infn.ct.ThreadPool.CheckJobStatusThreadPoolExecutor; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.TimeZone; -import java.util.Vector; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.sql.DataSource; - -import org.apache.log4j.Logger; - -public class UsersTrackingDBInterface { - - GridEngineConfig gec = GridEngineConfig.getInstance(); - - Connection conn = null; - String URL = ""; - String userName = ""; - String password = ""; - public boolean inAppServer; - int jobsUpdatingInterval = 300; - //Vector jobsStatusThread = new Vector(); - - private CheckJobStatusThreadPoolExecutor threadPool = null; - private boolean updatingJobsStatus=false; - - private static final Logger logger = Logger.getLogger(UsersTrackingDBInterface.class); - - /** - * - */ - public UsersTrackingDBInterface() { - inAppServer = true; - try { - threadPool = InitialContext.doLookup("GridEngine-CheckStatusPool"); - } - catch ( NamingException ex ) { - logger.error("Cannot get thread-pool: " + ex); -// System.out.println("Cannot get thread-pool: " + ex); - } - catch(Exception ex){ - logger.error("Cannot get thread-pool: " + ex); -// System.out.println("Cannot get thread-pool: " + ex); - } - } - - /** - * Constructs an objects that represents an interface to the users tracking database, - * where all user grid interactions are stored, specifying connection parameters. - * - * @param url database name - * @param username database username - * @param pwd database password. - */ - public UsersTrackingDBInterface(String url, String username, String pwd) { - inAppServer = false; - URL = url; - userName = username; - password = pwd; - } - - private boolean CreateDBConnection() { - if (inAppServer){ - logger.debug("###I'm in app server###"); - return CreateDBConnectionGlassfish(); - } - else{ - logger.debug("***I'm not in app server***"); - return CreateDBConnectionExternal(); - } - } - - /** Uses JNDI and Datasource (preferred style). */ - private boolean CreateDBConnectionGlassfish() { - if (conn != null) return true; //Connection just created - - //String DATASOURCE_CONTEXT = "java:comp/env/jdbc/blah"; - //String DATASOURCE_CONTEXT = "jdbc/UserTrackingPool"; - String DATASOURCE_CONTEXT = gec.getUserstrackingDatasource(); - - - Connection result = null; - try { - Context initialContext = new InitialContext(); - DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT); - if (datasource != null) { - result = datasource.getConnection(); - } - else { - logger.warn("Failed to lookup datasource."); -// System.out.println("Failed to lookup datasource."); - } - } - catch ( NamingException ex ) { - logger.error("Cannot get connection: " + ex); -// System.out.println("Cannot get connection: " + ex); - } - catch(SQLException ex){ - logger.error("Cannot get connection: " + ex); -// System.out.println("Cannot get connection: " + ex); - } - catch(Exception ex){ - logger.error("Cannot get connection: " + ex); -// System.out.println("Cannot get connection: " + ex); - } - conn = result; - - if (conn==null) return false; - - return true; - } - - private boolean CreateDBConnectionExternal() { - if (conn != null) return true; //Connection just created - - try - { - Class.forName ("com.mysql.jdbc.Driver").newInstance (); - conn = DriverManager.getConnection (URL, userName, password); - logger.info("Database connection established"); -// System.out.println ("Database connection established"); - return true; - } - catch (Exception e) - { - logger.error("Cannot connect to database server: " + e.toString()); -// System.out.println(e.toString()); - System.err.println ("Cannot connect to database server"); - } - - return false; - } - - private boolean CloseDBConnection() { - if (conn != null) - { - try - { - conn.close (); - conn = null; - logger.info("Database connection terminated"); -// System.out.println ("Database connection terminated"); - return true; - } - catch (Exception e) { - /* ignore close errors */ - return false; - } - } - - return true; - } - - /** - * Returns the interval between two consecutively updating job status events. - * - * @return the interval between two consecutively updating job status events. - */ - public int getJobsUpdatingInterval() { - return jobsUpdatingInterval; - } - - /** - * Sets the interval between two consecutively updating job status events. - * - * @param value the interval between two consecutively updating job status events. - */ - public void setJobsUpdatingInterval(int value) { - jobsUpdatingInterval = value; - } - -// public boolean isInAppServer() { -// return inAppServer; -// } - - /** - * Performs a SQL INSERT INTO in the ActiveGridInteractions users tracking database table - * - * @param commonName a String representing user name - * @param tcpAddress user's IP address - * @param gridInteraction an identifier of application in a specified portal - * @param gridId the grid identifier for this interaction - * @param robotCertificate used to submit this job - * @param proxyId used to submit this job - * @param VO - * @param FQAN - * @param userDescription a description for this job. - * @param jobIdCollection collection identifier, if job belongs to a collection, null otherwise - * @return auto generated id of this insert. - */ - public int InsertActiveGridInteraction(String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription, Integer jobIdCollection) { - //********MARIO********** - //email == eTokenServer == "" - //return InsertGridInteraction("ActiveGridInteractions", commonName, tcpAddress, gridInteraction, gridId, robotCertificate, proxyId, VO, FQAN, userDescription); - return InsertGridInteraction("ActiveGridInteractions", commonName, tcpAddress, gridInteraction, gridId, robotCertificate, proxyId, VO, FQAN, userDescription, "", "", jobIdCollection); - } - - /** - * Performs a SQL INSERT INTO in the ActiveGridInteractions users tracking database table - * - * @param commonName a String representing user name - * @param tcpAddress user's IP address - * @param gridInteraction an identifier of application in a specified portal - * @param gridId the grid identifier for this interaction - * @param robotCertificate used to submit this job - * @param proxyId used to submit this job - * @param VO - * @param FQAN - * @param userDescription a description for this job. - * @param email user email to notify that the job has been - * @param jobCollectionId collection identifier, if job belongs to a collection, null otherwise - * @return auto generated id of this insert. - */ - public int InsertActiveGridInteraction(String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription, String email, Integer jobCollectionId) { - //eTokenServer == "" - //email != "" - return InsertGridInteraction("ActiveGridInteractions", commonName, tcpAddress, gridInteraction, gridId, robotCertificate, proxyId, VO, FQAN, userDescription, email, "", jobCollectionId); - } - - /** - * Performs a SQL INSERT INTO in the ActiveGridInteractions users tracking database table - * - * @param commonName a String representing user name - * @param tcpAddress user's IP address - * @param gridInteraction an identifier of application in a specified portal - * @param gridId the grid identifier for this interaction - * @param robotCertificate used to submit this job - * @param proxyId used to submit this job - * @param VO - * @param FQAN - * @param userDescription a description for this job. - * @param email user email to notify that the job has been - * @param eTokenServer - * @param jobIdCollection collection identifier, if job belongs to a collection, null otherwise - * @return auto generated id of this insert. - */ - public int InsertActiveGridInteraction(String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription, String email, String eTokenServer, Integer jobIdCollection) { - //email != eTokenServer != "" - return InsertGridInteraction("ActiveGridInteractions", commonName, tcpAddress, gridInteraction, gridId, robotCertificate, proxyId, VO, FQAN, userDescription, email, eTokenServer, jobIdCollection ); - } - - private int InsertGridInteraction(String DB, String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription, String email, String eTokenServer, Integer jobIdCollection) { - //*********************** - //private int InsertGridInteraction(String DB, String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription) { - if(logger.isDebugEnabled()) - logger.debug("Input = " + DB + "," + commonName + "," + tcpAddress + "," + gridInteraction + "," + gridId + "," + robotCertificate + "," + proxyId + "," + VO + "," + FQAN); - - if (CreateDBConnection()) - { - try - { - //String query = "INSERT INTO " + DB + " (common_name, tcp_address, grid_interaction, grid_id, robot_certificate, proxy_id, virtual_organization, fqan, user_description, status, timestamp) VALUES (?,?,?,?,?,?,?,?,?,?,?) "; - String query = "INSERT INTO " + DB + " (common_name, tcp_address, grid_interaction, grid_id, robot_certificate, proxy_id, virtual_organization, fqan, user_description, status, timestamp, email, e_token_server, id_job_collection) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query,Statement.RETURN_GENERATED_KEYS); - pstmt.setString(1, commonName); - pstmt.setString(2, tcpAddress); - pstmt.setInt(3, gridInteraction); - pstmt.setString(4, gridId); - pstmt.setString(5, robotCertificate); - pstmt.setString(6, proxyId); - pstmt.setString(7, VO); - pstmt.setString(8, FQAN); - pstmt.setString(9, userDescription); - pstmt.setString(10, "SUBMITTED"); //TODO Can I leave this default value for the data management? - pstmt.setTimestamp(11, getCurrentUTCTimestamp()); - //***********MARIO************* - pstmt.setString(12, email); - pstmt.setString(13, eTokenServer); - if(jobIdCollection!=null) - pstmt.setInt(14, jobIdCollection); - else - pstmt.setNull(14, java.sql.Types.INTEGER); - //***************************** - - boolean flag = pstmt.execute(); - - if (flag) System.out.println("flag true"); - - logger.info("Data Inserted."); - - ResultSet rs = pstmt.getGeneratedKeys(); - if (rs.next()) { - int auto_id = rs.getInt(1); - logger.info("ID = " + auto_id); - - if (!updatingJobsStatus) - CloseDBConnection(); - - return auto_id; - } - else { - logger.warn("There are no generated keys."); -// System.out.println("There are no generated keys."); - } - - } - catch (Exception e) { - logger.error("Cannot insert data in the DB." + e.toString()); -// System.out.println(e.toString()); - System.err.println ("Cannot insert data in the DB."); - e.printStackTrace(); - } - } - else{ - logger.error("Cannot insert data in the DB: DB Connection is closed."); - System.err.println ("Cannot insert data in the DB: DB Connection is closed."); - } - - if(!updatingJobsStatus) - CloseDBConnection(); - - return -1; - - } - -// private int InsertEndGridInteraction(String DB, String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription, Timestamp jobStartDataTime, String status, String gridCE, float latitude, float longitude, Timestamp jobEndDataTime) { - private int InsertEndGridInteraction(String DB, String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription, Timestamp jobStartDataTime, String status, String gridCE, float latitude, float longitude, Timestamp jobEndDataTime, Integer idClosedCollection) { - if(logger.isDebugEnabled()) - logger.debug("Input = " + DB + "," + commonName + "," + tcpAddress + "," + gridInteraction + "," + gridId + "," + robotCertificate + "," + proxyId + "," + VO + "," + FQAN); - if (CreateDBConnection()) - { - try - { -// String query = "INSERT INTO " + DB + " (common_name, tcp_address, grid_interaction, grid_id, robot_certificate, proxy_id, virtual_organization, fqan, user_description, status, timestamp, grid_ce, latitude, longitude, timestamp_endjob) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; - String query = "INSERT INTO " + DB + " (common_name, tcp_address, grid_interaction, grid_id, robot_certificate, proxy_id, virtual_organization, fqan, user_description, status, timestamp, grid_ce, latitude, longitude, timestamp_endjob, id_job_collection) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query,Statement.RETURN_GENERATED_KEYS); - pstmt.setString(1, commonName); - pstmt.setString(2, tcpAddress); - pstmt.setInt(3, gridInteraction); - pstmt.setString(4, gridId); - pstmt.setString(5, robotCertificate); - pstmt.setString(6, proxyId); - pstmt.setString(7, VO); - pstmt.setString(8, FQAN); - pstmt.setString(9, userDescription); - pstmt.setString(10, status); //TODO Can I leave this default value for the data management? - pstmt.setTimestamp(11, jobStartDataTime); - pstmt.setString(12, gridCE); - pstmt.setFloat(13, latitude); - pstmt.setFloat(14, longitude); - pstmt.setTimestamp(15, jobEndDataTime); - if(idClosedCollection != null) - pstmt.setInt(16, idClosedCollection); - boolean flag = pstmt.execute(); - - if (flag) System.out.println("flag true"); - logger.info("Data Inserted."); -// System.out.println("Data Inserted."); - - ResultSet rs = pstmt.getGeneratedKeys(); - if (rs.next()) { - int auto_id = rs.getInt(1); - logger.info("ID = " + auto_id); -// System.out.println("ID = " + auto_id); - - if(!updatingJobsStatus) - CloseDBConnection(); - - return auto_id; - } - else { - logger.warn("There are no generated keys."); -// System.out.println("There are no generated keys."); - } - - } - catch (Exception e) { - logger.error("Cannot insert data in the DB." + e.toString()); -// System.out.println(e.toString()); - System.err.println ("Cannot insert data in the DB."); - } - } - else{ - logger.error("Cannot insert data in the DB: DB Connection is closed."); - System.err.println ("Cannot insert data in the DB: DB Connection is closed."); - } - - if(!updatingJobsStatus) - CloseDBConnection(); - - return -1; - - } - - /** - * Sets grid identifier to the active grid interaction with the specified id. - * - * @param grid_id grid identifier - * @param id identifier of the active grid interaction that will be updated. - * @return 0 if the update was successfully, -1 otherwise. - */ - public int updateGridInteraction(String grid_id, int id) { - if (CreateDBConnection()) - { - try - { - PreparedStatement pstmt = conn.prepareStatement( - "UPDATE ActiveGridInteractions SET grid_id = ? WHERE id = ?"); - - pstmt.setString(1, grid_id); - pstmt.setInt(2, id); - - pstmt.executeUpdate(); - - if(!updatingJobsStatus) - CloseDBConnection(); - - return 0; - - } - catch (Exception e) { - logger.error("Cannot update data in the DB." + e.toString()); -// System.out.println(e.toString()); - System.err.println ("Cannot update data in the DB."); - } - } - else{ - logger.error("Cannot update data in the DB: DB Connection is closed."); -// System.err.println ("Cannot update data in the DB: DB Connection is closed."); - } - - if(!updatingJobsStatus) - CloseDBConnection(); - - return -1; - } - - /** - * This method closes an active grid interaction by moving information from - * ActiveGridIteractions table to GridInteractions. - * - * @param id of the closing active grid interaction. - * @return 0 if the moving was successfully, -1 otherwise. - * @see #CloseGridInteraction(int id, int idClosedCollection) - */ - public int CloseGridInteraction(int id){ - return CloseGridInteraction(id, -1); - } - - /** - * This method closes an active grid interaction belonging to a collection by - * moving information from ActiveGridIteractions table to GridInteractions and - * setting the identifier of the closed collection. - * - * @param id of the closing active grid interaction - * @param idClosedCollection identifier of the closed collection. - * @return 0 if the moving was successfully, -1 otherwise. - */ - public int CloseGridInteraction(int id, int idClosedCollection) { - if (CreateDBConnection()) - { - try - { - String query = "SELECT * FROM ActiveGridInteractions WHERE id = ?"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query,Statement.RETURN_GENERATED_KEYS); - pstmt.setInt(1, id); - - ResultSet rs; - rs = pstmt.executeQuery(); - - //if (rs==null) System.out.println("rs is null"); - - if (rs.next()) { - logger.info("Inserting data in GridInteractions."); -// System.out.println("Inserting data in GridInteractions."); - //InsertEndGridInteraction(String DB, String commonName, String tcpAddress, int gridInteraction, String gridId, String robotCertificate, String proxyId, String VO, String FQAN, String userDescription, Timestamp jobStartDataTime, String status, String gridCE, float latitude, float longitude, Timestamp jobEndDataTime) { - String status = rs.getString(12); - if(!status.equals("DONE")) - status = "Aborted"; - -// InsertEndGridInteraction("GridInteractions",rs.getString(2),rs.getString(3),rs.getInt(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getString(9),rs.getString(10),rs.getString(11),rs.getTimestamp(4),status,rs.getString(13),rs.getFloat(14),rs.getFloat(15),rs.getTimestamp(16)); - InsertEndGridInteraction("GridInteractions",rs.getString(2),rs.getString(3),rs.getInt(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getString(9),rs.getString(10),rs.getString(11),rs.getTimestamp(4),status,rs.getString(13),rs.getFloat(14),rs.getFloat(15),rs.getTimestamp(16), idClosedCollection); - - if (CreateDBConnection()) { - logger.info("Deleting data in ActiveGridInteractions."); -// System.out.println("Deleting data in ActiveGridInteractions."); - query = "DELETE FROM ActiveGridInteractions WHERE id = ?"; - pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setInt(1, id); - - pstmt.execute(); - - if(!updatingJobsStatus) - CloseDBConnection(); - - return 0; - } - else - logger.warn("Error in delete entry in ActiveGridInteractions."); -// System.out.println("Error in delete entry in ActiveGridInteractions."); - - - } - - } - catch (Exception e) { - logger.error("Cannot move data in the DB." + e.toString()); -// System.out.println(e.toString()); - System.err.println ("Cannot move data in the DB."); - } - } - else{ - logger.error("Cannot move data in the DB: DB Connection is closed."); - System.err.println ("Cannot move data in the DB: DB Connection is closed."); - } - - if(!updatingJobsStatus) - CloseDBConnection(); - - return -1; - } - - /** - * Returns a {@link Vector} of {@link ActiveInteractions} - * - * @param commonName a String representing user name - * @return a {@link Vector} of {@link ActiveInteractions} - */ - public Vector getActiveInteractionsByName (String commonName) { - //l'output è un vettore di stringhe costituito da id(Activegrid..) Portal(GridOperation) descri(GO) userdesr(AcGI) timestamp(AcGI) status(AcGI) - //In caso di collection prenod i capi d acollection attive - - Vector activeInteractions = new Vector(); - - Vector activeJobsList = getActiveJobsListByName(commonName); -// Vector activeCollections = JobCollection.getActiveJobCollectionsByName(commonName); - HashMap> tmp = new HashMap>(); - - for(String[] gridInteraction : activeJobsList){ - if(gridInteraction[6]==null){ - activeInteractions.add(new ActiveInteractions(gridInteraction, null)); - } else { - Integer key = Integer.parseInt(gridInteraction[6]); - if(tmp.containsKey(key)) - tmp.get(key).add(gridInteraction); - else{ - Vector firstSubjob = new Vector(); - firstSubjob.add(gridInteraction); - tmp.put(key, firstSubjob); - } - } - } - - if(tmp!=null){ - for(Integer key : tmp.keySet()){ - JobCollection collection = JobCollection.getJobCollection(key); - String[] collectionInfos = collection.getCollectionInfos(); - if(collection instanceof WorkflowN1){ - if(collection.getCollectionStatus().equals("SUBMITTING_FINAL_JOB") || - collection.getCollectionStatus().equals("RUNNING_FINAL_JOB") || - collection.getCollectionStatus().equals("DONE")){ - Vector finalSubJob = new Vector(); - for(String[] subJobsinfos : tmp.get(key)) - if(subJobsinfos[3].contains("-Final")) - finalSubJob.add(subJobsinfos); - tmp.put(key, finalSubJob); - } - } - collectionInfos[1] = tmp.get(key).elementAt(0)[1]; - collectionInfos[2] = tmp.get(key).elementAt(0)[2]; - activeInteractions.add(new ActiveInteractions(collectionInfos, tmp.get(key))); - } - } - return activeInteractions; - } - - @Deprecated - public Vector getActiveJobsListByName (String commonName) { - //l'output è un vettore di stringhe costituito da id(Activegrid..) Portal(GridOperation) descri(GO) userdesr(AcGI) timestamp(AcGI) status(AcGI) - //In caso di collection prenod i capi d acollection attive - - - if (CreateDBConnection()) - { - Vector activeJobsList = new Vector(); - try - { - logger.info("Querying ActiveGridInteractions..."); -// System.out.println("querying ActiveGridInteractions..."); - String query = "SELECT * FROM ActiveGridInteractions WHERE common_name = ?"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, commonName); - - ResultSet rs; - rs = pstmt.executeQuery(); - -// if (rs==null) { -// System.out.println("rs is null"); -// System.out.println("jobs list is empty for " + commonName); -// CloseDBConnection(); -// return null; -// } - - while (rs.next()) { - String[] item = new String[7]; - logger.info("querying GridOperations..."); -// System.out.println("querying GridOperations..."); - query = "SELECT * FROM GridOperations WHERE id = ?"; - PreparedStatement pstmt2 = (PreparedStatement) conn.prepareStatement(query); - pstmt2.setInt(1, rs.getInt(5)); - - ResultSet rsGridOp; - rsGridOp = pstmt2.executeQuery(); - - if ( (rsGridOp!=null) && (rsGridOp.next()) ) { - logger.info("Getting GridOperations data..."); -// System.out.println("getting GridOperations data..."); - item[1] = rsGridOp.getString(2); - item[2] = rsGridOp.getString(3); - - rsGridOp.close(); - pstmt2.close(); - } - else { - logger.warn("Grid Interaction not registered."); -// System.out.println("Grid Interaction not registered."); - item[1] = ""; - item[2] = ""; - } - - item[0] = new String(String.valueOf(rs.getInt(1))); - item[3] = rs.getString(11).toString(); - item[4] = rs.getTimestamp(4).toString(); - logger.info("Querying for job status..."); -// System.out.println("querying for job status..."); - - item[5] = rs.getString(12); - item[6] = rs.getString(19); - activeJobsList.add(item); - - } - rs.close(); - pstmt.close(); - - if(!updatingJobsStatus) - CloseDBConnection(); - - return activeJobsList; - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - if(!updatingJobsStatus) - CloseDBConnection(); - } - else{ - logger.info("Cannot get active jobs list from DB: DB Connection is closed."); - System.err.println ("Cannot get active jobs list from DB: DB Connection is closed."); - } - return null; - } - - /** - * Returns the geographic distribution of the jobs for a given portal and user. The geographic - * distribution is made of a {@link Vector} of string[] containing the following values: - *
    - *
  1. computing element name;
  2. - *
  3. number of RUNNING jobs;
  4. - *
  5. number of DONE jobs;
  6. - *
  7. middleware name;
  8. - *
  9. computing element latitude;
  10. - *
  11. computing element longitude.
  12. - *
- * @param portal the given portal name - * @param commonName the given user name - * @return the geographic distribution of the jobs for a given portal and user. - */ - public Vector getCEsGeographicDistribution (String portal, String commonName) { - //middleware - //0 glite - //1 unicore - //2 wsgram - //3 ourgrid - //4 genesis II - //5 gos - if (CreateDBConnection()) - { - Vector cesGeographicDistribution = new Vector(); - Hashtable cesJobsCounter = new Hashtable(); - try - { - logger.info("Querying GridOperations..."); -// System.out.println("querying GridOperations..."); - String query = "SELECT * FROM GridOperations WHERE portal = ?"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, portal); - - ResultSet rs; - rs = pstmt.executeQuery(); - -// if (rs==null) { -// System.out.println("rs is null"); -// System.out.println("No applications defined in portal " + portal); -// CloseDBConnection(); -// return null; -// } - - Vector grid_interactions = new Vector(); - - while (rs.next()) { - grid_interactions.add(new Integer(rs.getInt(1))); - } - - rs.close(); - pstmt.close(); - - Iterator i = grid_interactions.iterator(); - - while(i.hasNext()) { - int gridInteractionID = ((Integer)i.next()).intValue(); - logger.info("Querying ActiveGridInteractions..."); -// System.out.println("querying ActiveGridInteractions..."); - query = "SELECT grid_ce, status, grid_id FROM ActiveGridInteractions WHERE common_name = ? AND grid_interaction = ?"; - PreparedStatement pstmtJob = (PreparedStatement) conn.prepareStatement(query); - pstmtJob.setString(1, commonName); - pstmtJob.setInt(2, gridInteractionID); - - ResultSet rsJob; - rsJob = pstmtJob.executeQuery(); - -// if (rsJob==null) { -// System.out.println("rs is null"); -// System.out.println("jobs list is empty for " + commonName); -// CloseDBConnection(); -// return null; -// } - - while (rsJob.next()) { - String ceName = rsJob.getString(1); - if (!ceName.equals("")) { - int[] jobsCounter = cesJobsCounter.get(ceName); - if (jobsCounter==null) { - jobsCounter = new int[3]; - if (rsJob.getString(2).equals("DONE")) { - jobsCounter[0] = 0; - jobsCounter[1] = 1; - } - else { - jobsCounter[0] = 1; - jobsCounter[1] = 0; - } - - String adaptor = (rsJob.getString(3)).substring(1,rsJob.getString(3).indexOf(":")); - if (adaptor.equals("glite")) - jobsCounter[2] = 0; - else if (adaptor.equals("unicore")) - jobsCounter[2] = 1; - else if (adaptor.equals("wsgram") || adaptor.equals("gatekeper") ) - jobsCounter[2] = 2; - else if (adaptor.equals("ourgrid")) - jobsCounter[2] = 3; - else if (adaptor.equals("bes-genesis2")) - jobsCounter[2] = 4; - else if (adaptor.equals("gos")) - jobsCounter[2] = 5; - else if (adaptor.equals("ssh")) - jobsCounter[2] = 6; - else if (adaptor.equals("rocci")) - jobsCounter[2] = 7; - - cesJobsCounter.put(ceName, jobsCounter); - } - else { - if (rsJob.getString(2).equals("DONE")) { - jobsCounter[1]++; - } - else { - jobsCounter[0]++; - } - cesJobsCounter.put(ceName, jobsCounter); - } - } - } - - rsJob.close(); - pstmtJob.close(); - } - - - Enumeration ces = cesJobsCounter.keys(); - while (ces.hasMoreElements()) { - String ce = (String)ces.nextElement(); - logger.info("Querying all_ces for lat and long - ce= " + ce); -// System.out.println("querying all_ces for lat and long - ce= " + ce); - query = "SELECT latitude, longitude FROM all_ces WHERE hostname = ?"; - pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, ce); - - rs = pstmt.executeQuery(); - - if (rs.next()) { - String ceGeogrhapicalData[] = new String[6]; - ceGeogrhapicalData[0] = ce; - ceGeogrhapicalData[1] = String.valueOf(cesJobsCounter.get(ce)[0]); - ceGeogrhapicalData[2] = String.valueOf(cesJobsCounter.get(ce)[1]); - ceGeogrhapicalData[3] = String.valueOf(cesJobsCounter.get(ce)[2]); - ceGeogrhapicalData[4] = (new Float(rs.getFloat(1))).toString(); - ceGeogrhapicalData[5] = (new Float(rs.getFloat(2))).toString(); - cesGeographicDistribution.add(ceGeogrhapicalData); - } - - rs.close(); - pstmt.close(); - } - - if(!updatingJobsStatus) - CloseDBConnection(); - return cesGeographicDistribution; - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - if(!updatingJobsStatus) - CloseDBConnection(); - } - - return null; - } - - public Vector getCEsGeographicDistributionForAll (String portal) { - //middleware - //0 glite - //1 unicore - //2 wsgram - //3 ourgrid - //4 genesis II - //5 gos - if (CreateDBConnection()) - { - Vector cesGeographicDistribution = new Vector(); - Hashtable cesJobsCounter = new Hashtable(); - try - { - logger.info("Querying GridOperations..."); -// System.out.println("querying GridOperations..."); - String query = "SELECT * FROM GridOperations WHERE portal = ?"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, portal); - - ResultSet rs; - rs = pstmt.executeQuery(); - -// if (rs==null) { -// System.out.println("rs is null"); -// System.out.println("No applications defined in portal " + portal); -// CloseDBConnection(); -// return null; -// } - - Vector grid_interactions = new Vector(); - - while (rs.next()) { - grid_interactions.add(new Integer(rs.getInt(1))); - } - - rs.close(); - pstmt.close(); - - Iterator i = grid_interactions.iterator(); - - while(i.hasNext()) { - int gridInteractionID = ((Integer)i.next()).intValue(); - logger.info("Querying ActiveGridInteractions..."); -// System.out.println("querying ActiveGridInteractions..."); - query = "SELECT grid_ce, status, grid_id FROM ActiveGridInteractions WHERE grid_interaction = ?"; - PreparedStatement pstmtJob = (PreparedStatement) conn.prepareStatement(query); - pstmtJob.setInt(1, gridInteractionID); - - ResultSet rsJob; - rsJob = pstmtJob.executeQuery(); - -// if (rsJob==null) { -// System.out.println("rs is null"); -// System.out.println("jobs list is empty for " + commonName); -// CloseDBConnection(); -// return null; -// } - - while (rsJob.next()) { - String ceName = rsJob.getString(1); - if (!ceName.equals("")) { - int[] jobsCounter = cesJobsCounter.get(ceName); - if (jobsCounter==null) { - jobsCounter = new int[3]; - if (rsJob.getString(2).equals("DONE")) { - jobsCounter[0] = 0; - jobsCounter[1] = 1; - } - else { - jobsCounter[0] = 1; - jobsCounter[1] = 0; - } - - String adaptor = (rsJob.getString(3)).substring(1,rsJob.getString(3).indexOf(":")); - if (adaptor.equals("glite")) - jobsCounter[2] = 0; - else if (adaptor.equals("unicore")) - jobsCounter[2] = 1; - else if (adaptor.equals("wsgram") || adaptor.equals("gatekeeper")) - jobsCounter[2] = 2; - else if (adaptor.equals("ourgrid")) - jobsCounter[2] = 3; - else if (adaptor.equals("bes-genesis2")) - jobsCounter[2] = 4; - else if (adaptor.equals("gos")) - jobsCounter[2] = 5; - else if (adaptor.equals("ssh")) - jobsCounter[2] = 6; - else if (adaptor.equals("rocci")) - jobsCounter[2] = 7; - - cesJobsCounter.put(ceName, jobsCounter); - } - else { - if (rsJob.getString(2).equals("DONE")) { - jobsCounter[1]++; - } - else { - jobsCounter[0]++; - } - cesJobsCounter.put(ceName, jobsCounter); - } - } - } - - rsJob.close(); - pstmtJob.close(); - } - - - Enumeration ces = cesJobsCounter.keys(); - while (ces.hasMoreElements()) { - String ce = (String)ces.nextElement(); - logger.info("Querying all_ces for lat and long - ce= " + ce); -// System.out.println("querying all_ces for lat and long - ce= " + ce); - query = "SELECT latitude, longitude FROM all_ces WHERE hostname = ?"; - pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, ce); - - rs = pstmt.executeQuery(); - - if (rs.next()) { - String ceGeogrhapicalData[] = new String[6]; - ceGeogrhapicalData[0] = ce; - ceGeogrhapicalData[1] = String.valueOf(cesJobsCounter.get(ce)[0]); - ceGeogrhapicalData[2] = String.valueOf(cesJobsCounter.get(ce)[1]); - ceGeogrhapicalData[3] = String.valueOf(cesJobsCounter.get(ce)[2]); - ceGeogrhapicalData[4] = (new Float(rs.getFloat(1))).toString(); - ceGeogrhapicalData[5] = (new Float(rs.getFloat(2))).toString(); - cesGeographicDistribution.add(ceGeogrhapicalData); - } - - rs.close(); - pstmt.close(); - } - if(!updatingJobsStatus) - CloseDBConnection(); - - return cesGeographicDistribution; - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - if(!updatingJobsStatus) - CloseDBConnection(); - } - - return null; - } - - /** - * Returns the total number of users with running jobs. - * - * @return the total number of users with running jobs. - */ - public int getTotalNumberOfUsersWithRunningJobs() { - if (CreateDBConnection()) - { - try - { - logger.info("Querying ActiveGridInteractions for total users running jobs..."); -// System.out.println("querying ActiveGridInteractions for total users running jobs..."); - String query = "SELECT COUNT(DISTINCT common_name) FROM ActiveGridInteractions"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - - ResultSet rs; - rs = pstmt.executeQuery(); - - rs.next(); - - int usersNumbers = rs.getInt(1); - - rs.close(); - pstmt.close(); - - if(!updatingJobsStatus) - CloseDBConnection(); - - return usersNumbers; - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - - if(!updatingJobsStatus) - CloseDBConnection(); - } - else{ - logger.error("Cannot get total number of users with running jobs: DB Connection is closed."); - System.err.println ("Cannot get total number of users with running jobs: DB Connection is closed."); - } - return 0; - } - - /** - * Returns a {@link Vector} of {@link ActiveInteractions} with all completed interactions - * for the specified user. - * - * @param commonName a String representing user name - * @return a {@link Vector} of {@link ActiveInteractions} - */ - public Vector getDoneInteractionsByName (String commonName) { - //l'output è un vettore di stringhe costituito da id(Activegrid..) Portal(GridOperation) descri(GO) userdesr(AcGI) timestamp(AcGI) status(AcGI) - //In caso di collection prenod i capi d acollection attive - - Vector activeInteractions = new Vector(); - - Vector doneJobsList = getDoneJobsListByName(commonName); -// Vector activeCollections = JobCollection.getActiveJobCollectionsByName(commonName); - HashMap> tmp = new HashMap>(); - - for(String[] gridInteraction : doneJobsList){ - if(Integer.parseInt(gridInteraction[6])==-1){ - activeInteractions.add(new ActiveInteractions(gridInteraction, null)); - } else { - Integer key = Integer.parseInt(gridInteraction[6]); - if(tmp.containsKey(key)) - tmp.get(key).add(gridInteraction); - else{ - Vector firstSubjob = new Vector(); - firstSubjob.add(gridInteraction); - tmp.put(key, firstSubjob); - } - } - } - - if(tmp!=null){ - for(Integer key : tmp.keySet()){ - ClosedJobCollection closedCollection = ClosedJobCollection.getClosedCollections(key); - String[] collectionInfos = closedCollection.getCollectionInfos(); - if(closedCollection.getCollectionType().equals(WorkflowN1.class.getClass().getSimpleName())){ - if(closedCollection.getCollectionStatus().equals("DONE")){ - Vector finalSubJob = new Vector(); - for(String[] subJobsinfos : tmp.get(key)) - if(subJobsinfos[3].contains("-Final")) - finalSubJob.add(subJobsinfos); - tmp.put(key, finalSubJob); - } - } - collectionInfos[1] = tmp.get(key).elementAt(0)[1]; - collectionInfos[2] = tmp.get(key).elementAt(0)[2]; - activeInteractions.add(new ActiveInteractions(collectionInfos, tmp.get(key))); - } - } - return activeInteractions; - } - /** - * @deprecated - * @param commonName - * @return - */ - public Vector getDoneJobsListByName (String commonName) { //MODIFICARE CON COLLECTION - - if (CreateDBConnection()) - { - Vector doneJobsList = new Vector(); - try - { - logger.info("Querying GridInteractions..."); -// System.out.println("querying GridInteractions..."); - String query = "SELECT * FROM GridInteractions WHERE common_name = ?"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, commonName); - - ResultSet rs; - rs = pstmt.executeQuery(); - -// if (rs==null) { -// System.out.println("rs is null"); -// System.out.println("jobs list is empty for " + commonName); -// CloseDBConnection(); -// return null; -// } - - while (rs.next()) { - String[] item = new String[7]; - logger.info("Querying GridOperations..."); -// System.out.println("querying GridOperations..."); - query = "SELECT * FROM GridOperations WHERE id = ?"; - PreparedStatement pstmt2 = (PreparedStatement) conn.prepareStatement(query); - pstmt2.setInt(1, rs.getInt(5)); - - ResultSet rsGridOp; - rsGridOp = pstmt2.executeQuery(); - - //if ( (rsGridOp!=null) && (rsGridOp.next()) ) { - if (rsGridOp.next()) { - logger.info("Getting GridOperations data..."); -// System.out.println("getting GridOperations data..."); - item[1] = rsGridOp.getString(2); - item[2] = rsGridOp.getString(3); - } - else { - logger.warn("Grid Interaction not registered."); -// System.out.println("Grid Interaction not registered."); - item[1] = ""; - item[2] = ""; - } - - rsGridOp.close(); - pstmt2.close(); - - item[0] = new String(String.valueOf(rs.getInt(1))); - item[3] = rs.getString(11).toString(); - item[4] = rs.getTimestamp(4).toString(); - item[5] = rs.getString(12); - item[6] = new String(String.valueOf(rs.getInt(17))); - - doneJobsList.add(item); - - } - rs.close(); - pstmt.close(); - - if(!updatingJobsStatus) - CloseDBConnection(); - return doneJobsList; - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - if(!updatingJobsStatus) - CloseDBConnection(); - } - else{ - logger.error("Cannot get active jobs list from DB: DB Connection is closed."); - System.err.println ("Cannot get active jobs list from DB: DB Connection is closed."); - } - return null; - } - - /** - * - * @param commonName - * @param jobOutputPath - * @param jobsUpdatingInterval - */ - public void updateJobsStatusAsync(final String commonName, final String jobOutputPath, final int jobsUpdatingInterval) { - // if (isUpdateJobsStatusAsyncRunning(portal,commonName)) - // return; - // - // final String temp = portal + "-" + commonName; - // jobsStatusThread.addElement(temp); - - final ScheduledExecutorService executor; - - if (threadPool != null) - executor = Executors.newSingleThreadScheduledExecutor(threadPool.getThreadFactory()); - else - executor = Executors.newSingleThreadScheduledExecutor(); - - final UsersTrackingDBInterface dbInt = this; - - Runnable periodicTask = new Runnable() { - public void run() { - updatingJobsStatus = true; - // Invoke method(s) to do the work - //String userData = temp; - logger.info("UpdateJobsStatusAsync running in Thread : " + Thread.currentThread()); -// System.out.println("updateJobsStatusAsync running in Thread : " + Thread.currentThread()); - final Vector runningJobs = new Vector(); - Vector runnigJobCollections = new Vector(); - Semaphore waitForThreads = null; - - if (CreateDBConnection()) - { - try - { - logger.info("Querying ActiveGridInteractions for common_name = " + commonName); -// System.out.println("querying ActiveGridInteractions for common_name = " + commonName); - String query = "SELECT * FROM ActiveGridInteractions WHERE common_name = ? AND grid_id!=''"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, commonName); - - ResultSet rs = pstmt.executeQuery(); - -// if (rs==null) { -// System.out.println("rs is null"); -// System.out.println("jobs list is empty for " + commonName); -// System.out.println("Closing status update thread..."); -// return; -// } - - //if (rs!=null) { - while (rs.next()) { -// if ( !(rs.getString(12).equals("DONE"))) { - if ( !(rs.getString(12).equals("DONE")) && !(rs.getString(12).equals("Aborted"))) { - - String jobData[] = new String[13]; - jobData[0] = rs.getString(6); - jobData[1] = String.valueOf(rs.getInt(1)); - jobData[2] = rs.getString(8); - jobData[3] = rs.getString(9); - jobData[4] = rs.getString(10); - jobData[5] = rs.getString(13); - jobData[6] = rs.getString(11); - //******MARIO*************** - jobData[7] = rs.getString(17); //get email field - jobData[8] = rs.getString(18); //get eTokenServer field - logger.debug("Getting GridOperations id="+rs.getInt(5)+"..."); - String query1 = "SELECT * FROM GridOperations WHERE id = ?"; - PreparedStatement pstmt1 = (PreparedStatement) conn.prepareStatement(query1); - pstmt1.setInt(1, rs.getInt(5)); - - ResultSet rs1 = pstmt1.executeQuery(); - - if (rs1.next()) { - jobData[9] = rs1.getString(2); //get Portal - jobData[10] = rs1.getString(3); //get Application - logger.debug("GridOperation: [Portal="+jobData[9]+"; Application="+jobData[10]+"]"); - } else { - logger.warn("No operation found for id="+rs.getInt(5)); - } - rs1.close(); - pstmt1.close(); - //************************** - jobData[11] = rs.getString(19); - jobData[12] = rs.getString(2); - runningJobs.add(jobData); - - } - } - - rs.close(); - //} - pstmt.close(); - - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - - - try { - if (runningJobs.size()==0) { - logger.info("Jobs list is empty for " + commonName + ". Closing status update thread..."); -// System.out.println("jobs list is empty for " + commonName); -// System.out.println("Closing status update thread..."); - executor.shutdown(); - //jobsStatusThread.removeElement(userData); - - JobCheckStatusService jobCheckStatusService = null; - - try { - jobCheckStatusService = InitialContext.doLookup("JobCheckStatusService"); - logger.info("Got JobCheckStatusService..."); -// System.out.println("Got JobCheckStatusService..."); - } - catch ( NamingException ex ) { - logger.error("Cannot get JobCheckStatusService: " + ex); -// System.out.println("Cannot get JobCheckStatusService: " + ex); - } - catch(Exception ex){ - logger.error("Cannot get JobCheckStatusService: " + ex); -// System.out.println("Cannot get JobCheckStatusService: " + ex); - } - - if (jobCheckStatusService==null) { - logger.info("Get local JobCheckStatusService"); -// System.out.println("get local JobCheckStatusService"); - jobCheckStatusService = JobCheckStatusService.getInstance(URL, userName, password); - } - - jobCheckStatusService.stopJobCheckStatusThread(commonName); - } - else { - waitForThreads = new Semaphore(0); - - Thread threads[] = new Thread[runningJobs.size()]; - //running jobs check status threads... - for(int i=0;i jobsId = new Vector(); - - Vector doneCollections = JobCollection.getDoneJobCollections(commonName); - HashMap> a = new HashMap>(); - - if (CreateDBConnection()) - { - try - { - logger.info("Get all jobs id for user = " + commonName); -// System.out.println("get all jobs id for user = " + commonName); - String query = "SELECT id, user_description, id_job_collection FROM ActiveGridInteractions WHERE common_name = ? AND status = 'DONE' order by id"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, commonName); - - ResultSet rs = pstmt.executeQuery(); - - while (rs.next()) { - Integer key = rs.getInt(3); - if(key==0){ - int dbId = rs.getInt(1); - jobsId.add(dbId); - command = command + JSagaJobSubmission.removeNotAllowedCharacter(rs.getString(2)) + "_" + dbId + ".tgz "; - logger.info("Command = "+command); - } else { - if(a.containsKey(key)) - a.get(key).add(rs.getInt(1)); - else{ - Vector tmp = new Vector(); - tmp.add(rs.getInt(1)); - a.put(key, tmp); - } - - } -// System.out.println("command="+command); - } - - rs.close(); - pstmt.close(); - - Iterator i = jobsId.iterator(); - - while(i.hasNext()) { //Chiudo i Job semplici - CloseGridInteraction(i.next().intValue()); - } - - //Chiudo collection e subjobs - for(JobCollection doneCollection : doneCollections){ - command = command + JSagaJobSubmission.removeNotAllowedCharacter(doneCollection.getDescription()) + "_" + doneCollection.getId() + ".tgz "; - int idClosedCollection = doneCollection.close(); - for(int idSubJob : a.get(doneCollection.getId())) - CloseGridInteraction(idSubJob, idClosedCollection); - - } - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - - if(!updatingJobsStatus) - CloseDBConnection(); - - return ""; - } - } - - if(!updatingJobsStatus) - CloseDBConnection(); - String outputFileName=""; - if (jobsId.size()==0) - if(doneCollections.size()==0) - return ""; - else - outputFileName = jobOutputPath + "/jobOutput/AllJobs_" + commonName + "_" + doneCollections.lastElement().getId() + ".tgz"; - else - outputFileName = jobOutputPath + "/jobOutput/AllJobs_" + commonName + "_" + jobsId.lastElement() + ".tgz"; - - try { - //creating a tgz archive containing output files - command = "tar czvf " + outputFileName + " --directory="+jobOutputPath+"/jobOutput/ " + command; - logger.info("Creating a tgz archive containing output files..."); -// System.out.println("creating a tgz archive containing output files..."); - logger.info(command); -// System.out.println(command); - Process creatingTar = Runtime.getRuntime().exec(command); - creatingTar.waitFor(); - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - logger.info("OutputFileName="+outputFileName); -// System.out.println("outputFileName="+outputFileName); - return outputFileName; - - } - - /** - * @deprecated - * @param commonName - * @param description - * @param jobOutputPath - * @return - */ - public String createAllJobsFromDescriptionArchive(String commonName, String description, String jobOutputPath) { //MODIFICATA QUERY, NON CONSIDERA I JOB CHE APPARTENGONO A COLLEZIONI. - String command = ""; - Vector jobsId = new Vector(); - - if (CreateDBConnection()) - { - try - { - logger.info("Get all jobs id for user = " + commonName); -// System.out.println("get all jobs id for user = " + commonName); -// String query = "SELECT id, user_description FROM ActiveGridInteractions WHERE common_name = ? AND user_description = ? AND status = 'DONE' order by id"; - String query = "SELECT id, user_description FROM ActiveGridInteractions WHERE common_name = ? AND user_description = ? AND status = 'DONE' AND id_job_collection IS NULL order by id"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setString(1, commonName); - pstmt.setString(2, description); - - ResultSet rs = pstmt.executeQuery(); - - while (rs.next()) { - int dbId = rs.getInt(1); - jobsId.add(dbId); - command = command + jobOutputPath + "/jobOutput/" + JSagaJobSubmission.removeNotAllowedCharacter(rs.getString(2)) + "_" + dbId + ".tgz "; - logger.info("Command = "+command); -// System.out.println("command="+command); - } - - rs.close(); - pstmt.close(); - - Iterator i = jobsId.iterator(); - - while(i.hasNext()) { - CloseGridInteraction(i.next().intValue()); - } - - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - - if(!updatingJobsStatus) - CloseDBConnection(); - - return ""; - } - } - if(!updatingJobsStatus) - CloseDBConnection(); - - if (jobsId.size()==0) - return ""; - - - String outputFileName = jobOutputPath + "/jobOutput/AllJobsForDesc_" + commonName + "_" + jobsId.lastElement() + ".tgz"; - try { - //creating a tgz archive containing output files - command = "tar czvf " + outputFileName + " " + command; - logger.info("Creating a tgz archive containing output files..."); -// System.out.println("creating a tgz archive containing output files..."); - logger.info(command); - System.out.println(command); - Process creatingTar = Runtime.getRuntime().exec(command); - creatingTar.waitFor(); - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - logger.info("outputFileName="+outputFileName); -// System.out.println("outputFileName="+outputFileName); - return outputFileName; - } - - /** - * Returns the user description for a specified active grid interacion. - * - * @param DbId database id for active grid interaction you want retrive user description. - * @return user description for this inteeraction. - */ - public String getJobUserDescription(int DbId) { - String userDescription = ""; - if (CreateDBConnection()) - { - try - { - logger.info("Querying GridOperations..."); -// System.out.println("querying GridOperations..."); - String query = "SELECT * FROM ActiveGridInteractions WHERE id = ?"; - PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(query); - pstmt.setInt(1, DbId); - - ResultSet rs; - rs = pstmt.executeQuery(); - - - if (rs.next()) - userDescription = rs.getString(11); - logger.info("UserDescription = " + userDescription); -// System.out.println("userDescription = " + userDescription); - - rs.close(); - pstmt.close(); - - } - catch (Exception e) { - logger.error(e.toString()); -// System.out.println(e.toString()); - } - } - if(!updatingJobsStatus) - CloseDBConnection(); - - return userDescription; - } - - private Timestamp getCurrentUTCTimestamp() { - Calendar calendar = Calendar.getInstance(); - java.util.Date date = calendar.getTime(); - TimeZone tz = calendar.getTimeZone(); - - long msFromEpochGMT = date.getTime(); - - int offsetFromUTC = tz.getOffset(msFromEpochGMT); - - Calendar UTCCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - UTCCalendar.setTime(date); - UTCCalendar.add(Calendar.MILLISECOND, -offsetFromUTC); - - Timestamp currentTimestamp = new Timestamp(UTCCalendar.getTimeInMillis()); - return currentTimestamp; - } - - /** - * @param args - */ - ///* - public static void main(String[] args) { - - UsersTrackingDBInterface DBInterface = new UsersTrackingDBInterface("jdbc:mysql://localhost/userstracking","tracking_user","usertracking"); -// for(int i=0; i<3; i++){ -// int x = DBInterface.insertMailAddress(i, "marius83@alice.it"); -// System.out.println("Error code: " +x); -// } - String CE = "ce-02.roma3.infn.it"; - //String CE = "grid012.ct.infn.it"; - float coord[] = DBInterface.getCECoordinate(CE); - - System.out.println("Lat="+coord[0]+" Long="+coord[1]); - - - - Vector jobsRunning = DBInterface.getCEsGeographicDistribution ("ViralGrid", "scardaci"); - - if (jobsRunning!=null) { - for (int i=0;i workQueue = new LinkedBlockingQueue(); - private static ThreadPoolExecutor instance; - - private ThreadPoolExecutor() { - super(defaultCorePoolSize, defaultMaximumPoolSize, defaultKeepAliveTime, defaultTimeUnit, workQueue); - } - - synchronized static ThreadPoolExecutor getInstance() { - if (instance == null) { - instance = new ThreadPoolExecutor(); - } - return instance; - } - -} diff --git a/it/infn/ct/ThreadPool/ThreadPoolExecutorFactory.java b/it/infn/ct/ThreadPool/ThreadPoolExecutorFactory.java deleted file mode 100644 index 792ec94..0000000 --- a/it/infn/ct/ThreadPool/ThreadPoolExecutorFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -package it.infn.ct.ThreadPool; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.concurrent.TimeUnit; - -import javax.naming.Context; -import javax.naming.Name; -import javax.naming.NamingException; -import javax.naming.RefAddr; -import javax.naming.Reference; - -import com.sun.appserv.server.LifecycleEvent; -import com.sun.appserv.server.ServerLifecycleException; - -public class ThreadPoolExecutorFactory implements -javax.naming.spi.ObjectFactory, - com.sun.appserv.server.LifecycleListener, java.io.Serializable { - public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable environment) throws Exception { - ThreadPoolExecutor tp = ThreadPoolExecutor.getInstance(); - try { - Reference reference = (Reference) obj; - Enumeration enumeration = reference.getAll(); - TimeUnit timeUnit = ThreadPoolExecutor.defaultTimeUnit; - long keepAliveTime = ThreadPoolExecutor.defaultKeepAliveTime; - while (enumeration.hasMoreElements()) { - RefAddr refAddr = (RefAddr) enumeration.nextElement(); - String pname = refAddr.getType(); - String pvalue = (String) refAddr.getContent(); - if ("corePoolSize".equalsIgnoreCase(pname)) { - tp.setCorePoolSize(Integer.parseInt(pvalue)); - } else if ("maximumPoolSize".equalsIgnoreCase(pname)) { - tp.setMaximumPoolSize(Integer.parseInt(pvalue)); - } else if ("timeUnit".equalsIgnoreCase(pname)) { - timeUnit = TimeUnit.valueOf(pvalue); - } else if ("keepAliveTime".equalsIgnoreCase(pname)) { - keepAliveTime = Long.parseLong(pvalue); - } else if ("allowCoreThreadTimeOut".equalsIgnoreCase(pname)) { - tp.allowCoreThreadTimeOut(Boolean.parseBoolean(pvalue)); - } else if ("prestartAllCoreThreads".equalsIgnoreCase(pname)) { - if (Boolean.parseBoolean(pvalue)) { - tp.prestartAllCoreThreads(); - } - } else { - throw new IllegalArgumentException("Unrecognized property name: " + pname); - } - } - tp.setKeepAliveTime(keepAliveTime, timeUnit); - } catch (Exception e) { - throw (NamingException) (new NamingException()).initCause(e); - } - return tp; - } - - public void handleEvent(LifecycleEvent event) throws ServerLifecycleException -{ - if (event.getEventType() == LifecycleEvent.TERMINATION_EVENT) { - ThreadPoolExecutor tp = ThreadPoolExecutor.getInstance(); - System.out.println("About to purge and shutdown " + tp + ", active thread count: " - + tp.getActiveCount()); - tp.purge(); - tp.shutdown(); - } - } -} diff --git a/lib/gridengine-threadpools-1.0.0.jar b/lib/gridengine-threadpools-1.0.0.jar deleted file mode 100644 index 47b733c..0000000 Binary files a/lib/gridengine-threadpools-1.0.0.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.3.7.jar b/lib/jsaga-job-management-1.3.7.jar deleted file mode 100644 index efe48f2..0000000 Binary files a/lib/jsaga-job-management-1.3.7.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.3.8.1.jar b/lib/jsaga-job-management-1.3.8.1.jar deleted file mode 100644 index 756ddd5..0000000 Binary files a/lib/jsaga-job-management-1.3.8.1.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.3.8.jar b/lib/jsaga-job-management-1.3.8.jar deleted file mode 100644 index 5d6025d..0000000 Binary files a/lib/jsaga-job-management-1.3.8.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.1.jar b/lib/jsaga-job-management-1.4.1.jar deleted file mode 100644 index 1f30bfd..0000000 Binary files a/lib/jsaga-job-management-1.4.1.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.10.jar b/lib/jsaga-job-management-1.4.10.jar deleted file mode 100644 index 56f5018..0000000 Binary files a/lib/jsaga-job-management-1.4.10.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.11.jar b/lib/jsaga-job-management-1.4.11.jar deleted file mode 100644 index ffd2874..0000000 Binary files a/lib/jsaga-job-management-1.4.11.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.12.jar b/lib/jsaga-job-management-1.4.12.jar deleted file mode 100644 index a6ddb52..0000000 Binary files a/lib/jsaga-job-management-1.4.12.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.13.jar b/lib/jsaga-job-management-1.4.13.jar deleted file mode 100644 index a33db90..0000000 Binary files a/lib/jsaga-job-management-1.4.13.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.14.jar b/lib/jsaga-job-management-1.4.14.jar deleted file mode 100644 index fca8df3..0000000 Binary files a/lib/jsaga-job-management-1.4.14.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.15.jar b/lib/jsaga-job-management-1.4.15.jar deleted file mode 100644 index 40a74f4..0000000 Binary files a/lib/jsaga-job-management-1.4.15.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.16.jar b/lib/jsaga-job-management-1.4.16.jar deleted file mode 100644 index 52de887..0000000 Binary files a/lib/jsaga-job-management-1.4.16.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.17.jar b/lib/jsaga-job-management-1.4.17.jar deleted file mode 100644 index b45aed3..0000000 Binary files a/lib/jsaga-job-management-1.4.17.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.18.jar b/lib/jsaga-job-management-1.4.18.jar deleted file mode 100644 index 6988e4e..0000000 Binary files a/lib/jsaga-job-management-1.4.18.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.19.jar b/lib/jsaga-job-management-1.4.19.jar deleted file mode 100644 index 8527afe..0000000 Binary files a/lib/jsaga-job-management-1.4.19.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.2.jar b/lib/jsaga-job-management-1.4.2.jar deleted file mode 100644 index 8e282fa..0000000 Binary files a/lib/jsaga-job-management-1.4.2.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.20.jar b/lib/jsaga-job-management-1.4.20.jar deleted file mode 100644 index 9c63188..0000000 Binary files a/lib/jsaga-job-management-1.4.20.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.21.jar b/lib/jsaga-job-management-1.4.21.jar deleted file mode 100644 index 2d34948..0000000 Binary files a/lib/jsaga-job-management-1.4.21.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.22.jar b/lib/jsaga-job-management-1.4.22.jar deleted file mode 100644 index bedbf46..0000000 Binary files a/lib/jsaga-job-management-1.4.22.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.3.jar b/lib/jsaga-job-management-1.4.3.jar deleted file mode 100644 index 1af75c6..0000000 Binary files a/lib/jsaga-job-management-1.4.3.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.4.jar b/lib/jsaga-job-management-1.4.4.jar deleted file mode 100644 index 4abc36d..0000000 Binary files a/lib/jsaga-job-management-1.4.4.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.5.jar b/lib/jsaga-job-management-1.4.5.jar deleted file mode 100644 index 99d56f2..0000000 Binary files a/lib/jsaga-job-management-1.4.5.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.6.jar b/lib/jsaga-job-management-1.4.6.jar deleted file mode 100644 index 8ea48f8..0000000 Binary files a/lib/jsaga-job-management-1.4.6.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.7.jar b/lib/jsaga-job-management-1.4.7.jar deleted file mode 100644 index 194a895..0000000 Binary files a/lib/jsaga-job-management-1.4.7.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.8.jar b/lib/jsaga-job-management-1.4.8.jar deleted file mode 100644 index b52ea1e..0000000 Binary files a/lib/jsaga-job-management-1.4.8.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.4.9.jar b/lib/jsaga-job-management-1.4.9.jar deleted file mode 100644 index 71c76c2..0000000 Binary files a/lib/jsaga-job-management-1.4.9.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.0.jar b/lib/jsaga-job-management-1.5.0.jar deleted file mode 100644 index a9bcb50..0000000 Binary files a/lib/jsaga-job-management-1.5.0.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.1.jar b/lib/jsaga-job-management-1.5.1.jar deleted file mode 100644 index 6690037..0000000 Binary files a/lib/jsaga-job-management-1.5.1.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.10.jar b/lib/jsaga-job-management-1.5.10.jar deleted file mode 100644 index f483b8d..0000000 Binary files a/lib/jsaga-job-management-1.5.10.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.11.jar b/lib/jsaga-job-management-1.5.11.jar deleted file mode 100644 index 060bee4..0000000 Binary files a/lib/jsaga-job-management-1.5.11.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.2.jar b/lib/jsaga-job-management-1.5.2.jar deleted file mode 100644 index a51700e..0000000 Binary files a/lib/jsaga-job-management-1.5.2.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.3.jar b/lib/jsaga-job-management-1.5.3.jar deleted file mode 100644 index bb0ee0d..0000000 Binary files a/lib/jsaga-job-management-1.5.3.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.4.jar b/lib/jsaga-job-management-1.5.4.jar deleted file mode 100644 index e83167e..0000000 Binary files a/lib/jsaga-job-management-1.5.4.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.5.jar b/lib/jsaga-job-management-1.5.5.jar deleted file mode 100644 index 1d9c32c..0000000 Binary files a/lib/jsaga-job-management-1.5.5.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.7.jar b/lib/jsaga-job-management-1.5.7.jar deleted file mode 100644 index e23dec9..0000000 Binary files a/lib/jsaga-job-management-1.5.7.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.8.jar b/lib/jsaga-job-management-1.5.8.jar deleted file mode 100644 index 45c98e6..0000000 Binary files a/lib/jsaga-job-management-1.5.8.jar and /dev/null differ diff --git a/lib/jsaga-job-management-1.5.9.jar b/lib/jsaga-job-management-1.5.9.jar deleted file mode 100644 index 962555c..0000000 Binary files a/lib/jsaga-job-management-1.5.9.jar and /dev/null differ