This is an automated email from the ASF dual-hosted git repository.
lahirujayathilake pushed a commit to branch airavata-aws
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/airavata-aws by this push:
new 888286071c register SlurmGroupComputeResourcePrefEntity and populate
resourceType & Slurm-specific preferences in repos
888286071c is described below
commit 888286071cb7966566e7545d11f95e7f21f6deb8
Author: lahiruj <[email protected]>
AuthorDate: Tue Jun 24 17:16:30 2025 -0400
register SlurmGroupComputeResourcePrefEntity and populate resourceType &
Slurm-specific preferences in repos
---
.../SlurmGroupComputeResourcePrefEntity.java | 17 ++---
.../appcatalog/GroupResourceProfileRepository.java | 49 ++++++++++----
.../appcatalog/GrpComputePrefRepository.java | 74 ++++++++++++++++------
.../src/main/resources/META-INF/persistence.xml | 1 +
4 files changed, 98 insertions(+), 43 deletions(-)
diff --git
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/SlurmGroupComputeResourcePrefEntity.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/SlurmGroupComputeResourcePrefEntity.java
index 9d6e1149e4..c7e1f5cfb7 100644
---
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/SlurmGroupComputeResourcePrefEntity.java
+++
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/SlurmGroupComputeResourcePrefEntity.java
@@ -25,6 +25,8 @@ import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
+import jakarta.persistence.PrimaryKeyJoinColumn;
+import jakarta.persistence.PrimaryKeyJoinColumns;
import jakarta.persistence.Table;
import java.util.List;
@@ -35,14 +37,15 @@ import java.util.List;
@Entity
@DiscriminatorValue("SLURM")
@Table(name = "SLURM_GROUP_COMPUTE_RESOURCE_PREFERENCE")
+@PrimaryKeyJoinColumns({
+ @PrimaryKeyJoinColumn(name = "RESOURCE_ID", referencedColumnName =
"RESOURCE_ID"),
+ @PrimaryKeyJoinColumn(name = "GROUP_RESOURCE_PROFILE_ID",
referencedColumnName = "GROUP_RESOURCE_PROFILE_ID")
+})
public class SlurmGroupComputeResourcePrefEntity extends
GroupComputeResourcePrefEntity {
@Column(name = "ALLOCATION_PROJECT_NUMBER")
private String allocationProjectNumber;
- @Column(name = "OVERRIDE_BY_AIRAVATA")
- private short overridebyAiravata;
-
@Column(name = "PREFERED_BATCH_QUEUE")
private String preferredBatchQueue;
@@ -88,14 +91,6 @@ public class SlurmGroupComputeResourcePrefEntity extends
GroupComputeResourcePre
this.allocationProjectNumber = allocationProjectNumber;
}
- public short getOverridebyAiravata() {
- return overridebyAiravata;
- }
-
- public void setOverridebyAiravata(short overridebyAiravata) {
- this.overridebyAiravata = overridebyAiravata;
- }
-
public String getPreferredBatchQueue() {
return preferredBatchQueue;
}
diff --git
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
index 5ac6c0a0e4..6275bb7703 100644
---
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
+++
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
@@ -34,6 +34,7 @@ import
org.apache.airavata.registry.core.entities.appcatalog.SlurmGroupComputeRe
import org.apache.airavata.registry.core.utils.DBConstants;
import org.apache.airavata.registry.core.utils.QueryConstants;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -148,15 +149,28 @@ public class GroupResourceProfileRepository
return isExists(groupResourceProfileId);
}
- public List<GroupResourceProfile> getAllGroupResourceProfiles(
- String gatewayId, List<String> accessibleGroupResProfileIds) {
- Map<String, Object> queryParameters = new HashMap<>();
- queryParameters.put(DBConstants.GroupResourceProfile.GATEWAY_ID,
gatewayId);
-
+ public List<GroupResourceProfile> getAllGroupResourceProfiles(String
gatewayId, List<String> accessibleGroupResProfileIds) {
if (accessibleGroupResProfileIds != null &&
!accessibleGroupResProfileIds.isEmpty()) {
- queryParameters.put(
-
DBConstants.GroupResourceProfile.ACCESSIBLE_GROUP_RESOURCE_IDS,
accessibleGroupResProfileIds);
- return
select(QueryConstants.FIND_ACCESSIBLE_GROUP_RESOURCE_PROFILES, -1, 0,
queryParameters);
+ List<GroupResourceProfile> profiles =
select(QueryConstants.FIND_ACCESSIBLE_GROUP_RESOURCE_PROFILES, -1, 0,
+ Map.of(DBConstants.GroupResourceProfile.GATEWAY_ID,
gatewayId, DBConstants.GroupResourceProfile.ACCESSIBLE_GROUP_RESOURCE_IDS,
accessibleGroupResProfileIds));
+
+ GrpComputePrefRepository prefRepo = new GrpComputePrefRepository();
+ for (GroupResourceProfile profile : profiles) {
+ List<GroupComputeResourcePreference> decoratedPrefs = new
ArrayList<>();
+
+ for (GroupComputeResourcePreference rawPref :
profile.getComputePreferences()) {
+ GroupComputeResourcePrefPK pk = new
GroupComputeResourcePrefPK();
+ pk.setComputeResourceId(rawPref.getComputeResourceId());
+
pk.setGroupResourceProfileId(rawPref.getGroupResourceProfileId());
+
+ GroupComputeResourcePreference fullPref = prefRepo.get(pk);
+ decoratedPrefs.add(fullPref);
+ }
+
+ profile.setComputePreferences(decoratedPrefs);
+ }
+ return profiles;
+
} else {
return Collections.emptyList();
}
@@ -204,12 +218,21 @@ public class GroupResourceProfileRepository
}
public List<GroupComputeResourcePreference>
getAllGroupComputeResourcePreferences(String groupResourceProfileId) {
- Map<String, Object> queryParameters = new HashMap<>();
-
queryParameters.put(DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID,
groupResourceProfileId);
- List<GroupComputeResourcePreference>
groupComputeResourcePreferenceList = (new GrpComputePrefRepository()
- .select(QueryConstants.FIND_ALL_GROUP_COMPUTE_PREFERENCES, -1,
0, queryParameters));
+ List<GroupComputeResourcePreference> rawPrefs = (new
GrpComputePrefRepository()
+ .select(QueryConstants.FIND_ALL_GROUP_COMPUTE_PREFERENCES, -1,
0, Map.of(DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID,
groupResourceProfileId)));
+
+ GrpComputePrefRepository prefRepo = new GrpComputePrefRepository();
+ List<GroupComputeResourcePreference> decorated = new ArrayList<>();
+ for (GroupComputeResourcePreference raw : rawPrefs) {
+ GroupComputeResourcePrefPK pk = new GroupComputeResourcePrefPK();
+ pk.setComputeResourceId(raw.getComputeResourceId());
+ pk.setGroupResourceProfileId(raw.getGroupResourceProfileId());
+ // this .get(...) will load the entity, detect SLURM, set
resourceType, and populate the specificPreferences union
+ GroupComputeResourcePreference full = prefRepo.get(pk);
+ decorated.add(full);
+ }
- return groupComputeResourcePreferenceList;
+ return decorated;
}
public List<BatchQueueResourcePolicy>
getAllGroupBatchQueueResourcePolicies(String groupResourceProfileId) {
diff --git
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
index 86ee24c29c..41ec472ed2 100644
---
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
+++
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
@@ -1,36 +1,72 @@
/**
-*
-* 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.
-*/
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.model.appcatalog.groupresourceprofile.EnvironmentSpecificPreferences;
import
org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.ResourceType;
+import
org.apache.airavata.model.appcatalog.groupresourceprofile.SlurmComputeResourcePreference;
import
org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefEntity;
import
org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefPK;
+import
org.apache.airavata.registry.core.entities.appcatalog.SlurmGroupComputeResourcePrefEntity;
/**
* Created by skariyat on 2/10/18.
*/
public class GrpComputePrefRepository
extends AppCatAbstractRepository<
- GroupComputeResourcePreference,
GroupComputeResourcePrefEntity, GroupComputeResourcePrefPK> {
+ GroupComputeResourcePreference, GroupComputeResourcePrefEntity,
GroupComputeResourcePrefPK> {
public GrpComputePrefRepository() {
super(GroupComputeResourcePreference.class,
GroupComputeResourcePrefEntity.class);
}
+
+ @Override
+ public GroupComputeResourcePreference get(GroupComputeResourcePrefPK
groupComputeResourcePrefPK) {
+ GroupComputeResourcePreference pref =
super.get(groupComputeResourcePrefPK);
+ if (pref == null) {
+ return null;
+ }
+
+ GroupComputeResourcePrefEntity ent = execute(em ->
em.find(GroupComputeResourcePrefEntity.class, groupComputeResourcePrefPK));
+ if (ent == null) {
+ return pref;
+ }
+
+ if (ent instanceof SlurmGroupComputeResourcePrefEntity sl) {
+ pref.setResourceType(ResourceType.SLURM);
+
+ SlurmComputeResourcePreference scrp = new
SlurmComputeResourcePreference();
+ scrp.setAllocationProjectNumber(sl.getAllocationProjectNumber());
+ scrp.setPreferredBatchQueue(sl.getPreferredBatchQueue());
+ scrp.setQualityOfService(sl.getQualityOfService());
+ scrp.setScratchLocation(sl.getScratchLocation());
+ scrp.setUsageReportingGatewayId(sl.getUsageReportingGatewayId());
+ scrp.setSshAccountProvisioner(sl.getSshAccountProvisioner());
+
scrp.setSshAccountProvisionerAdditionalInfo(sl.getSshAccountProvisionerAdditionalInfo());
+ // TODO - check whether the groupSSHAccountProvisionerConfigs and
reservations are needed
+
+ EnvironmentSpecificPreferences esp = new
EnvironmentSpecificPreferences();
+ esp.setSlurm(scrp);
+ pref.setSpecificPreferences(esp);
+ }
+
+ return pref;
+ }
}
diff --git
a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
index f3b4ef035c..bb5b7af886 100644
--- a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
+++ b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
@@ -66,6 +66,7 @@
<class>org.apache.airavata.registry.core.entities.appcatalog.BatchQueueResourcePolicyEntity</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePolicyEntity</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefEntity</class>
+
<class>org.apache.airavata.registry.core.entities.appcatalog.SlurmGroupComputeResourcePrefEntity</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.GroupSSHAccountProvisionerConfig</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.GroupResourceProfileEntity</class>
<class>org.apache.airavata.registry.core.entities.appcatalog.ModuleLoadCmdEntity</class>