Search in sources :

Example 6 with ExperimentStatus

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

the class SingleAppIntegrationTestBase method monitorJob.

// monitoring the job
protected void monitorJob(final String expId) {
    Thread monitor = (new Thread() {

        public void run() {
            authzToken = new AuthzToken("empty token");
            long previousUpdateTime = -1;
            ExperimentStatus experimentStatus = null;
            do {
                try {
                    experimentStatus = airavataClient.getExperimentStatus(authzToken, expId);
                    if (previousUpdateTime != experimentStatus.getTimeOfStateChange()) {
                        previousUpdateTime = experimentStatus.getTimeOfStateChange();
                        log.info(expId + " : " + experimentStatus.getState().toString() + " [" + new Date(previousUpdateTime).toString() + "]");
                    }
                    Thread.sleep(2000);
                } catch (Exception e) {
                    log.error("Thread interrupted", e);
                }
                Assert.assertFalse(experimentStatus.getState().equals(ExperimentState.FAILED));
            } while (!experimentStatus.getState().equals(ExperimentState.COMPLETED));
        }
    });
    monitor.start();
    try {
        monitor.join();
    } catch (InterruptedException e) {
        log.error("Thread interrupted..", e.getMessage());
    }
}
Also used : ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus) AuthzToken(org.apache.airavata.model.security.AuthzToken) Date(java.util.Date) ExperimentNotFoundException(org.apache.airavata.model.error.ExperimentNotFoundException) TException(org.apache.thrift.TException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 7 with ExperimentStatus

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

the class RegistryServerHandler method getExperimentStatus.

/**
 * Get Experiment Status
 * <p>
 * Obtain the status of an experiment by providing the Experiment Id
 *
 * @param airavataExperimentId Experiment ID of the experimnet you require the status.
 * @return ExperimentStatus
 * ExperimentStatus model with the current status will be returned.
 */
@Override
public ExperimentStatus getExperimentStatus(String airavataExperimentId) throws RegistryServiceException, TException {
    ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
    logger.debug("Airavata retrieved experiment status for experiment id : " + airavataExperimentId);
    return experimentStatus;
}
Also used : ExperimentStatus(org.apache.airavata.model.status.ExperimentStatus)

Example 8 with ExperimentStatus

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

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

the class AiravataIT method testLaunchExperiment.

@org.testng.annotations.Test(priority = 6)
public void testLaunchExperiment() {
    try {
        logger.info("testLaunchExperiment() -> Launching test experiment......");
        experimentExecution.launchExperiments(properties.getGname(), experimentId);
        experimentExecution.monitorExperiments();
        ExperimentStatus experimentStatus = experimentExecution.getExperimentStatus(experimentId);
        int maxTry = 5;
        while (maxTry != 0 && !experimentStatus.getState().equals(ExperimentState.COMPLETED) && !experimentStatus.getState().equals(ExperimentState.FAILED)) {
            experimentStatus = experimentExecution.getExperimentStatus(experimentId);
            maxTry--;
            Thread.sleep(2000);
        }
        if (experimentStatus.getState().equals(ExperimentState.COMPLETED)) {
            Assert.assertEquals(new String(Files.readAllBytes(Paths.get(TestFrameworkConstants.STORAGE_LOCATION + "stdout.txt"))), LOCAL_ECHO_EXPERIMENT_EXPECTED_OUTPUT + "\n");
            logger.info("testLaunchExperiment() -> Test experiment completed");
        } else if (experimentStatus.getState().equals(ExperimentState.FAILED)) {
            Assert.fail("Experiment failed to execute");
        } else {
            Assert.fail("Failed to execute experiment in 10 seconds.");
        }
    } catch (Exception e) {
        logger.error("Error occured while testLaunchExperiment", e);
        Assert.fail();
    }
}
Also used : 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