Search in sources :

Example 6 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class WorkflowInterpreter method taskStatusChanged.

@Subscribe
public void taskStatusChanged(TaskStatusChangeEvent taskStatus) {
    String taskId = taskStatus.getTaskIdentity().getTaskId();
    if (isTaskAwaiting(taskId)) {
        WorkflowNodeState state = WorkflowNodeState.UNKNOWN;
        Node node = getAwaitingNodeForTask(taskId);
        switch(taskStatus.getState()) {
            case CANCELED:
                ;
                break;
            case COMPLETED:
                // but we'll wait for outputdata
                break;
            case CONFIGURING_WORKSPACE:
                break;
            case FAILED:
                state = WorkflowNodeState.FAILED;
                node.setState(NodeExecutionState.FAILED);
                break;
            case EXECUTING:
            case WAITING:
            case PRE_PROCESSING:
            case POST_PROCESSING:
            case OUTPUT_DATA_STAGING:
            case INPUT_DATA_STAGING:
                state = WorkflowNodeState.EXECUTING;
                node.setState(NodeExecutionState.EXECUTING);
                break;
            case STARTED:
                break;
            case CANCELING:
                state = WorkflowNodeState.CANCELING;
                break;
            default:
                break;
        }
        try {
            if (state != WorkflowNodeState.UNKNOWN) {
                updateWorkflowNodeStatus(nodeInstanceList.get(node), state);
            }
        } catch (RegistryException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) SubWorkflowNode(org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) RegistryException(org.apache.airavata.registry.cpi.RegistryException) Subscribe(com.google.common.eventbus.Subscribe)

Example 7 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class WorkflowEngineImpl method launchExperiment.

@Override
public void launchExperiment(String experimentId, String token) throws WorkflowEngineException {
    try {
        ExperimentCatalog experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        Experiment experiment = (Experiment) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, experimentId);
        WorkflowCatalog workflowCatalog = WorkflowCatalogFactory.getWorkflowCatalog();
        WorkflowInterpreterConfiguration config = new WorkflowInterpreterConfiguration(new Workflow(workflowCatalog.getWorkflow(experiment.getApplicationId()).getGraph()));
        final WorkflowInterpreter workflowInterpreter = new WorkflowInterpreter(experiment, token, config, getOrchestratorClient(), rabbitMQPublisher);
        new Thread() {

            public void run() {
                try {
                    workflowInterpreter.scheduleDynamically();
                } catch (WorkflowException e) {
                    logger.error(e.getMessage(), e);
                } catch (RegistryException e) {
                    logger.error(e.getMessage(), e);
                } catch (AiravataException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }.start();
    } catch (Exception e) {
        logger.error("Error while retrieving the experiment", e);
        WorkflowEngineException exception = new WorkflowEngineException("Error while launching the workflow experiment. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : ExperimentCatalog(org.apache.airavata.registry.cpi.ExperimentCatalog) WorkflowInterpreter(org.apache.airavata.workflow.engine.interpretor.WorkflowInterpreter) WorkflowCatalog(org.apache.airavata.registry.cpi.WorkflowCatalog) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) WorkflowInterpreterConfiguration(org.apache.airavata.workflow.engine.interpretor.WorkflowInterpreterConfiguration) Workflow(org.apache.airavata.workflow.model.wf.Workflow) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) AiravataClientConnectException(org.apache.airavata.model.error.AiravataClientConnectException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 8 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class QueueStatusResourceTest method test.

@Test
public void test() {
    QueueStatusResource queueStatusResource1 = new QueueStatusResource();
    queueStatusResource1.setHostName("bigred2.uits.iu.edu");
    queueStatusResource1.setQueueName("cpu");
    queueStatusResource1.setTime((long) 1 + System.currentTimeMillis());
    queueStatusResource1.setQueueUp(true);
    queueStatusResource1.setRunningJobs(3);
    queueStatusResource1.setQueuedJobs(4);
    try {
        queueStatusResource1.save();
    } catch (RegistryException e) {
        e.printStackTrace();
        Assert.fail();
    }
    QueueStatusResource queueStatusResource2 = new QueueStatusResource();
    queueStatusResource2.setHostName("bigred2.uits.iu.edu");
    queueStatusResource2.setQueueName("cpu");
    queueStatusResource2.setTime((long) 2 + System.currentTimeMillis());
    queueStatusResource2.setQueueUp(true);
    queueStatusResource2.setRunningJobs(33);
    queueStatusResource2.setQueuedJobs(44);
    try {
        queueStatusResource2.save();
    } catch (RegistryException e) {
        e.printStackTrace();
        Assert.fail();
    }
    try {
        List<ExperimentCatResource> experimentCatResources = queueStatusResource1.get(ResourceType.QUEUE_STATUS);
        Assert.assertTrue(experimentCatResources.size() == 1);
        QueueStatusResource queueStatusResource = (QueueStatusResource) experimentCatResources.get(0);
        Assert.assertEquals(queueStatusResource2.getTime(), queueStatusResource.getTime());
    } catch (RegistryException e) {
        e.printStackTrace();
        Assert.fail();
    }
}
Also used : QueueStatusResource(org.apache.airavata.registry.core.experiment.catalog.resources.QueueStatusResource) RegistryException(org.apache.airavata.registry.cpi.RegistryException) ExperimentCatResource(org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource) Test(org.junit.Test)

Example 9 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method getJob.

public Object getJob(CompositeIdentifier cis, String fieldName) throws RegistryException {
    String taskId = (String) cis.getTopLevelIdentifier();
    String jobId = (String) cis.getSecondLevelIdentifier();
    try {
        TaskResource taskResource = new TaskResource();
        taskResource.setTaskId(taskId);
        JobResource resource = taskResource.getJob(jobId);
        if (fieldName == null) {
            return ThriftDataModelConversion.getJobModel(resource);
        } else if (fieldName.equals(Constants.FieldConstants.JobConstants.JOB_STATUS)) {
            return ThriftDataModelConversion.getJobStatus(resource.getJobStatus());
        } else {
            logger.error("Unsupported field name for job basic data..");
        }
    } catch (Exception e) {
        logger.error("Error while getting job data..", e);
        throw new RegistryException(e);
    }
    return null;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 10 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method addExpInputs.

public String addExpInputs(List<InputDataObjectType> exInputs, String experimentId) throws RegistryException {
    try {
        for (InputDataObjectType input : exInputs) {
            ExperimentInputResource resource = new ExperimentInputResource();
            resource.setExperimentId(experimentId);
            resource.setInputName(input.getName());
            resource.setInputValue(input.getValue());
            if (input.getType() != null) {
                resource.setDataType(input.getType().toString());
            }
            resource.setMetadata(input.getMetaData());
            resource.setApplicationArgument(input.getApplicationArgument());
            resource.setInputOrder(input.getInputOrder());
            resource.setIsRequired(input.isIsRequired());
            resource.setRequiredToAddedToCmd(input.isRequiredToAddedToCommandLine());
            resource.setStorageResourceId(input.getStorageResourceId());
            resource.setIsReadOnly(input.isIsReadOnly());
            resource.save();
        }
    } catch (Exception e) {
        logger.error("Unable to save experiment inputs", e);
        throw new RegistryException(e);
    }
    return experimentId;
}
Also used : InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Aggregations

RegistryException (org.apache.airavata.registry.cpi.RegistryException)134 EntityManager (javax.persistence.EntityManager)54 Query (javax.persistence.Query)29 QueryGenerator (org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator)29 ArrayList (java.util.ArrayList)15 List (java.util.List)12 ExperimentCatResource (org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)12 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)11 ExperimentCatalogException (org.apache.airavata.registry.cpi.ExperimentCatalogException)8 AiravataException (org.apache.airavata.common.exception.AiravataException)6 GFacException (org.apache.airavata.gfac.core.GFacException)6 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)6 Node (org.apache.airavata.workflow.model.graph.Node)6 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)6 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)6 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)6 Timestamp (java.sql.Timestamp)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 DataPort (org.apache.airavata.workflow.model.graph.DataPort)4 HashMap (java.util.HashMap)3