Search in sources :

Example 21 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method addSSHJobSubmissionDetails.

/**
 * Add a SSH Job Submission details to a compute resource
 * App catalog will return a jobSubmissionInterfaceId which will be added to the jobSubmissionInterfaces.
 *
 * @param computeResourceId The identifier of the compute resource to which JobSubmission protocol to be added
 * @param priorityOrder     Specify the priority of this job manager. If this is the only jobmanager, the priority can be zero.
 * @param sshJobSubmission  The SSHJobSubmission object to be added to the resource.
 * @return status
 * Returns the unique job submission id.
 */
@Override
public String addSSHJobSubmissionDetails(String computeResourceId, int priorityOrder, SSHJobSubmission sshJobSubmission) throws RegistryServiceException, TException {
    try {
        appCatalog = RegistryFactory.getAppCatalog();
        ComputeResource computeResource = appCatalog.getComputeResource();
        String submissionInterface = addJobSubmissionInterface(computeResource, computeResourceId, computeResource.addSSHJobSubmission(sshJobSubmission), JobSubmissionProtocol.SSH, priorityOrder);
        logger.debug("Airavata registered SSH job submission for compute resource id: " + computeResourceId);
        return submissionInterface;
    } catch (AppCatalogException e) {
        logger.error(computeResourceId, "Error while adding job submission interface to resource compute resource...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 22 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method getGatewayResourceProfile.

/**
 * Fetch the given Gateway Resource Profile.
 *
 * @param gatewayID The identifier for the requested gateway resource.
 * @return gatewayResourceProfile
 * Gateway Resource Profile Object.
 */
@Override
public GatewayResourceProfile getGatewayResourceProfile(String gatewayID) throws RegistryServiceException, TException {
    try {
        if (!isGatewayExistInternal(gatewayID)) {
            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);
        logger.debug("Airavata retrieved gateway profile with gateway id : " + gatewayID);
        return gatewayResourceProfile;
    } catch (AppCatalogException 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());
        throw exception;
    }
}
Also used : GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 23 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method updateGatewayComputeResourcePreference.

/**
 * Update a Compute Resource Preference to a registered gateway profile.
 *
 * @param gatewayID                 The identifier for the gateway profile to be updated.
 * @param computeResourceId         Preferences related to a particular compute resource
 * @param computeResourcePreference The ComputeResourcePreference object to be updated to the resource profile.
 * @return status
 * Returns a success/failure of the updation.
 */
@Override
public boolean updateGatewayComputeResourcePreference(String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference) throws RegistryServiceException, TException {
    try {
        if (!isGatewayExistInternal(gatewayID)) {
            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);
        List<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences();
        ComputeResourcePreference preferenceToRemove = null;
        for (ComputeResourcePreference preference : computeResourcePreferences) {
            if (preference.getComputeResourceId().equals(computeResourceId)) {
                preferenceToRemove = preference;
                break;
            }
        }
        if (preferenceToRemove != null) {
            profile.getComputeResourcePreferences().remove(preferenceToRemove);
        }
        profile.getComputeResourcePreferences().add(computeResourcePreference);
        gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
        logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
        return true;
    } catch (AppCatalogException 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());
        throw exception;
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)

Example 24 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method searchExperiments.

/**
 * Search Experiments.
 * Search Experiments by using multiple filter criteria with pagination. Results will be sorted based on creation time DESC.
 *
 * @param gatewayId Identifier of the requested gateway.
 * @param userName  Username of the user requesting the search function.
 * @param filters   Map of multiple filter criteria. Currenlt search filters includes Experiment Name, Description, Application, etc....
 * @param limit     Amount of results to be fetched.
 * @param offset    The starting point of the results to be fetched.
 * @return ExperimentSummaryModel
 * List of experiments for the given search filter. Here only the Experiment summary will be returned.
 */
@Override
public List<ExperimentSummaryModel> searchExperiments(String gatewayId, String userName, List<String> accessibleExpIds, Map<ExperimentSearchFields, String> filters, int limit, int offset) throws RegistryServiceException, TException {
    if (!validateString(userName)) {
        logger.error("Username cannot be empty. Please provide a valid user..");
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Username cannot be empty. Please provide a valid user..");
        throw exception;
    }
    if (!isGatewayExistInternal(gatewayId)) {
        logger.error("Gateway does not exist.Please provide a valid gateway id...");
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    }
    try {
        if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)) {
            logger.error("User does not exist in the system. Please provide a valid user..");
            AiravataSystemException exception = new AiravataSystemException();
            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
            exception.setMessage("User does not exist in the system. Please provide a valid user..");
            throw exception;
        }
        List<ExperimentSummaryModel> summaries = new ArrayList<ExperimentSummaryModel>();
        experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
        Map<String, String> regFilters = new HashMap();
        regFilters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);
        for (Map.Entry<ExperimentSearchFields, String> entry : filters.entrySet()) {
            if (entry.getKey().equals(ExperimentSearchFields.EXPERIMENT_NAME)) {
                regFilters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME, entry.getValue());
            } else if (entry.getKey().equals(ExperimentSearchFields.EXPERIMENT_DESC)) {
                regFilters.put(Constants.FieldConstants.ExperimentConstants.DESCRIPTION, entry.getValue());
            } else if (entry.getKey().equals(ExperimentSearchFields.APPLICATION_ID)) {
                regFilters.put(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID, entry.getValue());
            } else if (entry.getKey().equals(ExperimentSearchFields.STATUS)) {
                regFilters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS, entry.getValue());
            } else if (entry.getKey().equals(ExperimentSearchFields.FROM_DATE)) {
                regFilters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, entry.getValue());
            } else if (entry.getKey().equals(ExperimentSearchFields.TO_DATE)) {
                regFilters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, entry.getValue());
            } else if (entry.getKey().equals(ExperimentSearchFields.PROJECT_ID)) {
                regFilters.put(Constants.FieldConstants.ExperimentConstants.PROJECT_ID, entry.getValue());
            }
        }
        if (accessibleExpIds.size() == 0 && !ServerSettings.isEnableSharing()) {
            if (!regFilters.containsKey(AbstractExpCatResource.ExperimentConstants.USER_NAME)) {
                regFilters.put(AbstractExpCatResource.ExperimentConstants.USER_NAME, userName);
            }
        }
        List<Object> results = experimentCatalog.searchAllAccessible(ExperimentCatalogModelType.EXPERIMENT, accessibleExpIds, regFilters, limit, offset, Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
        for (Object object : results) {
            summaries.add((ExperimentSummaryModel) object);
        }
        logger.debug("Airavata retrieved experiments for user : " + userName + " and gateway id : " + gatewayId);
        return summaries;
    } catch (Exception e) {
        logger.error("Error while retrieving experiments", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while retrieving experiments. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 25 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method getSSHJobSubmission.

/**
 * This method returns SSHJobSubmission object
 *
 * @param jobSubmissionId@return SSHJobSubmission instance
 */
@Override
public SSHJobSubmission getSSHJobSubmission(String jobSubmissionId) throws RegistryServiceException, TException {
    try {
        appCatalog = RegistryFactory.getAppCatalog();
        SSHJobSubmission sshJobSubmission = appCatalog.getComputeResource().getSSHJobSubmission(jobSubmissionId);
        logger.debug("Airavata retrieved SSH job submission for job submission interface id: " + jobSubmissionId);
        return sshJobSubmission;
    } catch (AppCatalogException e) {
        String errorMsg = "Error while retrieving SSH job submission interface to resource compute resource...";
        logger.error(jobSubmissionId, errorMsg, e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage(errorMsg + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Aggregations

RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)131 TException (org.apache.thrift.TException)28 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)26 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)9 UserResourceProfile (org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile)5 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)4 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)4 UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)4 UserStoragePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference)4 DataProductModel (org.apache.airavata.model.data.replica.DataProductModel)4 JobModel (org.apache.airavata.model.job.JobModel)3 ProcessModel (org.apache.airavata.model.process.ProcessModel)3 ExperimentState (org.apache.airavata.model.status.ExperimentState)3 ExperimentStatus (org.apache.airavata.model.status.ExperimentStatus)3 Project (org.apache.airavata.model.workspace.Project)3 CredentialStoreService (org.apache.airavata.credential.store.cpi.CredentialStoreService)2 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)2 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)2 StoragePreference (org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)2 PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)2