Package org.apache.ode.jacob

Examples of org.apache.ode.jacob.ReceiveProcess


        private HashSet<CompensationHandler> _compensations = new HashSet<CompensationHandler>();

        public void run() {
            Iterator<ChildInfo> active = active();
            if (active.hasNext()) {
                CompositeProcess mlSet = ProcessUtil.compose(new ReceiveProcess() {
                    private static final long serialVersionUID = 2554750258974084466L;
                }.setChannel(_self.self).setReceiver(new Termination() {
                    public void terminate() {
                        for (Iterator<ChildInfo> i = active(); i.hasNext(); )
                            replication(i.next().activity.self).terminate();
                        instance(ACTIVE.this);
                    }
                }));

                for (;active.hasNext();) {
                    final ChildInfo child = active.next();
                    mlSet.or(new ReceiveProcess() {
                        private static final long serialVersionUID = -8027205709169238172L;
                    }.setChannel(child.activity.parent).setReceiver(new ParentScope() {
                        public void completed(FaultData faultData, Set<CompensationHandler> compensations) {
                            child.completed = true;
                            _compensations.addAll(compensations);
View Full Code Here


        WAITER(ActivityInfo child) {
            _child = child;
        }

        public void run() {
            object(false, compose(new ReceiveProcess() {
                private static final long serialVersionUID = -5471984635653784051L;
            }.setChannel(_self.self).setReceiver(new Termination() {
                public void terminate() {
                    _terminated = true;
                    replication(_child.self).terminate();
                    instance(WAITER.this);
                }
            })).or(new ReceiveProcess() {
                private static final long serialVersionUID = 3907167240907524405L;
            }.setChannel(_child.parent).setReceiver(new ParentScope() {
                public void compensate(OScope scope, Synch ret) {
                    _self.parent.compensate(scope,ret);
                    instance(WAITER.this);
View Full Code Here

        private WAITING(PickResponse pickResponseChannel) {
            this._pickResponseChannel = pickResponseChannel;
        }

        public void run() {
            object(false, compose(new ReceiveProcess() {
                private static final long serialVersionUID = -8237296827418738011L;
            }.setChannel(_pickResponseChannel).setReceiver(new PickResponse() {
                public void onRequestRcvd(int selectorIdx, String mexId) {
                    OPickReceive.OnMessage onMessage = _opick.onMessages.get(selectorIdx);

                    // dead path the non-selected onMessage blocks.
                    for (OPickReceive.OnMessage onmsg : _opick.onMessages) {
                        if (!onmsg.equals(onMessage)) {
                            dpe(onmsg.activity);
                        }
                    }

                    // dead-path the alarm (if any)
                    if (_alarm != null) {
                        dpe(_alarm.activity);
                    }

                    getBpelRuntimeContext().cancelOutstandingRequests(ProcessUtil.exportChannel(_pickResponseChannel));

                    FaultData fault;
                    initVariable(mexId, onMessage);
                    try {
                        VariableInstance vinst = _scopeFrame.resolve(onMessage.variable);
                        for (OScope.CorrelationSet cset : onMessage.initCorrelations) {
                            initializeCorrelation(_scopeFrame.resolve(cset), vinst);
                        }
                        for( OScope.CorrelationSet cset : onMessage.joinCorrelations ) {
                            // will be ignored if already initialized
                            initializeCorrelation(_scopeFrame.resolve(cset), vinst);
                        }
                        if (onMessage.partnerLink.hasPartnerRole()) {
                            // Trying to initialize partner epr based on a
                            // message-provided epr/session.

                            if (!getBpelRuntimeContext().isPartnerRoleEndpointInitialized(
                                    _scopeFrame.resolve(onMessage.partnerLink))
                                    || !onMessage.partnerLink.initializePartnerRole) {

                                Node fromEpr = getBpelRuntimeContext().getSourceEPR(mexId);
                                if (fromEpr != null) {
                                    if (__log.isDebugEnabled())
                                        __log.debug("Received callback EPR " + DOMUtils.domToString(fromEpr)
                                                + " saving it on partner link " + onMessage.partnerLink.getName());
                                    getBpelRuntimeContext().writeEndpointReference(
                                            _scopeFrame.resolve(onMessage.partnerLink), (Element) fromEpr);
                                }
                            }

                            String partnersSessionId = getBpelRuntimeContext().getSourceSessionId(mexId);
                            if (partnersSessionId != null)
                                getBpelRuntimeContext().initializePartnersSessionId(
                                        _scopeFrame.resolve(onMessage.partnerLink), partnersSessionId);

                        }
                        // this request is now waiting for a reply
                        getBpelRuntimeContext().processOutstandingRequest(_scopeFrame.resolve(onMessage.partnerLink),
                                onMessage.operation.getName(), onMessage.messageExchangeId, mexId);

                    } catch (FaultException e) {
                        __log.error(e);
                        fault = createFault(e.getQName(), onMessage);
                        _self.parent.completed(fault, CompensationHandler.emptySet());
                        dpe(onMessage.activity);
                        return;
                    }


                    // load 'onMessage' activity
                    // Because we are done with all the DPE, we can simply
                    // re-use our control
                    // channels for the child.
                    ActivityInfo child = new ActivityInfo(genMonotonic(), onMessage.activity, _self.self, _self.parent);
                    instance(createChild(child, _scopeFrame, _linkFrame));
                }

                public void onTimeout() {
                    // Dead path all the onMessage activiites (the other alarms
                    // have already been DPE'ed)
                    for (OPickReceive.OnMessage onMessage : _opick.onMessages) {
                        dpe(onMessage.activity);
                    }

                    // Because we are done with all the DPE, we can simply
                    // re-use our control
                    // channels for the child.
                    ActivityInfo child = new ActivityInfo(genMonotonic(), _alarm.activity, _self.self, _self.parent);
                    instance(createChild(child, _scopeFrame, _linkFrame));
                }

                public void onCancel() {
                    _self.parent.completed(null, CompensationHandler.emptySet());
                }

            })).or(new ReceiveProcess() {
                private static final long serialVersionUID = 4399496341785922396L;
            }.setChannel(_self.self).setReceiver(new Termination() {
                public void terminate() {
                    getBpelRuntimeContext().cancel(_pickResponseChannel);
                    instance(WAITING.this);
View Full Code Here

        if(dueDate.getTime() > getBpelRuntimeContext().getCurrentEventDateTime().getTime()) {
            final TimerResponse timerChannel = newChannel(TimerResponse.class);
            getBpelRuntimeContext().registerTimer(timerChannel, dueDate);

            object(false, compose(new ReceiveProcess() {
                private static final long serialVersionUID = 3120518305645437327L;
            }.setChannel(timerChannel).setReceiver(new TimerResponse() {
                public void onTimeout() {
                    _self.parent.completed(null, CompensationHandler.emptySet());
                }

                public void onCancel() {
                    _self.parent.completed(null, CompensationHandler.emptySet());
                }
            })).or(new ReceiveProcess() {
                private static final long serialVersionUID = -2791243270691333946L;
            }.setChannel(_self.self).setReceiver(new Termination() {
                public void terminate() {
                    _self.parent.completed(null, CompensationHandler.emptySet());
                    object(new ReceiveProcess() {
                        private static final long serialVersionUID = 677746737897792929L;
                    }.setChannel(timerChannel).setReceiver(new TimerResponse() {
                        public void onTimeout() {
                            //ignore
                        }
View Full Code Here

        ACTIVE(ActivityInfo child) {
            _child = child;
        }

        public void run() {
            object(false, compose(new ReceiveProcess() {
                private static final long serialVersionUID = -2680515407515637639L;
            }.setChannel(_self.self).setReceiver(new Termination() {
                public void terminate() {
                    replication(_child.self).terminate();

                    // Don't do any of the remaining activiites, DPE instead.
                    ArrayList<OActivity> remaining = new ArrayList<OActivity>(_remaining);
                    remaining.remove(0);
                    deadPathRemaining(remaining);

                    _terminateRequested = true;
                    instance(ACTIVE.this);
                }
            })).or(new ReceiveProcess() {
                private static final long serialVersionUID = 7195562310281985971L;
            }.setChannel(_child.parent).setReceiver(new ParentScope() {
                public void compensate(OScope scope, Synch ret) {
                    _self.parent.compensate(scope,ret);
                    instance(ACTIVE.this);
View Full Code Here

            _ret.ret();
        } else {
            Synch r = newChannel(Synch.class);
            CompensationHandler cdata = _compensations.remove(0);
            cdata.compChannel.compensate(r);
            object(new ReceiveProcess() {
                private static final long serialVersionUID = 7173916663479205420L;
            }.setChannel(r).setReceiver(new Synch() {
                public void ret() {
                    instance(ORDEREDCOMPENSATOR.this);
                }
View Full Code Here

            __log.debug("LINKSTATUSINTERCEPTOR: running ");

            CompositeProcess mlset = ProcessUtil.compose(null);
            if (_status == null)
                mlset.or(new ReceiveProcess() {
                    private static final long serialVersionUID = 5029554538593371750L;
                }.setChannel(_self).setReceiver(new Val() {
                    /** Our owner will notify us when it becomes clear what to do with the links. */
                    public void val(Object retVal) {
                        if (__log.isDebugEnabled()) {
                            __log.debug("LINKSTATUSINTERCEPTOR: status received " + retVal);
                        }
                       
                        _status = (Boolean) retVal;
                        for (OLink available : _statuses.keySet())
                            _linkFrame.resolve(available).pub.linkStatus(_statuses.get(available) && _status);
   
                        // Check if we still need to wait around for more links.
                        if (!isDone()) {
                            instance(LINKSTATUSINTERCEPTOR.this);
                        }
                    }
                }));

            for (final Map.Entry<OLink, LinkInfo> m : _interceptedChannels.links.entrySet()) {
                if (_statuses.containsKey(m.getKey()))
                    continue;
           
                mlset.or(new ReceiveProcess() {
                    private static final long serialVersionUID = 1568144473514091593L;
                }.setChannel(m.getValue().pub).setReceiver(new LinkStatus() {
                    public void linkStatus(boolean value) {
                        _statuses.put(m.getKey(), value);
                        if (_status != null) {
View Full Code Here

                if (il.writeLock)
                    il.lockChannel.writeLock(_synchChannel);
                else
                    il.lockChannel.readLock(_synchChannel);

                object(new ReceiveProcess() {
                    private static final long serialVersionUID = 2857261074409098274L;
                }.setChannel(_synchChannel).setReceiver(new Synch() {
                    public void ret() {
                        __log.debug("ISOLATIONGUARD: got lock: " + _locksNeeded.get(0));
                        _locksAcquired.add(_locksNeeded.remove(0));
View Full Code Here

        @Override
        public void run() {

            __log.debug("running UNLOCKER");
            object(new ReceiveProcess() {
                private static final long serialVersionUID = 1L;
            }.setChannel(_self).setReceiver(new ParentScope() {
                public void cancelled() {
                    _parent.cancelled();
                    unlockAll();
View Full Code Here

        _completedChildren = visibleCompensations;
    }

    public void run() {
        sendEvent(new CompensationHandlerRegistered());
        object(new ReceiveProcess() {
            private static final long serialVersionUID = -477602498730810094L;
        }.setChannel(_self.compChannel).setReceiver(new Compensation() {
            public void forget() {
                // Tell all our completed children to forget.
                for (Iterator<CompensationHandler> i = _completedChildren.iterator(); i.hasNext(); )
                    i.next().compChannel.forget();
            }

            public void compensate(final Synch ret) {
                // Only scopes with compensation handlers can be compensated.
                assert _self.compensated.oscope.compensationHandler != null;

                ActivityInfo ai = new ActivityInfo(genMonotonic(),
                    _self.compensated.oscope.compensationHandler,
                    newChannel(Termination.class), newChannel(ParentScope.class));


                ScopeFrame compHandlerScopeFrame = new ScopeFrame(
                    _self.compensated.oscope.compensationHandler,
                    getBpelRuntimeContext().createScopeInstance(_self.compensated.scopeInstanceId, _self.compensated.oscope.compensationHandler),
                    _self.compensated,
                    _completedChildren);

                // Create the compensation handler scope.
                instance(new SCOPE(ai,compHandlerScopeFrame, new LinkFrame(null)));

                object(new ReceiveProcess() {
                    private static final long serialVersionUID = 8044120498580711546L;
                }.setChannel(ai.parent).setReceiver(new ParentScope() {
                    public void compensate(OScope scope, Synch ret) {
                        throw new AssertionError("Unexpected.");
                    }
View Full Code Here

TOP

Related Classes of org.apache.ode.jacob.ReceiveProcess

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.