Search in sources :

Example 1 with ExperimentStatus

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

the class AiravataServerHandler method getExperimentStatus.

/**
 * Fetch the previously configured experiment configuration information.
 *
 * @param airavataExperimentId The identifier for the requested experiment. This is returned during the create experiment step.
 * @return This method returns the previously configured experiment configuration data.
 * @throws org.apache.airavata.model.error.InvalidRequestException     For any incorrect forming of the request itself.
 * @throws org.apache.airavata.model.error.ExperimentNotFoundException If the specified experiment is not previously created, then an Experiment Not Found Exception is thrown.
 * @throws org.apache.airavata.model.error.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 org.apache.airavata.model.error.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
@SecurityCheck
public ExperimentStatus getExperimentStatus(AuthzToken authzToken, String airavataExperimentId) throws TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        ExperimentStatus result = regClient.getExperimentStatus(airavataExperimentId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        AiravataSystemException exception = new AiravataSystemException();
        exception.setMessage(e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 2 with ExperimentStatus

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

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

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

the class OrchestratorServerHandler method launchExperiment.

/**
 * * After creating the experiment Data user have the * experimentID as the
 * handler to the experiment, during the launchProcess * We just have to
 * give the experimentID * * @param experimentID * @return sucess/failure *
 * *
 *
 * @param experimentId
 */
public boolean launchExperiment(String experimentId, String gatewayId) throws TException {
    ExperimentModel experiment = null;
    try {
        String experimentNodePath = GFacUtils.getExperimentNodePath(experimentId);
        ZKPaths.mkdirs(curatorClient.getZookeeperClient().getZooKeeper(), experimentNodePath);
        String experimentCancelNode = ZKPaths.makePath(experimentNodePath, ZkConstants.ZOOKEEPER_CANCEL_LISTENER_NODE);
        ZKPaths.mkdirs(curatorClient.getZookeeperClient().getZooKeeper(), experimentCancelNode);
        experiment = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, experimentId);
        if (experiment == null) {
            log.error("Error retrieving the Experiment by the given experimentID: {} ", experimentId);
            return false;
        }
        ComputeResourcePreference computeResourcePreference = appCatalog.getGatewayProfile().getComputeResourcePreference(gatewayId, experiment.getUserConfigurationData().getComputationalResourceScheduling().getResourceHostId());
        String token = computeResourcePreference.getResourceSpecificCredentialStoreToken();
        if (token == null || token.isEmpty()) {
            // try with gateway profile level token
            GatewayResourceProfile gatewayProfile = appCatalog.getGatewayProfile().getGatewayProfile(gatewayId);
            token = gatewayProfile.getCredentialStoreToken();
        }
        // still the token is empty, then we fail the experiment
        if (token == null || token.isEmpty()) {
            log.error("You have not configured credential store token at gateway profile or compute resource preference." + " Please provide the correct token at gateway profile or compute resource preference.");
            return false;
        }
        ExperimentType executionType = experiment.getExperimentType();
        if (executionType == ExperimentType.SINGLE_APPLICATION) {
            // its an single application execution experiment
            List<ProcessModel> processes = orchestrator.createProcesses(experimentId, gatewayId);
            for (ProcessModel processModel : processes) {
                // FIXME Resolving replica if available. This is a very crude way of resolving input replicas. A full featured
                // FIXME replica resolving logic should come here
                ReplicaCatalog replicaCatalog = RegistryFactory.getReplicaCatalog();
                processModel.getProcessInputs().stream().forEach(pi -> {
                    if (pi.getType().equals(DataType.URI) && pi.getValue().startsWith("airavata-dp://")) {
                        try {
                            DataProductModel dataProductModel = replicaCatalog.getDataProduct(pi.getValue());
                            Optional<DataReplicaLocationModel> rpLocation = dataProductModel.getReplicaLocations().stream().filter(rpModel -> rpModel.getReplicaLocationCategory().equals(ReplicaLocationCategory.GATEWAY_DATA_STORE)).findFirst();
                            if (rpLocation.isPresent()) {
                                pi.setValue(rpLocation.get().getFilePath());
                                pi.setStorageResourceId(rpLocation.get().getStorageResourceId());
                            } else {
                                log.error("Could not find a replica for the URI " + pi.getValue());
                            }
                        } catch (ReplicaCatalogException e) {
                            log.error(e.getMessage(), e);
                        }
                    } else if (pi.getType().equals(DataType.URI_COLLECTION) && pi.getValue().contains("airavata-dp://")) {
                        try {
                            String[] uriList = pi.getValue().split(",");
                            final ArrayList<String> filePathList = new ArrayList<>();
                            for (String uri : uriList) {
                                if (uri.startsWith("airavata-dp://")) {
                                    DataProductModel dataProductModel = replicaCatalog.getDataProduct(uri);
                                    Optional<DataReplicaLocationModel> rpLocation = dataProductModel.getReplicaLocations().stream().filter(rpModel -> rpModel.getReplicaLocationCategory().equals(ReplicaLocationCategory.GATEWAY_DATA_STORE)).findFirst();
                                    if (rpLocation.isPresent()) {
                                        filePathList.add(rpLocation.get().getFilePath());
                                    } else {
                                        log.error("Could not find a replica for the URI " + pi.getValue());
                                    }
                                } else {
                                    // uri is in file path format
                                    filePathList.add(uri);
                                }
                            }
                            pi.setValue(StringUtils.join(filePathList, ','));
                        } catch (ReplicaCatalogException e) {
                            log.error(e.getMessage(), e);
                        }
                    }
                });
                String taskDag = orchestrator.createAndSaveTasks(gatewayId, processModel, experiment.getUserConfigurationData().isAiravataAutoSchedule());
                processModel.setTaskDag(taskDag);
                experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processModel.getProcessId());
            }
            if (!validateProcess(experimentId, processes)) {
                log.error("Validating process fails for given experiment Id : {}", experimentId);
                return false;
            }
            log.debug(experimentId, "Launching single application experiment {}.", experimentId);
            ExperimentStatus status = new ExperimentStatus(ExperimentState.LAUNCHED);
            status.setReason("submitted all processes");
            status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
            OrchestratorUtils.updageAndPublishExperimentStatus(experimentId, status, publisher, gatewayId);
            log.info("expId: {}, Launched experiment ", experimentId);
            OrchestratorServerThreadPoolExecutor.getCachedThreadPool().execute(MDCUtil.wrapWithMDC(new SingleAppExperimentRunner(experimentId, token, gatewayId)));
        } else if (executionType == ExperimentType.WORKFLOW) {
            // its a workflow execution experiment
            log.debug(experimentId, "Launching workflow experiment {}.", experimentId);
            launchWorkflowExperiment(experimentId, token, gatewayId);
        } else {
            log.error(experimentId, "Couldn't identify experiment type, experiment {} is neither single application nor workflow.", experimentId);
            throw new TException("Experiment '" + experimentId + "' launch failed. Unable to figureout execution type for application " + experiment.getExecutionId());
        }
    } catch (LaunchValidationException launchValidationException) {
        ExperimentStatus status = new ExperimentStatus(ExperimentState.FAILED);
        status.setReason("Validation failed: " + launchValidationException.getErrorMessage());
        status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        OrchestratorUtils.updageAndPublishExperimentStatus(experimentId, status, publisher, gatewayId);
        throw new TException("Experiment '" + experimentId + "' launch failed. Experiment failed to validate: " + launchValidationException.getErrorMessage(), launchValidationException);
    } catch (Exception e) {
        throw new TException("Experiment '" + experimentId + "' launch failed. Unable to figureout execution type for application " + experiment.getExecutionId(), e);
    }
    return true;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) MDCUtil(org.apache.airavata.common.logging.MDCUtil) LoggerFactory(org.slf4j.LoggerFactory) org.apache.airavata.orchestrator.cpi.orchestrator_cpiConstants(org.apache.airavata.orchestrator.cpi.orchestrator_cpiConstants) Stat(org.apache.zookeeper.data.Stat) DataReplicaLocationModel(org.apache.airavata.model.data.replica.DataReplicaLocationModel) OrchestratorException(org.apache.airavata.orchestrator.core.exception.OrchestratorException) ZKPaths(org.apache.curator.utils.ZKPaths) ServerSettings(org.apache.airavata.common.utils.ServerSettings) TBase(org.apache.thrift.TBase) OrchestratorServerThreadPoolExecutor(org.apache.airavata.orchestrator.util.OrchestratorServerThreadPoolExecutor) AbstractExpCatResource(org.apache.airavata.registry.core.experiment.catalog.resources.AbstractExpCatResource) ZkConstants(org.apache.airavata.common.utils.ZkConstants) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) OrchestratorService(org.apache.airavata.orchestrator.cpi.OrchestratorService) DataType(org.apache.airavata.model.application.io.DataType) ValidationResults(org.apache.airavata.model.error.ValidationResults) HostScheduler(org.apache.airavata.gfac.core.scheduler.HostScheduler) AppCatAbstractResource(org.apache.airavata.registry.core.app.catalog.resources.AppCatAbstractResource) CuratorFramework(org.apache.curator.framework.CuratorFramework) ErrorModel(org.apache.airavata.model.commons.ErrorModel) RetryPolicy(org.apache.curator.RetryPolicy) AiravataUtils(org.apache.airavata.common.utils.AiravataUtils) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) java.util(java.util) SimpleOrchestratorImpl(org.apache.airavata.orchestrator.cpi.impl.SimpleOrchestratorImpl) MDCConstants(org.apache.airavata.common.logging.MDCConstants) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) ReplicaLocationCategory(org.apache.airavata.model.data.replica.ReplicaLocationCategory) ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacUtils(org.apache.airavata.gfac.core.GFacUtils) RegistryFactory(org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory) LaunchValidationException(org.apache.airavata.model.error.LaunchValidationException) Logger(org.slf4j.Logger) org.apache.airavata.messaging.core(org.apache.airavata.messaging.core) ExperimentState(org.apache.airavata.model.status.ExperimentState) TException(org.apache.thrift.TException) ExperimentType(org.apache.airavata.model.experiment.ExperimentType) DataProductModel(org.apache.airavata.model.data.replica.DataProductModel) ThriftUtils(org.apache.airavata.common.utils.ThriftUtils) org.apache.airavata.registry.cpi(org.apache.airavata.registry.cpi) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) MDC(org.slf4j.MDC) org.apache.airavata.model.messaging.event(org.apache.airavata.model.messaging.event) OrchestratorUtils(org.apache.airavata.orchestrator.util.OrchestratorUtils) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ProcessModel(org.apache.airavata.model.process.ProcessModel) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) TException(org.apache.thrift.TException) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) ProcessModel(org.apache.airavata.model.process.ProcessModel) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) LaunchValidationException(org.apache.airavata.model.error.LaunchValidationException) DataReplicaLocationModel(org.apache.airavata.model.data.replica.DataReplicaLocationModel) OrchestratorException(org.apache.airavata.orchestrator.core.exception.OrchestratorException) AiravataException(org.apache.airavata.common.exception.AiravataException) LaunchValidationException(org.apache.airavata.model.error.LaunchValidationException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) DataProductModel(org.apache.airavata.model.data.replica.DataProductModel) ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) ExperimentType(org.apache.airavata.model.experiment.ExperimentType)

Example 5 with ExperimentStatus

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

the class OrchestratorServerHandler method validateStatesAndCancel.

private boolean validateStatesAndCancel(String experimentId, String gatewayId) throws Exception {
    ExperimentStatus experimentStatus = OrchestratorUtils.getExperimentStatus(experimentId);
    switch(experimentStatus.getState()) {
        case COMPLETED:
        case CANCELED:
        case FAILED:
        case CANCELING:
            log.warn("Can't terminate already {} experiment", experimentStatus.getState().name());
            return false;
        case CREATED:
            log.warn("Experiment termination is only allowed for launched experiments.");
            return false;
        default:
            String expCancelNodePath = ZKPaths.makePath(ZKPaths.makePath(ZkConstants.ZOOKEEPER_EXPERIMENT_NODE, experimentId), ZkConstants.ZOOKEEPER_CANCEL_LISTENER_NODE);
            Stat stat = curatorClient.checkExists().forPath(expCancelNodePath);
            if (stat != null) {
                curatorClient.setData().withVersion(-1).forPath(expCancelNodePath, ZkConstants.ZOOKEEPER_CANCEL_REQEUST.getBytes());
                ExperimentStatus status = new ExperimentStatus(ExperimentState.CANCELING);
                status.setReason("Experiment cancel request processed");
                status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
                OrchestratorUtils.updageAndPublishExperimentStatus(experimentId, status, publisher, gatewayId);
                log.info("expId : " + experimentId + " :- Experiment status updated to " + status.getState());
                return true;
            }
            return false;
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus)

Aggregations

ExperimentStatus (org.apache.airavata.model.status.ExperimentStatus)9 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)5 TException (org.apache.thrift.TException)5 ExperimentState (org.apache.airavata.model.status.ExperimentState)4 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)4 AiravataException (org.apache.airavata.common.exception.AiravataException)2 Stat (org.apache.zookeeper.data.Stat)2 java.util (java.util)1 Date (java.util.Date)1 MDCConstants (org.apache.airavata.common.logging.MDCConstants)1 MDCUtil (org.apache.airavata.common.logging.MDCUtil)1 AiravataUtils (org.apache.airavata.common.utils.AiravataUtils)1 ServerSettings (org.apache.airavata.common.utils.ServerSettings)1 ThriftUtils (org.apache.airavata.common.utils.ThriftUtils)1 ZkConstants (org.apache.airavata.common.utils.ZkConstants)1 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)1 GFacUtils (org.apache.airavata.gfac.core.GFacUtils)1 HostScheduler (org.apache.airavata.gfac.core.scheduler.HostScheduler)1 org.apache.airavata.messaging.core (org.apache.airavata.messaging.core)1 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)1