zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anmolnar <...@git.apache.org>
Subject [GitHub] zookeeper pull request #453: ZOOKEEPER-2845: Apply commit log when restartin...
Date Tue, 13 Feb 2018 14:44:50 GMT
Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/453#discussion_r167884587
  
    --- Diff: src/java/main/org/apache/zookeeper/server/ZKDatabase.java ---
    @@ -233,14 +233,32 @@ public long getDataTreeLastProcessedZxid() {
          * @throws IOException
          */
         public long loadDataBase() throws IOException {
    -        PlayBackListener listener=new PlayBackListener(){
    +        PlayBackListener listener = new PlayBackListener(){
                 public void onTxnLoaded(TxnHeader hdr,Record txn){
                     Request r = new Request(0, hdr.getCxid(),hdr.getType(), hdr, txn, hdr.getZxid());
                     addCommittedProposal(r);
                 }
             };
     
    -        long zxid = snapLog.restore(dataTree,sessionsWithTimeouts,listener);
    +        long zxid = snapLog.restore(dataTree, sessionsWithTimeouts, listener);
    +        initialized = true;
    +        return zxid;
    +    }
    +
    +    /**
    +     * Fast forward the database adding transactions from the committed log into memory.
    +     * @return the last valid zxid.
    +     * @throws IOException
    +     */
    +    public long fastForwardDataBase() throws IOException {
    +        PlayBackListener listener = new PlayBackListener(){
    --- End diff --
    
    I think it'd be nice to extract the common logic of these two methods into a operate one.


---

Mime
View raw message