Search in sources :

Example 1 with ExperimentState

use of org.apache.airavata.model.status.ExperimentState in project airavata by apache.

the class RegistryServerHandler method updateResourceScheduleing.

@Override
public void updateResourceScheduleing(String airavataExperimentId, ComputationalResourceSchedulingModel resourceScheduling) throws RegistryServiceException, TException {
    try {
        experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
            logger.debug(airavataExperimentId, "Update resource scheduling failed, experiment {} doesn't exist.", airavataExperimentId);
            throw new ExperimentNotFoundException("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:
                case CANCELED:
                case FAILED:
                    experimentCatalog.add(ExpCatChildDataType.PROCESS_RESOURCE_SCHEDULE, resourceScheduling, airavataExperimentId);
                    logger.debug(airavataExperimentId, "Successfully updated resource scheduling for the experiment {}.", airavataExperimentId);
                    break;
                default:
                    logger.error(airavataExperimentId, "Error while updating scheduling info. 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 (Exception e) {
        logger.error(airavataExperimentId, "Error while updating scheduling info", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating scheduling info. " + "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...  " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) ExperimentState(org.apache.airavata.model.status.ExperimentState)

Example 2 with ExperimentState

use of org.apache.airavata.model.status.ExperimentState in project airavata by apache.

the class RegistryServerHandler method updateExperimentConfiguration.

@Override
public void updateExperimentConfiguration(String airavataExperimentId, UserConfigurationDataModel userConfiguration) throws RegistryServiceException, TException {
    try {
        experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
            logger.error(airavataExperimentId, "Update experiment configuration failed, experiment {} doesn't exist.", airavataExperimentId);
            throw new ExperimentNotFoundException("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:
                case CANCELED:
                case FAILED:
                    experimentCatalog.add(ExpCatChildDataType.USER_CONFIGURATION_DATA, userConfiguration, airavataExperimentId);
                    logger.debug(airavataExperimentId, "Successfully updated experiment configuration for experiment {}.", airavataExperimentId);
                    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... ", airavataExperimentId);
                    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 (Exception e) {
        logger.error(airavataExperimentId, "Error while updating user configuration", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating user configuration. " + "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...  " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) ExperimentState(org.apache.airavata.model.status.ExperimentState)

Example 3 with ExperimentState

use of org.apache.airavata.model.status.ExperimentState 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 4 with ExperimentState

use of org.apache.airavata.model.status.ExperimentState in project airavata by apache.

the class ExperimentExecution method processMessage.

private void processMessage(MessageContext message) {
    if (message.getType().equals(MessageType.EXPERIMENT)) {
        try {
            ExperimentStatusChangeEvent event = new ExperimentStatusChangeEvent();
            TBase messageEvent = message.getEvent();
            byte[] bytes = ThriftUtils.serializeThriftObject(messageEvent);
            ThriftUtils.createThriftFromBytes(bytes, event);
            ExperimentState expState = event.getState();
            String expId = event.getExperimentId();
            String gatewayId = event.getGatewayId();
            if (expState.equals(ExperimentState.COMPLETED)) {
                resultWriter.println("Results for experiment : " + expId + " of gateway Id : " + gatewayId);
                resultWriter.println("=====================================================================");
                resultWriter.println("Status : " + ExperimentState.COMPLETED.toString());
                // check file transfers
                List<OutputDataObjectType> experimentOutputs = airavata.getExperimentOutputs(authzToken, expId);
                int i = 1;
                for (OutputDataObjectType output : experimentOutputs) {
                    System.out.println("################ Experiment : " + expId + " COMPLETES ###################");
                    System.out.println("Output " + i + " : " + output.getValue());
                    resultWriter.println("Output " + i + " : " + output.getValue());
                    i++;
                }
                resultWriter.println("End of Results for Experiment : " + expId);
                resultWriter.println("=====================================================================");
            } else if (expState.equals(ExperimentState.FAILED)) {
                resultWriter.println("Results for experiment : " + expId + " of gateway Id : " + gatewayId);
                resultWriter.println("=====================================================================");
                int j = 1;
                resultWriter.println("Status : " + ExperimentState.FAILED.toString());
                System.out.println("################ Experiment : " + expId + " FAILED ###################");
                ExperimentModel experiment = airavata.getExperiment(authzToken, expId);
                List<ErrorModel> errors = experiment.getErrors();
                if (errors != null && !errors.isEmpty()) {
                    for (ErrorModel errorDetails : errors) {
                        System.out.println(errorDetails.getActualErrorMessage());
                        resultWriter.println("Actual Error : " + j + " : " + errorDetails.getActualErrorMessage());
                        resultWriter.println("User Friendly Message : " + j + " : " + errorDetails.getUserFriendlyMessage());
                    }
                }
                resultWriter.println("End of Results for Experiment : " + expId);
                resultWriter.println("=====================================================================");
            }
        } catch (TException e) {
            logger.error(e.getMessage(), e);
        }
    } else if (message.getType().equals(MessageType.JOB)) {
        try {
            JobStatusChangeEvent event = new JobStatusChangeEvent();
            TBase messageEvent = message.getEvent();
            byte[] bytes = ThriftUtils.serializeThriftObject(messageEvent);
            ThriftUtils.createThriftFromBytes(bytes, event);
        } catch (TException e) {
            logger.error(e.getMessage(), e);
        }
    }
    resultWriter.flush();
}
Also used : TException(org.apache.thrift.TException) JobStatusChangeEvent(org.apache.airavata.model.messaging.event.JobStatusChangeEvent) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) ExperimentState(org.apache.airavata.model.status.ExperimentState) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) ExperimentStatusChangeEvent(org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent) ErrorModel(org.apache.airavata.model.commons.ErrorModel) TBase(org.apache.thrift.TBase)

Aggregations

ExperimentState (org.apache.airavata.model.status.ExperimentState)4 ExperimentStatus (org.apache.airavata.model.status.ExperimentStatus)3 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)3 TException (org.apache.thrift.TException)3 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)1 ErrorModel (org.apache.airavata.model.commons.ErrorModel)1 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)1 ExperimentStatusChangeEvent (org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent)1 JobStatusChangeEvent (org.apache.airavata.model.messaging.event.JobStatusChangeEvent)1 TBase (org.apache.thrift.TBase)1