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());
}
}
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;
}
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;
}
}
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();
}
}
Aggregations