Package org.apache.openjpa.datacache

Examples of org.apache.openjpa.datacache.ClearableScheduler


    }

    public void testBasic() throws Exception {
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
        OpenJPAConfiguration conf = ((OpenJPAEntityManagerSPI) em).getConfiguration();
        ClearableScheduler scheduler = new ClearableScheduler(conf);
        // Make the scheduler run every 1 minute
        scheduler.setInterval(1);
        DummyCache cache1 = new DummyCache();
        DummyCache cache2 = new DummyCache();

        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int currMin = cal.get(Calendar.MINUTE);
        int plusOne = currMin+1;
        int plusTwo = plusOne+1;
        if(plusOne>=60){
            plusOne-=60;
        }
        if(plusTwo>=60){
            plusTwo-=60;
        }
        // Schedule eviction to happen the next two minutes
        scheduler.scheduleEviction(cache2, plusOne+","+plusTwo+" * * * *");

        // Schedule eviction to happen every mintue on cache 1
        scheduler.scheduleEviction(cache1, ("+1"));
       
        Thread.currentThread().sleep(61000);
        assertEquals(1,cache1.getClearCount());
        assertEquals(1,cache2.getClearCount());
       
View Full Code Here


    }

    public void testBasic() throws Exception {
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
        OpenJPAConfiguration conf = ((OpenJPAEntityManagerSPI) em).getConfiguration();
        ClearableScheduler scheduler = new ClearableScheduler(conf);
        // Make the scheduler run every 1 minute
        scheduler.setInterval(1);
        DummyCache cache1 = new DummyCache();
        DummyCache cache2 = new DummyCache();

        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int currMin = cal.get(Calendar.MINUTE);
        int plusOne = currMin+1;
        int plusTwo = plusOne+1;
        if(plusOne>=60){
            plusOne-=60;
        }
        if(plusTwo>=60){
            plusTwo-=60;
        }
        // Schedule eviction to happen the next two minutes
        scheduler.scheduleEviction(cache2, plusOne+","+plusTwo+" * * * *");

        // Schedule eviction to happen every mintue on cache 1
        scheduler.scheduleEviction(cache1, ("+1"));
       
        Thread.currentThread().sleep(61000);
        assertEquals(1,cache1.getClearCount());
        assertEquals(1,cache2.getClearCount());
       
View Full Code Here

TOP

Related Classes of org.apache.openjpa.datacache.ClearableScheduler

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.