Class OverwriteMergeStrategy

java.lang.Object
io.permazen.kv.raft.fallback.OverwriteMergeStrategy
All Implemented Interfaces:
MergeStrategy

public class OverwriteMergeStrategy extends Object implements MergeStrategy
MergeStrategy that completely overwrites the destination database with the content of the source database.
  • Constructor Details

    • OverwriteMergeStrategy

      public OverwriteMergeStrategy()
  • Method Details

    • mergeAndCommit

      public void mergeAndCommit(KVTransaction src, KVTransaction dst, Date lastActiveTime)
      Description copied from interface: MergeStrategy
      Merge data from the source database being migrated away from into the destination database being migrated to.

      This method should commit() both transactions before returning; src should be committed before dst.

      If an exception is thrown, rollback() will be invoked on both transactions (a rollback() on an already-commit()'ed transaction does nothing).

      Specified by:
      mergeAndCommit in interface MergeStrategy
      Parameters:
      src - read-only view into the database being migrated away from
      dst - read-write transaction open on the database being migrated to
      lastActiveTime - time that dst was last active, or null if never
    • overwrite

      protected void overwrite(KVTransaction src, KVTransaction dst)
      Overwrite one key/value database with another.

      This method deletes every key/value pair in dst, and then copy every key/value pair in src into dst.

      Does not commit src or dst.

      Parameters:
      src - database to copy from
      dst - database to copy src onto
    • toString

      public String toString()
      Overrides:
      toString in class Object