Search in sources :

Example 1 with HashMapPersister

use of io.s4.persist.HashMapPersister in project core by s4.

the class TestPersisterWallClock method testPersister.

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());
    }
}
Also used : ConMapPersister(io.s4.persist.ConMapPersister) HashMapPersister(io.s4.persist.HashMapPersister)

Example 2 with HashMapPersister

use of io.s4.persist.HashMapPersister in project core by s4.

the class TestPersisterEventClock method testPersister.

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());
    }
}
Also used : ConMapPersister(io.s4.persist.ConMapPersister) HashMapPersister(io.s4.persist.HashMapPersister)

Example 3 with HashMapPersister

use of io.s4.persist.HashMapPersister in project core by s4.

the class TestPersisterEventClock method main.

public static void main(String[] args) {
    TestPersisterEventClock testPersisterClock = new TestPersisterEventClock();
    s4Clock = new EventClock();
    s4Clock.updateTime(69990000);
    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);
}
Also used : ConMapPersister(io.s4.persist.ConMapPersister) EventClock(io.s4.util.clock.EventClock) HashMapPersister(io.s4.persist.HashMapPersister)

Example 4 with HashMapPersister

use of io.s4.persist.HashMapPersister in project core by s4.

the class TestPersisterWallClock method main.

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);
}
Also used : ConMapPersister(io.s4.persist.ConMapPersister) WallClock(io.s4.util.clock.WallClock) HashMapPersister(io.s4.persist.HashMapPersister)

Aggregations

ConMapPersister (io.s4.persist.ConMapPersister)4 HashMapPersister (io.s4.persist.HashMapPersister)4 EventClock (io.s4.util.clock.EventClock)1 WallClock (io.s4.util.clock.WallClock)1