Search in sources :

Example 1 with MultiCheckpointWriter

use of org.corfudb.runtime.MultiCheckpointWriter in project CorfuDB by CorfuDB.

the class CheckpointSmokeTest method MultiCheckpointWriterTestInner.

public void MultiCheckpointWriterTestInner(boolean consecutiveCkpoints) throws Exception {
    final String streamNameA = "mystream5A" + consecutiveCkpoints;
    final String streamNameB = "mystream5B" + consecutiveCkpoints;
    final String keyPrefix = "first";
    final int numKeys = 10;
    final String author = "Me, myself, and I";
    // Instantiate map and write first keys
    Map<String, Long> mA = instantiateMap(streamNameA);
    Map<String, Long> mB = instantiateMap(streamNameB);
    for (int j = 0; j < 2 * 2; j++) {
        for (int i = 0; i < numKeys; i++) {
            String key = "A" + keyPrefix + Integer.toString(i);
            mA.put(key, (long) i);
            key = "B" + keyPrefix + Integer.toString(i);
            mB.put(key, (long) i);
        }
    }
    mA.put("one more", 1L);
    mB.put("one more", 1L);
    MultiCheckpointWriter mcw1 = new MultiCheckpointWriter();
    mcw1.addMap((SMRMap) mA);
    mcw1.addMap((SMRMap) mB);
    long firstGlobalAddress1 = mcw1.appendCheckpoints(r, author);
    assertThat(firstGlobalAddress1).isGreaterThan(-1);
    assertThat(mcw1.getCheckpointLogAddresses().size()).isGreaterThan(-1);
    setRuntime();
    Map<String, Long> m2c = instantiateMap(streamNameA);
    // each other without any regular entries in between.
    if (consecutiveCkpoints) {
        mA.put("one more", 1L);
        mB.put("one more", 1L);
    }
    MultiCheckpointWriter mcw2 = new MultiCheckpointWriter();
    mcw2.addMap((SMRMap) mA);
    mcw2.addMap((SMRMap) mB);
    long firstGlobalAddress2 = mcw2.appendCheckpoints(r, author);
    assertThat(firstGlobalAddress2).isGreaterThan(firstGlobalAddress1);
    setRuntime();
    Map<String, Long> m2A = instantiateMap(streamNameA);
    Map<String, Long> m2B = instantiateMap(streamNameB);
    for (int i = 0; i < numKeys; i++) {
        String keyA = "A" + keyPrefix + Integer.toString(i);
        String keyB = "B" + keyPrefix + Integer.toString(i);
        assertThat(m2A.get(keyA)).isEqualTo(i);
        assertThat(m2B.get(keyB)).isEqualTo(i);
    }
}
Also used : MultiCheckpointWriter(org.corfudb.runtime.MultiCheckpointWriter)

Example 2 with MultiCheckpointWriter

use of org.corfudb.runtime.MultiCheckpointWriter in project CorfuDB by CorfuDB.

the class CheckpointTest method periodicCkpointTest.

@Test
public void periodicCkpointTest() throws Exception {
    final String streamNameA = "mystreamA";
    final String streamNameB = "mystreamB";
    final String author = "periodicCkpoint";
    myRuntime = getDefaultRuntime().connect();
    Map<String, Long> m2A = instantiateMap(streamNameA);
    Map<String, Long> m2B = instantiateMap(streamNameB);
    scheduleConcurrently(1, ignored_task_num -> {
        for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
            m2A.put(String.valueOf(i), (long) i);
            m2B.put(String.valueOf(i), (long) 0);
        }
    });
    scheduleConcurrently(1, ignored_task_num -> {
        CorfuRuntime currentRuntime = getMyRuntime();
        for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_VERY_LOW; i++) {
            MultiCheckpointWriter mcw1 = new MultiCheckpointWriter();
            mcw1.addMap((SMRMap) m2A);
            mcw1.addMap((SMRMap) m2B);
            long firstGlobalAddress1 = mcw1.appendCheckpoints(currentRuntime, author);
        }
    });
    scheduleConcurrently(PARAMETERS.NUM_ITERATIONS_LOW, ignored_task_num -> {
        setRuntime();
        Map<String, Long> localm2A = instantiateMap(streamNameA);
        Map<String, Long> localm2B = instantiateMap(streamNameB);
        for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
            assertThat(localm2A.get(String.valueOf(i)) == null || localm2A.get(String.valueOf(i)) == (long) i).isTrue();
            assertThat(localm2B.get(String.valueOf(i)) == null || localm2B.get(String.valueOf(i)) == (long) 0).isTrue();
        }
    });
    executeScheduled(PARAMETERS.CONCURRENCY_SOME, PARAMETERS.TIMEOUT_LONG);
    // System.out.println("done executeScheduled");
    setRuntime();
    Map<String, Long> localm2A = instantiateMap(streamNameA);
    Map<String, Long> localm2B = instantiateMap(streamNameB);
    for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
        assertThat(localm2A.get(String.valueOf(i))).isEqualTo((long) i);
        assertThat(localm2B.get(String.valueOf(i))).isEqualTo(0L);
    }
}
Also used : MultiCheckpointWriter(org.corfudb.runtime.MultiCheckpointWriter) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) AbstractObjectTest(org.corfudb.runtime.object.AbstractObjectTest) Test(org.junit.Test)

Example 3 with MultiCheckpointWriter

use of org.corfudb.runtime.MultiCheckpointWriter in project CorfuDB by CorfuDB.

the class CheckpointTest method emptyCkpointTest.

@Test
public void emptyCkpointTest() throws Exception {
    final String streamNameA = "mystreamA";
    final String streamNameB = "mystreamB";
    final String author = "periodicCkpoint";
    myRuntime = getDefaultRuntime().connect();
    Map<String, Long> m2A = instantiateMap(streamNameA);
    Map<String, Long> m2B = instantiateMap(streamNameB);
    scheduleConcurrently(1, ignored_task_num -> {
        CorfuRuntime currentRuntime = getMyRuntime();
        for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_VERY_LOW; i++) {
            MultiCheckpointWriter mcw1 = new MultiCheckpointWriter();
            mcw1.addMap((SMRMap) m2A);
            mcw1.addMap((SMRMap) m2B);
            long firstGlobalAddress1 = mcw1.appendCheckpoints(currentRuntime, author);
        }
    });
    scheduleConcurrently(PARAMETERS.NUM_ITERATIONS_LOW, ignored_task_num -> {
        setRuntime();
        Map<String, Long> localm2A = instantiateMap(streamNameA);
        Map<String, Long> localm2B = instantiateMap(streamNameB);
        for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
            assertThat(localm2A.get(String.valueOf(i))).isNull();
            assertThat(localm2B.get(String.valueOf(i))).isNull();
        }
    });
    executeScheduled(PARAMETERS.CONCURRENCY_SOME, PARAMETERS.TIMEOUT_LONG);
    // System.out.println("done executeScheduled");
    setRuntime();
    Map<String, Long> localm2A = instantiateMap(streamNameA);
    Map<String, Long> localm2B = instantiateMap(streamNameB);
    for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
        assertThat(localm2A.get(String.valueOf(i))).isNull();
        assertThat(localm2B.get(String.valueOf(i))).isNull();
    }
}
Also used : MultiCheckpointWriter(org.corfudb.runtime.MultiCheckpointWriter) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) AbstractObjectTest(org.corfudb.runtime.object.AbstractObjectTest) Test(org.junit.Test)

Example 4 with MultiCheckpointWriter

use of org.corfudb.runtime.MultiCheckpointWriter in project CorfuDB by CorfuDB.

the class CheckpointTest method periodicCkpointTestNoUpdates.

@Test
public void periodicCkpointTestNoUpdates() throws Exception {
    final String streamNameA = "mystreamA";
    final String streamNameB = "mystreamB";
    final String author = "periodicCkpoint";
    myRuntime = getDefaultRuntime().connect();
    Map<String, Long> m2A = instantiateMap(streamNameA);
    Map<String, Long> m2B = instantiateMap(streamNameB);
    // pre-populate map
    for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
        m2A.put(String.valueOf(i), (long) i);
        m2B.put(String.valueOf(i), (long) 0);
    }
    scheduleConcurrently(1, ignored_task_num -> {
        CorfuRuntime currentRuntime = getMyRuntime();
        for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_VERY_LOW; i++) {
            MultiCheckpointWriter mcw1 = new MultiCheckpointWriter();
            mcw1.addMap((SMRMap) m2A);
            mcw1.addMap((SMRMap) m2B);
            long firstGlobalAddress1 = mcw1.appendCheckpoints(currentRuntime, author);
        }
    });
    scheduleConcurrently(PARAMETERS.NUM_ITERATIONS_LOW, ignored_task_num -> {
        setRuntime();
        Map<String, Long> localm2A = instantiateMap(streamNameA);
        Map<String, Long> localm2B = instantiateMap(streamNameB);
        for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
            assertThat(localm2A.get(String.valueOf(i))).isEqualTo((long) i);
            assertThat(localm2B.get(String.valueOf(i))).isEqualTo((long) 0);
        }
    });
    executeScheduled(PARAMETERS.CONCURRENCY_SOME, PARAMETERS.TIMEOUT_LONG);
    // System.out.println("done executeScheduled");
    setRuntime();
    Map<String, Long> localm2A = instantiateMap(streamNameA);
    Map<String, Long> localm2B = instantiateMap(streamNameB);
    for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) {
        assertThat(localm2A.get(String.valueOf(i))).isEqualTo((long) i);
        assertThat(localm2B.get(String.valueOf(i))).isEqualTo(0L);
    }
}
Also used : MultiCheckpointWriter(org.corfudb.runtime.MultiCheckpointWriter) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) AbstractObjectTest(org.corfudb.runtime.object.AbstractObjectTest) Test(org.junit.Test)

Aggregations

MultiCheckpointWriter (org.corfudb.runtime.MultiCheckpointWriter)4 CorfuRuntime (org.corfudb.runtime.CorfuRuntime)3 AbstractObjectTest (org.corfudb.runtime.object.AbstractObjectTest)3 Test (org.junit.Test)3