Search in sources :

Example 16 with ComputeResourcePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.

the class GwyResourceProfileImpl method getAllGatewayProfiles.

@Override
public List<GatewayResourceProfile> getAllGatewayProfiles() throws AppCatalogException {
    try {
        List<GatewayResourceProfile> gatewayResourceProfileList = new ArrayList<GatewayResourceProfile>();
        GatewayProfileResource profileResource = new GatewayProfileResource();
        List<AppCatalogResource> resourceList = profileResource.getAll();
        if (resourceList != null && !resourceList.isEmpty()) {
            for (AppCatalogResource resource : resourceList) {
                GatewayProfileResource gatewayProfileResource = (GatewayProfileResource) resource;
                List<ComputeResourcePreference> computeResourcePreferences = getAllComputeResourcePreferences(gatewayProfileResource.getGatewayID());
                List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayProfileResource.getGatewayID());
                GatewayResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getGatewayResourceProfile(gatewayProfileResource, computeResourcePreferences, dataStoragePreferences);
                gatewayResourceProfileList.add(gatewayResourceProfile);
            }
        }
        return gatewayResourceProfileList;
    } catch (Exception e) {
        logger.error("Error while retrieving gateway ids...", e);
        throw new AppCatalogException(e);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) ArrayList(java.util.ArrayList) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 17 with ComputeResourcePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.

the class GwyResourceProfileImpl method getGatewayProfile.

@Override
public GatewayResourceProfile getGatewayProfile(String gatewayId) throws AppCatalogException {
    try {
        GatewayProfileResource resource = new GatewayProfileResource();
        GatewayProfileResource gwresource = (GatewayProfileResource) resource.get(gatewayId);
        ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
        List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
        List<ComputeResourcePreference> computeResourcePreferences = AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
        List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayId);
        return AppCatalogThriftConversion.getGatewayResourceProfile(gwresource, computeResourcePreferences, dataStoragePreferences);
    } catch (Exception e) {
        logger.error("Error while retrieving gateway profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 18 with ComputeResourcePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.

the class GwyResourceProfileImpl method addGatewayResourceProfile.

@Override
public String addGatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile gatewayProfile) throws AppCatalogException {
    try {
        GatewayProfileResource profileResource = new GatewayProfileResource();
        if (!gatewayProfile.getGatewayID().equals("")) {
            profileResource.setGatewayID(gatewayProfile.getGatewayID());
        }
        if (gatewayProfile.getCredentialStoreToken() != null) {
            profileResource.setCredentialStoreToken(gatewayProfile.getCredentialStoreToken());
        }
        if (gatewayProfile.getIdentityServerTenant() != null) {
            profileResource.setIdentityServerTenant(gatewayProfile.getIdentityServerTenant());
        }
        if (gatewayProfile.getIdentityServerPwdCredToken() != null) {
            profileResource.setIdentityServerPwdCredToken(gatewayProfile.getIdentityServerPwdCredToken());
        }
        profileResource.setGatewayID(gatewayProfile.getGatewayID());
        profileResource.save();
        List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();
        if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()) {
            for (ComputeResourcePreference preference : computeResourcePreferences) {
                ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
                resource.setGatewayProfile(profileResource);
                resource.setResourceId(preference.getComputeResourceId());
                ComputeResourceResource computeHostResource = new ComputeResourceResource();
                resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
                resource.setGatewayId(profileResource.getGatewayID());
                resource.setOverrideByAiravata(preference.isOverridebyAiravata());
                resource.setLoginUserName(preference.getLoginUserName());
                resource.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
                resource.setUsageReportingGatewayId(preference.getUsageReportingGatewayId());
                if (preference.getPreferredJobSubmissionProtocol() != null) {
                    resource.setPreferredJobProtocol(preference.getPreferredJobSubmissionProtocol().toString());
                }
                if (preference.getPreferredDataMovementProtocol() != null) {
                    resource.setPreferedDMProtocol(preference.getPreferredDataMovementProtocol().toString());
                }
                resource.setBatchQueue(preference.getPreferredBatchQueue());
                resource.setProjectNumber(preference.getAllocationProjectNumber());
                resource.setScratchLocation(preference.getScratchLocation());
                resource.setQualityOfService(preference.getQualityOfService());
                resource.setReservation(preference.getReservation());
                if (preference.getReservationStartTime() > 0) {
                    resource.setReservationStartTime(AiravataUtils.getTime(preference.getReservationStartTime()));
                }
                if (preference.getReservationEndTime() > 0) {
                    resource.setReservationEndTime(AiravataUtils.getTime(preference.getReservationEndTime()));
                }
                resource.setSshAccountProvisioner(preference.getSshAccountProvisioner());
                if (preference.getSshAccountProvisionerConfig() != null && !preference.getSshAccountProvisionerConfig().isEmpty()) {
                    Map<String, String> sshAccountProvisionerConfigurationsCopy = new HashMap<>(preference.getSshAccountProvisionerConfig());
                    resource.setSshAccountProvisionerConfigurations(sshAccountProvisionerConfigurationsCopy);
                }
                resource.setSshAccountProvisionerAdditionalInfo(preference.getSshAccountProvisionerAdditionalInfo());
                resource.save();
            }
        }
        List<StoragePreference> dataStoragePreferences = gatewayProfile.getStoragePreferences();
        if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
            for (StoragePreference storagePreference : dataStoragePreferences) {
                StoragePreferenceResource resource = new StoragePreferenceResource();
                resource.setStorageResourceId(storagePreference.getStorageResourceId());
                resource.setGatewayId(profileResource.getGatewayID());
                resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
                resource.setLoginUserName(storagePreference.getLoginUserName());
                resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
                resource.setGatewayProfile(profileResource);
                resource.save();
            }
        }
        return profileResource.getGatewayID();
    } catch (Exception e) {
        logger.error("Error while saving gateway profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) HashMap(java.util.HashMap) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 19 with ComputeResourcePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.

the class OrchestratorUtils method getScratchLocation.

public static String getScratchLocation(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    try {
        ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
        ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
        if (processModel.isUseUserCRPref()) {
            UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
            UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
            if (isValid(userComputeResourcePreference.getScratchLocation())) {
                return userComputeResourcePreference.getScratchLocation();
            } else if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
                logger.warn("User computer resource preference doesn't have valid scratch location, using computer " + "resource scheduling scratch location " + processResourceSchedule.getOverrideScratchLocation());
                return processResourceSchedule.getOverrideScratchLocation();
            } else if (isValid(computeResourcePreference.getScratchLocation())) {
                logger.warn("Either User computer resource preference or computer resource scheduling doesn't have " + "valid scratch location, using  gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
                return computeResourcePreference.getScratchLocation();
            } else {
                throw new AiravataException("Scratch location is not found");
            }
        } else {
            if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
                return processResourceSchedule.getOverrideScratchLocation();
            } else if (isValid(computeResourcePreference.getScratchLocation())) {
                logger.warn("Process compute resource scheduling doesn't have valid scratch location, " + "using  gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
                return computeResourcePreference.getScratchLocation();
            } else {
                throw new AiravataException("Scratch location is not found");
            }
        }
    } catch (AppCatalogException e) {
        logger.error("Error occurred while initializing app catalog to fetch scratch location", e);
        throw new RegistryException("Error occurred while initializing app catalog to fetch scratch location", e);
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 20 with ComputeResourcePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.

the class OrchestratorUtils method getPrefferredDataMovementInterface.

public static DataMovementInterface getPrefferredDataMovementInterface(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException {
    try {
        String resourceHostId = processModel.getComputeResourceId();
        ComputeResourcePreference resourcePreference = getComputeResourcePreference(context, processModel, gatewayId);
        DataMovementProtocol preferredDataMovementProtocol = resourcePreference.getPreferredDataMovementProtocol();
        ComputeResourceDescription resourceDescription = context.getRegistry().getAppCatalog().getComputeResource().getComputeResource(resourceHostId);
        List<DataMovementInterface> dataMovementInterfaces = resourceDescription.getDataMovementInterfaces();
        if (dataMovementInterfaces != null && !dataMovementInterfaces.isEmpty()) {
            for (DataMovementInterface dataMovementInterface : dataMovementInterfaces) {
                if (preferredDataMovementProtocol != null) {
                    if (preferredDataMovementProtocol.toString().equals(dataMovementInterface.getDataMovementProtocol().toString())) {
                        return dataMovementInterface;
                    }
                }
            }
        } else {
            throw new RegistryException("Compute resource should have at least one data movement interface defined...");
        }
    } catch (AppCatalogException e) {
        throw new RegistryException("Error occurred while retrieving data from app catalog", e);
    }
    return null;
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) DataMovementProtocol(org.apache.airavata.model.data.movement.DataMovementProtocol) DataMovementInterface(org.apache.airavata.model.data.movement.DataMovementInterface)

Aggregations

ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)30 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)10 UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)10 TException (org.apache.thrift.TException)10 AiravataException (org.apache.airavata.common.exception.AiravataException)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)5 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)5 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)5 StoragePreference (org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)4 RegistryService (org.apache.airavata.registry.api.RegistryService)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)3 JobSubmissionInterface (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface)3 AuthzToken (org.apache.airavata.model.security.AuthzToken)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)2 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)2 LaunchValidationException (org.apache.airavata.model.error.LaunchValidationException)2 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)2