Search in sources :

Example 11 with MessageContext

use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.

the class MessageConsumer method handleDelivery.

@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
    Message message = new Message();
    try {
        logger.info("handleDelivery() -> Handling message delivery. Consumer Tag : " + consumerTag);
        ThriftUtils.createThriftFromBytes(body, message);
        DBEventMessage dBEventMessage = new DBEventMessage();
        ThriftUtils.createThriftFromBytes(message.getEvent(), dBEventMessage);
        MessageContext messageContext = new MessageContext((TBase) dBEventMessage, message.getMessageType(), message.getMessageId(), "gatewayId", envelope.getDeliveryTag());
        handler.onMessage(messageContext);
    // sendAck(deliveryTag);
    } catch (TException e) {
        logger.error("handleDelivery() -> Error handling delivery. Consumer Tag : " + consumerTag, e);
    }
}
Also used : TException(org.apache.thrift.TException) DBEventMessage(org.apache.airavata.model.dbevent.DBEventMessage) DBEventMessage(org.apache.airavata.model.dbevent.DBEventMessage) Message(org.apache.airavata.model.messaging.event.Message) MessageContext(org.apache.airavata.messaging.core.MessageContext) DBEventMessageContext(org.apache.airavata.model.dbevent.DBEventMessageContext)

Example 12 with MessageContext

use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.

the class GFACPassiveJobSubmitter method terminate.

/**
 * Submit the experiment the terminate.queue job queue and remove the experiment from shared launch.queue
 * @param experimentId
 * @param processId
 * @return
 * @throws OrchestratorException
 */
public boolean terminate(String experimentId, String processId, String tokenId) throws OrchestratorException {
    String gatewayId = null;
    try {
        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();
        }
        ProcessTerminateEvent processTerminateEvent = new ProcessTerminateEvent(processId, gatewayId, tokenId);
        MessageContext messageContext = new MessageContext(processTerminateEvent, MessageType.TERMINATEPROCESS, "LAUNCH.TERMINATE-" + UUID.randomUUID().toString(), gatewayId);
        messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
        publisher.publish(messageContext);
        return true;
    } catch (Exception e) {
        throw new OrchestratorException(e);
    }
}
Also used : CredentialReader(org.apache.airavata.credential.store.store.CredentialReader) ProcessTerminateEvent(org.apache.airavata.model.messaging.event.ProcessTerminateEvent) 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 13 with MessageContext

use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.

the class SharingServiceDBEventMessagingFactory method registerSharingServiceWithPublishers.

/**
 * Register sharing service with stated publishers
 * @param publishers
 * @return
 * @throws AiravataException
 */
public static boolean registerSharingServiceWithPublishers(List<String> publishers) throws AiravataException {
    for (String publisher : publishers) {
        log.info("Sending service discovery message. Publisher : " + publisher + ", Subscriber : " + DBEventService.SHARING.toString());
        DBEventSubscriber dbEventSubscriber = new DBEventSubscriber(DBEventService.SHARING.toString());
        DBEventMessageContext dbEventMessageContext = new DBEventMessageContext();
        dbEventMessageContext.setSubscriber(dbEventSubscriber);
        DBEventMessage dbEventMessage = new DBEventMessage(DBEventType.SUBSCRIBER, dbEventMessageContext, publisher);
        MessageContext messageContext = new MessageContext(dbEventMessage, MessageType.DB_EVENT, "", "");
        getDBEventPublisher().publish(messageContext, DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
    }
    return true;
}
Also used : DBEventMessage(org.apache.airavata.model.dbevent.DBEventMessage) DBEventMessageContext(org.apache.airavata.model.dbevent.DBEventMessageContext) DBEventSubscriber(org.apache.airavata.model.dbevent.DBEventSubscriber) MessageContext(org.apache.airavata.messaging.core.MessageContext) DBEventMessageContext(org.apache.airavata.model.dbevent.DBEventMessageContext)

Example 14 with MessageContext

use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.

the class AiravataServerHandler method submitCancelExperiment.

private void submitCancelExperiment(String gatewayId, String experimentId) throws AiravataException {
    ExperimentSubmitEvent event = new ExperimentSubmitEvent(experimentId, gatewayId);
    MessageContext messageContext = new MessageContext(event, MessageType.EXPERIMENT_CANCEL, "CANCEL.EXP-" + UUID.randomUUID().toString(), gatewayId);
    messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
    experimentPublisher.publish(messageContext);
}
Also used : ExperimentSubmitEvent(org.apache.airavata.model.messaging.event.ExperimentSubmitEvent) MessageContext(org.apache.airavata.messaging.core.MessageContext)

Example 15 with MessageContext

use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.

the class AiravataServerHandler method submitExperiment.

private void submitExperiment(String gatewayId, String experimentId) throws AiravataException {
    ExperimentSubmitEvent event = new ExperimentSubmitEvent(experimentId, gatewayId);
    MessageContext messageContext = new MessageContext(event, MessageType.EXPERIMENT, "LAUNCH.EXP-" + UUID.randomUUID().toString(), gatewayId);
    messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
    experimentPublisher.publish(messageContext);
}
Also used : ExperimentSubmitEvent(org.apache.airavata.model.messaging.event.ExperimentSubmitEvent) MessageContext(org.apache.airavata.messaging.core.MessageContext)

Aggregations

MessageContext (org.apache.airavata.messaging.core.MessageContext)20 TException (org.apache.thrift.TException)9 AiravataException (org.apache.airavata.common.exception.AiravataException)6 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)6 DBEventMessage (org.apache.airavata.model.dbevent.DBEventMessage)4 DBEventMessageContext (org.apache.airavata.model.dbevent.DBEventMessageContext)4 Message (org.apache.airavata.model.messaging.event.Message)4 URISyntaxException (java.net.URISyntaxException)3 UnknownHostException (java.net.UnknownHostException)3 ExperimentStatusChangeEvent (org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent)3 ExperimentSubmitEvent (org.apache.airavata.model.messaging.event.ExperimentSubmitEvent)3 TBase (org.apache.thrift.TBase)3 Timestamp (java.sql.Timestamp)2 CredentialReader (org.apache.airavata.credential.store.store.CredentialReader)2 DBEventSubscriber (org.apache.airavata.model.dbevent.DBEventSubscriber)2 ProcessStatusChangeEvent (org.apache.airavata.model.messaging.event.ProcessStatusChangeEvent)2 ProcessSubmitEvent (org.apache.airavata.model.messaging.event.ProcessSubmitEvent)2 OrchestratorException (org.apache.airavata.orchestrator.core.exception.OrchestratorException)2 RegistryException (org.apache.airavata.registry.cpi.RegistryException)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1