use of org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent in project airavata by apache.
the class RabbitMQListener method getMessageHandler.
private static MessageHandler getMessageHandler(final BufferedWriter bw) {
return message -> {
try {
long latency = System.currentTimeMillis() - message.getUpdatedTime().getTime();
bw.write(message.getMessageId() + " :" + latency);
bw.newLine();
bw.flush();
} catch (IOException e) {
e.printStackTrace();
}
if (message.getType().equals(MessageType.EXPERIMENT)) {
try {
ExperimentStatusChangeEvent event = new ExperimentStatusChangeEvent();
TBase messageEvent = message.getEvent();
byte[] bytes = ThriftUtils.serializeThriftObject(messageEvent);
ThriftUtils.createThriftFromBytes(bytes, event);
System.out.println(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getType() + "' and with state : '" + event.getState().toString() + " for Gateway " + event.getGatewayId());
} catch (TException e) {
logger.error(e.getMessage(), e);
}
} else if (message.getType().equals(MessageType.PROCESS)) {
/*try {
WorkflowNodeStatusChangeEvent event = new WorkflowNodeStatusChangeEvent();
TBase messageEvent = message.getEvent();
byte[] bytes = ThriftUtils.serializeThriftObject(messageEvent);
ThriftUtils.createThriftFromBytes(bytes, event);
System.out.println(" Message Received with message id '" + message.getMessageId()
+ "' and with message type '" + message.getType() + "' and with state : '" + event.getState().toString() +
" for Gateway " + event.getWorkflowNodeIdentity().getGatewayId());
} catch (TException e) {
logger.error(e.getMessage(), e);
}*/
} else if (message.getType().equals(MessageType.TASK)) {
try {
TaskStatusChangeEvent event = new TaskStatusChangeEvent();
TBase messageEvent = message.getEvent();
byte[] bytes = ThriftUtils.serializeThriftObject(messageEvent);
ThriftUtils.createThriftFromBytes(bytes, event);
System.out.println(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getType() + "' and with state : '" + event.getState().toString() + " for Gateway " + event.getTaskIdentity().getGatewayId());
} 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);
System.out.println(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getType() + "' and with state : '" + event.getState().toString() + " for Gateway " + event.getJobIdentity().getGatewayId());
} catch (TException e) {
logger.error(e.getMessage(), e);
}
}
};
}
use of org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent 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();
}
Aggregations