Pārlūkot izejas kodu

ZOOKEEPER-3348: Make TxnLog and TxnLog Iterator Closable

Author: Beluga Behr <dam6923@gmail.com>

Reviewers: andor@apache.org

Closes #894 from BELUGABEHR/ZOOKEEPER-3348
Beluga Behr 6 gadi atpakaļ
vecāks
revīzija
a6abb9315b

+ 4 - 14
zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/TxnLog.java

@@ -18,6 +18,7 @@
 
 package org.apache.zookeeper.server.persistence;
 
+import java.io.Closeable;
 import java.io.IOException;
 
 import org.apache.jute.Record;
@@ -28,7 +29,7 @@ import org.apache.zookeeper.txn.TxnHeader;
  * Interface for reading transaction logs.
  *
  */
-public interface TxnLog {
+public interface TxnLog extends Closeable {
 
     /**
      * Setter for ServerStats to monitor fsync threshold exceed
@@ -96,15 +97,11 @@ public interface TxnLog {
      */
     long getTxnLogSyncElapsedTime();
    
-    /** 
-     * close the transactions logs
-     */
-    void close() throws IOException;
     /**
      * an iterating interface for reading 
      * transaction logs. 
      */
-    public interface TxnIterator {
+    public interface TxnIterator extends Closeable {
         /**
          * return the transaction header.
          * @return return the transaction header.
@@ -122,14 +119,7 @@ public interface TxnLog {
          * @throws IOException
          */
         boolean next() throws IOException;
-        
-        /**
-         * close files and release the 
-         * resources
-         * @throws IOException
-         */
-        void close() throws IOException;
-        
+
         /**
          * Get an estimated storage space used to store transaction records
          * that will return by this iterator