Uploaded image for project: 'controller'
  1. controller
  2. CONTROLLER-2115

Separate out byte-level atomix-storage access

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Medium Medium
    • 10.0.0
    • None
    • clustering

      SegmentedJournal's core API revolves around a user-supplied generic type, <E>, which is assumed to be serializable via Kryo.

      This means our on-disk format is dependent on Kryo, but more importantly it requires Serializable in the picture.

      We would like to have an interface which allows zero-copy writeout and read in: the Payload subclasses we are persisting typically holds a byte[] of already-serialized data. That serialized data should never be stored on heap.

      Let's assume <E> is a Netty ByteBuf (because of its lifecycle, otherwise we could also use java.nio.ByteBuffer). Then JournalReader's critical API becomes:

      interface EntryReader {
      
          long getNextIndex();
      
          @Nullable Indexed<ByteBuf> tryNext();
      }
      

      where really Indexed is just a distraction: Indexed.length is already expressed in ByteBuf's readableBytes() and Indexed.index is available through getNextIndex(), so a user could say:

      int index; // seek to this
      Entry reader reader;
      for (var nextIndex = reader.getNextIndex(); nextIndex <= index; nextIndex = reader.getNextIndex()) {
          var buf = reader.tryNext();
          // process the buffer
      }
      

      This will be useful for Payloads, as they can run their serialization mojo directly on the file byte range in case of StorageLevel.MAPPED.

      Introduce this API as the primary means to access to files, going all the way down to in FileReader.read() etc. The primary entry point should be a ByteJournal (equivalent of Journal<E>):

      interface ByteJournal implements AutoCloseable {
      
        EntryWriter writer();
      
        EntryReader openReader(long index);
      
        // ...
      }
      

      Current Kryo-based access should be then layered on top of that – i.e. SegmentedJournal should use a ByteJournal internally.

            rkashapov Ruslan Kashapov
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: