Search in sources :

Example 1 with ProcessSubmitEvent

use of org.apache.airavata.model.messaging.event.ProcessSubmitEvent in project airavata by apache.

the class GFACPassiveJobSubmitter method submit.

/**
 * Submit the job to a shared launch.queue accross multiple gfac instances
 *
 * @param experimentId
 * @param processId
 * @param tokenId
 * @return
 * @throws OrchestratorException
 */
public boolean submit(String experimentId, String processId, String tokenId) throws OrchestratorException {
    try {
        String gatewayId = null;
        CredentialReader credentialReader = GFacUtils.getCredentialReader();
        if (credentialReader != null) {
            try {
                gatewayId = credentialReader.getGatewayID(tokenId);
            } catch (Exception e) {
                logger.error(e.getLocalizedMessage());
            }
        }
        if (gatewayId == null || gatewayId.isEmpty()) {
            gatewayId = ServerSettings.getDefaultUserGateway();
        }
        ProcessSubmitEvent processSubmitEvent = new ProcessSubmitEvent(processId, gatewayId, experimentId, tokenId);
        MessageContext messageContext = new MessageContext(processSubmitEvent, MessageType.LAUNCHPROCESS, "LAUNCH" + ".PROCESS-" + UUID.randomUUID().toString(), gatewayId);
        messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
        publisher.publish(messageContext);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new OrchestratorException(e);
    }
    return true;
}
Also used : CredentialReader(org.apache.airavata.credential.store.store.CredentialReader) ProcessSubmitEvent(org.apache.airavata.model.messaging.event.ProcessSubmitEvent) OrchestratorException(org.apache.airavata.orchestrator.core.exception.OrchestratorException) MessageContext(org.apache.airavata.messaging.core.MessageContext) OrchestratorException(org.apache.airavata.orchestrator.core.exception.OrchestratorException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 2 with ProcessSubmitEvent

use of org.apache.airavata.model.messaging.event.ProcessSubmitEvent in project airavata by apache.

the class ProcessConsumer method handleDelivery.

@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties basicProperties, byte[] body) throws IOException {
    Message message = new Message();
    try {
        ThriftUtils.createThriftFromBytes(body, message);
        TBase event = null;
        String gatewayId = null;
        long deliveryTag = envelope.getDeliveryTag();
        if (message.getMessageType().equals(MessageType.LAUNCHPROCESS)) {
            ProcessSubmitEvent processSubmitEvent = new ProcessSubmitEvent();
            ThriftUtils.createThriftFromBytes(message.getEvent(), processSubmitEvent);
            log.info(" Message Received with message id '" + message.getMessageId() + " and with message type:" + message.getMessageType() + ", for processId:" + processSubmitEvent.getProcessId() + ", expId:" + processSubmitEvent.getExperimentId());
            event = processSubmitEvent;
            gatewayId = processSubmitEvent.getGatewayId();
            MessageContext messageContext = new MessageContext(event, message.getMessageType(), message.getMessageId(), gatewayId, deliveryTag);
            messageContext.setUpdatedTime(AiravataUtils.getTime(message.getUpdatedTime()));
            messageContext.setIsRedeliver(envelope.isRedeliver());
            handler.onMessage(messageContext);
        } else {
            log.error("{} message type is not handle in ProcessLaunch Subscriber. Sending ack for " + "delivery tag {} ", message.getMessageType().name(), deliveryTag);
            sendAck(deliveryTag);
        }
    } catch (TException e) {
        String msg = "Failed to de-serialize the thrift message, from routing keys:" + envelope.getRoutingKey();
        log.warn(msg, e);
    }
}
Also used : TException(org.apache.thrift.TException) Message(org.apache.airavata.model.messaging.event.Message) ProcessSubmitEvent(org.apache.airavata.model.messaging.event.ProcessSubmitEvent) TBase(org.apache.thrift.TBase) MessageContext(org.apache.airavata.messaging.core.MessageContext)

Aggregations

MessageContext (org.apache.airavata.messaging.core.MessageContext)2 ProcessSubmitEvent (org.apache.airavata.model.messaging.event.ProcessSubmitEvent)2 AiravataException (org.apache.airavata.common.exception.AiravataException)1 CredentialReader (org.apache.airavata.credential.store.store.CredentialReader)1 Message (org.apache.airavata.model.messaging.event.Message)1 OrchestratorException (org.apache.airavata.orchestrator.core.exception.OrchestratorException)1 TBase (org.apache.thrift.TBase)1 TException (org.apache.thrift.TException)1