Package org.apache.airavata.workflow.tracking

Examples of org.apache.airavata.workflow.tracking.WorkflowNotifier


    public Object runWorkflow1(InvocationEntity myInvoker, URI myWorkflowID, URI myServiceID, String myNodeID,
            Integer myTimestep) throws XmlException {

        assert WORKFLOW_1.equals(myServiceID);

        WorkflowNotifier notifier = NotifierFactory.createWorkflowNotifier();
        WorkflowTrackingContext context = notifier.createTrackingContext(new Properties(), BROKER_URL, myWorkflowID,
                myServiceID, myNodeID, myTimestep);

        InvocationContext myInvocation = notifier.workflowInvoked(context, myInvoker,
                XmlObject.Factory.parse("<soapHeader/>"),
                XmlObject.Factory.parse("<soapBody>input1,input2</soapBody>"), "This is the start of this workflow");

        // BEGIN SERVICE1
        {
            // prepare to invoke service1
            InvocationEntity service1 = notifier.createEntity(myServiceID, SERVICE_1, "NODE1", 1);
            InvocationContext service1Invocation = notifier.invokingService(context, service1,
                    XmlObject.Factory.parse("<soapHeader/>"), XmlObject.Factory.parse("<soapBody>input1</soapBody>"),
                    "This workflow is invoking a service");

            Object result = null;
            try {
                // prepare to invoke service1
                result = runService1(service1, service1.getWorkflowID(), service1.getServiceID(),
                        service1.getWorkflowNodeID(), service1.getWorkflowTimestep());

                // If this were an async invocation, we would have finished
                // sending request.
                // we acknowledge the successful request.
                notifier.invokingServiceSucceeded(context, service1Invocation, "Invoked service1 successfully");

            } catch (Exception ex) {
                // If there had been a problem sending the request on the wire,
                // we acknowledge a failed request.
                notifier.invokingServiceFailed(context, service1Invocation, ex, "Failed to invoke service1");
            }

            // At this point, we would have waited for response from service1 if
            // it were an async call.
            // assume we received response at this point and continue.
            if (result instanceof Success) {
                notifier.receivedResult(context, service1Invocation, ((Success) result).header,
                        ((Success) result).body, "got success response from service1");
            } else if (result instanceof Failure) {
                notifier.receivedFault(context, service1Invocation, ((Failure) result).header, ((Failure) result).body,
                        "got fault response from service1");
            }

        }

        // BEGIN SERVICE2
        {
            // prepare to invoke service1
            InvocationEntity service2 = notifier.createEntity(myServiceID, SERVICE_2, "NODE2", 2);
            InvocationContext service1Invocation = notifier.invokingService(context, service2,
                    XmlObject.Factory.parse("<soapHeader/>"),
                    XmlObject.Factory.parse("<soapBody>input2,input3</soapBody>"),
                    "This workflow is invoking another service");

            Object result = null;
            try {
                // prepare to invoke service2
                result = runService2(service2, service2.getWorkflowID(), service2.getServiceID(),
                        service2.getWorkflowNodeID(), service2.getWorkflowTimestep());

                // If this were an async invocation, we would have finished
                // sending request.
                // we acknowledge the successful request.
                notifier.invokingServiceSucceeded(context, service1Invocation, "Invoked service2 successfully");

            } catch (Exception ex) {
                // If there had been a problem sending the request on the wire,
                // we acknowledge a failed request.
                notifier.invokingServiceFailed(context, service1Invocation, ex, "Failed to invoke service2");
            }

            // At this point, we would have waited for response from service1 if
            // it were an async call.
            // assume we received response at this point and continue.
            if (result instanceof Success) {
                notifier.receivedResult(context, service1Invocation, ((Success) result).header,
                        ((Success) result).body, "got success response from service2");
            } else if (result instanceof Failure) {
                notifier.receivedFault(context, service1Invocation, ((Failure) result).header, ((Failure) result).body,
                        "got fault response from service2");
            }

        }

        Object result = null;
        notifier.sendingResult(context, myInvocation, "sending result back to the invoker of this workflow");
        try {
            result = new Success();
            notifier.sendingResponseSucceeded(context, myInvocation, "sent result to invoker");
        } catch (Exception ex) {
            notifier.sendingResponseFailed(context, myInvocation, ex);
        }

        return result;
    }
View Full Code Here


        WorkflowTrackingContext context = notifier.createTrackingContext(null, BROKER_URL, WORKFLOW_1, SERVICE_0, null,
                null);
        // create workflow and service instances
        {

            WorkflowNotifier notifier = NotifierFactory.createWorkflowNotifier();
            notifier.workflowInitialized(context, WORKFLOW_1, "Workflow ready to start",
                    "<wfInfo>some annotation about the workflow</wfInfo>",
                    "<dummy>just to check annotations list</dummy>");
            notifier.serviceInitialized(context, SERVICE_1);
            notifier.serviceInitialized(context, SERVICE_2);
        }

        {
            GenericNotifier notifier = NotifierFactory.createGenericNotifier();
            InvocationEntity initiatingService = notifier.createEntity(null, SERVICE_0, null, null);

            runWorkflow1(initiatingService, null, WORKFLOW_1, null, null);
        }

        // terminate workflow and service instances
        {
            WorkflowNotifier notifier = NotifierFactory.createWorkflowNotifier();
            notifier.workflowTerminated(context, WORKFLOW_1);
            notifier.serviceTerminated(context, SERVICE_1);
            notifier.serviceTerminated(context, SERVICE_2);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.workflow.tracking.WorkflowNotifier

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.