sijie commented on a change in pull request #873: Issue280: Turn bookie into 
readonly when sortedLedgerStorage failed to flush data
URL: https://github.com/apache/bookkeeper/pull/873#discussion_r157924276
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
 ##########
 @@ -1446,6 +1304,153 @@ public LedgerStorage getLedgerStorage() {
         return ledgerStorage;
     }
 
+    /**
+     * A implementation of StateManager.
+     */
+    public class BookieStateManager implements StateManager{
 
 Review comment:
   - I think you can move this class out of Bookie. The current `Bookie` class 
is too huge. The tricky part is StateManager need to trigger bookie shutdown if 
it can't register to registration service. What you can do is adding a shutdown 
handler, bookie register a shutdown handler to state manager. if state manager 
can't not register, then it will trigger shutdown. An example code:
   
   ```
   
   interface StateManager {
   
       interface ShutdownHandler {
            void shutdown();
       }
   
       void setShutdownHandler(ShutdownHandler handler);
   
   }
   
   ```
   
   - remove `public` to make it a package protected class
   - need space before '{'
   
   Once you moved this class out of `Bookie` class, you can write a unit test 
for this class. you can mock RegistrationManager. so we will have a good code 
coverage of testing bookie state transitions.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to