Package org.apache.ode.bpel.dao

Examples of org.apache.ode.bpel.dao.CorrelatorDAO


            for (OPartnerLink plink : process.getOProcess().getAllPartnerLinks()) {
                if (plink.hasMyRole()) {
                    for (Iterator opI = plink.myRolePortType.getOperations().iterator(); opI.hasNext();) {
                        Operation op = (Operation)opI.next();
                        try {
                            CorrelatorDAO corr = processDao.getCorrelator(plink.getId() + "." + op.getName());
                            corr.setCorrelatorId(plink.getName() + "." + op.getName());
                            __log.debug("Migrated correlator " + plink.getName() + "." + op.getName());
                        } catch (IllegalArgumentException e) {
                            __log.debug("Correlator with id " + plink.getId() + "." +
                                    op.getName() + " couldn't be found, skipping.");
                        }
View Full Code Here


        assertNotNull(p.getType());
        assertNotNull(p.getProcessId());
        assertEquals( p.getVersion() , 1 );

        // Assert the CorrelatorDAO
        CorrelatorDAO corr = p.getCorrelator(CORRELATOR_ID1);
        assertNotNull( corr );
        assertEquals(corr.getCorrelatorId(),CORRELATOR_ID1);

        // Assert the MessageRouteDAO
        List<MessageRouteDAO> routes = corr.findRoute(new CorrelationKeySet().add(key1));
        MessageRouteDAO route = null;
        if (routes != null && routes.size() > 0) {
            route = routes.get(0);
        }
        assertNotNull( route );
        assertEquals(route.getGroupId(),"testRoute" );
        assertEquals(route.getIndex() , 1 );
        assertNotNull(route.getTargetInstance() );

        // Assert the ProcessInstanceDAO
        for ( ProcessInstanceDAO inst : insts ) {
            Long id = inst.getInstanceId();
            assertNotNull( id );

            ProcessInstanceDAO inst2 = conn.getInstance(id);
            assertSame(inst2,inst);

            ProcessInstanceDAO inst3 = p.getInstance(id);
            assertSame( inst3 , inst );

            Long mon = inst.genMonotonic();
            assertEquals(inst.getActivityFailureCount() , 2);
            assertNotNull(inst.getActivityFailureDateTime() );
            assertNotNull(inst.getCreateTime() );
            assertTrue(inst.getExecutionState().length > 0 );
            assertNotNull(inst.getLastActiveTime() );
            assertSame(inst.getProcess() , p );
            assertEquals(inst.getPreviousState() , 0);
            assertEquals(inst.getState() , 1);

            // Assert the Root ScopeDAO
            ScopeDAO rs = inst.getRootScope();
            assertNotNull( rs );
            assertNotNull(rs.getChildScopes());
            ScopeDAO child1 = null;
            for ( ScopeDAO childItr : rs.getChildScopes()){
                child1 = childItr;
                break;
            }
            assertNotNull(child1);
            assertNotNull(rs.getCorrelationSets());
            assertEquals(rs.getCorrelationSets().size() , 0 );
            assertEquals(rs.getModelId(),1);
            assertEquals(rs.getName(),"Root");
            assertTrue(rs.getParentScope() == null);
            assertNotNull(rs.getPartnerLinks());
            assertEquals(rs.getPartnerLinks().size() ,0);
            assertSame(rs.getProcessInstance(),inst);
            assertNotNull(rs.getScopeInstanceId());
            assertEquals(rs.getState(),ScopeStateEnum.ACTIVE);
            assertNotNull(rs.getVariables());
            assertEquals(rs.getVariables().size(),0);


            // Assert the ActivityRecoveryDAO
            assertNotNull(inst.getActivityRecoveries());
            ActivityRecoveryDAO rec1 = null;
            for (ActivityRecoveryDAO recItr : inst.getActivityRecoveries()) {
       if (recItr.getActivityId() == 3) {
         rec1 = recItr;break;
       }
      }
            assertNotNull(rec1);
            String tmpAct = rec1.getActions();
//      assertEquals(rec1.getActionsList(),actions);
            assertEquals(rec1.getActivityId(),3);
            assertEquals(rec1.getChannel(),"testChannel1");
            assertNotNull(rec1.getDateTime());
//      assertNotNull(rec1.getDetails());
            assertEquals(rec1.getReason(),"testReason1");
            assertEquals(rec1.getRetries(),2);

            // Assert the CorrelationSetDAO
            //assertNotNull(inst.getCorrelationSets());
            //CorrelationSetDAO cs1 = null;
            //for ( CorrelationSetDAO csItr : inst.getCorrelationSets() ) {
            //  cs1 = csItr;
            //  break;
            //}
            //assertNotNull(cs1);

            // Assert the FaultDAO
            FaultDAO fault = inst.getFault();
            assertNotNull(fault);
            assertEquals(fault.getActivityId(),1);
            assertNotNull(fault.getData());
            assertEquals(fault.getExplanation(),"testExplanation");
            assertEquals(fault.getLineNo(),1);
            assertEquals(fault.getName(),new QName(TEST_NS,"testFault"));

            // Assert MessageExchangeDAO
            CorrelatorDAO ic = inst.getInstantiatingCorrelator();
            assertNotNull(ic);
            assertEquals(ic.getCorrelatorId(),CORRELATOR_ID1);
            // The message is dequeued but not persisted
            MessageExchangeDAO me = ic.dequeueMessage(new CorrelationKeySet().add(key1));
            assertNotNull(me);
            assertEquals(me.getCallee(),new QName(TEST_NS,"testCallee"));
            assertEquals(me.getPropagateTransactionFlag(),false);
            assertEquals(me.getChannel(),"testChannel");
            assertEquals(me.getCorrelationId(),"testCorrelationId");
View Full Code Here

    }

    void createStuff(BPELDAOConnectionFactoryImpl factory) throws Exception {
        BpelDAOConnection conn = factory.getConnection();

        CorrelatorDAO corr = createProcess(conn,"testPID1","testType");
        ProcessInstanceDAO pi1 = createProcessInstance(_process, corr);
    }
View Full Code Here

        return m;
    }

    private CorrelatorDAO createProcess(BpelDAOConnection conn, String pid, String type) {
        _process = conn.createProcess(new QName(TEST_NS,pid), new QName(TEST_NS,type),"GUID1",1);
        CorrelatorDAO corr = _process.addCorrelator(CORRELATOR_ID1);
        _process.addCorrelator(CORRELATOR_ID2);
        return corr;
    }
View Full Code Here

            throw new FaultException(_bpelProcess.getOProcess().constants.qnConflictingReceive, selectors[conflict]
                    .toString());

        // Check for ambiguous receive
        for (int i = 0; i < selectors.length; ++i) {
            CorrelatorDAO correlator = correlators.get(i);
            Selector selector = selectors[i];

            if (!correlator.checkRoute(selector.correlationKeySet)) {
                throw new FaultException(_bpelProcess.getOProcess().constants.qnAmbiguousReceive(), selector.toString());
            }
        }

        //Registering
        _imaManager.register(pickResponseChannelStr, selectors);

        // First check if we match to a new instance.
        if (_instantiatingMessageExchange != null && _dao.getState() == ProcessState.STATE_READY) {
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + ": CHECKING for NEW INSTANCE match");
            }
            for (int i = 0; i < correlators.size(); ++i) {
                CorrelatorDAO ci = correlators.get(i);
                if (ci.equals(_dao.getInstantiatingCorrelator())) {
                    inputMsgMatch(pickResponseChannelStr, i, _instantiatingMessageExchange);
                    if (BpelProcess.__log.isDebugEnabled()) {
                        BpelProcess.__log.debug("SELECT: " + pickResponseChannel
                                + ": FOUND match for NEW instance mexRef=" + _instantiatingMessageExchange);
                    }
                    return;
                }
            }
        }

        if (timeout != null) {
            registerTimer(pickResponseChannel, timeout);
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + "REGISTERED TIMEOUT for " + timeout);
            }
        }

        for (int i = 0; i < selectors.length; ++i) {
            CorrelatorDAO correlator = correlators.get(i);
            Selector selector = selectors[i];

            correlator.addRoute(ProcessUtil.exportChannel(pickResponseChannel), _dao, i, selector.correlationKeySet, selector.route);
            scheduleCorrelatorMatcher(correlator.getCorrelatorId(), selector.correlationKeySet);

            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + ": ADDED ROUTE " + correlator.getCorrelatorId() + ": "
                        + selector.correlationKeySet + " --> " + _dao.getInstanceId());
            }
        }
    }
View Full Code Here

     */
    public void matcherEvent(String correlatorId, CorrelationKeySet ckeySet) {
        if (BpelProcess.__log.isDebugEnabled()) {
            __log.debug("MatcherEvent handling: correlatorId=" + correlatorId + ", ckeySet=" + ckeySet);
        }
        CorrelatorDAO correlator = _dao.getProcess().getCorrelator(correlatorId);

        // Find the route first, this is a SELECT FOR UPDATE on the "selector" row,
        // So we want to acquire the lock before we do anthing else.
        List<MessageRouteDAO> mroutes = correlator.findRoute(ckeySet);
        if (mroutes == null || mroutes.size() == 0) {
            // Ok, this means that a message arrived before we did, so nothing to do.
            __log.debug("MatcherEvent handling: nothing to do, route no longer in DB");
            return;
        }

        // Now see if there is a message that matches this selector.
        MessageExchangeDAO mexdao = correlator.dequeueMessage(ckeySet);
        if (mexdao != null) {
            __log.debug("MatcherEvent handling: found matching message in DB (i.e. message arrived before <receive>)");
            if( MessageExchangePattern.REQUEST_RESPONSE.toString().equals(mexdao.getPattern())) {
                __log.warn("A message arrived before a receive is ready for a request/response pattern. This may be processed to success. However, you should consider revising your process since a TCP port and a container thread will be held for a longer time and the process will not scale under heavy load.");
            }

            for (MessageRouteDAO mroute : mroutes) {
                // We have a match, so we can get rid of the routing entries.
                correlator.removeRoutes(mroute.getGroupId(), _dao);
            }

            // Selecting first route to proceed, other matching entries are ignored
            MessageRouteDAO mroute = mroutes.get(0);

View Full Code Here

        // now, the tricks begin: when a message arrives we have to see if there
        // is anyone waiting for it. Get the correlator, a persisted communication-reduction
        // data structure supporting correlation correlationKey matching!
        String correlatorId = BpelProcess.genCorrelatorId(_plinkDef, operation.getName());

        CorrelatorDAO correlator = _process.getProcessDAO().getCorrelator(correlatorId);

        CorrelationKeySet keySet;

        // We need to compute the correlation keys (based on the operation
        // we can  infer which correlation keys to compute - this is merely a set
        // consisting of each correlationKey used in each correlation sets
        // that is ever referenced in an <receive>/<onMessage> on this
        // partnerlink/operation.
        try {
            keySet = computeCorrelationKeys(mex);
        } catch (InvalidMessageException ime) {
            // We'd like to do a graceful exit here, no sense in rolling back due to a
            // a message format problem.
            __log.debug("Unable to evaluate correlation keys, invalid message format. ",ime);
            mex.setFailure(MessageExchange.FailureType.FORMAT_ERROR, ime.getMessage(), null);
            return null;
        }

        String mySessionId = mex.getProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID);
        String partnerSessionId = mex.getProperty(MessageExchange.PROPERTY_SEP_PARTNERROLE_SESSIONID);
        if (__log.isDebugEnabled()) {
            __log.debug("INPUTMSG: " + correlatorId + ": MSG RCVD keys="
                    + keySet + " mySessionId=" + mySessionId
                    + " partnerSessionId=" + partnerSessionId);
        }

        // Try to find a route for one of our keys.
        List<MessageRouteDAO> messageRoutes = correlator.findRoute(keySet);
        if (messageRoutes != null && messageRoutes.size() > 0) {
            for (MessageRouteDAO messageRoute : messageRoutes) {
                if (__log.isDebugEnabled()) {
                    __log.debug("INPUTMSG: " + correlatorId + ": ckeySet " + messageRoute.getCorrelationKeySet() + " route is to " + messageRoute);
                }
View Full Code Here

    public QName getProcessId() {
        return _processId;
    }

    public CorrelatorDAO getCorrelator(String cid) {
        CorrelatorDAO ret = _correlators.get(cid);
        if (ret == null) {
            throw new IllegalArgumentException("no such correlator: " + cid);
        }
        return ret;
    }
View Full Code Here

    }
   
    public void testCleanup() throws Exception {
        SessionManager sm = ((BpelDAOConnectionImpl) daoConn)._sm;
        ProcessDAO p = daoConn.createProcess(QName.valueOf("abc"), QName.valueOf("abc"), "abc", 1);
        CorrelatorDAO correlator = p.addCorrelator("abc");
        ProcessInstanceDAO instance = p.createInstance(correlator);

        MessageExchangeDAO mex = daoConn.createMessageExchange('M');
        mex.setProperty("abc", "def");
        mex.setInstance(instance);
View Full Code Here

    public QName getProcessId() {
        return _processId;
    }

    public CorrelatorDAO getCorrelator(String cid) {
        CorrelatorDAO ret = _correlators.get(cid);
        if (ret == null) {
            throw new IllegalArgumentException("no such correlator: " + cid);
        }
        return ret;
    }
View Full Code Here

TOP

Related Classes of org.apache.ode.bpel.dao.CorrelatorDAO

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.