Search in sources :

Example 1 with ThriftClientData

use of org.apache.airavata.xbaya.ThriftClientData in project airavata by apache.

the class RegistryWindow method ok.

private void ok() {
    setServerName(this.serverTextField.getText());
    setPreviousServerName(this.serverTextField.getText());
    setGatewayId(this.gatewayIdTextField.getText());
    setUsername(new String(this.usernameTextField.getText()));
    setServerPort(this.portTextField.getText());
    setServiceType((ThriftServiceType) serviceTypeModel.getSelectedItem());
    try {
        validateData();
        XBayaConfiguration configuration = this.engine.getConfiguration();
        configuration.addThriftClientData(new ThriftClientData(getServiceType(), serverName, Integer.parseInt(serverPort), gatewayId, username));
        hide();
    } catch (Exception e) {
        this.engine.getGUI().getErrorWindow().error(e.getMessage());
    }
}
Also used : XBayaConfiguration(org.apache.airavata.xbaya.XBayaConfiguration) ThriftClientData(org.apache.airavata.xbaya.ThriftClientData) AiravataClientConnectException(org.apache.airavata.model.error.AiravataClientConnectException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 2 with ThriftClientData

use of org.apache.airavata.xbaya.ThriftClientData 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 3 with ThriftClientData

use of org.apache.airavata.xbaya.ThriftClientData in project airavata by apache.

the class RegistryWindow method initGUI.

/**
 * Initializes the GUI.
 */
private void initGUI() {
    this.serverTextField = new XBayaTextField();
    this.portTextField = new XBayaTextField();
    this.gatewayIdTextField = new XBayaTextField();
    this.usernameTextField = new XBayaTextField();
    this.serverTextField.setText("localhost");
    this.portTextField.setText("8930");
    this.gatewayIdTextField.setText("sample");
    this.usernameTextField.setText("airavata");
    ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
    if (thriftClientData != null) {
        this.serverTextField.setText(thriftClientData.getServerAddress());
        this.gatewayIdTextField.setText(thriftClientData.getGatewayId());
        this.portTextField.setText(String.valueOf(thriftClientData.getServerPort()));
        this.usernameTextField.setText(thriftClientData.getUsername());
    }
    try {
        ClientSettings.initializeTrustStore();
    } catch (ApplicationSettingsException e) {
        throw new RuntimeException("An error occurred while initializing client configurations");
    }
    XBayaLabel serverAddressLabel = new XBayaLabel("Server Address", this.serverTextField);
    XBayaLabel serverPortLabel = new XBayaLabel("Server Port", this.portTextField);
    XBayaLabel gatewayNameLabel = new XBayaLabel("Gateway ID", this.gatewayIdTextField);
    XBayaLabel gatewayUserLabel = new XBayaLabel("Gateway User", this.usernameTextField);
    serviceTypeModel = new DefaultComboBoxModel(ThriftServiceType.values());
    serviceTypeModel.setSelectedItem(getServiceType());
    this.serviceTypeCombo = new XBayaComboBox(serviceTypeModel);
    JLabel serviceTypeLabel = new JLabel("Airavata Service");
    // serviceTypeCombo.addActionListener(new AbstractAction() {
    // public void actionPerformed(ActionEvent e) {
    // //                createNewUser();
    // }
    // });
    GridPanel infoPanel = new GridPanel();
    infoPanel.add(serviceTypeLabel);
    infoPanel.add(this.serviceTypeCombo);
    infoPanel.add(serverAddressLabel);
    infoPanel.add(this.serverTextField);
    infoPanel.add(serverPortLabel);
    infoPanel.add(this.portTextField);
    infoPanel.add(gatewayNameLabel);
    infoPanel.add(this.gatewayIdTextField);
    infoPanel.add(gatewayUserLabel);
    infoPanel.add(this.usernameTextField);
    infoPanel.layout(5, 2, GridPanel.WEIGHT_NONE, 1);
    // infoPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
    infoPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            ok();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    GridPanel buttonPanel = new GridPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    buttonPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Configure Airavata Thrift Service", infoPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) XBayaComboBox(org.apache.airavata.xbaya.ui.widgets.XBayaComboBox) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ThriftClientData(org.apache.airavata.xbaya.ThriftClientData) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 4 with ThriftClientData

use of org.apache.airavata.xbaya.ThriftClientData in project airavata by apache.

the class RegistryWorkflowPublisherWindow method ok.

private void ok() {
    String name = this.nameTextField.getText();
    String description = this.descriptionTextArea.getText();
    GraphCanvas graphCanvas = this.engine.getGUI().getGraphCanvas();
    graphCanvas.setNameAndDescription(name, description);
    workflow.setName(name);
    String workflowTemplateName = workflow.getName();
    try {
        ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
        Client client = AiravataClientFactory.createAiravataClient(thriftClientData.getServerAddress(), thriftClientData.getServerPort());
        if (client.isWorkflowExistWithName(workflowTemplateName)) {
            int result = JOptionPane.showConfirmDialog(this.dialog.getDialog(), "A workflow with the name " + workflowTemplateName + " already exists. Do you want to update it?", "Register Workflow", JOptionPane.YES_NO_CANCEL_OPTION);
            if (result == JOptionPane.NO_OPTION) {
                return;
            } else if (result == JOptionPane.CANCEL_OPTION) {
                hide();
            }
            String workflowAsString = XMLUtil.xmlElementToString(engine.getGUI().getGraphCanvas().getWorkflow().toXML());
            org.apache.airavata.model.Workflow workflowData = new org.apache.airavata.model.Workflow();
            workflowData.setName(workflowTemplateName);
            workflowData.setGraph(workflowAsString);
            client.registerWorkflow(engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId(), workflowData);
            hide();
        }
    } catch (Exception e) {
        this.engine.getGUI().getErrorWindow().error(e.getMessage());
    }
}
Also used : ThriftClientData(org.apache.airavata.xbaya.ThriftClientData) Workflow(org.apache.airavata.workflow.model.wf.Workflow) Client(org.apache.airavata.api.Airavata.Client) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Aggregations

ThriftClientData (org.apache.airavata.xbaya.ThriftClientData)4 Client (org.apache.airavata.api.Airavata.Client)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 Workflow (org.apache.airavata.workflow.model.wf.Workflow)2 XBayaTextField (org.apache.airavata.xbaya.ui.widgets.XBayaTextField)2 ActionEvent (java.awt.event.ActionEvent)1 ArrayList (java.util.ArrayList)1 AbstractAction (javax.swing.AbstractAction)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 InputDataObjectType (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType)1 OutputDataObjectType (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType)1 AiravataClientConnectException (org.apache.airavata.model.error.AiravataClientConnectException)1 ComputationalResourceScheduling (org.apache.airavata.model.experiment.ComputationalResourceScheduling)1 UserConfigurationData (org.apache.airavata.model.experiment.UserConfigurationData)1 Project (org.apache.airavata.model.workspace.Project)1 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)1 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)1 XBayaConfiguration (org.apache.airavata.xbaya.XBayaConfiguration)1