Package org.drools.command.impl

Examples of org.drools.command.impl.ContextImplWithEviction



    @Test
    public void simpleEvictionTest() throws InterruptedException {
        MessageReceiverHandler handler = new GridNodeImpl( "myNode", null ).getMessageReceiverHandler();
        ContextImplWithEviction contextTemp = (ContextImplWithEviction) ((GridNodeServer) handler).getData().getTemp();
        ((ContextImplWithEviction) contextTemp).setEntryEvictionTime(2000); // 2 seconds
        ((ContextImplWithEviction) contextTemp).setEvictionWakeUpTime(1000); // 1 seconds
        JDKTimerService timer = new JDKTimerService(1);
       
        contextTemp.set("myvalue", "value");


        Long evictionWakeUpTime = contextTemp.getEvictionWakeUpTime();


        timer.scheduleJob(new EvictionJob(contextTemp), new MockJobContext(), new MockTrigger(new Date(), evictionWakeUpTime));
        //Set the timestamp for the first time
        contextTemp.set("myvalue", "value");

        Thread.sleep(1000);
       
        //Update the timestamp
        String value = (String) contextTemp.get("myvalue");

        //Wait for eviction
        Thread.sleep(4000);

        assertNull((String) contextTemp.get("myvalue"));


    }
View Full Code Here


        ((ContextManagerImpl) this.contextManager).addContext( this.root );
        this.root.set( NODE_DATA,
                       this );
        // Setup TEMP context, this will hold all short lived instanceId and instances
        // TODO: TEMP context should have a time/utilisation eviction queue added
        this.temp = new ContextImplWithEviction( TEMP,
                                     this.contextManager,
                                     this.root);
       
        ((ContextManagerImpl) this.contextManager).addContext( this.temp );
    }
View Full Code Here


    @Test
    public void simpleEvictionTest() throws InterruptedException {
        MessageReceiverHandler handler = new GridNodeImpl("myNode").getMessageReceiverHandler();
        ContextImplWithEviction contextTemp = (ContextImplWithEviction) ((GridNodeServer) handler).getData().getTemp();
        ((ContextImplWithEviction) contextTemp).setEntryEvictionTime(2000); // 2 seconds
        ((ContextImplWithEviction) contextTemp).setEvictionWakeUpTime(1000); // 1 seconds
        JDKTimerService timer = new JDKTimerService(1);
       
        contextTemp.set("myvalue", "value");


        Long evictionWakeUpTime = contextTemp.getEvictionWakeUpTime();


        timer.scheduleJob(new EvictionJob(contextTemp), new MockJobContext(), new MockTrigger(new Date(), evictionWakeUpTime));
        //Set the timestamp for the first time
        contextTemp.set("myvalue", "value");

        Thread.sleep(1000);
       
        //Update the timestamp
        String value = (String) contextTemp.get("myvalue");

        //Wait for eviction
        Thread.sleep(4000);

        assertNull((String) contextTemp.get("myvalue"));


    }
View Full Code Here


    @Test
    public void simpleEvictionTest() throws InterruptedException {
        MessageReceiverHandler handler = new GridNodeImpl("myNode").getMessageReceiverHandler();
        ContextImplWithEviction contextTemp = (ContextImplWithEviction) ((GridNodeServer) handler).getData().getTemp();
        ((ContextImplWithEviction) contextTemp).setEntryEvictionTime(2000); // 2 seconds
        ((ContextImplWithEviction) contextTemp).setEvictionWakeUpTime(1000); // 1 seconds
        JDKTimerService timer = new JDKTimerService(1);

        contextTemp.set("myvalue", "value");


        Long evictionWakeUpTime = contextTemp.getEvictionWakeUpTime();


        timer.scheduleJob(new EvictionJob(contextTemp), null, new MockTrigger(new Date(), evictionWakeUpTime));
        //Set the timestamp for the first time
        contextTemp.set("myvalue", "value");

        Thread.sleep(1000);
       
        //Update the timestamp
        String value = (String) contextTemp.get("myvalue");

        //Wait for eviction
        Thread.sleep(4000);

        assertNull((String) contextTemp.get("myvalue"));


    }
View Full Code Here


    @Test
    public void simpleEvictionTest() throws InterruptedException {
        MessageReceiverHandler handler = new GridNodeImpl("myNode").getMessageReceiverHandler();
        ContextImplWithEviction contextTemp = (ContextImplWithEviction) ((GridNodeServer) handler).getData().getTemp();
        ((ContextImplWithEviction) contextTemp).setEntryEvictionTime(2000); // 2 seconds
        ((ContextImplWithEviction) contextTemp).setEvictionWakeUpTime(1000); // 1 seconds
        JDKTimerService timer = new JDKTimerService(1);

        contextTemp.set("myvalue", "value");


        Long evictionWakeUpTime = contextTemp.getEvictionWakeUpTime();


        timer.scheduleJob(new EvictionJob(contextTemp), null, new MockTrigger(new Date(), evictionWakeUpTime));
        //Set the timestamp for the first time
        contextTemp.set("myvalue", "value");

        Thread.sleep(1000);
       
        //Update the timestamp
        String value = (String) contextTemp.get("myvalue");

        //Wait for eviction
        Thread.sleep(4000);

        assertNull((String) contextTemp.get("myvalue"));


    }
View Full Code Here

        ((ContextManagerImpl) this.contextManager).addContext( this.root );
        this.root.set( NODE_DATA,
                       this );
        // Setup TEMP context, this will hold all short lived instanceId and instances
        // TODO: TEMP context should have a time/utilisation eviction queue added
        this.temp = new ContextImplWithEviction( TEMP,
                                     this.contextManager,
                                     this.root);
       
        ((ContextManagerImpl) this.contextManager).addContext( this.temp );
    }
View Full Code Here

TOP

Related Classes of org.drools.command.impl.ContextImplWithEviction

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.