Search in sources :

Example 1 with Position

use of io.atomix.storage.journal.index.Position in project atomix by atomix.

the class JournalSegmentReader method reset.

@Override
public void reset(long index) {
    reset();
    Position position = this.index.lookup(index - 1);
    if (position != null) {
        currentEntry = new Indexed<>(position.index() - 1, null, 0);
        buffer.position(position.position());
        readNext();
    }
    while (getNextIndex() < index && hasNext()) {
        next();
    }
}
Also used : Position(io.atomix.storage.journal.index.Position)

Example 2 with Position

use of io.atomix.storage.journal.index.Position in project atomix by atomix.

the class FileChannelJournalSegmentReader method reset.

@Override
public void reset(long index) {
    reset();
    Position position = this.index.lookup(index - 1);
    if (position != null) {
        currentEntry = new Indexed<>(position.index() - 1, null, 0);
        try {
            channel.position(position.position());
            memory.clear().flip();
        } catch (IOException e) {
            throw new StorageException(e);
        }
        readNext();
    }
    while (getNextIndex() < index && hasNext()) {
        next();
    }
}
Also used : Position(io.atomix.storage.journal.index.Position) IOException(java.io.IOException) StorageException(io.atomix.storage.StorageException)

Example 3 with Position

use of io.atomix.storage.journal.index.Position in project atomix by atomix.

the class MappedJournalSegmentReader method reset.

@Override
public void reset(long index) {
    reset();
    Position position = this.index.lookup(index - 1);
    if (position != null) {
        currentEntry = new Indexed<>(position.index() - 1, null, 0);
        buffer.position(position.position());
        readNext();
    }
    while (getNextIndex() < index && hasNext()) {
        next();
    }
}
Also used : Position(io.atomix.storage.journal.index.Position)

Aggregations

Position (io.atomix.storage.journal.index.Position)3 StorageException (io.atomix.storage.StorageException)1 IOException (java.io.IOException)1