use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class RegistryServerHandler method getJobStatuses.
/**
* Get Job Statuses for an Experiment
* This method to be used when need to get the job status of an Experiment. An experiment may have one or many jobs; there for one or many job statuses may turnup
*
* @param airavataExperimentId@return JobStatus
* Job status (string) for all all the existing jobs for the experiment will be returned in the form of a map
*/
@Override
public Map<String, JobStatus> getJobStatuses(String airavataExperimentId) throws RegistryServiceException, TException {
try {
experimentCatalog = RegistryFactory.getDefaultExpCatalog();
if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
logger.error(airavataExperimentId, "Error while retrieving job details, experiment {} doesn't exist.", airavataExperimentId);
throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
List<Object> processModels = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
Map<String, JobStatus> jobStatus = new HashMap<String, JobStatus>();
if (processModels != null && !processModels.isEmpty()) {
for (Object process : processModels) {
ProcessModel processModel = (ProcessModel) process;
List<TaskModel> tasks = processModel.getTasks();
if (tasks != null && !tasks.isEmpty()) {
for (TaskModel task : tasks) {
String taskId = task.getTaskId();
List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, taskId);
if (jobs != null && !jobs.isEmpty()) {
for (Object jobObject : jobs) {
JobModel jobModel = (JobModel) jobObject;
String jobID = jobModel.getJobId();
List<JobStatus> status = jobModel.getJobStatuses();
if (status != null && status.size() > 0) {
jobStatus.put(jobID, status.get(0));
}
}
}
}
}
}
}
logger.debug("Airavata retrieved job statuses for experiment with experiment id : " + airavataExperimentId);
return jobStatus;
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while retrieving the job statuses", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Error while retrieving the job statuses. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class BaseCaseIT method testEchoService.
// @Test(groups = {"setupTests"}, dependsOnMethods = {"testSetup"})
// public void testURLs() throws AiravataAPIInvocationException {
// URI eventingServiceURL = this.airavataAPI.getAiravataManager().getEventingServiceURL();
// Assert.assertNotNull(eventingServiceURL);
//
// URI messageBoxServiceURL = this.airavataAPI.getAiravataManager().getMessageBoxServiceURL();
// Assert.assertNotNull(messageBoxServiceURL);
// }
@Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
public void testEchoService() throws Exception {
log.info("Running job in trestles...");
DocumentCreatorNew documentCreator = new DocumentCreatorNew(client);
documentCreator.createPBSDocsForOGCE_Echo();
List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
InputDataObjectType input = new InputDataObjectType();
input.setName("echo_input");
input.setType(DataType.STRING);
input.setValue("echo_output=Hello World");
exInputs.add(input);
List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
OutputDataObjectType output = new OutputDataObjectType();
output.setName("echo_output");
output.setType(DataType.STRING);
output.setValue("");
exOut.add(output);
Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
String projectId = getClient().createProject(authzToken, "default", project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(gatewayName, projectId, "admin", "echoExperiment", "SimpleEcho2", "SimpleEcho2", exInputs);
simpleExperiment.setExperimentOutputs(exOut);
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("trestles.sdsc.edu", 1, 1, 1, "normal", 0, 0);
scheduling.setResourceHostId("gsissh-trestles");
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationData);
final String expId = createExperiment(simpleExperiment);
System.out.println("Experiment Id returned : " + expId);
log.info("Experiment Id returned : " + expId);
launchExperiment(expId);
System.out.println("Launched successfully");
Thread monitor = (new Thread() {
public void run() {
Map<String, JobStatus> jobStatuses = null;
while (true) {
try {
jobStatuses = client.getJobStatuses(authzToken, expId);
Set<String> strings = jobStatuses.keySet();
for (String key : strings) {
JobStatus jobStatus = jobStatuses.get(key);
if (jobStatus == null) {
return;
} else {
if (JobState.COMPLETE.equals(jobStatus.getJobState())) {
log.info("Job completed Job ID: " + key);
return;
} else {
log.info("Job ID:" + key + " Job Status : " + jobStatuses.get(key).getJobState().toString());
}
}
}
Thread.sleep(5000);
} catch (Exception e) {
log.error("Thread interrupted", e.getMessage());
}
}
}
});
monitor.start();
try {
monitor.join();
} catch (InterruptedException e) {
log.error("Thread interrupted..", e.getMessage());
}
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class BaseCaseIT method testEchoServiceStampede.
@Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
public void testEchoServiceStampede() throws Exception {
log.info("Running job in Stampede...");
DocumentCreatorNew documentCreator = new DocumentCreatorNew(client);
documentCreator.createSlurmDocs();
List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
InputDataObjectType input = new InputDataObjectType();
input.setName("echo_input");
input.setType(DataType.STRING);
input.setValue("echo_output=Hello World");
exInputs.add(input);
List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
OutputDataObjectType output = new OutputDataObjectType();
output.setName("echo_output");
output.setType(DataType.STRING);
output.setValue("");
exOut.add(output);
Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
String projectId = getClient().createProject(authzToken, "default", project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(gatewayName, projectId, "admin", "echoExperiment", "SimpleEcho3", "SimpleEcho3", exInputs);
simpleExperiment.setExperimentOutputs(exOut);
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("stampede.tacc.xsede.org", 1, 1, 1, "normal", 0, 0);
scheduling.setResourceHostId("stampede-host");
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationData);
final String expId = createExperiment(simpleExperiment);
System.out.println("Experiment Id returned : " + expId);
log.info("Experiment Id returned : " + expId);
launchExperiment(expId);
System.out.println("Launched successfully");
Thread monitor = (new Thread() {
public void run() {
Map<String, JobStatus> jobStatuses = null;
while (true) {
try {
jobStatuses = client.getJobStatuses(authzToken, expId);
Set<String> strings = jobStatuses.keySet();
for (String key : strings) {
JobStatus jobStatus = jobStatuses.get(key);
if (jobStatus == null) {
return;
} else {
if (JobState.COMPLETE.equals(jobStatus.getJobState())) {
log.info("Job completed Job ID: " + key);
return;
} else {
log.info("Job ID:" + key + " Job Status : " + jobStatuses.get(key).getJobState().toString());
}
}
}
Thread.sleep(5000);
} catch (Exception e) {
log.error("Thread interrupted", e.getMessage());
}
}
}
});
monitor.start();
try {
monitor.join();
} catch (InterruptedException e) {
log.error("Thread interrupted..", e.getMessage());
}
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class CreateLaunchExperiment method main.
public static void main(String[] args) throws Exception {
airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
AuthzToken token = new AuthzToken("empty_token");
System.out.println("API version is " + airavataClient.getAPIVersion(token));
// registerApplications(); // run this only the first time
// Map<String, String> master = airavataClient.getAllUserSSHPubKeys(token, "master");
// System.out.println(master.size());
Map<String, JobStatus> jobStatuses = airavataClient.getJobStatuses(token, "SLM3-QEspresso-Stampede_dc2af008-a832-4fba-ab0a-4b61fa79f5b9");
for (String jobId : jobStatuses.keySet()) {
JobStatus jobStatus = jobStatuses.get(jobId);
System.out.println(jobId);
System.out.println(jobStatus.getJobState().toString());
}
// createAndLaunchExp();
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class LocalRemoteCluster method cancelJob.
@Override
public JobStatus cancelJob(String jobID) throws GFacException {
JobStatus oldStatus = getJobStatus(jobID);
RawCommandInfo cancelCommand = jobManagerConfiguration.getCancelCommand(jobID);
execute(cancelCommand);
return oldStatus;
}
Aggregations