Package org.apache.airavata.xbaya.monitor

Examples of org.apache.airavata.xbaya.monitor.MonitorConfiguration


            }
        }

        this.workflow = this.engine.getWorkflow();

        MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
        if (notifConfig.getBrokerURL() == null) {
            this.engine.getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR);
            return;
        }

        BPELScript bpel = new BPELScript(this.workflow);

        // Check if there is any errors in the workflow first.
        ArrayList<String> warnings = new ArrayList<String>();
        if (!bpel.validate(warnings)) {
            StringBuilder buf = new StringBuilder();
            for (String warning : warnings) {
                buf.append("- ");
                buf.append(warning);
                buf.append("\n");
            }
            this.engine.getErrorWindow().warning(buf.toString());
            return;
        }

        try {
            // Generate a BPEL process.
            bpel.create(BPELScriptType.BPEL2);
            this.workflow.setGpelProcess(bpel.getGpelProcess());
            this.workflow.setWorkflowWSDL(bpel.getWorkflowWSDL().getWsdlDefinitions());
        } catch (GraphException e) {
            this.engine.getErrorWindow().error(ErrorMessages.GRAPH_NOT_READY_ERROR, e);
            return;
        }

        // Create a GUI without depending on the graph.
        List<WSComponentPort> inputs;
        try {

            inputs = this.workflow.getInputs();
        } catch (ComponentException e) {
            // This should not happen when we create WSDL here, but if we use
            // precompiled workflow, it might happen.
            this.engine.getErrorWindow().error(ErrorMessages.WORKFLOW_WSDL_ERROR, e);
            return;
        }
        List<Double> columnWeights = new ArrayList<Double>();
        long timeNow = System.currentTimeMillis();
        SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
        for (WSComponentPort input : inputs) {

            // Somethign special for the control workflow
            if (-1 != engine.getWorkflow().getName().indexOf("Control_")) {
                if ("epr".equals(input.getName())) {
                    input.setDefaultValue("https://pagodatree.cs.indiana.edu:17443/ode/processes/"
                            + engine.getWorkflow().getName() + "?wsdl");
                } else if ("operation".equals(input.getName())) {
                    input.setDefaultValue("Run");
                } else if ("startTime".equals(input.getName())) {
                    Date now = new Date(timeNow);
                    input.setDefaultValue(format.format(now));
                } else if ("endTime".equals(input.getName())) {
                    input.setDefaultValue(format.format(new Date(timeNow + 2 * 60 * 60 * 1000)));
                } else if ("eql".equals(input.getName())) {
                    input.setDefaultValue("select * from java.lang.String.win:length_batch(1)");
                }
            }

            String id = input.getName();
            QName type = input.getType();
            JLabel paramLabel = new JLabel(id, SwingConstants.TRAILING);
            JLabel typeLabel = new JLabel(type.getLocalPart());
            XBayaTextComponent paramField;
            if (LEADTypes.isKnownType(type)) {
                paramField = new XBayaTextField();
                columnWeights.add(new Double(0));
            } else {
                paramField = new XBayaTextArea();
                columnWeights.add(new Double(1.0));
            }
            paramLabel.setLabelFor(paramField.getSwingComponent());

            // default value
            Object value = input.getDefaultValue();
            String valueString = null;
            if (value != null) {
                if (value instanceof XmlElement) {
                    XmlElement valueElement = (XmlElement) value;
                    valueString = XMLUtil.xmlElementToString(valueElement);
                } else {
                    // Only string comes here for now.
                    valueString = value.toString();
                }
            }

            if (valueString == null) {
                // show some sample URI to ease inputs.
                final String sampleURI = "gsiftp://rainier.extreme.indiana.edu//tmp/foo.txt";
                if (LEADTypes.isURIType(type)) {
                    valueString = sampleURI;
                } else if (LEADTypes.isURIArrayType(type)) {
                    StringBuffer buf = new StringBuffer();
                    for (int i = 0; i < 4; i++) {
                        buf.append(sampleURI).append(" ");
                    }
                    valueString = buf.toString();
                }
            }
            paramField.setText(valueString);

            this.parameterPanel.add(paramLabel);
            this.parameterPanel.add(typeLabel);
            this.parameterPanel.add(paramField);
            this.parameterTextFields.add(paramField);
        }
        List<Double> rowWeights = new ArrayList<Double>();
        rowWeights.add(new Double(0));
        rowWeights.add(new Double(0));
        rowWeights.add(new Double(1));
        this.parameterPanel.layout(columnWeights, rowWeights);

        XBayaConfiguration configuration = this.engine.getConfiguration();
        MonitorConfiguration monitorConfiguration = this.engine.getMonitor().getConfiguration();

        // Topic
        String topic = monitorConfiguration.getTopic();
        if (topic != null) {
            this.topicTextField.setText(topic);
        } else {
            this.topicTextField.setText(UUID.randomUUID().toString());
        }
View Full Code Here


     * Shows the dialog.
     */
    public void show() {
        this.workflow = this.engine.getWorkflow();

        MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
        if (notifConfig.getBrokerURL() == null) {
            this.engine.getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR);
            return;
        }

        // Create input fields
View Full Code Here

        // Use topic as a base of workflow instance ID so that the monitor can
        // find it.
        URI workfowInstanceID = URI.create(StringUtil.convertToJavaIdentifier(topic));
        this.workflow.setGPELInstanceID(workfowInstanceID);

        MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
        notifConfig.setTopic(topic);
        arguments.add("-" + JythonScript.TOPIC_VARIABLE);
        arguments.add(topic);
        Collection<WSNode> wsNodes = GraphUtil.getWSNodes(this.engine.getWorkflow().getGraph());
        for (WSNode node : wsNodes) {
            ((WSNodeGUI) node.getGUI()).setInteractiveMode(false);
View Full Code Here

    public Monitor getWorkflowExecutionMonitor(String topic,
            MonitorEventListener listener) {
        final String fTopic = topic;
        try {
            monitorConfiguration = new MonitorConfiguration(new URI(
                    configuration.get(BROKER)), fTopic, true, new URI(
                            configuration.get(MSGBOX)));
        } catch (URISyntaxException e1) {
            e1.printStackTrace();
        }
View Full Code Here

    public XBayaEngine(XBayaConfiguration configuration) {
        this.configuration = configuration;

        // Creates some essential objects.

        MonitorConfiguration monitorConfiguration = new MonitorConfiguration(configuration.getBrokerURL(),
                configuration.getTopic(), configuration.isPullMode(), configuration.getMessageBoxURL());
        this.monitor = new Monitor(monitorConfiguration);

        // MyProxy
        // this.myProxyClient = new MyProxyClient(this.configuration.getMyProxyServer(),
View Full Code Here

            if (XBayaUtil.isURLExists(gfacUrl + "?wsdl")) {
                this.gfacUrlListField.addItem(gfacUrl);
            }
        }
        this.gfacUrlListField.setEditable(true);
        MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
        if (notifConfig.getBrokerURL() == null) {
            this.engine.getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR);
            return;
        }

        // Create input fields
View Full Code Here

        // Use topic as a base of workflow instance ID so that the monitor can
        // find it.
        URI workfowInstanceID = URI.create(StringUtil.convertToJavaIdentifier(topic));
        this.workflow.setGPELInstanceID(workfowInstanceID);

        MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
        notifConfig.setTopic(topic);
        arguments.add("-" + JythonScript.TOPIC_VARIABLE);
        arguments.add(topic);
        Collection<WSNode> wsNodes = GraphUtil.getWSNodes(this.engine.getWorkflow().getGraph());
        // This is to enable service interaction with the back end
        if (this.interactChkBox.isSelected()) {
            LinkedList<String> nodeIDs = new LinkedList<String>();
            for (WSNode node : wsNodes) {
                nodeIDs.add(node.getID());
                ((WSNodeGUI) node.getGUI()).setInteractiveMode(true);
            }
            notifConfig.setInteractiveNodeIDs(nodeIDs);
        } else {
            for (WSNode node : wsNodes) {
                ((WSNodeGUI) node.getGUI()).setInteractiveMode(false);
            }
        }

        final boolean isRunCrossProduct=chkRunWithCrossProduct.isSelected();
        // TODO error check for user inputs

        final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
        builder.newFragment("inputs");
        new ODEClient();
        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();
            inputNode.setDefaultValue(value);
        }

        // final String xregistryUrl = this.xRegistryTextField.getText();
        // if (null != xregistryUrl && !"".equals(xregistryUrl)) {
        // try {
        // this.engine.getConfiguration().setXRegistryURL(new URI(xregistryUrl));
        // } catch (URISyntaxException e) {
        // this.engine.getErrorWindow().error(e);
        // }
        // }

        final String gFacUrl = (String) this.gfacUrlListField.getSelectedItem();
        if (null != gFacUrl && !"".equals(gFacUrl)) {
            try {
                this.engine.getConfiguration().setGFacURL(new URI(gFacUrl));
            } catch (URISyntaxException e) {
                this.engine.getErrorWindow().error(e);
            }
        }
        this.engine.getConfiguration().setTopic(topic);

        /*
         * Load host description from xregistry and add to interpreter
         */
        LeadResourceMapping mapping = null;
        // String host = this.resourceSelectionComboBox.getText();
        // if (host != null && !host.isEmpty()) {
        // XRegistryAccesser xregistryAccesser = new XRegistryAccesser(this.engine);
        //
        // HostDescriptionRegistrationWindow hostWindow = HostDescriptionRegistrationWindow.getInstance();
        //
        // if (!hostWindow.isEngineSet()) {
        // hostWindow.setXBayaEngine(this.engine);
        // }
        //
        // HostBean hostBean = xregistryAccesser.getHostBean(host);
        //
        // mapping = new LeadResourceMapping(host);
        // try {
        // mapping.setGatekeeperEPR(new URI(hostBean.getGateKeeperendPointReference()));
        // } catch (Exception e) {
        // this.engine.getErrorWindow().error(e);
        // }
        //
        // }

        final LeadResourceMapping resourceMapping = mapping;
        final String topicString = topic;
        new Thread() {
            /**
             * @see java.lang.Thread#run()
             */
            @Override
            public void run() {

                WorkflowInterpreter workflowInterpreter = new WorkflowInterpreter(
                        DynamicWorkflowRunnerWindow.this.engine, topicString);
                workflowInterpreter.setRunWithCrossProduct(isRunCrossProduct);
                try {
                    MonitorConfiguration notifConfig = DynamicWorkflowRunnerWindow.this.engine.getMonitor()
                            .getConfiguration();
                    notifConfig.setTopic(topicString);
                    DynamicWorkflowRunnerWindow.this.engine.getMonitor().start();

                    if (resourceMapping != null)
                        workflowInterpreter.setResourceMapping(resourceMapping);

View Full Code Here

     * @see org.apache.airavata.xbaya.event.EventListener#eventReceived(org.apache.airavata.xbaya.event.Event)
     */
    public void eventReceived(Event event) {
        Type type = event.getType();
        if (type.equals(Event.Type.MONITOR_CONFIGURATION_CHANGED)) {
            MonitorConfiguration configuration = this.engine.getMonitor().getConfiguration();
            boolean valid = configuration.isValid();
            resumeMonitoringItem.setVisible(valid);
            pauseMonitoringItem.setVisible(false);
            resetMonitoringItem.setVisible(false);
        } else if (type.equals(Event.Type.MONITOR_STARTED)) {
            resumeMonitoringItem.setVisible(false);
View Full Code Here

        this.topicTextField = topicTextField;
        this.parameterTextFields = parameterTextFields;
        this.gfacTextField = new XBayaTextField();
        this.script = new JythonScript(this.workflow, this.engine.getConfiguration());

        MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
        if (notifConfig.getBrokerURL() == null) {
            this.engine.getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR);
            return;
        }

        // Check if the workflow is valid before the user types in input
View Full Code Here

     */
    public void show() {
        this.workflow = this.engine.getWorkflow();
        this.script = new JythonScript(this.workflow, this.engine.getConfiguration());

        MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
        if (notifConfig.getBrokerURL() == null) {
            this.engine.getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR);
            return;
        }

        // Check if the workflow is valid before the user types in input
        // values.
        ArrayList<String> warnings = new ArrayList<String>();
        if (!this.script.validate(warnings)) {
            StringBuilder buf = new StringBuilder();
            for (String warning : warnings) {
                buf.append("- ");
                buf.append(warning);
                buf.append("\n");
            }
            this.engine.getErrorWindow().warning(buf.toString());
            return;
        }

        // Create a script here. It might throw some exception because the
        // validation is not perfect.
        try {
            this.script.create();
        } catch (GraphException e) {
            this.engine.getErrorWindow().error(ErrorMessages.GRAPH_NOT_READY_ERROR, e);
            hide();
            return;
        } catch (RuntimeException e) {
            this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            hide();
            return;
        } catch (Error e) {
            this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            hide();
            return;
        }

        // Create input fields
        Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
        for (InputNode node : inputNodes) {
            String id = node.getID();
            QName parameterType = node.getParameterType();
            JLabel nameLabel = new JLabel(id);
            JLabel typeField = new JLabel(parameterType.getLocalPart());
            XBayaTextField paramField = new XBayaTextField();
            Object value = node.getDefaultValue();

            String valueString;
            if (value == null) {
                valueString = "";
            } else {
                if (value instanceof XmlElement) {
                    XmlElement valueElement = (XmlElement) value;
                    valueString = XMLUtil.xmlElementToString(valueElement);
                } else {
                    // Only string comes here for now.
                    valueString = value.toString();
                }
            }
            paramField.setText(valueString);
            this.parameterPanel.add(nameLabel);
            this.parameterPanel.add(typeField);
            this.parameterPanel.add(paramField);
            this.parameterTextFields.add(paramField);
        }
        this.parameterPanel.layout(inputNodes.size(), 3, GridPanel.WEIGHT_NONE, 2);

        this.topicTextField.setText(notifConfig.getTopic());

        XBayaConfiguration config = this.engine.getConfiguration();

        URI gfacURL = config.getGFacURL();
        this.gfacTextField.setText(StringUtil.toString(gfacURL));
View Full Code Here

TOP

Related Classes of org.apache.airavata.xbaya.monitor.MonitorConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.