Search in sources :

Example 16 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class WorkflowInterpreterLaunchWindow method execute.

private void execute() throws AiravataClientConnectException, TException {
    String instanceName = this.instanceNameTextField.getText();
    if (instanceName.trim().equals("")) {
        JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Experiment name cannot be empty", "Experiment Name", JOptionPane.ERROR_MESSAGE);
        return;
    }
    ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
    Client airavataClient = XBayaUtil.getAiravataClient(thriftClientData);
    String gatewayId = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId();
    final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
    List<InputDataObjectType> inputDataTypes = new ArrayList<InputDataObjectType>();
    List<OutputDataObjectType> outputDataTypes = new ArrayList<OutputDataObjectType>();
    InputDataObjectType input = null;
    for (int i = 0; i < inputNodes.size(); i++) {
        InputNode inputNode = inputNodes.get(i);
        XBayaTextField parameterTextField = this.parameterTextFields.get(i);
        inputNode.getID();
        String value = parameterTextField.getText();
        input = new InputDataObjectType();
        // inputNode.setDefaultValue(value);
        input.setName(inputNode.getID());
        input.setType(inputNode.getDataType());
        input.setValue(value);
        input.setApplicationArgument(inputNode.getApplicationArgument());
        input.setInputOrder(inputNode.getInputOrder());
        inputDataTypes.add(input);
    }
    final List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.workflow.getGraph());
    OutputDataObjectType output = null;
    for (OutputNode outputNode : outputNodes) {
        output = new OutputDataObjectType();
        output.setName(outputNode.getID());
        output.setType(DataType.STRING);
        outputDataTypes.add(output);
    }
    Workflow workflowClone = workflow.clone();
    workflowClone.setName(workflowClone.getName() + UUID.randomUUID().toString());
    org.apache.airavata.model.Workflow workflowModel = new org.apache.airavata.model.Workflow();
    workflowModel.setName(workflowClone.getName());
    workflowModel.setGraph(JSONUtil.jsonElementToString(workflowClone.toJSON()));
    for (InputDataObjectType inputDataType : inputDataTypes) {
        workflowModel.addToWorkflowInputs(inputDataType);
    }
    for (OutputDataObjectType outputDataType : outputDataTypes) {
        workflowModel.addToWorkflowOutputs(outputDataType);
    }
    workflowModel.setTemplateId(airavataClient.registerWorkflow(gatewayId, workflowModel));
    // Use topic as a base of workflow instance ID so that the monitor can
    // find it.
    Project project = new Project();
    project.setName("project1");
    project.setOwner(thriftClientData.getUsername());
    project.setProjectID(airavataClient.createProject(gatewayId, project));
    final Experiment experiment = new Experiment();
    experiment.setApplicationId(workflowModel.getTemplateId());
    experiment.setName(instanceName);
    experiment.setProjectID(project.getProjectID());
    experiment.setUserName(thriftClientData.getUsername());
    for (InputDataObjectType inputDataType : inputDataTypes) {
        experiment.addToExperimentInputs(inputDataType);
    }
    for (OutputDataObjectType outputDataType : outputDataTypes) {
        experiment.addToExperimentOutputs(outputDataType);
    }
    // Add scheduling configurations
    if (host != null && host.getSelectedIndex() >= 0) {
        String selectedHostName = host.getSelectedItem().toString();
        String computeResouceId = hostNames.get(selectedHostName);
        ComputationalResourceScheduling computationalResourceScheduling;
        if (selectedHostName.equals("localhost")) {
            computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, "test");
        } else if (selectedHostName.equals("trestles.sdsc.xsede.org")) {
            computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, "sds128");
        } else if (selectedHostName.equals("stampede.tacc.xsede.org")) {
            computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 2, 32, 1, "development", 90, 0, 1, "TG-STA110014S");
        } else if (selectedHostName.equals("bigred2.uits.iu.edu")) {
            computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, null);
        } else {
            // TODO handle for other computer resources too.
            throw new IllegalArgumentException("Computational resource scheduling is not configured for host :" + computeResouceId);
        }
        UserConfigurationData userConfigurationData = new UserConfigurationData();
        userConfigurationData.setAiravataAutoSchedule(false);
        userConfigurationData.setOverrideManualScheduledParams(false);
        userConfigurationData.setComputationalResourceScheduling(computationalResourceScheduling);
        experiment.setUserConfigurationData(userConfigurationData);
    } else {
        throw new RuntimeException("Resource scheduling failed, target computer resource host name is not defined");
    }
    /*
// code snippet for load test.
        for (int i = 0; i < 20; i++) {
            experiment.setName(instanceName + "_" + i);

            experiment.setExperimentID(airavataClient.createExperiment(experiment));

            try {
                this.engine.getMonitor().subscribe(experiment.getExperimentID());
                this.engine.getMonitor().fireStartMonitoring(workflow.getName());
            } catch (MonitorException e) {
                logger.error("Error while subscribing with experiment Id : " + experiment.getExperimentID(), e);
            }
            airavataClient.launchExperiment(experiment.getExperimentID(), "testToken");

        }*/
    experiment.setExperimentID(airavataClient.createExperiment(gatewayId, experiment));
    try {
        this.engine.getMonitor().subscribe(experiment.getExperimentID());
        this.engine.getMonitor().fireStartMonitoring(workflow.getName());
    } catch (MonitorException e) {
        logger.error("Error while subscribing with experiment Id : " + experiment.getExperimentID(), e);
    }
    airavataClient.launchExperiment(experiment.getExperimentID(), token.getText());
    clean();
    hide();
}
Also used : ComputationalResourceScheduling(org.apache.airavata.model.experiment.ComputationalResourceScheduling) ArrayList(java.util.ArrayList) OutputDataObjectType(org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType) Client(org.apache.airavata.api.Airavata.Client) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) UserConfigurationData(org.apache.airavata.model.experiment.UserConfigurationData) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) ThriftClientData(org.apache.airavata.xbaya.ThriftClientData) InputDataObjectType(org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType) Workflow(org.apache.airavata.workflow.model.wf.Workflow) Project(org.apache.airavata.model.workspace.Project) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField)

Example 17 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class WSGraphFactory method createNode.

/**
 * @see org.apache.airavata.workflow.model.graph.GraphFactory#createNode(org.xmlpull.infoset.XmlElement)
 */
public NodeImpl createNode(XmlElement nodeElement) throws GraphException {
    String type = nodeElement.attributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE);
    if (type == null) {
        // Old graphs don't have the namespace for the attribute.
        type = nodeElement.attributeValue(GraphSchema.NODE_TYPE_ATTRIBUTE);
    }
    NodeImpl node;
    if (GraphSchema.NODE_TYPE_WS.equals(type)) {
        node = new WSNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_STREAM_SOURCE.equals(type)) {
        node = new StreamSourceNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_WORKFLOW.equals(type)) {
        node = new WorkflowNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_INPUT.equals(type)) {
        node = new InputNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_OUTPUT.equals(type)) {
        node = new OutputNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_CONSTANT.equals(type)) {
        node = new ConstantNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_SPLIT.equals(type)) {
        node = new ForEachNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_MERGE.equals(type)) {
        node = new EndForEachNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_IF.equals(type)) {
        node = new IfNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDIF.equals(type)) {
        node = new EndifNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_DOWHILE.equals(type)) {
        node = new DoWhileNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDDOWHILE.equals(type)) {
        node = new EndDoWhileNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_MEMO.equals(type)) {
        node = new MemoNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_RECEIVE.equals(type)) {
        node = new ReceiveNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_BLOCK.equals(type)) {
        node = new BlockNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDBLOCK.equals(type)) {
        node = new EndBlockNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_INSTANCE.equals(type)) {
        node = new InstanceNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_TERMINATE.equals(type)) {
        node = new TerminateInstanceNode(nodeElement);
    } else {
        // Default is WsNode for backward compatibility.
        node = new WSNode(nodeElement);
    }
    return node;
}
Also used : BlockNode(org.apache.airavata.workflow.model.graph.system.BlockNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) ReceiveNode(org.apache.airavata.workflow.model.graph.system.ReceiveNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) InstanceNode(org.apache.airavata.workflow.model.graph.amazon.InstanceNode) TerminateInstanceNode(org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) DoWhileNode(org.apache.airavata.workflow.model.graph.system.DoWhileNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) TerminateInstanceNode(org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Example 18 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class WSGraphFactory method createNode.

public NodeImpl createNode(JsonObject nodeObject) throws GraphException {
    String type = nodeObject.getAsJsonPrimitive(GraphSchema.NODE_TYPE_ATTRIBUTE).getAsString();
    NodeImpl node;
    if (GraphSchema.NODE_TYPE_WS.equals(type)) {
        node = new WSNode(nodeObject);
    } else if (GraphSchema.NODE_TYPE_WORKFLOW.equals(type)) {
        node = new WorkflowNode(nodeObject);
    } else if (GraphSchema.NODE_TYPE_INPUT.equals(type)) {
        node = new InputNode(nodeObject);
    } else if (GraphSchema.NODE_TYPE_OUTPUT.equals(type)) {
        node = new OutputNode(nodeObject);
    /*        } else if (GraphSchema.NODE_TYPE_STREAM_SOURCE.equals(type)) {
            node = new StreamSourceNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_CONSTANT.equals(type)) {
            node = new ConstantNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_SPLIT.equals(type)) {
            node = new ForEachNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_MERGE.equals(type)) {
            node = new EndForEachNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_IF.equals(type)) {
            node = new IfNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_ENDIF.equals(type)) {
            node = new EndifNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_DOWHILE.equals(type)) {
            node = new DoWhileNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_ENDDOWHILE.equals(type)) {
            node = new EndDoWhileNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_MEMO.equals(type)) {
            node = new MemoNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_RECEIVE.equals(type)) {
            node = new ReceiveNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_BLOCK.equals(type)) {
            node = new BlockNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_ENDBLOCK.equals(type)) {
            node = new EndBlockNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_INSTANCE.equals(type)) {
            node = new InstanceNode(nodeElement);
        } else if (GraphSchema.NODE_TYPE_TERMINATE.equals(type)) {
            node = new TerminateInstanceNode(nodeElement);*/
    } else {
        // Default is WsNode for backward compatibility.
        node = new WSNode(nodeObject);
    }
    return node;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl)

Example 19 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class InterpreterUtil method getInputsForForEachNode.

/**
 * This method returns the input values for given foreach node
 *
 * @param forEachNode
 * @param listOfValues
 * @param invokerMap
 * @return
 * @throws WorkflowException
 */
public static Object getInputsForForEachNode(final ForEachNode forEachNode, final LinkedList<String> listOfValues, Map<Node, Invoker> invokerMap) throws WorkflowException {
    List<DataPort> inputPorts = forEachNode.getInputPorts();
    Object returnValForProvenance = null;
    for (DataPort inputPort : inputPorts) {
        Node inputNode = inputPort.getFromNode();
        // if input node for for-each is WSNode
        if (inputNode instanceof InputNode) {
            // for (DataPort dataPort : forEachNode.getInputPorts()) {
            returnValForProvenance = InterpreterUtil.findInputFromPort(inputPort, invokerMap);
            if (null == returnValForProvenance) {
                throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
            }
            String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
            listOfValues.addAll(Arrays.asList(vals));
        // }
        }
    }
    return returnValForProvenance;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkFlowInterpreterException(org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)

Example 20 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class InputComponent method createNode.

/**
 * @see org.apache.airavata.workflow.model.component.Component#createNode(org.apache.airavata.workflow.model.graph.Graph)
 */
@Override
public InputNode createNode(Graph graph) {
    InputNode node = new InputNode(graph);
    node.setName(NAME);
    node.setComponent(this);
    // Creates a unique ID for the node. This has to be after setName().
    node.createID();
    // Creates a output port
    createPorts(node);
    return node;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode)

Aggregations

InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)29 Node (org.apache.airavata.workflow.model.graph.Node)14 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)10 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)10 Port (org.apache.airavata.workflow.model.graph.Port)9 DataPort (org.apache.airavata.workflow.model.graph.DataPort)7 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)7 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)7 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)7 GraphException (org.apache.airavata.workflow.model.graph.GraphException)6 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)6 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)6 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)6 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)6 LinkedList (java.util.LinkedList)5 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)5 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 Workflow (org.apache.airavata.workflow.model.wf.Workflow)4 WorkFlowInterpreterException (org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)3