Search in sources :

Example 1 with MonitorException

use of org.apache.airavata.xbaya.messaging.MonitorException in project airavata by apache.

the class XBayaGUI method createFrame.

/**
 * Creates a frame.
 */
private void createFrame() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        // OK. The default will be used.
        logger.error(e.getMessage(), e);
    }
    JFrame.setDefaultLookAndFeelDecorated(false);
    this.frame = new JFrame();
    // Adjust the size
    XBayaConfiguration config = this.engine.getConfiguration();
    int width = config.getWidth();
    int height = config.getHeight();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final int inset = 50;
    this.frame.setLocation(inset, inset);
    Dimension size = new Dimension(screenSize.width - inset * 2, screenSize.height - inset * 2);
    if (width != 0) {
        size.width = width;
    }
    if (height != 0) {
        size.height = height;
    }
    // This controls the size when you open in a huge screen
    if (size.width > 1280 && size.height > 800) {
        size.width = 1280;
        size.height = 800;
    }
    this.frame.setPreferredSize(size);
    this.frame.setTitle(XBayaConstants.APPLICATION_NAME);
    this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    this.frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent event) {
            int result = JOptionPane.showConfirmDialog(frame, "Are you sure you want to exit?", "Exit XBaya", JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.NO_OPTION || (!closeAllGraphCanvas())) {
                return;
            }
            logger.debug(event.toString());
            XBayaGUI.this.frame.setVisible(false);
            try {
                XBayaGUI.this.engine.dispose();
            } catch (WorkflowException e) {
                // Ignore the error.
                logger.error(e.getMessage(), e);
            } catch (RuntimeException e) {
                // Ignore the error.
                logger.error(e.getMessage(), e);
            }
            if (XBayaGUI.this.engine.getConfiguration().isCloseOnExit()) {
                System.exit(0);
            }
        }

        @Override
        public void windowClosed(WindowEvent e) {
            logger.debug(e.toString());
            try {
                XBayaGUI.this.engine.getMonitor().stop();
            } catch (MonitorException e1) {
                logger.error(e1.getMessage(), e1);
            }
            // Dispose only when it can be disposed to prevent infinite loop
            if (XBayaGUI.this.frame.isDisplayable()) {
                XBayaGUI.this.frame.dispose();
            }
        }
    });
    this.frame.setIconImage(SwingUtil.createImage("airavata-2.png"));
}
Also used : XBayaConfiguration(org.apache.airavata.xbaya.XBayaConfiguration) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException)

Example 2 with MonitorException

use of org.apache.airavata.xbaya.messaging.MonitorException 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 MonitorException

use of org.apache.airavata.xbaya.messaging.MonitorException in project airavata by apache.

the class WorkflowModifier method getOutput.

private String getOutput(String nodeID, String messageName, String parameterName) throws MonitorException {
    List<EventData> events = this.eventData.getEvents();
    for (EventData event : events) {
        // String value = parameter.requiredText();
        return event.getMessage();
    }
    // TODO
    String message = "Couldn't find a notification of the output from the service with nodeID, " + nodeID;
    throw new MonitorException(message);
}
Also used : EventData(org.apache.airavata.xbaya.messaging.EventData) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException)

Example 4 with MonitorException

use of org.apache.airavata.xbaya.messaging.MonitorException in project airavata by apache.

the class WorkflowModifier method getWorkflowInput.

private String getWorkflowInput(String nodeID) throws MonitorException {
    logger.debug("Node:" + nodeID);
    List<EventData> events = this.eventData.getEvents();
    for (EventData event : events) {
        // String value = parameter.requiredText();
        return event.getMessage();
    }
    // TODO
    String message = "Couldn't find a notification of about the input with nodeID, " + nodeID;
    throw new MonitorException(message);
}
Also used : EventData(org.apache.airavata.xbaya.messaging.EventData) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException)

Aggregations

MonitorException (org.apache.airavata.xbaya.messaging.MonitorException)4 EventData (org.apache.airavata.xbaya.messaging.EventData)2 Dimension (java.awt.Dimension)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 JFrame (javax.swing.JFrame)1 Client (org.apache.airavata.api.Airavata.Client)1 InputDataObjectType (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType)1 OutputDataObjectType (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType)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 WorkflowException (org.apache.airavata.workflow.model.exceptions.WorkflowException)1 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)1 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)1 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)1 Workflow (org.apache.airavata.workflow.model.wf.Workflow)1 ThriftClientData (org.apache.airavata.xbaya.ThriftClientData)1