Search in sources :

Example 1 with SequenceNumber

use of org.apache.flink.runtime.state.changelog.SequenceNumber in project flink by apache.

the class FsStateChangelogWriterTest method testPersistAgain.

@Test
public void testPersistAgain() throws Exception {
    withWriter((writer, uploader) -> {
        byte[] bytes = getBytes();
        SequenceNumber sqn = append(writer, bytes);
        writer.persist(sqn);
        uploader.reset();
        writer.confirm(sqn, writer.lastAppendedSqnUnsafe().next());
        writer.persist(sqn);
        assertNoUpload(uploader, "confirmed changes shouldn't be re-uploaded");
    });
}
Also used : SequenceNumber(org.apache.flink.runtime.state.changelog.SequenceNumber) Test(org.junit.Test)

Example 2 with SequenceNumber

use of org.apache.flink.runtime.state.changelog.SequenceNumber in project flink by apache.

the class FsStateChangelogWriterTest method testPersistFailure.

@Test(expected = IOException.class)
public void testPersistFailure() throws Exception {
    withWriter((writer, uploader) -> {
        byte[] bytes = getBytes();
        SequenceNumber sqn = append(writer, bytes);
        CompletableFuture<ChangelogStateHandleStreamImpl> future = writer.persist(sqn);
        uploader.failUpload(new RuntimeException("test"));
        try {
            future.get();
        } catch (ExecutionException e) {
            rethrowIOException(e.getCause());
        }
    });
}
Also used : ChangelogStateHandleStreamImpl(org.apache.flink.runtime.state.changelog.ChangelogStateHandleStreamImpl) SequenceNumber(org.apache.flink.runtime.state.changelog.SequenceNumber) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 3 with SequenceNumber

use of org.apache.flink.runtime.state.changelog.SequenceNumber in project flink by apache.

the class FsStateChangelogWriterTest method testNoReUploadBeforeCompletion.

@Test
public void testNoReUploadBeforeCompletion() throws Exception {
    withWriter((writer, uploader) -> {
        byte[] bytes = getBytes();
        SequenceNumber sqn = append(writer, bytes);
        writer.persist(sqn);
        uploader.reset();
        writer.persist(sqn);
        assertNoUpload(uploader, "no re-upload should happen");
    });
}
Also used : SequenceNumber(org.apache.flink.runtime.state.changelog.SequenceNumber) Test(org.junit.Test)

Example 4 with SequenceNumber

use of org.apache.flink.runtime.state.changelog.SequenceNumber in project flink by apache.

the class FsStateChangelogWriterTest method testPreUpload.

@Test
public void testPreUpload() throws Exception {
    int threshold = 1000;
    withWriter(threshold, (writer, uploader) -> {
        byte[] bytes = getBytes(threshold);
        SequenceNumber sqn = append(writer, bytes);
        assertSubmittedOnly(uploader, bytes);
        uploader.reset();
        writer.persist(sqn);
        assertNoUpload(uploader, "changes should have been pre-uploaded");
    });
}
Also used : SequenceNumber(org.apache.flink.runtime.state.changelog.SequenceNumber) Test(org.junit.Test)

Example 5 with SequenceNumber

use of org.apache.flink.runtime.state.changelog.SequenceNumber in project flink by apache.

the class FsStateChangelogWriterTest method testPersistAfterReset.

/**
 * Emulates checkpoint abortion followed by a new checkpoint.
 */
@Test
public void testPersistAfterReset() throws Exception {
    withWriter((writer, uploader) -> {
        byte[] bytes = getBytes();
        SequenceNumber sqn = append(writer, bytes);
        writer.reset(sqn, SequenceNumber.of(Long.MAX_VALUE));
        uploader.reset();
        writer.persist(sqn);
        assertSubmittedOnly(uploader, bytes);
    });
}
Also used : SequenceNumber(org.apache.flink.runtime.state.changelog.SequenceNumber) Test(org.junit.Test)

Aggregations

SequenceNumber (org.apache.flink.runtime.state.changelog.SequenceNumber)20 Test (org.junit.Test)16 ChangelogStateHandleStreamImpl (org.apache.flink.runtime.state.changelog.ChangelogStateHandleStreamImpl)3 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Path (org.apache.flink.core.fs.Path)2 ManuallyTriggeredScheduledExecutorService (org.apache.flink.core.testutils.ManuallyTriggeredScheduledExecutorService)2 HistogramStatistics (org.apache.flink.metrics.HistogramStatistics)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 Executors.newSingleThreadScheduledExecutor (java.util.concurrent.Executors.newSingleThreadScheduledExecutor)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 JobID (org.apache.flink.api.common.JobID)1 CHANGELOG_STORAGE_UPLOAD_QUEUE_SIZE (org.apache.flink.changelog.fs.ChangelogStorageMetricGroup.CHANGELOG_STORAGE_UPLOAD_QUEUE_SIZE)1