Review Board 1.7.22


BOOKKEEPER-203: improve ledger manager interface to remove zookeeper dependency on metadata operations.

Review Request #4603 - Created April 1, 2012 and updated

Sijie Guo
BOOKKEEPER-203
Reviewers
bookkeeper
bookkeeper-git
we need to improve ledger manager interface to remove zookeeper dependency on metadata operations, so it is easy for us to implement a MetaStore based ledger manager.

 

Diff revision 1

This is not the most recent revision of the diff. The latest diff is revision 6. See what's changed.

1 2 3 4 5 6
1 2 3 4 5 6

  1. bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java: Loading...
  2. bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java: Loading...
  3. bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java: Loading...
  4. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BKException.java: Loading...
  5. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java: Loading...
  6. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java: Loading...
  7. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java: Loading...
  8. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerDeleteOp.java: Loading...
  9. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java: Loading...
  10. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java: Loading...
  11. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerOpenOp.java: Loading...
  12. bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java: Loading...
  13. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java: Loading...
  14. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ActiveLedgerManager.java: Loading...
  15. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManager.java: Loading...
  16. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java: Loading...
  17. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManager.java: Loading...
  18. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java: Loading...
  19. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java: Loading...
  20. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManager.java: Loading...
This diff has been split across 2 pages: 1 2 >
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
Revision ee38862 New Change
[20] 43 lines
[+20]
44
import java.util.LinkedList;
44
import java.util.LinkedList;
45
import java.util.List;
45
import java.util.List;
46
import java.util.concurrent.LinkedBlockingQueue;
46
import java.util.concurrent.LinkedBlockingQueue;
47
import java.util.concurrent.atomic.AtomicBoolean;
47
import java.util.concurrent.atomic.AtomicBoolean;
48

    
   
48

   
49
import org.apache.bookkeeper.meta.LedgerManager;
49
import org.apache.bookkeeper.meta.ActiveLedgerManager;
50
import org.apache.bookkeeper.meta.LedgerManagerFactory;
50
import org.apache.bookkeeper.meta.LedgerManagerFactory;
51
import org.apache.bookkeeper.bookie.BookieException;
51
import org.apache.bookkeeper.bookie.BookieException;
52
import org.apache.bookkeeper.conf.ServerConfiguration;
52
import org.apache.bookkeeper.conf.ServerConfiguration;
53
import org.apache.bookkeeper.jmx.BKMBeanInfo;
53
import org.apache.bookkeeper.jmx.BKMBeanInfo;
54
import org.apache.bookkeeper.jmx.BKMBeanRegistry;
54
import org.apache.bookkeeper.jmx.BKMBeanRegistry;
[+20] [20] 26 lines
[+20] [+] public class Bookie extends Thread {
81
    final File ledgerDirectories[];
81
    final File ledgerDirectories[];
82

    
   
82

   
83
    final ServerConfiguration conf;
83
    final ServerConfiguration conf;
84

    
   
84

   
85
    final SyncThread syncThread;
85
    final SyncThread syncThread;
86
    final LedgerManager ledgerManager;
86
    final LedgerManagerFactory activeLedgerManagerFactory;

    
   
87
    final ActiveLedgerManager activeLedgerManager;
87
    final HandleFactory handles;
88
    final HandleFactory handles;
88

    
   
89

   
89
    static final long METAENTRY_ID_LEDGER_KEY = -0x1000;
90
    static final long METAENTRY_ID_LEDGER_KEY = -0x1000;
90

    
   
91

   
91
    // ZK registration path for this bookie
92
    // ZK registration path for this bookie
[+20] [20] 306 lines
[+20] [+] public void process(long ledgerId, ByteBuffer buffer)
398

    
   
399

   
399
        // instantiate zookeeper client to initialize ledger manager
400
        // instantiate zookeeper client to initialize ledger manager
400
        this.zk = instantiateZookeeperClient(conf);
401
        this.zk = instantiateZookeeperClient(conf);
401
        checkEnvironment(this.zk);
402
        checkEnvironment(this.zk);
402

    
   
403

   
403
        ledgerManager = LedgerManagerFactory.newLedgerManager(conf, this.zk);
404
        activeLedgerManagerFactory = LedgerManagerFactory.newLedgerManagerFactory(conf, this.zk);

    
   
405
        activeLedgerManager = activeLedgerManagerFactory.newActiveLedgerManager();
404

    
   
406

   
405
        syncThread = new SyncThread(conf);
407
        syncThread = new SyncThread(conf);
406
        entryLogger = new EntryLogger(conf);
408
        entryLogger = new EntryLogger(conf);
407
        ledgerCache = new LedgerCacheImpl(conf, ledgerManager);
409
        ledgerCache = new LedgerCacheImpl(conf, activeLedgerManager);
408
        gcThread = new GarbageCollectorThread(conf, this.zk, ledgerCache, entryLogger,
410
        gcThread = new GarbageCollectorThread(conf, this.zk, ledgerCache, entryLogger,
409
                ledgerManager, new EntryLogCompactionScanner());
411
                activeLedgerManager, new EntryLogCompactionScanner());
410
        handles = new HandleFactoryImpl(entryLogger, ledgerCache);
412
        handles = new HandleFactoryImpl(entryLogger, ledgerCache);
411

    
   
413

   
412
        // replay journals
414
        // replay journals
413
        readJournal();
415
        readJournal();
414
    }
416
    }
[+20] [20] 522 lines
[+20] [+] public int shutdown() {
937
                syncThread.shutdown();
939
                syncThread.shutdown();
938

    
   
940

   
939
                // Shutdown the EntryLogger which has the GarbageCollector Thread running
941
                // Shutdown the EntryLogger which has the GarbageCollector Thread running
940
                entryLogger.shutdown();
942
                entryLogger.shutdown();
941
                // close Ledger Manager
943
                // close Ledger Manager
942
                ledgerManager.close();
944
                try {

    
   
945
                    activeLedgerManager.close();

    
   
946
                } catch (IOException ie) {

    
   
947
                    LOG.error("Failed to close active ledger manager : ", ie);

    
   
948
                }
943
                // setting running to false here, so watch thread in bookie server know it only after bookie shut down
949
                // setting running to false here, so watch thread in bookie server know it only after bookie shut down
944
                running = false;
950
                running = false;
945
            }
951
            }
946
        } catch (InterruptedException ie) {
952
        } catch (InterruptedException ie) {
947
            LOG.error("Interrupted during shutting down bookie : ", ie);
953
            LOG.error("Interrupted during shutting down bookie : ", ie);
[+20] [20] 166 lines
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
Revision 2eed192 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
Revision 17c70f1 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BKException.java
Revision 911c660 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
Revision 490c130 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
Revision b9cd624 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java
Revision f0a165f New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerDeleteOp.java
Revision 5b10a5b New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
Revision e576792 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
Revision 2dcf0e4 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerOpenOp.java
Revision 56186ab New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
Revision e1bd1ff New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java
Revision 8fd7df8 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ActiveLedgerManager.java
New File
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManager.java
Revision 1300974 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
New File
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManager.java
Revision b573181 New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
New File
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
Revision 3a3a81e New Change
 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManager.java
Revision 7d9eb96 New Change
 
  1. bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java: Loading...
  2. bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java: Loading...
  3. bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java: Loading...
  4. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BKException.java: Loading...
  5. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java: Loading...
  6. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java: Loading...
  7. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java: Loading...
  8. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerDeleteOp.java: Loading...
  9. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java: Loading...
  10. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java: Loading...
  11. bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerOpenOp.java: Loading...
  12. bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java: Loading...
  13. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java: Loading...
  14. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ActiveLedgerManager.java: Loading...
  15. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManager.java: Loading...
  16. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java: Loading...
  17. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManager.java: Loading...
  18. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java: Loading...
  19. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java: Loading...
  20. bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManager.java: Loading...
This diff has been split across 2 pages: 1 2 >