Search in sources :

Example 96 with RegistryServiceException

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

the class RegistryServerHandler method getDetailedExperimentTree.

/**
 * Get Complete Experiment Details
 * Fetch the completed nested tree structue of previously created experiment metadata which includes processes ->
 * tasks -> jobs information.
 *
 * @param airavataExperimentId The identifier for the requested experiment. This is returned during the create experiment step.
 * @return ExperimentModel
 * This method will return the previously stored experiment metadata including application input parameters, computational resource scheduling
 * information, special input output handling and additional quality of service parameters.
 * @throws InvalidRequestException     For any incorrect forming of the request itself.
 * @throws ExperimentNotFoundException If the specified experiment is not previously created, then an Experiment Not Found Exception is thrown.
 * @throws AiravataClientException     The following list of exceptions are thrown which Airavata Client can take corrective actions to resolve:
 *                                     <p>
 *                                     UNKNOWN_GATEWAY_ID - If a Gateway is not registered with Airavata as a one time administrative
 *                                     step, then Airavata Registry will not have a provenance area setup. The client has to follow
 *                                     gateway registration steps and retry this request.
 *                                     <p>
 *                                     AUTHENTICATION_FAILURE - How Authentication will be implemented is yet to be determined.
 *                                     For now this is a place holder.
 *                                     <p>
 *                                     INVALID_AUTHORIZATION - This will throw an authorization exception. When a more robust security hand-shake
 *                                     is implemented, the authorization will be more substantial.
 * @throws AiravataSystemException     This exception will be thrown for any Airavata Server side issues and if the problem cannot be corrected by the client
 *                                     rather an Airavata Administrator will be notified to take corrective action.
 */
@Override
public ExperimentModel getDetailedExperimentTree(String airavataExperimentId) throws RegistryServiceException, TException {
    try {
        ExperimentModel experimentModel = getExperimentInternal(airavataExperimentId);
        experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        List<Object> processObjects = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentModel.getExperimentId());
        List<ProcessModel> processList = new ArrayList<>();
        if (processObjects != null) {
            processObjects.stream().forEach(p -> {
                // Process already has the task object
                ((ProcessModel) p).getTasks().stream().forEach(t -> {
                    try {
                        List<Object> jobObjects = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, ((TaskModel) t).getTaskId());
                        List<JobModel> jobList = new ArrayList<JobModel>();
                        if (jobObjects != null) {
                            jobObjects.stream().forEach(j -> jobList.add((JobModel) j));
                            Collections.sort(jobList, new Comparator<JobModel>() {

                                @Override
                                public int compare(JobModel o1, JobModel o2) {
                                    return (int) (o1.getCreationTime() - o2.getCreationTime());
                                }
                            });
                            t.setJobs(jobList);
                        }
                    } catch (RegistryException e) {
                        logger.error(e.getMessage(), e);
                    }
                });
                processList.add((ProcessModel) p);
            });
            experimentModel.setProcesses(processList);
        }
        logger.debug("Airavata retrieved detailed experiment with experiment id : " + airavataExperimentId);
        return experimentModel;
    } catch (Exception e) {
        logger.error("Error while retrieving the experiment", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while retrieving the experiment. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) 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) JobModel(org.apache.airavata.model.job.JobModel)

Example 97 with RegistryServiceException

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

the class RegistryServerHandler method addLocalDataMovementDetails.

/**
 * Add a Local data movement details to a compute resource
 * App catalog will return a dataMovementInterfaceId which will be added to the dataMovementInterfaces.
 *
 * productUri        The identifier of the compute resource to which JobSubmission protocol to be added
 * @param dataMoveType
 * @param priorityOrder     Specify the priority of this job manager. If this is the only jobmanager, the priority can be zero.
 * @param localDataMovement The LOCALDataMovement object to be added to the resource.
 * @return status
 * Returns the unique job submission id.
 */
@Override
public String addLocalDataMovementDetails(String resourceId, DMType dataMoveType, int priorityOrder, LOCALDataMovement localDataMovement) throws RegistryServiceException, TException {
    try {
        appCatalog = RegistryFactory.getAppCatalog();
        ComputeResource computeResource = appCatalog.getComputeResource();
        String movementInterface = addDataMovementInterface(computeResource, resourceId, dataMoveType, computeResource.addLocalDataMovement(localDataMovement), DataMovementProtocol.LOCAL, priorityOrder);
        logger.debug("Airavata registered local data movement for resource Id: " + resourceId);
        return movementInterface;
    } catch (AppCatalogException e) {
        logger.error(resourceId, "Error while adding data movement interface to resource resource...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while adding data movement interface to resource. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 98 with RegistryServiceException

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

the class RegistryServerHandler method updateCloudJobSubmissionDetails.

/**
 * Update the cloud Job Submission details
 *
 * @param jobSubmissionInterfaceId The identifier of the JobSubmission Interface to be updated.
 * @param sshJobSubmission
 * @return status
 * Returns a success/failure of the update.
 */
@Override
public boolean updateCloudJobSubmissionDetails(String jobSubmissionInterfaceId, CloudJobSubmission sshJobSubmission) throws RegistryServiceException, TException {
    try {
        CloudSubmissionResource submission = AppCatalogThriftConversion.getCloudJobSubmission(sshJobSubmission);
        submission.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
        submission.save();
        logger.debug("Airavata updated Cloud job submission for job submission interface id: " + jobSubmissionInterfaceId);
        return true;
    } catch (Exception e) {
        logger.error(jobSubmissionInterfaceId, "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) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 99 with RegistryServiceException

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

the class RegistryServerHandler method updateExperiment.

/**
 * Update a Previously Created Experiment
 * Configure the CREATED experiment with required inputs, scheduling and other quality of service parameters. This method only updates the experiment object within the registry.
 * The experiment has to be launched to make it actionable by the server.
 *
 * @param airavataExperimentId The identifier for the requested experiment. This is returned during the create experiment step.
 * @param experiment
 * @return This method call does not have a return value.
 * @throws InvalidRequestException     For any incorrect forming of the request itself.
 * @throws ExperimentNotFoundException If the specified experiment is not previously created, then an Experiment Not Found Exception is thrown.
 * @throws AiravataClientException     The following list of exceptions are thrown which Airavata Client can take corrective actions to resolve:
 *                                     <p>
 *                                     UNKNOWN_GATEWAY_ID - If a Gateway is not registered with Airavata as a one time administrative
 *                                     step, then Airavata Registry will not have a provenance area setup. The client has to follow
 *                                     gateway registration steps and retry this request.
 *                                     <p>
 *                                     AUTHENTICATION_FAILURE - How Authentication will be implemented is yet to be determined.
 *                                     For now this is a place holder.
 *                                     <p>
 *                                     INVALID_AUTHORIZATION - This will throw an authorization exception. When a more robust security hand-shake
 *                                     is implemented, the authorization will be more substantial.
 * @throws AiravataSystemException     This exception will be thrown for any Airavata Server side issues and if the problem cannot be corrected by the client
 *                                     rather an Airavata Administrator will be notified to take corrective action.
 */
@Override
public void updateExperiment(String airavataExperimentId, ExperimentModel experiment) throws RegistryServiceException, TException {
    try {
        experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
            logger.error(airavataExperimentId, "Update request failed, Experiment {} doesn't exist.", airavataExperimentId);
            throw new RegistryServiceException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
        }
        ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
        if (experimentStatus != null) {
            ExperimentState experimentState = experimentStatus.getState();
            switch(experimentState) {
                case CREATED:
                case VALIDATED:
                    if (experiment.getUserConfigurationData() != null && experiment.getUserConfigurationData().getComputationalResourceScheduling() != null) {
                        String compResourceId = experiment.getUserConfigurationData().getComputationalResourceScheduling().getResourceHostId();
                        ComputeResourceDescription computeResourceDescription = appCatalog.getComputeResource().getComputeResource(compResourceId);
                        if (!computeResourceDescription.isEnabled()) {
                            logger.error("Compute Resource is not enabled by the Admin!");
                            AiravataSystemException exception = new AiravataSystemException();
                            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
                            exception.setMessage("Compute Resource is not enabled by the Admin!");
                            throw exception;
                        }
                    }
                    experimentCatalog.update(ExperimentCatalogModelType.EXPERIMENT, experiment, airavataExperimentId);
                    logger.debug(airavataExperimentId, "Successfully updated experiment {} ", experiment.getExperimentName());
                    break;
                default:
                    logger.error(airavataExperimentId, "Error while updating experiment. Update experiment is only valid for experiments " + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " + "experiment is in one of above statuses... ");
                    AiravataSystemException exception = new AiravataSystemException();
                    exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
                    exception.setMessage("Error while updating experiment. Update experiment is only valid for experiments " + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " + "experiment is in one of above statuses... ");
                    throw exception;
            }
        }
    } catch (RegistryException e) {
        logger.error(airavataExperimentId, "Error while updating experiment", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating experiment. More info : " + e.getMessage());
        throw exception;
    } catch (AppCatalogException e) {
        logger.error(airavataExperimentId, "Error while updating experiment", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating experiment. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) ExperimentState(org.apache.airavata.model.status.ExperimentState)

Example 100 with RegistryServiceException

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

the class RegistryServerHandler method deleteApplicationInterface.

/**
 * Delete an Application Interface.
 *
 * @param appInterfaceId The identifier for the requested application interface to be deleted.
 * @return status
 * Returns a success/failure of the deletion.
 */
@Override
public boolean deleteApplicationInterface(String appInterfaceId) throws RegistryServiceException, TException {
    try {
        appCatalog = RegistryFactory.getAppCatalog();
        boolean removeApplicationInterface = appCatalog.getApplicationInterface().removeApplicationInterface(appInterfaceId);
        logger.debug("Airavata removed application interface with interface id : " + appInterfaceId);
        return removeApplicationInterface;
    } catch (AppCatalogException e) {
        logger.error(appInterfaceId, "Error while deleting application interface...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while deleting application interface. More info : " + 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