You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2025/11/18 20:25:36 UTC
(airavata) 01/01: compute resource repository changes to handle SLURM and AWS updates
This is an automated email from the ASF dual-hosted git repository.
lahirujayathilake pushed a commit to branch group-resource-profile-changes
in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 39a5f402b437c23f2887774455048e0a5475ea10
Author: lahiruj <la...@gmail.com>
AuthorDate: Tue Nov 18 15:25:26 2025 -0500
compute resource repository changes to handle SLURM and AWS updates
---
.../appcatalog/GroupResourceProfileRepository.java | 40 ++++++++++++++++++++++
.../registry/core/utils/CustomBeanFactory.java | 24 ++++++++++---
2 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java b/airavata-api/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
index db6e0edb4d..b2521277f2 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.AwsComputeResourcePreference;
import org.apache.airavata.model.appcatalog.groupresourceprofile.BatchQueueResourcePolicy;
import org.apache.airavata.model.appcatalog.groupresourceprofile.ComputeResourcePolicy;
import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference;
@@ -33,6 +34,7 @@ import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupResourcePr
import org.apache.airavata.model.appcatalog.groupresourceprofile.ResourceType;
import org.apache.airavata.model.appcatalog.groupresourceprofile.SlurmComputeResourcePreference;
import org.apache.airavata.model.commons.airavata_commonsConstants;
+import org.apache.airavata.registry.core.entities.appcatalog.AWSGroupComputeResourcePrefEntity;
import org.apache.airavata.registry.core.entities.appcatalog.ComputeResourceReservationEntity;
import org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefEntity;
import org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefPK;
@@ -115,6 +117,7 @@ public class GroupResourceProfileRepository
updatedGroupResourceProfile.setUpdatedTime(System.currentTimeMillis());
updateChildren(updatedGroupResourceProfile, updatedGroupResourceProfile.getGroupResourceProfileId());
GroupResourceProfileEntity groupResourceProfileEntity = mapToEntity(updatedGroupResourceProfile);
+ patchComputePrefEntities(groupResourceProfileEntity, updatedGroupResourceProfile);
updateChildrenEntities(groupResourceProfileEntity);
GroupResourceProfile groupResourceProfile = mergeEntity(groupResourceProfileEntity);
return groupResourceProfile.getGroupResourceProfileId();
@@ -138,6 +141,43 @@ public class GroupResourceProfileRepository
}
}
+ private void patchComputePrefEntities(GroupResourceProfileEntity destEntity, GroupResourceProfile sourceModel) {
+ if (destEntity.getComputePreferences() == null || sourceModel.getComputePreferences() == null) {
+ return;
+ }
+ Map<String, GroupComputeResourcePreference> sourcePrefs = new HashMap<>();
+ for (GroupComputeResourcePreference pref : sourceModel.getComputePreferences()) {
+ sourcePrefs.put(pref.getComputeResourceId(), pref);
+ }
+
+ for (GroupComputeResourcePrefEntity prefEntity : destEntity.getComputePreferences()) {
+ GroupComputeResourcePreference sourcePref = sourcePrefs.get(prefEntity.getComputeResourceId());
+ if (sourcePref == null || !sourcePref.isSetSpecificPreferences()) {
+ continue;
+ }
+ if (prefEntity instanceof SlurmGroupComputeResourcePrefEntity slurmEntity) {
+ if (sourcePref.getSpecificPreferences().isSetSlurm()) {
+ SlurmComputeResourcePreference slurm =
+ sourcePref.getSpecificPreferences().getSlurm();
+ slurmEntity.setAllocationProjectNumber(slurm.getAllocationProjectNumber());
+ slurmEntity.setPreferredBatchQueue(slurm.getPreferredBatchQueue());
+ slurmEntity.setQualityOfService(slurm.getQualityOfService());
+ slurmEntity.setUsageReportingGatewayId(slurm.getUsageReportingGatewayId());
+ slurmEntity.setSshAccountProvisioner(slurm.getSshAccountProvisioner());
+ slurmEntity.setSshAccountProvisionerAdditionalInfo(slurm.getSshAccountProvisionerAdditionalInfo());
+ }
+ } else if (prefEntity instanceof AWSGroupComputeResourcePrefEntity awsEntity) {
+ if (sourcePref.getSpecificPreferences().isSetAws()) {
+ AwsComputeResourcePreference aws =
+ sourcePref.getSpecificPreferences().getAws();
+ awsEntity.setRegion(aws.getRegion());
+ awsEntity.setPreferredAmiId(aws.getPreferredAmiId());
+ awsEntity.setPreferredInstanceType(aws.getPreferredInstanceType());
+ }
+ }
+ }
+ }
+
public GroupResourceProfile getGroupResourceProfile(String groupResourceProfileId) {
GroupResourceProfile groupResourceProfile = get(groupResourceProfileId);
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/core/utils/CustomBeanFactory.java b/airavata-api/src/main/java/org/apache/airavata/registry/core/utils/CustomBeanFactory.java
index 985f2250e5..558fc30487 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/core/utils/CustomBeanFactory.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/core/utils/CustomBeanFactory.java
@@ -26,6 +26,11 @@ import com.github.dozermapper.core.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Map.Entry;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.ResourceType;
+import org.apache.airavata.registry.core.entities.appcatalog.AWSGroupComputeResourcePrefEntity;
+import org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefEntity;
+import org.apache.airavata.registry.core.entities.appcatalog.SlurmGroupComputeResourcePrefEntity;
import org.apache.thrift.TBase;
import org.apache.thrift.TFieldIdEnum;
import org.apache.thrift.meta_data.FieldMetaData;
@@ -40,8 +45,17 @@ public class CustomBeanFactory implements BeanFactory {
public Object createBean(Object source, Class<?> sourceClass, String targetBeanId, BeanContainer beanContainer) {
Object result;
Class<?> destClass = MappingUtils.loadClass(targetBeanId, beanContainer);
+ if (GroupComputeResourcePrefEntity.class.equals(destClass)
+ && source instanceof GroupComputeResourcePreference pref) {
+ ResourceType resourceType = pref.isSetResourceType() ? pref.getResourceType() : null;
+ if (resourceType == ResourceType.AWS) {
+ destClass = AWSGroupComputeResourcePrefEntity.class;
+ } else {
+ destClass = SlurmGroupComputeResourcePrefEntity.class;
+ }
+ }
if (logger.isDebugEnabled()) {
- logger.debug("Creating bean of type " + destClass.getSimpleName());
+ logger.debug("Creating bean of type {}", destClass.getSimpleName());
}
result = ReflectionUtils.newInstance(destClass);
if (result instanceof TBase) {
@@ -79,13 +93,15 @@ public class CustomBeanFactory implements BeanFactory {
Map<F, FieldMetaData> metaDataMap = (Map<F, FieldMetaData>) metaDataMapField.get(null);
for (Entry<F, FieldMetaData> metaDataEntry : metaDataMap.entrySet()) {
if (logger.isDebugEnabled()) {
- logger.debug("processing field " + metaDataEntry.getValue().fieldName);
+ logger.debug("processing field {}", metaDataEntry.getValue().fieldName);
}
Object fieldValue = instance.getFieldValue(metaDataEntry.getKey());
if (fieldValue != null) {
if (logger.isDebugEnabled()) {
- logger.debug("field " + metaDataEntry.getValue().fieldName + " has a default value ["
- + fieldValue + "], calling setter to force the field to be set");
+ logger.debug(
+ "field {} has a default value [{}], calling setter to force the field to be set",
+ metaDataEntry.getValue().fieldName,
+ fieldValue);
}
instance.setFieldValue(metaDataEntry.getKey(), fieldValue);
}