Search in sources :

Example 6 with NodeImpl

use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.

the class GraphUtil method partitionGraphOnLabel.

/**
 * @param wsGraph
 * @return
 */
public static HashMap<String, LinkedList<Node>> partitionGraphOnLabel(WSGraph wsGraph) {
    HashMap<String, LinkedList<Node>> returnMap = new HashMap<String, LinkedList<Node>>();
    List<NodeImpl> nodes = wsGraph.getNodes();
    for (NodeImpl node : nodes) {
        if (!isInputOutputNode(node)) {
            LinkedList<Node> list = returnMap.get(node.getLabel());
            if (null == list) {
                list = new LinkedList<Node>();
                returnMap.put(node.getLabel(), list);
            }
            list.add(node);
        }
    }
    return returnMap;
}
Also used : NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) HashMap(java.util.HashMap) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) LinkedList(java.util.LinkedList)

Example 7 with NodeImpl

use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.

the class WSPort method copyType.

/**
 * @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
 */
@Override
public void copyType(DataPort port) throws GraphException {
    DataType newType = port.getType();
    DataType type = getType();
    NodeImpl node = port.getNode();
    if (node instanceof ForEachNode || node instanceof EndForEachNode) {
        // from WSDL.
        return;
    }
    if (!(newType == null || newType.equals(WSConstants.XSD_ANY_TYPE) || type == null || type.equals(WSConstants.XSD_ANY_TYPE) || newType.equals(type))) {
        String message = "The type (" + newType + ")  must be same as the type  " + " (" + type + ") of " + getID() + ".";
        throw new GraphException(message);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DataType(org.apache.airavata.model.application.io.DataType) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Example 8 with NodeImpl

use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.

the class LaunchApplicationWindow method execute.

private void execute() throws AiravataClientConnectException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
    List<NodeImpl> nodes = workflow.getGraph().getNodes();
    String gatewayId = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId();
    String appId = null;
    NodeImpl node = null;
    for (int i = 0; i < nodes.size(); i++) {
        node = nodes.get(i);
        String html = node.getComponent().toHTML();
        String nodeType = html.substring(html.indexOf("<h1>") + 4, html.indexOf(":")).trim();
        if (nodeType.equals("Application")) {
            appId = html.substring(html.indexOf("</h2>") + 6, html.indexOf("<br")).trim();
            break;
        }
    }
    String hostId = null;
    String hostName = (String) host.getSelectedItem();
    hostId = hostNames.get(hostName);
    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;
    }
    // previous instance name
    if (!instanceNameTextField.getText().equals("")) {
        this.instanceNameTextField.setText("");
    }
    Project project = new Project();
    project.setName("project1");
    String owner = this.thriftClientData.getUsername();
    if (owner.equals(""))
        owner = "NotKnown";
    project.setOwner(owner);
    project.setProjectID(airavataClient.createProject(gatewayId, project));
    // final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
    final List<DataPort> inputPorts = node.getInputPorts();
    final Experiment experiment = new Experiment();
    experiment.setApplicationId(appId);
    ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
    scheduling.setResourceHostId(hostId);
    if (hostName.trim().equals("trestles.sdsc.xsede.org")) {
        scheduling.setComputationalProjectAccount("sds128");
    } else if (hostName.trim().equals("stampede.tacc.xsede.org")) {
        scheduling.setComputationalProjectAccount("TG-STA110014S");
    }
    scheduling.setNodeCount(1);
    scheduling.setTotalCPUCount(1);
    scheduling.setWallTimeLimit(15);
    scheduling.setQueueName("normal");
    UserConfigurationData userConfigurationData = new UserConfigurationData();
    userConfigurationData.setAiravataAutoSchedule(false);
    userConfigurationData.setOverrideManualScheduledParams(false);
    userConfigurationData.setComputationalResourceScheduling(scheduling);
    experiment.setUserConfigurationData(userConfigurationData);
    experiment.setName(instanceName);
    experiment.setProjectID(project.getProjectID());
    experiment.setUserName(thriftClientData.getUsername());
    for (int i = 0; i < inputPorts.size(); i++) {
        DataPort inputPort = inputPorts.get(i);
        XBayaTextField parameterTextField = this.parameterTextFields.get(i);
        String value = parameterTextField.getText();
        InputDataObjectType elem = new InputDataObjectType();
        elem.setName(inputPort.getName());
        elem.setType(elem.getType());
        elem.setValue(value);
        experiment.addToExperimentInputs(elem);
    }
    final List<DataPort> outputPorts = node.getOutputPorts();
    for (int i = 0; i < outputPorts.size(); i++) {
        DataPort outputPort = outputPorts.get(i);
        OutputDataObjectType elem = new OutputDataObjectType();
        elem.setName(outputPort.getName());
        elem.setType(elem.getType());
        elem.setValue("");
        experiment.addToExperimentOutputs(elem);
    }
    experiment.setExperimentID(airavataClient.createExperiment(gatewayId, experiment));
    airavataClient.launchExperiment(experiment.getExperimentID(), "testToken");
    hide();
    JOptionPane.showMessageDialog(null, "Experiment Launched. You will be alerted on completion.");
    String status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
    while (!status.equals("COMPLETED") && !status.equals("FAILED")) {
        try {
            Thread.sleep(1000);
            status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }
    }
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        logger.error(e.getMessage(), e);
    }
    if (status.equals("COMPLETED")) {
        String output = "";
        ;
        String fullOutput = "";
        while (output.equals("")) {
            output = "";
            fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
            List<OutputDataObjectType> outputs = airavataClient.getExperimentOutputs(experiment.getExperimentID());
            for (int i1 = 0; i1 < outputs.size(); i1++) {
                output = outputs.get(i1).getValue();
                fullOutput += outputs.get(i1).getName() + ": " + output + "\n";
            }
        }
        JOptionPane.showMessageDialog(null, fullOutput);
    } else {
        JOptionPane.showMessageDialog(null, "Experiment Failed");
        return;
    }
    new Thread() {

        @Override
        public void run() {
        }
    }.start();
    hide();
}
Also used : ComputationalResourceScheduling(org.apache.airavata.model.experiment.ComputationalResourceScheduling) UserConfigurationData(org.apache.airavata.model.experiment.UserConfigurationData) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) InputDataObjectType(org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Project(org.apache.airavata.model.workspace.Project) OutputDataObjectType(org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField)

Example 9 with NodeImpl

use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.

the class MonitorEventHandler method getOutputNodes.

private LinkedList<OutputNode> getOutputNodes(WSGraph graph) {
    List<NodeImpl> nodes = graph.getNodes();
    LinkedList<OutputNode> outputNodes = new LinkedList<OutputNode>();
    for (NodeImpl nodeImpl : nodes) {
        if (nodeImpl instanceof OutputNode) {
            outputNodes.add((OutputNode) nodeImpl);
        }
    }
    return outputNodes;
}
Also used : OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) LinkedList(java.util.LinkedList)

Example 10 with NodeImpl

use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.

the class MonitorEventHandler method getInputNodes.

/**
 * @param graph
 * @return
 */
private LinkedList<InputNode> getInputNodes(WSGraph graph) {
    List<NodeImpl> nodes = graph.getNodes();
    LinkedList<InputNode> inputNodes = new LinkedList<InputNode>();
    for (NodeImpl nodeImpl : nodes) {
        if (nodeImpl instanceof InputNode) {
            inputNodes.add((InputNode) nodeImpl);
        }
    }
    return inputNodes;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) LinkedList(java.util.LinkedList)

Aggregations

NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)24 Node (org.apache.airavata.workflow.model.graph.Node)14 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)14 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)12 LinkedList (java.util.LinkedList)11 DataPort (org.apache.airavata.workflow.model.graph.DataPort)8 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)6 GraphException (org.apache.airavata.workflow.model.graph.GraphException)5 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)5 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)5 Pair (org.apache.airavata.common.utils.Pair)4 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)4 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)4 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)4 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)4 Workflow (org.apache.airavata.workflow.model.wf.Workflow)3 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RegistryException (org.apache.airavata.registry.cpi.RegistryException)2