Package org.apache.s4.persist

Examples of org.apache.s4.persist.ConMapPersister$CacheEntry


    @Test
    public void test() {
        ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory
                .getLogger(Logger.ROOT_LOGGER_NAME);
        root.setLevel(Level.DEBUG);
        Injector injector = Guice.createInjector(new MockCommModule(), new MockCoreModule());
        TestTimeWindowedApp app = injector.getInstance(TestTimeWindowedApp.class);
        app.init();
        app.start();

        for (int i = 0; i < NB_EVENTS; i++) {
View Full Code Here


        return prototype.getId();
    }

    public PrototypeWrapper(AbstractPE prototype, Clock s4Clock) {
        this.prototype = prototype;
        lookupTable = new ConMapPersister(s4Clock);
        // TODO lookup table with PEIds
        System.out.println("Using ConMapPersister ..");
        // this bit of reflection is not a performance issue because it is only
        // invoked at configuration time
        try {
View Full Code Here

        TimeUpdaterThread timeUpdater = new TimeUpdaterThread(s4Clock);
        Thread timeUpdaterThread = new Thread(timeUpdater);
        timeUpdaterThread.start();
        persister = new HashMapPersister(s4Clock);
        testPersisterClock.testPersister(persister);
        persister = new ConMapPersister(s4Clock);
        testPersisterClock.testPersister(persister);
    }
View Full Code Here

        testPersisterClock.testPersister(persister);
    }

    public void testPersister(Persister persister) {
        HashMapPersister hp = null;
        ConMapPersister cp = null;
        if (persister instanceof HashMapPersister) {
            hp = (HashMapPersister) persister;
            hp.init();

            hp.set("mykey1", "Test1", 40);
            hp.set("mykey2", "Test2", 48);
            hp.set("mykey3", "Test2", -1);

            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 1);
            } catch (Exception e) {
            }

            System.out.println("mykey1: " + hp.get("mykey1"));
            System.out.println("mykey2: " + hp.get("mykey2"));
            System.out.println("mykey3: " + hp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 41000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + hp.get("mykey1"));
            System.out.println("mykey2: " + hp.get("mykey2"));
            System.out.println("mykey3: " + hp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 10000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + hp.get("mykey1"));
            System.out.println("mykey2: " + hp.get("mykey2"));
            System.out.println("mykey3: " + hp.get("mykey3"));
            System.out.println("cleanUp: " + hp.cleanOutGarbage());

        }
        if (persister instanceof ConMapPersister) {
            cp = (ConMapPersister) persister;
            cp.init();

            cp.set("mykey1", "Test1", 40);
            cp.set("mykey2", "Test2", 48);
            cp.set("mykey3", "Test2", -1);

            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 1);
            } catch (Exception e) {
            }

            System.out.println("mykey1: " + cp.get("mykey1"));
            System.out.println("mykey2: " + cp.get("mykey2"));
            System.out.println("mykey3: " + cp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 41000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + cp.get("mykey1"));
            System.out.println("mykey2: " + cp.get("mykey2"));
            System.out.println("mykey3: " + cp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 10000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + cp.get("mykey1"));
            System.out.println("mykey2: " + cp.get("mykey2"));
            System.out.println("mykey3: " + cp.get("mykey3"));
            System.out.println("cleanUp: " + cp.cleanOutGarbage());
        }
    }
View Full Code Here

    public static void main(String[] args) {
        TestPersisterWallClock testPersisterClock = new TestPersisterWallClock();
        s4Clock = new WallClock();
        persister = new HashMapPersister(s4Clock);
        testPersisterClock.testPersister(persister);
        persister = new ConMapPersister(s4Clock);
        testPersisterClock.testPersister(persister);
    }
View Full Code Here

        testPersisterClock.testPersister(persister);
    }

    public void testPersister(Persister persister) {
        HashMapPersister hp = null;
        ConMapPersister cp = null;
        if (persister instanceof HashMapPersister) {
            hp = (HashMapPersister) persister;
            hp.init();

            hp.set("mykey1", "Test1", 40);
            hp.set("mykey2", "Test2", 48);
            hp.set("mykey3", "Test2", -1);

            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 1);
            } catch (Exception e) {
            }

            System.out.println("mykey1: " + hp.get("mykey1"));
            System.out.println("mykey2: " + hp.get("mykey2"));
            System.out.println("mykey3: " + hp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 41000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + hp.get("mykey1"));
            System.out.println("mykey2: " + hp.get("mykey2"));
            System.out.println("mykey3: " + hp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 10000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + hp.get("mykey1"));
            System.out.println("mykey2: " + hp.get("mykey2"));
            System.out.println("mykey3: " + hp.get("mykey3"));
            System.out.println("cleanUp: " + hp.cleanOutGarbage());

        }
        if (persister instanceof ConMapPersister) {
            cp = (ConMapPersister) persister;
            cp.init();

            cp.set("mykey1", "Test1", 40);
            cp.set("mykey2", "Test2", 48);
            cp.set("mykey3", "Test2", -1);

            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 1);
            } catch (Exception e) {
            }

            System.out.println("mykey1: " + cp.get("mykey1"));
            System.out.println("mykey2: " + cp.get("mykey2"));
            System.out.println("mykey3: " + cp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 41000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + cp.get("mykey1"));
            System.out.println("mykey2: " + cp.get("mykey2"));
            System.out.println("mykey3: " + cp.get("mykey3"));

            System.out.println("Going to sleep...");
            try {
                s4Clock.waitForTime(s4Clock.getCurrentTime() + 10000);
            } catch (Exception e) {
            }
            System.out.println("Waking up");

            System.out.println("mykey1: " + cp.get("mykey1"));
            System.out.println("mykey2: " + cp.get("mykey2"));
            System.out.println("mykey3: " + cp.get("mykey3"));
            System.out.println("cleanUp: " + cp.cleanOutGarbage());
        }
    }
View Full Code Here

        CommTestUtils.watchAndSignalCreation("/onEvent@" + time1, signalEvent1Processed, zk);

        CountDownLatch signalEvent1Triggered = new CountDownLatch(1);
        CommTestUtils.watchAndSignalCreation("/onTrigger[StringEvent]@" + time1, signalEvent1Triggered, zk);

        app.stream.receiveEvent(new EventMessage("-1", "stream", app.getSerDeser().serialize(new StringEvent(time1))));

        // check event processed
        Assert.assertTrue(signalEvent1Processed.await(5, TimeUnit.SECONDS));

        // return latch on trigger signal
View Full Code Here

*/
public class LeastRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (lruCacheEntry == null) {
                lruCacheEntry = cacheEntry;
            } else if (lruCacheEntry.getLastAccessed() > cacheEntry.getLastAccessed()) {
                lruCacheEntry = cacheEntry;
            }
        }
        if (lruCacheEntry != null) {
            cache.evict(lruCacheEntry.getKey());
View Full Code Here

*/
public class MostRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry mruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (mruCacheEntry == null) {
                mruCacheEntry = cacheEntry;
            } else if (mruCacheEntry.getLastAccessed() < cacheEntry.getLastAccessed()) {
                mruCacheEntry = cacheEntry;
            }
        }
        if (mruCacheEntry != null) {
            cache.evict(mruCacheEntry.getKey());
View Full Code Here

public class RandomEvictionAlgorithm implements EvictionAlgorithm {
    private static Random random = new Random();

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        Collection all = cache.getAll();
        int evictionIndex = random.nextInt(all.size());
        int index = 0;

        for (Object anAll : all) {
            CacheEntry cacheEntry = (CacheEntry) anAll;
            if (index == evictionIndex) {
                lruCacheEntry = cacheEntry;
                break;
            }
            index++;
View Full Code Here

TOP

Related Classes of org.apache.s4.persist.ConMapPersister$CacheEntry

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.