Search in sources :

Example 1 with ProcessTerminateEvent

use of org.apache.airavata.model.messaging.event.ProcessTerminateEvent 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)

Aggregations

AiravataException (org.apache.airavata.common.exception.AiravataException)1 CredentialReader (org.apache.airavata.credential.store.store.CredentialReader)1 MessageContext (org.apache.airavata.messaging.core.MessageContext)1 ProcessTerminateEvent (org.apache.airavata.model.messaging.event.ProcessTerminateEvent)1 OrchestratorException (org.apache.airavata.orchestrator.core.exception.OrchestratorException)1