Package org.drools.time.impl

Examples of org.drools.time.impl.PseudoClockScheduler


        if( globalResolver != null ) {
            session.setGlobalResolver( globalResolver );
        }

        if ( session.getTimerService() instanceof PseudoClockScheduler ) {
            PseudoClockScheduler clock = (PseudoClockScheduler) session.getTimerService();
            clock.advanceTime( _session.getTime(),
                               TimeUnit.MILLISECONDS );
        }

        // RuleFlowGroups need to reference the session
        for ( RuleFlowGroup group : agenda.getRuleFlowGroupsMap().values() ) {
View Full Code Here


            DefaultAgenda agenda,
            long time,
            boolean multithread,
            MarshallerReaderContext context ) throws IOException, ClassNotFoundException {
        if (session.getTimerService() instanceof PseudoClockScheduler) {
            PseudoClockScheduler clock = (PseudoClockScheduler) session.getTimerService();
            clock.advanceTime( time,
                               TimeUnit.MILLISECONDS );
        }

        // RuleFlowGroups need to reference the session
        for (RuleFlowGroup group : agenda.getRuleFlowGroupsMap().values()) {
View Full Code Here

        if( globalResolver != null ) {
            session.setGlobalResolver( globalResolver );
        }

        if ( session.getTimerService() instanceof PseudoClockScheduler ) {
            PseudoClockScheduler clock = (PseudoClockScheduler) session.getTimerService();
            clock.advanceTime( _session.getTime(),
                               TimeUnit.MILLISECONDS );
        }

        // RuleFlowGroups need to reference the session
        for ( RuleFlowGroup group : agenda.getRuleFlowGroupsMap().values() ) {
View Full Code Here

            DefaultAgenda agenda,
            long time,
            boolean multithread,
            MarshallerReaderContext context ) throws IOException, ClassNotFoundException {
        if (session.getTimerService() instanceof PseudoClockScheduler) {
            PseudoClockScheduler clock = (PseudoClockScheduler) session.getTimerService();
            clock.advanceTime( time,
                               TimeUnit.MILLISECONDS );
        }

        // RuleFlowGroups need to reference the session
        for (RuleFlowGroup group : agenda.getRuleFlowGroupsMap().values()) {
View Full Code Here

       
        knowledgeBase.addKnowledgePackages(Collections.singleton((KnowledgePackage) impl));
        SessionConfiguration config = new SessionConfiguration();
        config.setClockType(ClockType.PSEUDO_CLOCK);
        StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession(config, KnowledgeBaseFactory.newEnvironment());
        PseudoClockScheduler scheduler = ksession.getSessionClock();
        Marshaller marshaller = MarshallerFactory.newMarshaller(knowledgeBase);
       


        ksession.insert("cheese");
        assertTrue(fired.isEmpty());
        //marshall, then unmarshall session
        readWrite(knowledgeBase, ksession, config);
        //the activations should fire after 10 seconds
        assertTrue(fired.isEmpty());
        scheduler.advanceTime(12, TimeUnit.SECONDS);
        assertFalse(fired.isEmpty());

    }
View Full Code Here

        assertEquals( 1, bep.getFactHandles().size() );
       
        cep = ksession.getWorkingMemoryEntryPoint( "c-ep" );
        assertEquals( 1, cep.getFactHandles().size() );
       
        PseudoClockScheduler timeService = ( PseudoClockScheduler ) ksession.getSessionClock();       
        timeService.advanceTime( 11, TimeUnit.SECONDS );      
       
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        ksession.fireAllRules();
       
View Full Code Here

        WorkingMemoryEntryPoint aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
       
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        PseudoClockScheduler timeService = ( PseudoClockScheduler ) ksession.getSessionClock();       
        timeService.advanceTime( 3, TimeUnit.SECONDS )
       
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        ksession.fireAllRules();
       
View Full Code Here

        list.clear();
        ksession.fireAllRules();
        ksession = marsallStatefulKnowledgeSession(ksession);
        assertEquals( 2, ((List)list.get( 0 )).size() );
       
        PseudoClockScheduler timeService = ( PseudoClockScheduler ) ksession.getSessionClock();       
        timeService.advanceTime( 15, TimeUnit.SECONDS );         
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
        aep.insert( new A() );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        list.clear();
        ksession.fireAllRules();
        ksession = marsallStatefulKnowledgeSession(ksession);
        assertEquals( 4, ((List)list.get( 0 )).size() );
       
        timeService = ( PseudoClockScheduler ) ksession.getSessionClock();       
        timeService.advanceTime( 20, TimeUnit.SECONDS );
        ksession = marsallStatefulKnowledgeSession(ksession);
       
        list.clear();
        ksession.fireAllRules();
        assertEquals( 1, list.size() );
View Full Code Here

            DefaultAgenda agenda,
            long time,
            boolean multithread,
            MarshallerReaderContext context ) throws IOException, ClassNotFoundException {
        if (session.getTimerService() instanceof PseudoClockScheduler) {
            PseudoClockScheduler clock = (PseudoClockScheduler) session.getTimerService();
            clock.advanceTime( time,
                               TimeUnit.MILLISECONDS );
        }

        // RuleFlowGroups need to reference the session
        for (RuleFlowGroup group : agenda.getRuleFlowGroupsMap().values()) {
View Full Code Here

        SessionConfiguration conf = new SessionConfiguration();
        conf.setClockType( ClockType.PSEUDO_CLOCK );
        StatefulSession wm = ruleBase.newStatefulSession( conf,
                                                          null );

        final PseudoClockScheduler clock = (PseudoClockScheduler) wm.getSessionClock();

        clock.setStartupTime( 1000 );
        final List results_coincides = new ArrayList();
        final List results_before = new ArrayList();
        final List results_after = new ArrayList();
        final List results_meets = new ArrayList();
        final List results_met_by = new ArrayList();
        final List results_overlaps = new ArrayList();
        final List results_overlapped_by = new ArrayList();
        final List results_during = new ArrayList();
        final List results_includes = new ArrayList();
        final List results_starts = new ArrayList();
        final List results_started_by = new ArrayList();
        final List results_finishes = new ArrayList();
        final List results_finished_by = new ArrayList();

        wm.setGlobal( "results_coincides",
                      results_coincides );
        wm.setGlobal( "results_before",
                      results_before );
        wm.setGlobal( "results_after",
                      results_after );
        wm.setGlobal( "results_meets",
                      results_meets );
        wm.setGlobal( "results_met_by",
                      results_met_by );
        wm.setGlobal( "results_overlaps",
                      results_overlaps );
        wm.setGlobal( "results_overlapped_by",
                      results_overlapped_by );
        wm.setGlobal( "results_during",
                      results_during );
        wm.setGlobal( "results_includes",
                      results_includes );
        wm.setGlobal( "results_starts",
                      results_starts );
        wm.setGlobal( "results_started_by",
                      results_started_by );
        wm.setGlobal( "results_finishes",
                      results_finishes );
        wm.setGlobal( "results_finished_by",
                      results_finished_by );

        StockTickInterface tick1 = new StockTick( 1,
                                                  "DROO",
                                                  50,
                                                  System.currentTimeMillis(),
                                                  3 );
        StockTickInterface tick2 = new StockTick( 2,
                                                  "ACME",
                                                  10,
                                                  System.currentTimeMillis(),
                                                  3 );
        StockTickInterface tick3 = new StockTick( 3,
                                                  "ACME",
                                                  10,
                                                  System.currentTimeMillis(),
                                                  3 );
        StockTickInterface tick4 = new StockTick( 4,
                                                  "DROO",
                                                  50,
                                                  System.currentTimeMillis(),
                                                  5 );
        StockTickInterface tick5 = new StockTick( 5,
                                                  "ACME",
                                                  10,
                                                  System.currentTimeMillis(),
                                                  5 );
        StockTickInterface tick6 = new StockTick( 6,
                                                  "ACME",
                                                  10,
                                                  System.currentTimeMillis(),
                                                  3 );
        StockTickInterface tick7 = new StockTick( 7,
                                                  "ACME",
                                                  10,
                                                  System.currentTimeMillis(),
                                                  5 );
        StockTickInterface tick8 = new StockTick( 8,
                                                  "ACME",
                                                  10,
                                                  System.currentTimeMillis(),
                                                  3 );

        InternalFactHandle handle1 = (InternalFactHandle) wm.insert( tick1 );
        clock.advanceTime( 4,
                           TimeUnit.MILLISECONDS );
        InternalFactHandle handle2 = (InternalFactHandle) wm.insert( tick2 );
        clock.advanceTime( 4,
                           TimeUnit.MILLISECONDS );
        InternalFactHandle handle3 = (InternalFactHandle) wm.insert( tick3 );
        clock.advanceTime( 4,
                           TimeUnit.MILLISECONDS );
        InternalFactHandle handle4 = (InternalFactHandle) wm.insert( tick4 );
        InternalFactHandle handle5 = (InternalFactHandle) wm.insert( tick5 );
        clock.advanceTime( 1,
                           TimeUnit.MILLISECONDS );
        InternalFactHandle handle6 = (InternalFactHandle) wm.insert( tick6 );
        InternalFactHandle handle7 = (InternalFactHandle) wm.insert( tick7 );
        clock.advanceTime( 2,
                           TimeUnit.MILLISECONDS );
        InternalFactHandle handle8 = (InternalFactHandle) wm.insert( tick8 );

        assertNotNull( handle1 );
        assertNotNull( handle2 );
View Full Code Here

TOP

Related Classes of org.drools.time.impl.PseudoClockScheduler

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.