Class EntryCopierImpl

  • All Implemented Interfaces:
    EntryCopier

    public class EntryCopierImpl
    extends java.lang.Object
    implements EntryCopier
    Implementation for the EntryCopier interface. Handles the reading of entries from peer bookies.
    • Method Detail

      • newBatch

        public EntryCopier.Batch newBatch​(long ledgerId,
                                          LedgerMetadata metadata)
                                   throws java.io.IOException
        Description copied from interface: EntryCopier
        Start copying a new batch. In general, there should be a batch per ledger.
        Specified by:
        newBatch in interface EntryCopier
        Throws:
        java.io.IOException
      • preferredBookieIndices

        static com.google.common.collect.ImmutableSortedMap<java.lang.Long,​com.google.common.collect.ImmutableList<java.lang.Integer>> preferredBookieIndices​(BookieId bookieId,
                                                                                                                                                                    LedgerMetadata metadata,
                                                                                                                                                                    java.util.Set<BookieId> errorBookies,
                                                                                                                                                                    long seed)
        Generate a map of preferred bookie indices. For each ensemble, generate the order in which bookies should be tried for entries, notwithstanding errors. For example, if a e5,w2,a2 ensemble has the bookies: [bookie1, bookie2, bookie3, bookie4, bookie5] and the current bookie is bookie2, then we should return something like: [4, 2, 0, 3] Then when retrieving an entry, even though it is only written to 2, we try the bookie in the order from this list. This will cause more requests to go to the same bookie, which should give us the benefit of read locality. We don't want to simply sort by bookie id, as that would cause the same bookies to be loaded for all ensembles. Bookies which have presented errors are always tried last.