[ https://issues.apache.org/jira/browse/AIRAVATA-2619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16301781#comment-16301781 ]
ASF GitHub Bot commented on AIRAVATA-2619: ------------------------------------------ smarru closed pull request #156: [AIRAVATA-2619] Refactoring App Catalog implementation - GatewayResourceProfile URL: https://github.com/apache/airavata/pull/156 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/modules/registry-refactoring/pom.xml b/modules/registry-refactoring/pom.xml index b794349f33..ab95f616f3 100644 --- a/modules/registry-refactoring/pom.xml +++ b/modules/registry-refactoring/pom.xml @@ -69,6 +69,21 @@ <version>4.12</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-commons</artifactId> + <version>0.17-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-server-configuration</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-registry-cpi</artifactId> + <version>0.17-SNAPSHOT</version> + </dependency> </dependencies> <build> diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferenceEntity.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferenceEntity.java index 8b005c606b..682981add2 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferenceEntity.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferenceEntity.java @@ -32,7 +32,7 @@ * The persistent class for the compute_resource_preference database table. */ @Entity -@Table(name = "compute_resource_preference") +@Table(name = "COMPUTE_RESOURCE_PREFERENCE") public class ComputeResourcePreferenceEntity implements Serializable { private static final long serialVersionUID = 1L; diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferencePK.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferencePK.java index 7cfba0ce72..f94cd65499 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferencePK.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ComputeResourcePreferencePK.java @@ -36,7 +36,7 @@ private String gatewayId; @Column(name = "RESOURCE_ID", insertable = false, updatable = false) - private String resourceId; + private String computeResourceId; public ComputeResourcePreferencePK() { } @@ -49,12 +49,12 @@ public void setGatewayId(String gatewayId) { this.gatewayId = gatewayId; } - public String getResourceId() { - return resourceId; + public String getComputeResourceId() { + return computeResourceId; } - public void setResourceId(String resourceId) { - this.resourceId = resourceId; + public void setComputeResourceId(String computeResourceId) { + this.computeResourceId = computeResourceId; } public boolean equals(Object other) { @@ -67,14 +67,14 @@ public boolean equals(Object other) { ComputeResourcePreferencePK castOther = (ComputeResourcePreferencePK) other; return this.gatewayId.equals(castOther.gatewayId) - && this.resourceId.equals(castOther.resourceId); + && this.computeResourceId.equals(castOther.computeResourceId); } public int hashCode() { final int prime = 31; int hash = 17; hash = hash * prime + this.gatewayId.hashCode(); - hash = hash * prime + this.resourceId.hashCode(); + hash = hash * prime + this.computeResourceId.hashCode(); return hash; } diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java index ea92602b75..71fcd71cb7 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java @@ -32,7 +32,7 @@ * The persistent class for the gateway_profile database table. */ @Entity -@Table(name = "gateway_profile") +@Table(name = "GATEWAY_PROFILE") public class GatewayProfileEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -43,8 +43,8 @@ @Column(name = "CREATION_TIME") private Timestamp creationTime; - @Column(name = "CS_TOKEN") - private String csToken; + @Column(name = "CREDENTIAL_STORE_TOKEN") + private String credentialStoreToken; @Column(name = "IDENTITY_SERVER_PWD_CRED_TOKEN") private String identityServerPwdCredToken; @@ -55,7 +55,6 @@ @Column(name = "UPDATE_TIME") private Timestamp updateTime; - public GatewayProfileEntity() { } @@ -75,12 +74,12 @@ public void setCreationTime(Timestamp creationTime) { this.creationTime = creationTime; } - public String getCsToken() { - return csToken; + public String getCredentialStoreToken() { + return credentialStoreToken; } - public void setCsToken(String csToken) { - this.csToken = csToken; + public void setCredentialStoreToken(String credentialStoreToken) { + this.credentialStoreToken = credentialStoreToken; } public String getIdentityServerPwdCredToken() { diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/DataStoragePreferenceEntity.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/StoragePreferenceEntity.java similarity index 87% rename from modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/DataStoragePreferenceEntity.java rename to modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/StoragePreferenceEntity.java index 0798cad675..631657cb7f 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/DataStoragePreferenceEntity.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/StoragePreferenceEntity.java @@ -30,12 +30,12 @@ * The persistent class for the data_storage_preference database table. */ @Entity -@Table(name = "data_storage_preference") -public class DataStoragePreferenceEntity implements Serializable { +@Table(name = "STORAGE_PREFERENCE") +public class StoragePreferenceEntity implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId - private DataStoragePreferencePK id; + private StoragePreferencePK id; @Column(name = "FS_ROOT_LOCATION") private String fsRootLocation; @@ -46,14 +46,14 @@ @Column(name = "RESOURCE_CS_TOKEN") private String resourceCsToken; - public DataStoragePreferenceEntity() { + public StoragePreferenceEntity() { } - public DataStoragePreferencePK getId() { + public StoragePreferencePK getId() { return id; } - public void setId(DataStoragePreferencePK id) { + public void setId(StoragePreferencePK id) { this.id = id; } diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/DataStoragePreferencePK.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/StoragePreferencePK.java similarity index 90% rename from modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/DataStoragePreferencePK.java rename to modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/StoragePreferencePK.java index a03c62c272..7002540a90 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/DataStoragePreferencePK.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/StoragePreferencePK.java @@ -28,7 +28,7 @@ * The primary key class for the data_storage_preference database table. */ @Embeddable -public class DataStoragePreferencePK implements Serializable { +public class StoragePreferencePK implements Serializable { //default serial version id, required for serializable classes. private static final long serialVersionUID = 1L; @@ -38,7 +38,7 @@ @Column(name = "STORAGE_RESOURCE_ID") private String storageResourceId; - public DataStoragePreferencePK() { + public StoragePreferencePK() { } public String getGatewayId() { @@ -61,10 +61,10 @@ public boolean equals(Object other) { if (this == other) { return true; } - if (!(other instanceof DataStoragePreferencePK)) { + if (!(other instanceof StoragePreferencePK)) { return false; } - DataStoragePreferencePK castOther = (DataStoragePreferencePK) other; + StoragePreferencePK castOther = (StoragePreferencePK) other; return this.gatewayId.equals(castOther.gatewayId) && this.storageResourceId.equals(castOther.storageResourceId); diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/AppCatAbstractRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/AppCatAbstractRepository.java new file mode 100644 index 0000000000..f4b91e0493 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/AppCatAbstractRepository.java @@ -0,0 +1,132 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + * +*/ +package org.apache.airavata.registry.core.repositories.appcatalog; + +import org.apache.airavata.registry.core.utils.Committer; +import org.apache.airavata.registry.core.utils.DBConstants; +import org.apache.airavata.registry.core.utils.JPAUtil.AppCatalogJPAUtils; +import org.apache.airavata.registry.core.utils.ObjectMapperSingleton; +import org.dozer.Mapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public abstract class AppCatAbstractRepository<T, E, Id> { + private final static Logger logger = LoggerFactory.getLogger(AppCatAbstractRepository.class); + + private Class<T> thriftGenericClass; + private Class<E> dbEntityGenericClass; + + public AppCatAbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass) { + this.thriftGenericClass = thriftGenericClass; + this.dbEntityGenericClass = dbEntityGenericClass; + } + + public T create(T t) { + return update(t); + } + + public T update(T t) { + Mapper mapper = ObjectMapperSingleton.getInstance(); + E entity = mapper.map(t, dbEntityGenericClass); + E persistedCopy = execute(entityManager -> entityManager.merge(entity)); + return mapper.map(persistedCopy, thriftGenericClass); + } + + public boolean delete(Id id) { + execute(entityManager -> { + E entity = entityManager.find(dbEntityGenericClass, id); + entityManager.remove(entity); + return entity; + }); + return true; + } + + public T get(Id id) { + E entity = execute(entityManager -> entityManager + .find(dbEntityGenericClass, id)); + if(entity == null) + return null; + Mapper mapper = ObjectMapperSingleton.getInstance(); + return mapper.map(entity, thriftGenericClass); + } + + public List<T> select(String query, int offset) { + List resultSet = (List) execute(entityManager -> entityManager.createQuery(query).setFirstResult(offset) + .getResultList()); + Mapper mapper = ObjectMapperSingleton.getInstance(); + List<T> gatewayList = new ArrayList<>(); + resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass))); + return gatewayList; + } + + public List<T> select(String query, int limit, int offset, Map<String, Object> queryParams) { + int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit; + + List resultSet = (List) execute(entityManager -> { + Query jpaQuery = entityManager.createQuery(query); + + for (Map.Entry<String, Object> entry : queryParams.entrySet()) { + + jpaQuery.setParameter(entry.getKey(), entry.getValue()); + } + + return jpaQuery.setFirstResult(offset).setMaxResults(newLimit).getResultList(); + + }); + Mapper mapper = ObjectMapperSingleton.getInstance(); + List<T> gatewayList = new ArrayList<>(); + resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass))); + return gatewayList; + } + + public boolean isExists(Id id) { + return get(id) != null; + } + + public <R> R execute(Committer<EntityManager, R> committer){ + EntityManager entityManager = null; + try { + entityManager = AppCatalogJPAUtils.getEntityManager(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + entityManager.getTransaction().begin(); + R r = committer.commit(entityManager); + entityManager.getTransaction().commit(); + return r; + }finally { + if (entityManager != null && entityManager.isOpen()) { + if (entityManager.getTransaction().isActive()) { + entityManager.getTransaction().rollback(); + } + entityManager.close(); + } + } + } + +} \ No newline at end of file diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ComputeResourceRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ComputeResourceRepository.java new file mode 100644 index 0000000000..0a4136c661 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ComputeResourceRepository.java @@ -0,0 +1,14 @@ +package org.apache.airavata.registry.core.repositories.appcatalog; + +import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; +import org.apache.airavata.registry.core.entities.appcatalog.ComputeResourceEntity; +import org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePreferenceEntity; +import org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePreferencePK; +import org.apache.airavata.registry.core.repositories.AbstractRepository; + +public class ComputeResourceRepository extends AppCatAbstractRepository<ComputeResourcePreference, ComputeResourcePreferenceEntity, ComputeResourcePreferencePK> { + + public ComputeResourceRepository() { + super(ComputeResourcePreference.class, ComputeResourcePreferenceEntity.class); + } +} diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GwyResourceProfileRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GwyResourceProfileRepository.java new file mode 100644 index 0000000000..00afa6652d --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GwyResourceProfileRepository.java @@ -0,0 +1,156 @@ +package org.apache.airavata.registry.core.repositories.appcatalog; + +import org.apache.airavata.common.utils.AiravataUtils; +import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; +import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile; +import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference; +import org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePreferencePK; +import org.apache.airavata.registry.core.entities.appcatalog.StoragePreferencePK; +import org.apache.airavata.registry.core.entities.appcatalog.GatewayProfileEntity; +import org.apache.airavata.registry.core.utils.DBConstants; +import org.apache.airavata.registry.core.utils.ObjectMapperSingleton; +import org.apache.airavata.registry.core.utils.QueryConstants; +import org.apache.airavata.registry.cpi.AppCatalogException; +import org.apache.airavata.registry.cpi.GwyResourceProfile; +import org.dozer.Mapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GwyResourceProfileRepository extends AppCatAbstractRepository<GatewayResourceProfile, GatewayProfileEntity, String> implements GwyResourceProfile { + + private final static Logger logger = LoggerFactory.getLogger(GwyResourceProfileRepository.class); + + public GwyResourceProfileRepository() { + super(GatewayResourceProfile.class, GatewayProfileEntity.class); + } + + @Override + public String addGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) { + + return updateGatewayResourceProfile(gatewayResourceProfile); + } + + @Override + public void updateGatewayResourceProfile(String gatewayId, GatewayResourceProfile updatedProfile) throws AppCatalogException { + updateGatewayResourceProfile(updatedProfile); + } + + public String updateGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) { + String gatewayId = gatewayResourceProfile.getGatewayID(); + Mapper mapper = ObjectMapperSingleton.getInstance(); + GatewayProfileEntity gatewayProfileEntity = mapper.map(gatewayResourceProfile, GatewayProfileEntity.class); + if (get(gatewayId) != null) { + gatewayProfileEntity.setUpdateTime(AiravataUtils.getCurrentTimestamp()); + } + else { + gatewayProfileEntity.setCreationTime(AiravataUtils.getCurrentTimestamp()); + } + GatewayProfileEntity persistedCopy = execute(entityManager -> entityManager.merge(gatewayProfileEntity)); + + List<ComputeResourcePreference> computeResourcePreferences = gatewayResourceProfile.getComputeResourcePreferences(); + if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()) { + for (ComputeResourcePreference preference : computeResourcePreferences ) { + (new ComputeResourceRepository()).create(preference); + } + } + + List<StoragePreference> dataStoragePreferences = gatewayResourceProfile.getStoragePreferences(); + if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) { + for (StoragePreference storagePreference : dataStoragePreferences) { + (new StoragePrefRepository()).create(storagePreference); + } + } + return persistedCopy.getGatewayId(); + } + + @Override + public GatewayResourceProfile getGatewayProfile(String gatewayId) { + GatewayResourceProfile gatewayResourceProfile = get(gatewayId); + gatewayResourceProfile.setComputeResourcePreferences(getAllComputeResourcePreferences(gatewayId)); + gatewayResourceProfile.setStoragePreferences(getAllStoragePreferences(gatewayId)); + return gatewayResourceProfile; + } + + @Override + public boolean removeGatewayResourceProfile(String gatewayId) throws AppCatalogException { + return delete(gatewayId); + } + + @Override + public List<GatewayResourceProfile> getAllGatewayProfiles() { + + List<GatewayResourceProfile> gwyResourceProfileList = new ArrayList<GatewayResourceProfile>(); + List<GatewayResourceProfile> gatewayResourceProfileList = select(QueryConstants.FIND_ALL_GATEWAY_PROFILES, 0); + if (gatewayResourceProfileList != null && !gatewayResourceProfileList.isEmpty()) { + for (GatewayResourceProfile gatewayResourceProfile: gatewayResourceProfileList) { + gatewayResourceProfile.setComputeResourcePreferences(getAllComputeResourcePreferences(gatewayResourceProfile.getGatewayID())); + gatewayResourceProfile.setStoragePreferences(getAllStoragePreferences(gatewayResourceProfile.getGatewayID())); + } + } + return gatewayResourceProfileList; + } + + @Override + public boolean removeComputeResourcePreferenceFromGateway(String gatewayId, String preferenceId) { + ComputeResourcePreferencePK computeResourcePreferencePK = new ComputeResourcePreferencePK(); + computeResourcePreferencePK.setGatewayId(gatewayId); + computeResourcePreferencePK.setComputeResourceId(preferenceId); + (new ComputeResourceRepository()).delete(computeResourcePreferencePK); + return true; + } + + @Override + public boolean removeDataStoragePreferenceFromGateway(String gatewayId, String preferenceId) { + StoragePreferencePK storagePreferencePK = new StoragePreferencePK(); + storagePreferencePK.setGatewayId(gatewayId); + storagePreferencePK.setStorageResourceId(preferenceId); + (new StoragePrefRepository()).delete(storagePreferencePK); + return true; + } + + @Override + public boolean isGatewayResourceProfileExists(String gatewayId) throws AppCatalogException { + return isExists(gatewayId); + } + + @Override + public ComputeResourcePreference getComputeResourcePreference(String gatewayId, String hostId) { + ComputeResourcePreferencePK computeResourcePreferencePK = new ComputeResourcePreferencePK(); + computeResourcePreferencePK.setGatewayId(gatewayId); + computeResourcePreferencePK.setComputeResourceId(hostId); + return (new ComputeResourceRepository()).get(computeResourcePreferencePK); + } + + @Override + public StoragePreference getStoragePreference(String gatewayId, String storageId){ + StoragePreferencePK storagePreferencePK = new StoragePreferencePK(); + storagePreferencePK.setStorageResourceId(storageId); + storagePreferencePK.setGatewayId(gatewayId); + return (new StoragePrefRepository()).get(storagePreferencePK); + } + + @Override + public List<ComputeResourcePreference> getAllComputeResourcePreferences(String gatewayId) { + Map<String,Object> queryParameters = new HashMap<>(); + queryParameters.put(DBConstants.ComputeResourcePreference.GATEWAY_ID, gatewayId); + return (new ComputeResourceRepository()).select(QueryConstants.FIND_ALL_COMPUTE_RESOURCE_PREFERENCES, -1, 0, queryParameters); + } + + @Override + public List<StoragePreference> getAllStoragePreferences(String gatewayId) { + Map<String,Object> queryParameters = new HashMap<>(); + queryParameters.put(DBConstants.StorageResourcePreference.GATEWAY_ID, gatewayId); + return (new StoragePrefRepository()).select(QueryConstants.FIND_ALL_STORAGE_RESOURCE_PREFERENCES, -1, 0, queryParameters); + } + + @Override + public List<String> getGatewayProfileIds(String gatewayName) throws AppCatalogException { + //not used anywhere. Skipping the implementation + return null; + } +} diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/StoragePrefRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/StoragePrefRepository.java new file mode 100644 index 0000000000..423cd2b392 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/StoragePrefRepository.java @@ -0,0 +1,13 @@ +package org.apache.airavata.registry.core.repositories.appcatalog; + +import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference; +import org.apache.airavata.registry.core.entities.appcatalog.StoragePreferenceEntity; +import org.apache.airavata.registry.core.entities.appcatalog.StoragePreferencePK; +import org.apache.airavata.registry.core.repositories.AbstractRepository; + +public class StoragePrefRepository extends AppCatAbstractRepository<StoragePreference, StoragePreferenceEntity, StoragePreferencePK> { + + public StoragePrefRepository() { + super(StoragePreference.class, StoragePreferenceEntity.class); + } +} diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java new file mode 100644 index 0000000000..bdd3cb4d19 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java @@ -0,0 +1,15 @@ +package org.apache.airavata.registry.core.utils; + +public class DBConstants { + + public static int SELECT_MAX_ROWS = 1000; + + public static class ComputeResourcePreference { + public static final String GATEWAY_ID = "gatewayId"; + } + + public static class StorageResourcePreference { + public static final String GATEWAY_ID = "gatewayId"; + } + +} diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtil/AppCatalogJPAUtils.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtil/AppCatalogJPAUtils.java new file mode 100644 index 0000000000..c42de64128 --- /dev/null +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtil/AppCatalogJPAUtils.java @@ -0,0 +1,67 @@ +package org.apache.airavata.registry.core.utils.JPAUtil; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.utils.ServerSettings; +import org.apache.airavata.registry.core.utils.Committer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.*; +import java.util.HashMap; +import java.util.Map; + +public class AppCatalogJPAUtils { + + private final static Logger logger = LoggerFactory.getLogger(AppCatalogJPAUtils.class); + private static final String PERSISTENCE_UNIT_NAME = "appcatalog_data"; + private static final String APPCATALOG_JDBC_DRIVER = "appcatalog.jdbc.driver"; + private static final String APPCATALOG_JDBC_URL = "appcatalog.jdbc.url"; + private static final String APPCATALOG_JDBC_USER = "appcatalog.jdbc.user"; + private static final String APPCATALOG_JDBC_PWD = "appcatalog.jdbc.password"; + private static final String APPCATALOG_VALIDATION_QUERY = "appcatalog.validationQuery"; + @PersistenceUnit(unitName = "appcatalog_data") + protected static EntityManagerFactory factory; + @PersistenceContext(unitName = "appcatalog_data") + private static EntityManager appCatEntityManager; + + public static EntityManager getEntityManager() throws ApplicationSettingsException { + if (factory == null) { + String connectionProperties = "DriverClassName=" + readServerProperties(APPCATALOG_JDBC_DRIVER) + "," + + "Url=" + readServerProperties(APPCATALOG_JDBC_URL) + "?autoReconnect=true," + + "Username=" + readServerProperties(APPCATALOG_JDBC_USER) + "," + + "Password=" + readServerProperties(APPCATALOG_JDBC_PWD) + + ",validationQuery=" + readServerProperties(APPCATALOG_VALIDATION_QUERY); + System.out.println(connectionProperties); + Map<String, String> properties = new HashMap<String, String>(); + properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource"); + properties.put("openjpa.ConnectionProperties", connectionProperties); + properties.put("openjpa.DynamicEnhancementAgent", "true"); + properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported"); + properties.put("openjpa.RemoteCommitProvider", "sjvm"); + properties.put("openjpa.Log", "DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO"); + properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); + properties.put("openjpa.jdbc.QuerySQLCache", "false"); + properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72, PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000, autoReconnect=true"); + factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties); + } + // clear cache at entitymangerfactory level + if (factory.getCache() != null) { + factory.getCache().evictAll(); + } + appCatEntityManager = factory.createEntityManager(); + // clear the entitymanager cache + if (appCatEntityManager != null) { + appCatEntityManager.clear(); + } + return appCatEntityManager; + } + + private static String readServerProperties(String propertyName) throws ApplicationSettingsException { + try { + return ServerSettings.getSetting(propertyName); + } catch (ApplicationSettingsException e) { + logger.error("Unable to read airavata-server.properties...", e); + throw new ApplicationSettingsException("Unable to read airavata-server.properties..."); + } + } +} diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java index 250c4618ab..7802c84dea 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java @@ -2,6 +2,10 @@ import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePreferenceEntity; +import org.apache.airavata.registry.core.entities.appcatalog.StoragePreferenceEntity; +import org.apache.airavata.registry.core.entities.appcatalog.GatewayProfileEntity; + public interface QueryConstants { String FIND_USER_PROFILE_BY_USER_ID = "SELECT u FROM UserProfileEntity u " + @@ -10,4 +14,10 @@ String FIND_ALL_USER_PROFILES_BY_GATEWAY_ID = "SELECT u FROM UserProfileEntity u " + "where u.gatewayId LIKE :"+ UserProfile._Fields.GATEWAY_ID.getFieldName() + ""; + + String FIND_ALL_GATEWAY_PROFILES = "SELECT G FROM " + GatewayProfileEntity.class.getSimpleName() + " G"; + String FIND_ALL_COMPUTE_RESOURCE_PREFERENCES = "SELECT DISTINCT CR FROM " + ComputeResourcePreferenceEntity.class.getSimpleName() + " CR " + + "WHERE CR.id.gatewayId LIKE : " + DBConstants.ComputeResourcePreference.GATEWAY_ID; + String FIND_ALL_STORAGE_RESOURCE_PREFERENCES = "SELECT DISTINCT S FROM " + StoragePreferenceEntity.class.getSimpleName() + " S " + + "WHERE S.id.gatewayId LIKE : " + DBConstants.StorageResourcePreference.GATEWAY_ID; } diff --git a/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml b/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml index 68861e476f..7f0297f687 100644 --- a/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml +++ b/modules/registry-refactoring/src/main/resources/META-INF/persistence.xml @@ -20,7 +20,7 @@ * * --> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> - <persistence-unit name="airavata_catalog"> + <persistence-unit name="appcatalog_data"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <class>org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity</class> <class>org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity</class> @@ -97,7 +97,7 @@ <class>org.apache.airavata.registry.core.entities.appcatalog.JobManagerCommandEntity</class> <class>org.apache.airavata.registry.core.entities.appcatalog.ParallelismCommandEntity</class> <class>org.apache.airavata.registry.core.entities.appcatalog.LocalDataMovementEntity</class> - <class>org.apache.airavata.registry.core.entities.appcatalog.DataStoragePreferenceEntity</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.StoragePreferenceEntity</class> <class>org.apache.airavata.registry.core.entities.appcatalog.GlobusGkEndpointPK</class> <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshPostjobcommandPK</class> <class>org.apache.airavata.registry.core.entities.appcatalog.GsisshPrejobcommandPK</class> @@ -124,7 +124,7 @@ <class>org.apache.airavata.registry.core.entities.appcatalog.StorageInterfacePK</class> <class>org.apache.airavata.registry.core.entities.appcatalog.JobManagerCommandPK</class> <class>org.apache.airavata.registry.core.entities.appcatalog.ParallelismCommandPK</class> - <class>org.apache.airavata.registry.core.entities.appcatalog.DataStoragePreferencePK</class> + <class>org.apache.airavata.registry.core.entities.appcatalog.StoragePreferencePK</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> diff --git a/modules/registry-refactoring/src/main/resources/appcatalog-derby.sql b/modules/registry-refactoring/src/main/resources/appcatalog-derby.sql new file mode 100644 index 0000000000..db9e26164e --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/appcatalog-derby.sql @@ -0,0 +1,583 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + * + */ + +CREATE TABLE COMPUTE_RESOURCE +( + RESOURCE_ID VARCHAR (255) NOT NULL, + HOST_NAME VARCHAR (255) NOT NULL, + RESOURCE_DESCRIPTION VARCHAR (255), + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + MAX_MEMORY_NODE INTEGER, + CPUS_PER_NODE INTEGER, + DEFAULT_NODE_COUNT INTEGER, + DEFAULT_CPU_COUNT INTEGER, + DEFAULT_WALLTIME INTEGER, + ENABLED SMALLINT, + GATEWAY_USAGE_REPORTING SMALLINT, + GATEWAY_USAGE_MODULE_LOAD_CMD VARCHAR(500), + GATEWAY_USAGE_EXECUTABLE VARCHAR(255), + PRIMARY KEY (RESOURCE_ID) +); + +CREATE TABLE HOST_ALIAS +( + RESOURCE_ID VARCHAR(255), + ALIAS VARCHAR(255), + PRIMARY KEY(RESOURCE_ID,ALIAS), + FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE HOST_IPADDRESS +( + RESOURCE_ID VARCHAR(255), + IP_ADDRESS VARCHAR(255), + PRIMARY KEY(RESOURCE_ID,IP_ADDRESS), + FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE GSISSH_SUBMISSION +( + SUBMISSION_ID VARCHAR(255), + RESOURCE_JOB_MANAGER VARCHAR(255), + SSH_PORT INTEGER, + INSTALLED_PATH VARCHAR(255), + MONITOR_MODE VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID) +); + +CREATE TABLE GSISSH_EXPORT +( + SUBMISSION_ID VARCHAR(255), + EXPORT VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID, EXPORT), + FOREIGN KEY (SUBMISSION_ID) REFERENCES GSISSH_SUBMISSION(SUBMISSION_ID) ON DELETE CASCADE +); + + + +CREATE TABLE GLOBUS_SUBMISSION +( + SUBMISSION_ID VARCHAR(255), + RESOURCE_JOB_MANAGER VARCHAR(255), + SECURITY_PROTOCAL VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID) +); + +CREATE TABLE UNICORE_SUBMISSION +( + SUBMISSION_ID VARCHAR(255), + SECURITY_PROTOCAL VARCHAR(255), + UNICORE_ENDPOINT_URL VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID) +); + +CREATE TABLE UNICORE_DATAMOVEMENT +( + DATAMOVEMENT_ID VARCHAR(255), + SECURITY_PROTOCAL VARCHAR(255), + UNICORE_ENDPOINT_URL VARCHAR(255), + PRIMARY KEY(DATAMOVEMENT_ID) +); + + +CREATE TABLE GLOBUS_GK_ENDPOINT +( + SUBMISSION_ID VARCHAR(255), + ENDPOINT VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID, ENDPOINT), + FOREIGN KEY (SUBMISSION_ID) REFERENCES GLOBUS_SUBMISSION(SUBMISSION_ID) ON DELETE CASCADE +); + +CREATE TABLE RESOURCE_JOB_MANAGER +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + PUSH_MONITORING_ENDPOINT VARCHAR (255), + JOB_MANAGER_BIN_PATH VARCHAR (255), + RESOURCE_JOB_MANAGER_TYPE VARCHAR (255) NOT NULL, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (RESOURCE_JOB_MANAGER_ID) +); + + + +CREATE TABLE SSH_JOB_SUBMISSION +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + JOB_SUBMISSION_INTERFACE_ID VARCHAR (255) NOT NULL, + ALTERNATIVE_SSH_HOSTNAME VARCHAR (255), + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + SSH_PORT INTEGER, + MONITOR_MODE VARCHAR (255), + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (JOB_SUBMISSION_INTERFACE_ID), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) +); + +CREATE TABLE SCP_DATA_MOVEMENT +( + QUEUE_DESCRIPTION VARCHAR (255), + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + ALTERNATIVE_SCP_HOSTNAME VARCHAR (255), + SSH_PORT INTEGER, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID) +); + +CREATE TABLE GRIDFTP_DATA_MOVEMENT +( + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID) +); + +CREATE TABLE GRIDFTP_ENDPOINT +( + ENDPOINT VARCHAR (255) NOT NULL, + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID,ENDPOINT), + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + FOREIGN KEY (DATA_MOVEMENT_INTERFACE_ID) REFERENCES GRIDFTP_DATA_MOVEMENT(DATA_MOVEMENT_INTERFACE_ID) ON DELETE CASCADE +); + +--CREATE TABLE JOB_SUBMISSION_PROTOCOL +--( +-- RESOURCE_ID VARCHAR(255), +-- SUBMISSION_ID VARCHAR(255), +-- JOB_TYPE VARCHAR(255), +-- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, +-- UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', +-- PRIMARY KEY(RESOURCE_ID,SUBMISSION_ID,JOB_TYPE), +-- FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +--); +-- +--CREATE TABLE DATA_MOVEMENT_PROTOCOL +--( +-- RESOURCE_ID VARCHAR(255), +-- DATA_MOVE_ID VARCHAR(255), +-- DATA_MOVE_TYPE VARCHAR(255), +-- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, +-- UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', +-- PRIMARY KEY(RESOURCE_ID,DATA_MOVE_ID,DATA_MOVE_TYPE), +-- FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +--); + +CREATE TABLE APPLICATION_MODULE +( + MODULE_ID VARCHAR(255), + MODULE_NAME VARCHAR(255), + MODULE_VERSION VARCHAR(255), + MODULE_DESC VARCHAR(500), + GATEWAY_ID VARCHAR (255), + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY(MODULE_ID) +); + +CREATE TABLE APPLICATION_DEPLOYMENT +( + DEPLOYMENT_ID VARCHAR(255), + APP_MODULE_ID VARCHAR(255), + COMPUTE_HOSTID VARCHAR(255), + EXECUTABLE_PATH VARCHAR(255), + PARALLELISM VARCHAR(255), + APPLICATION_DESC VARCHAR(255), + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + GATEWAY_ID VARCHAR(255), + DEFAULT_QUEUE_NAME VARCHAR(255), + DEFAULT_NODE_COUNT INTEGER, + DEFAULT_CPU_COUNT INTEGER, + DEFAULT_WALLTIME INTEGER, + EDITABLE_BY_USER BOOLEAN, + PRIMARY KEY(DEPLOYMENT_ID), + FOREIGN KEY (COMPUTE_HOSTID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE, + FOREIGN KEY (APP_MODULE_ID) REFERENCES APPLICATION_MODULE(MODULE_ID) ON DELETE CASCADE +); + +CREATE TABLE MODULE_LOAD_CMD +( + CMD VARCHAR (255) NOT NULL, + APP_DEPLOYMENT_ID VARCHAR (255) NOT NULL, + PRIMARY KEY (APP_DEPLOYMENT_ID,CMD), + FOREIGN KEY (APP_DEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE PREJOB_COMMAND +( + APPDEPLOYMENT_ID VARCHAR(255), + COMMAND VARCHAR(255), + PRIMARY KEY(APPDEPLOYMENT_ID, COMMAND), + FOREIGN KEY (APPDEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE POSTJOB_COMMAND +( + APPDEPLOYMENT_ID VARCHAR(255), + COMMAND VARCHAR(255), + PRIMARY KEY(APPDEPLOYMENT_ID, COMMAND), + FOREIGN KEY (APPDEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE LIBRARY_PREPAND_PATH +( + DEPLOYMENT_ID VARCHAR(255), + NAME VARCHAR(255), + VALUE VARCHAR(255), + PRIMARY KEY(DEPLOYMENT_ID, NAME), + FOREIGN KEY (DEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE LIBRARY_APEND_PATH +( + DEPLOYMENT_ID VARCHAR(255), + NAME VARCHAR(255), + VALUE VARCHAR(255), + PRIMARY KEY(DEPLOYMENT_ID, NAME), + FOREIGN KEY (DEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE APP_ENVIRONMENT +( + DEPLOYMENT_ID VARCHAR(255), + NAME VARCHAR(255), + VALUE VARCHAR(255), + PRIMARY KEY(DEPLOYMENT_ID, NAME), + FOREIGN KEY (DEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE APPLICATION_INTERFACE +( + INTERFACE_ID VARCHAR(255), + APPLICATION_NAME VARCHAR(255), + APPLICATION_DESCRIPTION VARCHAR(500), + GATEWAY_ID VARCHAR(255), + ARCHIVE_WORKING_DIRECTORY SMALLINT, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY(INTERFACE_ID) +); + +CREATE TABLE APP_MODULE_MAPPING +( + INTERFACE_ID VARCHAR(255), + MODULE_ID VARCHAR(255), + PRIMARY KEY(INTERFACE_ID, MODULE_ID), + FOREIGN KEY (INTERFACE_ID) REFERENCES APPLICATION_INTERFACE(INTERFACE_ID) ON DELETE CASCADE, + FOREIGN KEY (MODULE_ID) REFERENCES APPLICATION_MODULE(MODULE_ID) ON DELETE CASCADE +); + +CREATE TABLE APPLICATION_INPUT +( + INTERFACE_ID VARCHAR(255), + INPUT_KEY VARCHAR(255), + INPUT_VALUE VARCHAR(255), + DATA_TYPE VARCHAR(255), + METADATA VARCHAR(255), + APP_ARGUMENT VARCHAR(255), + STANDARD_INPUT SMALLINT, + INPUT_ORDER INTEGER, + IS_REQUIRED SMALLINT, + REQUIRED_TO_COMMANDLINE SMALLINT, + DATA_STAGED SMALLINT, + USER_FRIENDLY_DESC VARCHAR(255), + IS_READ_ONLY SMALLINT, + PRIMARY KEY(INTERFACE_ID,INPUT_KEY), + FOREIGN KEY (INTERFACE_ID) REFERENCES APPLICATION_INTERFACE(INTERFACE_ID) ON DELETE CASCADE +); + +CREATE TABLE APPLICATION_OUTPUT +( + INTERFACE_ID VARCHAR(255), + OUTPUT_KEY VARCHAR(255), + OUTPUT_VALUE VARCHAR(255), + DATA_TYPE VARCHAR(255), + IS_REQUIRED SMALLINT, + REQUIRED_TO_COMMANDLINE SMALLINT, + DATA_MOVEMENT SMALLINT, + DATA_NAME_LOCATION VARCHAR(255), + SEARCH_QUERY VARCHAR(255), + APP_ARGUMENT VARCHAR(255), + OUTPUT_STREAMING SMALLINT, + PRIMARY KEY(INTERFACE_ID,OUTPUT_KEY), + FOREIGN KEY (INTERFACE_ID) REFERENCES APPLICATION_INTERFACE(INTERFACE_ID) ON DELETE CASCADE +); + +CREATE TABLE GATEWAY_PROFILE +( + GATEWAY_ID VARCHAR(255), + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + CS_TOKEN VARCHAR (255), + IDENTITY_SERVER_TENANT VARCHAR (255), + IDENTITY_SERVER_PWD_CRED_TOKEN VARCHAR (255), + PRIMARY KEY(GATEWAY_ID) +); + +CREATE TABLE COMPUTE_RESOURCE_PREFERENCE +( + GATEWAY_ID VARCHAR(255), + RESOURCE_ID VARCHAR(255), + OVERRIDE_BY_AIRAVATA SMALLINT, + PREFERED_JOB_SUB_PROTOCOL VARCHAR(255), + PREFERED_DATA_MOVE_PROTOCOL VARCHAR(255), + PREFERED_BATCH_QUEUE VARCHAR(255), + SCRATCH_LOCATION VARCHAR(255), + ALLOCATION_PROJECT_NUMBER VARCHAR(255), + LOGIN_USERNAME VARCHAR(255), + RESOURCE_CS_TOKEN VARCHAR(255), + USAGE_REPORTING_GATEWAY_ID VARCHAR(255), + QUALITY_OF_SERVICE VARCHAR(255), + RESERVATION VARCHAR (255), + RESERVATION_START_TIME timestamp, + RESERVATION_END_TIME timestamp, + SSH_ACCOUNT_PROVISIONER VARCHAR(255), + SSH_ACCOUNT_PROVISIONER_ADDITIONAL_INFO VARCHAR(1000), + PRIMARY KEY(GATEWAY_ID,RESOURCE_ID), + FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE, + FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY_PROFILE(GATEWAY_ID) ON DELETE CASCADE +); + +CREATE TABLE SSH_ACCOUNT_PROVISIONER_CONFIG +( + GATEWAY_ID VARCHAR(255), + RESOURCE_ID VARCHAR(255), + CONFIG_NAME VARCHAR(255), + CONFIG_VALUE VARCHAR(255), + PRIMARY KEY (GATEWAY_ID, RESOURCE_ID, CONFIG_NAME), + FOREIGN KEY (GATEWAY_ID, RESOURCE_ID) REFERENCES COMPUTE_RESOURCE_PREFERENCE (GATEWAY_ID, RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE BATCH_QUEUE +( + COMPUTE_RESOURCE_ID VARCHAR(255) NOT NULL, + MAX_RUNTIME INTEGER, + MAX_JOB_IN_QUEUE INTEGER, + QUEUE_DESCRIPTION VARCHAR(255), + QUEUE_NAME VARCHAR(255) NOT NULL, + MAX_PROCESSORS INTEGER, + MAX_NODES INTEGER, + MAX_MEMORY INTEGER, + CPU_PER_NODE INTEGER, + DEFAULT_NODE_COUNT INTEGER, + DEFAULT_CPU_COUNT INTEGER, + DEFAULT_WALLTIME INTEGER, + QUEUE_SPECIFIC_MACROS VARCHAR(255), + IS_DEFAULT_QUEUE BOOLEAN, + PRIMARY KEY (COMPUTE_RESOURCE_ID,QUEUE_NAME), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE COMPUTE_RESOURCE_FILE_SYSTEM +( + COMPUTE_RESOURCE_ID VARCHAR (255) NOT NULL, + PATH VARCHAR (255), + FILE_SYSTEM VARCHAR (255) NOT NULL, + PRIMARY KEY (COMPUTE_RESOURCE_ID,FILE_SYSTEM), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE + ); + +CREATE TABLE JOB_SUBMISSION_INTERFACE +( + JOB_SUBMISSION_INTERFACE_ID VARCHAR (255) NOT NULL, + COMPUTE_RESOURCE_ID VARCHAR (255) NOT NULL, + JOB_SUBMISSION_PROTOCOL VARCHAR (255) NOT NULL, + PRIORITY_ORDER INTEGER, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (COMPUTE_RESOURCE_ID,JOB_SUBMISSION_INTERFACE_ID), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE DATA_MOVEMENT_INTERFACE +( + COMPUTE_RESOURCE_ID VARCHAR (255) NOT NULL, + DATA_MOVEMENT_PROTOCOL VARCHAR (255) NOT NULL, + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + PRIORITY_ORDER INTEGER, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (COMPUTE_RESOURCE_ID,DATA_MOVEMENT_INTERFACE_ID), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE STORAGE_RESOURCE +( + STORAGE_RESOURCE_ID VARCHAR (255) NOT NULL, + HOST_NAME VARCHAR (255) NOT NULL, + DESCRIPTION VARCHAR (255), + ENABLED SMALLINT , + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (STORAGE_RESOURCE_ID) +); + +CREATE TABLE STORAGE_INTERFACE +( + STORAGE_RESOURCE_ID VARCHAR (255) NOT NULL, + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + DATA_MOVEMENT_PROTOCOL VARCHAR (255) NOT NULL, + PRIORITY_ORDER INTEGER, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (STORAGE_RESOURCE_ID,DATA_MOVEMENT_INTERFACE_ID), + FOREIGN KEY (STORAGE_RESOURCE_ID) REFERENCES STORAGE_RESOURCE(STORAGE_RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE JOB_MANAGER_COMMAND +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + COMMAND_TYPE VARCHAR (255) NOT NULL, + COMMAND VARCHAR (255), + PRIMARY KEY (RESOURCE_JOB_MANAGER_ID,COMMAND_TYPE), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE +); + +CREATE TABLE PARALLELISM_COMMAND +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + COMMAND_TYPE VARCHAR (255) NOT NULL, + COMMAND VARCHAR (255), + PRIMARY KEY (RESOURCE_JOB_MANAGER_ID,COMMAND_TYPE), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE +); + +CREATE TABLE LOCAL_SUBMISSION +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + JOB_SUBMISSION_INTERFACE_ID VARCHAR (255) NOT NULL, + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (JOB_SUBMISSION_INTERFACE_ID), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) +); + +CREATE TABLE STORAGE_PREFERENCE +( + GATEWAY_ID VARCHAR(255), + STORAGE_RESOURCE_ID VARCHAR(255), + LOGIN_USERNAME VARCHAR(255), + FS_ROOT_LOCATION VARCHAR(255), + RESOURCE_CS_TOKEN VARCHAR(255), + PRIMARY KEY(GATEWAY_ID,STORAGE_RESOURCE_ID), + FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY_PROFILE(GATEWAY_ID) ON DELETE CASCADE +); + +CREATE TABLE LOCAL_DATA_MOVEMENT +( + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID) +); + +CREATE TABLE WORKFLOW +( + WF_TEMPLATE_ID VARCHAR (255) NOT NULL, + WF_NAME VARCHAR (255) NOT NULL, + GRAPH CLOB, + OWNER VARCHAR(255), + GATEWAY_ID VARCHAR(255), + CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + IMAGE BLOB, + PRIMARY KEY (WF_TEMPLATE_ID) +); + +CREATE TABLE WORKFLOW_INPUT +( + WF_TEMPLATE_ID VARCHAR(255), + INPUT_KEY VARCHAR(255), + INPUT_VALUE CLOB, + DATA_TYPE VARCHAR(255), + METADATA VARCHAR(255), + APP_ARGUMENT VARCHAR(255), + STANDARD_INPUT SMALLINT, + USER_FRIENDLY_DESC VARCHAR(255), + PRIMARY KEY(WF_TEMPLATE_ID,INPUT_KEY), + FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE +); + +CREATE TABLE WORKFLOW_OUTPUT +( + WF_TEMPLATE_ID VARCHAR(255), + OUTPUT_KEY VARCHAR(255), + OUTPUT_VALUE CLOB, + DATA_TYPE VARCHAR(255), + PRIMARY KEY(WF_TEMPLATE_ID,OUTPUT_KEY), + FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE +); + +CREATE TABLE USER_RESOURCE_PROFILE ( + USER_ID varchar(255) NOT NULL, + CREATION_TIME TIMESTAMP DEFAULT NULL, + CS_TOKEN varchar(255) DEFAULT NULL, + GATEWAY_ID varchar(255) DEFAULT NULL, + IDENTITY_SERVER_PWD_CRED_TOKEN varchar(255) DEFAULT NULL, + IDENTITY_SERVER_TENANT varchar(255) DEFAULT NULL, + UPDATE_TIME TIMESTAMP DEFAULT NULL, + PRIMARY KEY (USER_ID,GATEWAY_ID) +); + +CREATE TABLE USER_STORAGE_PREFERENCE ( + STORAGE_RESOURCE_ID varchar(255) NOT NULL, + USER_ID varchar(255) NOT NULL, + RESOURCE_CS_TOKEN varchar(255) DEFAULT NULL, + FS_ROOT_LOCATION varchar(255) DEFAULT NULL, + GATEWAY_ID varchar(255) DEFAULT NULL, + LOGIN_USERNAME varchar(255) DEFAULT NULL, + PRIMARY KEY (STORAGE_RESOURCE_ID,USER_ID,GATEWAY_ID) +); + +CREATE TABLE USER_COMPUTE_RESOURCE_PREFERENCE ( + RESOURCE_ID varchar(255) NOT NULL, + USER_ID varchar(255) NOT NULL, + PREFERED_BATCH_QUEUE varchar(255) DEFAULT NULL, + RESOURCE_CS_TOKEN varchar(255) DEFAULT NULL, + GATEWAY_ID varchar(255) DEFAULT NULL, + LOGIN_USERNAME varchar(255) DEFAULT NULL, + ALLOCATION_PROJECT_NUMBER varchar(255) DEFAULT NULL, + QUALITY_OF_SERVICE varchar(255) DEFAULT NULL, + RESERVATION varchar(255) DEFAULT NULL, + RESERVATION_END_TIME TIMESTAMP DEFAULT NULL, + RESERVATION_START_TIME TIMESTAMP DEFAULT NULL, + SCRATCH_LOCATION varchar(255) DEFAULT NULL, + VALIDATED SMALLINT NOT NULL DEFAULT 0, + PRIMARY KEY (RESOURCE_ID,USER_ID,GATEWAY_ID) +); + +CREATE TABLE CONFIGURATION +( + CONFIG_KEY VARCHAR(255), + CONFIG_VAL VARCHAR(255), + PRIMARY KEY(CONFIG_KEY, CONFIG_VAL) +); + +INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL) VALUES('app_catalog_version', '0.16'); + + + diff --git a/modules/registry-refactoring/src/main/resources/appcatalog-mysql.sql b/modules/registry-refactoring/src/main/resources/appcatalog-mysql.sql new file mode 100644 index 0000000000..3664a630ca --- /dev/null +++ b/modules/registry-refactoring/src/main/resources/appcatalog-mysql.sql @@ -0,0 +1,579 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + * + */ +CREATE TABLE COMPUTE_RESOURCE +( + RESOURCE_ID VARCHAR (255) NOT NULL, + HOST_NAME VARCHAR (255) NOT NULL, + RESOURCE_DESCRIPTION VARCHAR (255), + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + MAX_MEMORY_NODE INTEGER, + CPUS_PER_NODE INTEGER, + DEFAULT_NODE_COUNT INTEGER, + DEFAULT_CPU_COUNT INTEGER, + DEFAULT_WALLTIME INTEGER, + ENABLED SMALLINT, + GATEWAY_USAGE_REPORTING SMALLINT, + GATEWAY_USAGE_MODULE_LOAD_CMD VARCHAR(500), + GATEWAY_USAGE_EXECUTABLE VARCHAR(255), + PRIMARY KEY (RESOURCE_ID) +); + +CREATE TABLE HOST_ALIAS +( + RESOURCE_ID VARCHAR(255), + ALIAS VARCHAR(255), + PRIMARY KEY(RESOURCE_ID,ALIAS), + FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE HOST_IPADDRESS +( + RESOURCE_ID VARCHAR(255), + IP_ADDRESS VARCHAR(255), + PRIMARY KEY(RESOURCE_ID,IP_ADDRESS), + FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE GSISSH_SUBMISSION +( + SUBMISSION_ID VARCHAR(255), + RESOURCE_JOB_MANAGER VARCHAR(255), + SSH_PORT INTEGER, + INSTALLED_PATH VARCHAR(255), + MONITOR_MODE VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID) +); + +CREATE TABLE GSISSH_EXPORT +( + SUBMISSION_ID VARCHAR(255), + EXPORT VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID, EXPORT), + FOREIGN KEY (SUBMISSION_ID) REFERENCES GSISSH_SUBMISSION(SUBMISSION_ID) ON DELETE CASCADE +); + +CREATE TABLE GSISSH_PREJOBCOMMAND +( + SUBMISSION_ID VARCHAR(255), + COMMAND VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID, COMMAND), + FOREIGN KEY (SUBMISSION_ID) REFERENCES GSISSH_SUBMISSION(SUBMISSION_ID) ON DELETE CASCADE +); + +CREATE TABLE GSISSH_POSTJOBCOMMAND +( + SUBMISSION_ID VARCHAR(255), + COMMAND VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID, COMMAND), + FOREIGN KEY (SUBMISSION_ID) REFERENCES GSISSH_SUBMISSION(SUBMISSION_ID) ON DELETE CASCADE +); + +CREATE TABLE GLOBUS_SUBMISSION +( + SUBMISSION_ID VARCHAR(255), + RESOURCE_JOB_MANAGER VARCHAR(255), + SECURITY_PROTOCAL VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID) +); +CREATE TABLE UNICORE_SUBMISSION +( + SUBMISSION_ID VARCHAR(255), + SECURITY_PROTOCAL VARCHAR(255), + UNICORE_ENDPOINT_URL VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID) +); + +CREATE TABLE UNICORE_DATAMOVEMENT +( + DATAMOVEMENT_ID VARCHAR(255), + SECURITY_PROTOCAL VARCHAR(255), + UNICORE_ENDPOINT_URL VARCHAR(255), + PRIMARY KEY(DATAMOVEMENT_ID) +); + +CREATE TABLE GLOBUS_GK_ENDPOINT +( + SUBMISSION_ID VARCHAR(255), + ENDPOINT VARCHAR(255), + PRIMARY KEY(SUBMISSION_ID, ENDPOINT), + FOREIGN KEY (SUBMISSION_ID) REFERENCES GLOBUS_SUBMISSION(SUBMISSION_ID) ON DELETE CASCADE +); + +CREATE TABLE RESOURCE_JOB_MANAGER +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + PUSH_MONITORING_ENDPOINT VARCHAR (255), + JOB_MANAGER_BIN_PATH VARCHAR (255), + RESOURCE_JOB_MANAGER_TYPE VARCHAR (255) NOT NULL, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (RESOURCE_JOB_MANAGER_ID) +); + +CREATE TABLE SSH_JOB_SUBMISSION +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + JOB_SUBMISSION_INTERFACE_ID VARCHAR (255) NOT NULL, + ALTERNATIVE_SSH_HOSTNAME VARCHAR (255), + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + SSH_PORT INTEGER, + MONITOR_MODE VARCHAR (255), + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' , + PRIMARY KEY (JOB_SUBMISSION_INTERFACE_ID), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) +); + + +CREATE TABLE SCP_DATA_MOVEMENT +( + QUEUE_DESCRIPTION VARCHAR (255), + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + ALTERNATIVE_SCP_HOSTNAME VARCHAR (255), + SSH_PORT INTEGER, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' , + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID) +); + +CREATE TABLE GRIDFTP_DATA_MOVEMENT +( + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' , + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID) +); + +CREATE TABLE GRIDFTP_ENDPOINT +( + ENDPOINT VARCHAR (255) NOT NULL, + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID,ENDPOINT), + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' , + FOREIGN KEY (DATA_MOVEMENT_INTERFACE_ID) REFERENCES GRIDFTP_DATA_MOVEMENT(DATA_MOVEMENT_INTERFACE_ID) ON DELETE CASCADE +); + +--CREATE TABLE JOB_SUBMISSION_PROTOCOL +--( +-- RESOURCE_ID VARCHAR(255), +-- SUBMISSION_ID VARCHAR(255), +-- JOB_TYPE VARCHAR(255), +-- PRIMARY KEY(RESOURCE_ID,SUBMISSION_ID,JOB_TYPE), +-- FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +--); +-- +--CREATE TABLE DATA_MOVEMENT_PROTOCOL +--( +-- RESOURCE_ID VARCHAR(255), +-- DATA_MOVE_ID VARCHAR(255), +-- DATA_MOVE_TYPE VARCHAR(255), +-- PRIMARY KEY(RESOURCE_ID,DATA_MOVE_ID,DATA_MOVE_TYPE), +-- FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +--); + +CREATE TABLE APPLICATION_MODULE +( + MODULE_ID VARCHAR(255), + MODULE_NAME VARCHAR(255), + MODULE_VERSION VARCHAR(255), + MODULE_DESC VARCHAR(500), + GATEWAY_ID VARCHAR (255), + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' , + PRIMARY KEY(MODULE_ID) +); + +CREATE TABLE APPLICATION_DEPLOYMENT +( + DEPLOYMENT_ID VARCHAR(255), + APP_MODULE_ID VARCHAR(255), + COMPUTE_HOSTID VARCHAR(255), + EXECUTABLE_PATH VARCHAR(255), + PARALLELISM VARCHAR(255), + APPLICATION_DESC VARCHAR(255), + ENV_MODULE_LOAD_CMD VARCHAR(255), + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' , + GATEWAY_ID VARCHAR(255), + DEFAULT_QUEUE_NAME VARCHAR(255), + DEFAULT_NODE_COUNT INTEGER, + DEFAULT_CPU_COUNT INTEGER, + DEFAULT_WALLTIME INTEGER, + EDITABLE_BY_USER TINYINT(1), + PRIMARY KEY(DEPLOYMENT_ID), + FOREIGN KEY (COMPUTE_HOSTID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE, + FOREIGN KEY (APP_MODULE_ID) REFERENCES APPLICATION_MODULE(MODULE_ID) ON DELETE CASCADE +); + +CREATE TABLE LIBRARY_PREPAND_PATH +( + DEPLOYMENT_ID VARCHAR(255), + NAME VARCHAR(255), + VALUE VARCHAR(255), + PRIMARY KEY(DEPLOYMENT_ID, NAME), + FOREIGN KEY (DEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE LIBRARY_APEND_PATH +( + DEPLOYMENT_ID VARCHAR(255), + NAME VARCHAR(255), + VALUE VARCHAR(255), + PRIMARY KEY(DEPLOYMENT_ID, NAME), + FOREIGN KEY (DEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE APP_ENVIRONMENT +( + DEPLOYMENT_ID VARCHAR(255), + NAME VARCHAR(255), + VALUE VARCHAR(255), + PRIMARY KEY(DEPLOYMENT_ID, NAME), + FOREIGN KEY (DEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE PREJOB_COMMAND +( + APPDEPLOYMENT_ID VARCHAR(255), + COMMAND VARCHAR(255), + PRIMARY KEY(APPDEPLOYMENT_ID, COMMAND), + FOREIGN KEY (APPDEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE POSTJOB_COMMAND +( + APPDEPLOYMENT_ID VARCHAR(255), + COMMAND VARCHAR(255), + PRIMARY KEY(APPDEPLOYMENT_ID, COMMAND), + FOREIGN KEY (APPDEPLOYMENT_ID) REFERENCES APPLICATION_DEPLOYMENT(DEPLOYMENT_ID) ON DELETE CASCADE +); + +CREATE TABLE APPLICATION_INTERFACE +( + INTERFACE_ID VARCHAR(255), + APPLICATION_NAME VARCHAR(255), + APPLICATION_DESCRIPTION VARCHAR(500), + GATEWAY_ID VARCHAR(255), + ARCHIVE_WORKING_DIRECTORY SMALLINT, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY(INTERFACE_ID) +); + +CREATE TABLE APP_MODULE_MAPPING +( + INTERFACE_ID VARCHAR(255), + MODULE_ID VARCHAR(255), + PRIMARY KEY(INTERFACE_ID, MODULE_ID), + FOREIGN KEY (INTERFACE_ID) REFERENCES APPLICATION_INTERFACE(INTERFACE_ID) ON DELETE CASCADE, + FOREIGN KEY (MODULE_ID) REFERENCES APPLICATION_MODULE(MODULE_ID) ON DELETE CASCADE +); + +CREATE TABLE APPLICATION_INPUT +( + INTERFACE_ID VARCHAR(255), + INPUT_KEY VARCHAR(255), + INPUT_VALUE VARCHAR(255), + DATA_TYPE VARCHAR(255), + METADATA VARCHAR(255), + APP_ARGUMENT VARCHAR(255), + STANDARD_INPUT SMALLINT, + USER_FRIENDLY_DESC VARCHAR(255), + INPUT_ORDER INTEGER, + IS_REQUIRED SMALLINT, + REQUIRED_TO_COMMANDLINE SMALLINT, + DATA_STAGED SMALLINT, + IS_READ_ONLY SMALLINT, + PRIMARY KEY(INTERFACE_ID,INPUT_KEY), + FOREIGN KEY (INTERFACE_ID) REFERENCES APPLICATION_INTERFACE(INTERFACE_ID) ON DELETE CASCADE +); + +CREATE TABLE APPLICATION_OUTPUT +( + INTERFACE_ID VARCHAR(255), + OUTPUT_KEY VARCHAR(255), + OUTPUT_VALUE VARCHAR(255), + DATA_TYPE VARCHAR(255), + IS_REQUIRED SMALLINT, + REQUIRED_TO_COMMANDLINE SMALLINT, + DATA_MOVEMENT SMALLINT, + DATA_NAME_LOCATION VARCHAR(255), + SEARCH_QUERY VARCHAR(255), + APP_ARGUMENT VARCHAR(255), + OUTPUT_STREAMING SMALLINT, + PRIMARY KEY(INTERFACE_ID,OUTPUT_KEY), + FOREIGN KEY (INTERFACE_ID) REFERENCES APPLICATION_INTERFACE(INTERFACE_ID) ON DELETE CASCADE +); + +CREATE TABLE GATEWAY_PROFILE +( + GATEWAY_ID VARCHAR(255), + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' , + CS_TOKEN VARCHAR (255), + IDENTITY_SERVER_TENANT VARCHAR (255), + IDENTITY_SERVER_PWD_CRED_TOKEN VARCHAR (255), + PRIMARY KEY(GATEWAY_ID) +); + +CREATE TABLE COMPUTE_RESOURCE_PREFERENCE +( + GATEWAY_ID VARCHAR(255), + RESOURCE_ID VARCHAR(255), + OVERRIDE_BY_AIRAVATA SMALLINT, + PREFERED_JOB_SUB_PROTOCOL VARCHAR(255), + PREFERED_DATA_MOVE_PROTOCOL VARCHAR(255), + PREFERED_BATCH_QUEUE VARCHAR(255), + SCRATCH_LOCATION VARCHAR(255), + ALLOCATION_PROJECT_NUMBER VARCHAR(255), + LOGIN_USERNAME VARCHAR(255), + RESOURCE_CS_TOKEN VARCHAR(255), + USAGE_REPORTING_GATEWAY_ID VARCHAR(255), + QUALITY_OF_SERVICE VARCHAR(255), + RESERVATION VARCHAR (255), + RESERVATION_START_TIME timestamp, + RESERVATION_END_TIME timestamp, + SSH_ACCOUNT_PROVISIONER VARCHAR(255), + SSH_ACCOUNT_PROVISIONER_ADDITIONAL_INFO VARCHAR(1000), + PRIMARY KEY(GATEWAY_ID,RESOURCE_ID), + FOREIGN KEY (RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE, + FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY_PROFILE(GATEWAY_ID) ON DELETE CASCADE +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE SSH_ACCOUNT_PROVISIONER_CONFIG +( + GATEWAY_ID VARCHAR(255), + RESOURCE_ID VARCHAR(255), + CONFIG_NAME VARCHAR(255), + CONFIG_VALUE VARCHAR(255), + PRIMARY KEY (GATEWAY_ID, RESOURCE_ID, CONFIG_NAME), + FOREIGN KEY (GATEWAY_ID, RESOURCE_ID) REFERENCES COMPUTE_RESOURCE_PREFERENCE (GATEWAY_ID, RESOURCE_ID) ON DELETE CASCADE +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE BATCH_QUEUE +( + COMPUTE_RESOURCE_ID VARCHAR(255) NOT NULL, + MAX_RUNTIME INTEGER, + MAX_JOB_IN_QUEUE INTEGER, + QUEUE_DESCRIPTION VARCHAR(255), + QUEUE_NAME VARCHAR(255) NOT NULL, + MAX_PROCESSORS INTEGER, + MAX_NODES INTEGER, + MAX_MEMORY INTEGER, + CPU_PER_NODE INTEGER, + DEFAULT_NODE_COUNT INTEGER, + DEFAULT_CPU_COUNT INTEGER, + DEFAULT_WALLTIME INTEGER, + QUEUE_SPECIFIC_MACROS VARCHAR(255), + IS_DEFAULT_QUEUE TINYINT(1), + PRIMARY KEY (COMPUTE_RESOURCE_ID,QUEUE_NAME), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE COMPUTE_RESOURCE_FILE_SYSTEM +( + COMPUTE_RESOURCE_ID VARCHAR (255) NOT NULL, + PATH VARCHAR (255), + FILE_SYSTEM VARCHAR (255) NOT NULL, + PRIMARY KEY (COMPUTE_RESOURCE_ID,FILE_SYSTEM), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE JOB_SUBMISSION_INTERFACE +( + JOB_SUBMISSION_INTERFACE_ID VARCHAR (255) NOT NULL, + COMPUTE_RESOURCE_ID VARCHAR (255) NOT NULL, + JOB_SUBMISSION_PROTOCOL VARCHAR (255) NOT NULL, + PRIORITY_ORDER INTEGER, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (COMPUTE_RESOURCE_ID,JOB_SUBMISSION_INTERFACE_ID), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE DATA_MOVEMENT_INTERFACE +( + COMPUTE_RESOURCE_ID VARCHAR (255) NOT NULL, + DATA_MOVEMENT_PROTOCOL VARCHAR (255) NOT NULL, + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + PRIORITY_ORDER INTEGER, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (COMPUTE_RESOURCE_ID,DATA_MOVEMENT_INTERFACE_ID), + FOREIGN KEY (COMPUTE_RESOURCE_ID) REFERENCES COMPUTE_RESOURCE(RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE STORAGE_RESOURCE +( + STORAGE_RESOURCE_ID VARCHAR (255) NOT NULL, + HOST_NAME VARCHAR (255) NOT NULL, + DESCRIPTION VARCHAR (255), + ENABLED SMALLINT, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (STORAGE_RESOURCE_ID) +); + +CREATE TABLE STORAGE_INTERFACE +( + STORAGE_RESOURCE_ID VARCHAR (255) NOT NULL, + DATA_MOVEMENT_PROTOCOL VARCHAR (255) NOT NULL, + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + PRIORITY_ORDER INTEGER, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (STORAGE_RESOURCE_ID,DATA_MOVEMENT_INTERFACE_ID), + FOREIGN KEY (STORAGE_RESOURCE_ID) REFERENCES STORAGE_RESOURCE(STORAGE_RESOURCE_ID) ON DELETE CASCADE +); + +CREATE TABLE JOB_MANAGER_COMMAND +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + COMMAND_TYPE VARCHAR (255) NOT NULL, + COMMAND VARCHAR (255), + PRIMARY KEY (RESOURCE_JOB_MANAGER_ID,COMMAND_TYPE), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE +); + +CREATE TABLE PARALLELISM_COMMAND +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + COMMAND_TYPE VARCHAR (255) NOT NULL, + COMMAND VARCHAR (255), + PRIMARY KEY (RESOURCE_JOB_MANAGER_ID,COMMAND_TYPE), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE +); + +CREATE TABLE LOCAL_SUBMISSION +( + RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL, + JOB_SUBMISSION_INTERFACE_ID VARCHAR (255) NOT NULL, + SECURITY_PROTOCOL VARCHAR (255) NOT NULL, + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (JOB_SUBMISSION_INTERFACE_ID), + FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) +); + +CREATE TABLE LOCAL_DATA_MOVEMENT +( + DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, + PRIMARY KEY (DATA_MOVEMENT_INTERFACE_ID) +); + +CREATE TABLE DATA_STORAGE_PREFERENCE +( + GATEWAY_ID VARCHAR(255), + STORAGE_RESOURCE_ID VARCHAR(255), + LOGIN_USERNAME VARCHAR(255), + FS_ROOT_LOCATION VARCHAR(255), + RESOURCE_CS_TOKEN VARCHAR(255), + PRIMARY KEY(GATEWAY_ID,STORAGE_RESOURCE_ID), + FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY_PROFILE(GATEWAY_ID) ON DELETE CASCADE +); + +CREATE TABLE WORKFLOW +( + WF_TEMPLATE_ID VARCHAR (255) NOT NULL, + WF_NAME VARCHAR (255) NOT NULL, + GRAPH LONGTEXT, + OWNER VARCHAR(255), + CREATION_TIME TIMESTAMP DEFAULT NOW(), + UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', + IMAGE BLOB, + PRIMARY KEY (WF_TEMPLATE_ID) +); + +CREATE TABLE WORKFLOW_INPUT +( + WF_TEMPLATE_ID VARCHAR(255), + INPUT_KEY VARCHAR(255), + INPUT_VALUE LONGTEXT, + DATA_TYPE VARCHAR(255), + METADATA VARCHAR(255), + APP_ARGUMENT VARCHAR(255), + STANDARD_INPUT SMALLINT, + USER_FRIENDLY_DESC VARCHAR(255), + PRIMARY KEY(WF_TEMPLATE_ID,INPUT_KEY), + FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE +); + +CREATE TABLE WORKFLOW_OUTPUT +( + WF_TEMPLATE_ID VARCHAR(255), + OUTPUT_KEY VARCHAR(255), + OUTPUT_VALUE LONGTEXT, + DATA_TYPE VARCHAR(255), + PRIMARY KEY(WF_TEMPLATE_ID,OUTPUT_KEY), + FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE +); + +CREATE TABLE USER_RESOURCE_PROFILE ( + USER_ID varchar(255) NOT NULL, + CREATION_TIME datetime DEFAULT NULL, + CS_TOKEN varchar(255) DEFAULT NULL, + GATEWAY_ID varchar(255) DEFAULT NULL, + IDENTITY_SERVER_PWD_CRED_TOKEN varchar(255) DEFAULT NULL, + IDENTITY_SERVER_TENANT varchar(255) DEFAULT NULL, + UPDATE_TIME datetime DEFAULT NULL, + PRIMARY KEY (USER_ID,GATEWAY_ID) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE USER_STORAGE_PREFERENCE ( + STORAGE_RESOURCE_ID varchar(255) NOT NULL, + USER_ID varchar(255) NOT NULL, + RESOURCE_CS_TOKEN varchar(255) DEFAULT NULL, + FS_ROOT_LOCATION varchar(255) DEFAULT NULL, + GATEWAY_ID varchar(255) DEFAULT NULL, + LOGIN_USERNAME varchar(255) DEFAULT NULL, + PRIMARY KEY (STORAGE_RESOURCE_ID,USER_ID,GATEWAY_ID) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE USER_COMPUTE_RESOURCE_PREFERENCE ( + RESOURCE_ID varchar(255) NOT NULL, + USER_ID varchar(255) NOT NULL, + PREFERED_BATCH_QUEUE varchar(255) DEFAULT NULL, + RESOURCE_CS_TOKEN varchar(255) DEFAULT NULL, + GATEWAY_ID varchar(255) DEFAULT NULL, + LOGIN_USERNAME varchar(255) DEFAULT NULL, + ALLOCATION_PROJECT_NUMBER varchar(255) DEFAULT NULL, + QUALITY_OF_SERVICE varchar(255) DEFAULT NULL, + RESERVATION varchar(255) DEFAULT NULL, + RESERVATION_END_TIME datetime DEFAULT NULL, + RESERVATION_START_TIME datetime DEFAULT NULL, + SCRATCH_LOCATION varchar(255) NOT NULL DEFAULT NULL, + VALIDATED TINYINT(1) DEFAULT 0, + PRIMARY KEY (RESOURCE_ID,USER_ID,GATEWAY_ID) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE CONFIGURATION +( + CONFIG_KEY VARCHAR(255), + CONFIG_VAL VARCHAR(255), + PRIMARY KEY(CONFIG_KEY, CONFIG_VAL) +); + +INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL) VALUES('app_catalog_version', '0.16'); + diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/GatewayProfileRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/GatewayProfileRepositoryTest.java new file mode 100644 index 0000000000..5eec2e0781 --- /dev/null +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/GatewayProfileRepositoryTest.java @@ -0,0 +1,69 @@ +package org.apache.airavata.registry.core.repositories; + +import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile; +import org.apache.airavata.registry.core.repositories.appcatalog.GwyResourceProfileRepository; +import org.apache.airavata.registry.core.repositories.util.Initialize; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public class GatewayProfileRepositoryTest { + + private static Initialize initialize; + private GwyResourceProfileRepository gwyResourceProfileRepository; + private static final Logger logger = LoggerFactory.getLogger(GatewayProfileRepositoryTest.class); + + @Before + public void setUp() { + try { + initialize = new Initialize("appcatalog-derby.sql"); + initialize.initializeDB(); + gwyResourceProfileRepository = new GwyResourceProfileRepository(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } + + @After + public void tearDown() throws Exception { + System.out.println("********** TEAR DOWN ************"); + initialize.stopDerbyServer(); + } + + @Test + public void gatewayProfileRepositorytest() { + GatewayResourceProfile gf = new GatewayResourceProfile(); + gf.setGatewayID("testGateway"); + gf.setCredentialStoreToken("testCredential"); + gf.setIdentityServerPwdCredToken("pwdCredential"); + gf.setIdentityServerTenant("testTenant"); + + GatewayResourceProfile gf1 = new GatewayResourceProfile(); + gf1.setGatewayID("testGateway1"); + gf1.setCredentialStoreToken("testCredential"); + gf1.setIdentityServerPwdCredToken("pwdCredential"); + gf1.setIdentityServerTenant("testTenant"); + + String gwId = gwyResourceProfileRepository.addGatewayResourceProfile(gf); + GatewayResourceProfile retrievedProfile = null; + if (gwyResourceProfileRepository.isExists(gwId)){ + retrievedProfile = gwyResourceProfileRepository.getGatewayProfile(gwId); + System.out.println("************ gateway id ************** :" + retrievedProfile.getGatewayID()); + assertTrue("Retrieved gateway id matched", retrievedProfile.getGatewayID().equals("testGateway")); + assertTrue(retrievedProfile.getCredentialStoreToken().equals("testCredential")); + assertTrue(retrievedProfile.getIdentityServerPwdCredToken().equals("pwdCredential")); + assertTrue(retrievedProfile.getIdentityServerTenant().equals("testTenant")); + } + + gwyResourceProfileRepository.addGatewayResourceProfile(gf1); + List<GatewayResourceProfile> getGatewayResourceList = gwyResourceProfileRepository.getAllGatewayProfiles(); + assertTrue(getGatewayResourceList.size() == 2); + } + +} diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/util/Initialize.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/util/Initialize.java new file mode 100644 index 0000000000..8581cb7ef4 --- /dev/null +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/util/Initialize.java @@ -0,0 +1,318 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.airavata.registry.core.repositories.util; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.utils.ServerSettings; +import org.apache.derby.drda.NetworkServerControl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.InetAddress; +import java.net.URI; +import java.sql.*; +import java.util.StringTokenizer; + +public class Initialize { + private static final Logger logger = LoggerFactory.getLogger(Initialize.class); + public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer"; + public String scriptName = "appcatalog-derby.sql"; + private NetworkServerControl server; + private static final String delimiter = ";"; + public static final String COMPUTE_RESOURCE_TABLE = "COMPUTE_RESOURCE"; + private String jdbcUrl = null; + private String jdbcDriver = null; + private String jdbcUser = null; + private String jdbcPassword = null; + + public Initialize(String scriptName) { + this.scriptName = scriptName; + } + + public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) { + if (suffix.length() > buffer.length()) { + return false; + } + // this loop is done on purpose to avoid memory allocation performance + // problems on various JDKs + // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and + // implementation is ok though does allocation/copying + // StringBuffer.toString().endsWith() does massive memory + // allocation/copying on JDK 1.5 + // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169 + int endIndex = suffix.length() - 1; + int bufferIndex = buffer.length() - 1; + while (endIndex >= 0) { + if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) { + return false; + } + bufferIndex--; + endIndex--; + } + return true; + } + + private static boolean isServerStarted(NetworkServerControl server, int ntries) + { + for (int i = 1; i <= ntries; i ++) + { + try { + Thread.sleep(500); + server.ping(); + return true; + } + catch (Exception e) { + if (i == ntries) + return false; + } + } + return false; + } + + public void initializeDB() { + + try{ + jdbcDriver = ServerSettings.getSetting("appcatalog.jdbc.driver"); + jdbcUrl = ServerSettings.getSetting("appcatalog.jdbc.url"); + jdbcUser = ServerSettings.getSetting("appcatalog.jdbc.user"); + jdbcPassword = ServerSettings.getSetting("appcatalog.jdbc.password"); + jdbcUrl = jdbcUrl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword; + } catch (ApplicationSettingsException e) { + logger.error("Unable to read properties", e); + } + + startDerbyInServerMode(); + if(!isServerStarted(server, 20)){ + throw new RuntimeException("Derby server cound not started within five seconds..."); + } +// startDerbyInEmbeddedMode(); + + Connection conn = null; + try { + Class.forName(jdbcDriver).newInstance(); + conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword); + if (!isDatabaseStructureCreated(COMPUTE_RESOURCE_TABLE, conn)) { + executeSQLScript(conn); + logger.info("New Database created for App Catalog !!!"); + } else { + logger.debug("Database already created for App Catalog!"); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new RuntimeException("Database failure", e); + } finally { + try { + if (conn != null){ + if (!conn.getAutoCommit()) { + conn.commit(); + } + conn.close(); + } + } catch (SQLException e) { + logger.error(e.getMessage(), e); + } + } + } + + public static boolean isDatabaseStructureCreated(String tableName, Connection conn) { + try { + System.out.println("Running a query to test the database tables existence."); + // check whether the tables are already created with a query + Statement statement = null; + try { + statement = conn.createStatement(); + ResultSet rs = statement.executeQuery("select * from " + tableName); + if (rs != null) { + rs.close(); + } + } finally { + try { + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + return false; + } + } + } catch (SQLException e) { + return false; + } + + return true; + } + + private void executeSQLScript(Connection conn) throws Exception { + StringBuffer sql = new StringBuffer(); + BufferedReader reader = null; + try{ + + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(scriptName); + reader = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.startsWith("//")) { + continue; + } + if (line.startsWith("--")) { + continue; + } + StringTokenizer st = new StringTokenizer(line); + if (st.hasMoreTokens()) { + String token = st.nextToken(); + if ("REM".equalsIgnoreCase(token)) { + continue; + } + } + sql.append(" ").append(line); + + // SQL defines "--" as a comment to EOL + // and in Oracle it may contain a hint + // so we cannot just remove it, instead we must end it + if (line.indexOf("--") >= 0) { + sql.append("\n"); + } + if ((checkStringBufferEndsWith(sql, delimiter))) { + executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn); + sql.replace(0, sql.length(), ""); + } + } + // Catch any statements not followed by ; + if (sql.length() > 0) { + executeSQL(sql.toString(), conn); + } + }catch (IOException e){ + logger.error("Error occurred while executing SQL script for creating Airavata database", e); + throw new Exception("Error occurred while executing SQL script for creating Airavata database", e); + }finally { + if (reader != null) { + reader.close(); + } + + } + + } + + private static void executeSQL(String sql, Connection conn) throws Exception { + // Check and ignore empty statements + if ("".equals(sql.trim())) { + return; + } + + Statement statement = null; + try { + logger.debug("SQL : " + sql); + + boolean ret; + int updateCount = 0, updateCountTotal = 0; + statement = conn.createStatement(); + ret = statement.execute(sql); + updateCount = statement.getUpdateCount(); + do { + if (!ret) { + if (updateCount != -1) { + updateCountTotal += updateCount; + } + } + ret = statement.getMoreResults(); + if (ret) { + updateCount = statement.getUpdateCount(); + } + } while (ret); + + logger.debug(sql + " : " + updateCountTotal + " rows affected"); + + SQLWarning warning = conn.getWarnings(); + while (warning != null) { + logger.warn(warning + " sql warning"); + warning = warning.getNextWarning(); + } + conn.clearWarnings(); + } catch (SQLException e) { + if (e.getSQLState().equals("X0Y32")) { + // eliminating the table already exception for the derby + // database + logger.info("Table Already Exists", e); + } else { + throw new Exception("Error occurred while executing : " + sql, e); + } + } finally { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + logger.error("Error occurred while closing result set.", e); + } + } + } + } + + private void startDerbyInServerMode() { + try { + System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true"); + server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"), + 20000, + jdbcUser, jdbcPassword); + java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true); + server.start(consoleWriter); + } catch (IOException e) { + logger.error("Unable to start Apache derby in the server mode! Check whether " + + "specified port is available"); + } catch (Exception e) { + logger.error("Unable to start Apache derby in the server mode! Check whether " + + "specified port is available"); + } + + } + + public static int getPort(String jdbcURL){ + try{ + String cleanURI = jdbcURL.substring(5); + URI uri = URI.create(cleanURI); + return uri.getPort(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return -1; + } + } + + private void startDerbyInEmbeddedMode(){ + try { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); + DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close(); + } catch (ClassNotFoundException e) { + logger.error(e.getMessage(), e); + } catch (SQLException e) { + logger.error(e.getMessage(), e); + } + } + + public void stopDerbyServer() { + try { + server.shutdown(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } +} diff --git a/modules/registry/registry-server/registry-api-service/pom.xml b/modules/registry/registry-server/registry-api-service/pom.xml index 8a12c8e2f0..43bb7977b6 100644 --- a/modules/registry/registry-server/registry-api-service/pom.xml +++ b/modules/registry/registry-server/registry-api-service/pom.xml @@ -70,5 +70,10 @@ <artifactId>libthrift</artifactId> <version>${thrift.version}</version> </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>registry-refactoring</artifactId> + <version>0.17-SNAPSHOT</version> + </dependency> </dependencies> </project> \ No newline at end of file diff --git a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java index d90c20b3be..011cee0e4e 100644 --- a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java +++ b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java @@ -62,6 +62,7 @@ import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; import org.apache.airavata.registry.core.experiment.catalog.resources.AbstractExpCatResource; +import org.apache.airavata.registry.core.repositories.appcatalog.GwyResourceProfileRepository; import org.apache.airavata.registry.cpi.*; import org.apache.airavata.registry.cpi.utils.Constants; import org.apache.thrift.TException; @@ -1596,12 +1597,11 @@ public GatewayResourceProfile getGatewayResourceProfile(String gatewayID) throws logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - GatewayResourceProfile gatewayResourceProfile = gatewayProfile.getGatewayProfile(gatewayID); + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + GatewayResourceProfile gatewayResourceProfile = gwyResourceProfileRepository.getGatewayProfile(gatewayID); logger.debug("Airavata retrieved gateway profile with gateway id : " + gatewayID); return gatewayResourceProfile; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error(gatewayID, "Error while retrieving gateway resource profile...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while retrieving gateway resource profile. More info : " + e.getMessage()); @@ -1623,12 +1623,11 @@ public boolean deleteGatewayResourceProfile(String gatewayID) throws RegistrySer logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - gatewayProfile.removeGatewayResourceProfile(gatewayID); + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + gwyResourceProfileRepository.delete(gatewayID); logger.debug("Airavata deleted gateway profile with gateway id : " + gatewayID); return true; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error(gatewayID, "Error while removing gateway resource profile...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while removing gateway resource profile. More info : " + e.getMessage()); @@ -1726,10 +1725,9 @@ public StoragePreference getGatewayStoragePreference(String gatewayID, String st logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - return gatewayProfile.getGatewayProfile(gatewayID).getComputeResourcePreferences(); - } catch (AppCatalogException e) { + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + return gwyResourceProfileRepository.getGatewayProfile(gatewayID).getComputeResourcePreferences(); + } catch (Exception e) { logger.error(gatewayID, "Error while reading gateway compute resource preferences...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while reading gateway compute resource preferences. More info : " + e.getMessage()); @@ -1751,10 +1749,9 @@ public StoragePreference getGatewayStoragePreference(String gatewayID, String st logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - return gatewayProfile.getGatewayProfile(gatewayID).getStoragePreferences(); - } catch (AppCatalogException e) { + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + return gwyResourceProfileRepository.getGatewayProfile(gatewayID).getStoragePreferences(); + } catch (Exception e) { logger.error(gatewayID, "Error while reading gateway data storage preferences...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while reading gateway data storage preferences. More info : " + e.getMessage()); @@ -1771,10 +1768,9 @@ public StoragePreference getGatewayStoragePreference(String gatewayID, String st @Override public List<GatewayResourceProfile> getAllGatewayResourceProfiles() throws RegistryServiceException, TException { try { - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - return gatewayProfile.getAllGatewayProfiles(); - } catch (AppCatalogException e) { + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + return gwyResourceProfileRepository.getAllGatewayProfiles(); + } catch (Exception e) { RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while reading retrieving all gateway profiles. More info : " + e.getMessage()); throw exception; @@ -1796,10 +1792,10 @@ public boolean deleteGatewayComputeResourcePreference(String gatewayID, String c logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - return gatewayProfile.removeComputeResourcePreferenceFromGateway(gatewayID, computeResourceId); - } catch (AppCatalogException e) { + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + + return gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayID, computeResourceId); + } catch (Exception e) { logger.error(gatewayID, "Error while reading gateway compute resource preference...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while updating gateway compute resource preference. More info : " + e.getMessage()); @@ -1822,10 +1818,10 @@ public boolean deleteGatewayStoragePreference(String gatewayID, String storageId logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - return gatewayProfile.removeDataStoragePreferenceFromGateway(gatewayID, storageId); - } catch (AppCatalogException e) { + + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + return gwyResourceProfileRepository.removeDataStoragePreferenceFromGateway(gatewayID, storageId); + } catch (Exception e) { logger.error(gatewayID, "Error while reading gateway data storage preference...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while updating gateway data storage preference. More info : " + e.getMessage()); @@ -2055,9 +2051,8 @@ public boolean updateGatewayStoragePreference(String gatewayID, String storageId logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID); + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID); List<StoragePreference> dataStoragePreferences = profile.getStoragePreferences(); StoragePreference preferenceToRemove = null; for (StoragePreference preference : dataStoragePreferences) { @@ -2071,10 +2066,10 @@ public boolean updateGatewayStoragePreference(String gatewayID, String storageId preferenceToRemove); } profile.getStoragePreferences().add(storagePreference); - gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); + gwyResourceProfileRepository.updateGatewayResourceProfile(profile); logger.debug("Airavata updated storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageId ); return true; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error(gatewayID, "Error while reading gateway data storage preference...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while updating gateway data storage preference. More info : " + e.getMessage()); @@ -2098,9 +2093,8 @@ public boolean updateGatewayComputeResourcePreference(String gatewayID, String c logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID); + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID); List<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences(); ComputeResourcePreference preferenceToRemove = null; for (ComputeResourcePreference preference : computeResourcePreferences) { @@ -2114,10 +2108,10 @@ public boolean updateGatewayComputeResourcePreference(String gatewayID, String c preferenceToRemove); } profile.getComputeResourcePreferences().add(computeResourcePreference); - gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); + gwyResourceProfileRepository.updateGatewayResourceProfile(profile); logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId ); return true; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error(gatewayID, "Error while reading gateway compute resource preference...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while updating gateway compute resource preference. More info : " + e.getMessage()); @@ -2142,19 +2136,19 @@ public boolean addGatewayStoragePreference(String gatewayID, String storageResou logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)){ + + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + if (!(gwyResourceProfileRepository.isExists(gatewayID))){ throw new RegistryServiceException("Gateway resource profile '"+gatewayID+"' does not exist!!!"); } - GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID); -// gatewayProfile.removeGatewayResourceProfile(gatewayID); + GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID); + dataStoragePreference.setStorageResourceId(storageResourceId); profile.addToStoragePreferences(dataStoragePreference); - gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); + gwyResourceProfileRepository.updateGatewayResourceProfile(profile); logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageResourceId ); return true; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error(gatewayID, "Error while registering gateway resource profile preference...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while registering gateway resource profile preference. More info : " + e.getMessage()); @@ -2179,18 +2173,16 @@ public boolean addGatewayComputeResourcePreference(String gatewayID, String comp logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)){ + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + if (!(gwyResourceProfileRepository.isExists(gatewayID))){ throw new RegistryServiceException("Gateway resource profile '"+gatewayID+"' does not exist!!!"); } - GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID); -// gatewayProfile.removeGatewayResourceProfile(gatewayID); + GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID); profile.addToComputeResourcePreferences(computeResourcePreference); - gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); + gwyResourceProfileRepository.updateGatewayResourceProfile(profile); logger.debug("Airavata added gateway compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId ); return true; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error(gatewayID, "Error while registering gateway resource profile preference...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while registering gateway resource profile preference. More info : " + e.getMessage()); @@ -2213,12 +2205,11 @@ public boolean updateGatewayResourceProfile(String gatewayID, GatewayResourcePro logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - gatewayProfile.updateGatewayResourceProfile(gatewayID, gatewayResourceProfile); + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + gwyResourceProfileRepository.updateGatewayResourceProfile(gatewayResourceProfile); logger.debug("Airavata updated gateway profile with gateway id : " + gatewayID); return true; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error(gatewayID, "Error while updating gateway resource profile...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while updating gateway resource profile. More info : " + e.getMessage()); @@ -2248,12 +2239,11 @@ public String registerGatewayResourceProfile(GatewayResourceProfile gatewayResou logger.error("Gateway does not exist.Please provide a valid gateway id..."); throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id..."); } - appCatalog = RegistryFactory.getAppCatalog(); - GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - String resourceProfile = gatewayProfile.addGatewayResourceProfile(gatewayResourceProfile); + GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository(); + String resourceProfile = gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile); logger.debug("Airavata registered gateway profile with gateway id : " + gatewayResourceProfile.getGatewayID()); return resourceProfile; - } catch (AppCatalogException e) { + } catch (Exception e) { logger.error("Error while registering gateway resource profile...", e); RegistryServiceException exception = new RegistryServiceException(); exception.setMessage("Error while registering gateway resource profile. More info : " + e.getMessage()); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Refactoring App Catalog implementation > -------------------------------------- > > Key: AIRAVATA-2619 > URL: https://issues.apache.org/jira/browse/AIRAVATA-2619 > Project: Airavata > Issue Type: Sub-task > Reporter: Sachin Kariyattin > Assignee: Sachin Kariyattin > > The app catalog module contains the following Impl classes. > {quote}ApplicationDeploymentImpl > ApplicationInterfaceImpl > ComputeResourceImpl > GwyResourceProfileImpl > StorageResourceImpl > UsrResourceProfileImpl{quote} > This task involves creating a repository class for app catalog and include > all the methods from the Impl classes mentioned above. As a modular approach > is being followed, to start of, only methods GwyResourceProfileImpl will be > considered. So the RegistryServiceHandler methods only with respect to > GwyResourceProfileImpl will be modified. Subsequently all methods related to > app catalog will be refactored. -- This message was sent by Atlassian JIRA (v6.4.14#64029)