Review Board 1.7.22


ZOOKEEPER-1147: Add support for local sessions

Review Request #8935 - Created Jan. 12, 2013 and updated

Thawan Kooburat
trunk
ZOOKEEPER-1147
Reviewers
zookeeper
mahadev, phunt
zookeeper
See ZOOKEEPER-1147 for high level description 

Implementation notes:

- Local sessions don’t get persisted on disk.  Existing SessionTrackerImpl is used by the leader to track global sessions.  Each participant (including the leader) also has a local session tracker (which is another instance of SessionTrackerImpl) to track its local session in memory. 

- Each participant intercepts a request before it enters the pipeline. In order to do 2 things
 o Update local session to global session when it saw create ephemeral node request. Update is done by issuing a create session rquest before issuing the create request
 o Add local session flag to a request. So that the pipeline know that this type of request don’t need to send to the leader and wait for commit

- PrepRequestProcessor (on the leader) now explicitly validate global session on create ephemeral node request.  For other type of request, there is no need for session validation because the leader doesn’t know about local sessions on other machine, so the request has to go through.  The correctness is preserve as long a no ephemeral node is created after session is already expired

- Observer/FollowerRequestProcessor has logic to validate session. However, I believe this logic is in correct since the request is already send downstream to the CommitProcessor. The observer and the follower have no other option but to send the request to leader. 
unit tests.  For our internal branch, we haven't run into bugs related to local session for quite a while so it is quite stable. We enabled local session by default in all our deployment.

Diff revision 6 (Latest)

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

  1. /src/c/include/zookeeper.h: Loading...
  2. /src/java/main/org/apache/zookeeper/KeeperException.java: Loading...
  3. /src/java/main/org/apache/zookeeper/cli/CreateCommand.java: Loading...
  4. /src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java: Loading...
  5. /src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java: Loading...
  6. /src/java/main/org/apache/zookeeper/server/Request.java: Loading...
  7. /src/java/main/org/apache/zookeeper/server/SessionTracker.java: Loading...
  8. /src/java/main/org/apache/zookeeper/server/SessionTrackerImpl.java: Loading...
  9. /src/java/main/org/apache/zookeeper/server/TraceFormatter.java: Loading...
  10. /src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java: Loading...
  11. /src/java/main/org/apache/zookeeper/server/quorum/CommitProcessor.java: Loading...
  12. /src/java/main/org/apache/zookeeper/server/quorum/FollowerRequestProcessor.java: Loading...
  13. /src/java/main/org/apache/zookeeper/server/quorum/LeaderRequestProcessor.java: Loading...
  14. /src/java/main/org/apache/zookeeper/server/quorum/LeaderSessionTracker.java: Loading...
  15. /src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java: Loading...
  16. /src/java/main/org/apache/zookeeper/server/quorum/Learner.java: Loading...
  17. /src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java: Loading...
  18. /src/java/main/org/apache/zookeeper/server/quorum/LearnerSessionTracker.java: Loading...
  19. /src/java/main/org/apache/zookeeper/server/quorum/LearnerZooKeeperServer.java: Loading...
  20. /src/java/main/org/apache/zookeeper/server/quorum/LocalSessionTracker.java: Loading...
This diff has been split across 2 pages: 1 2 >
/src/c/include/zookeeper.h
Revision 1463329 New Change
[20] 113 lines
[+20] [+] enum ZOO_ERRORS {
114
  ZCLOSING = -116, /*!< ZooKeeper is closing */
114
  ZCLOSING = -116, /*!< ZooKeeper is closing */
115
  ZNOTHING = -117, /*!< (not error) no server responses to process */
115
  ZNOTHING = -117, /*!< (not error) no server responses to process */
116
  ZSESSIONMOVED = -118, /*!<session moved to another server, so operation is ignored */
116
  ZSESSIONMOVED = -118, /*!<session moved to another server, so operation is ignored */
117
  ZNEWCONFIGNOQUORUM = -120,  /*!< No quorum of new config is connected and up-to-date with the leader of last commmitted config - try
117
  ZNEWCONFIGNOQUORUM = -120,  /*!< No quorum of new config is connected and up-to-date with the leader of last commmitted config - try
118
                                 invoking reconfiguration after new servers are connected and synced */
118
                                 invoking reconfiguration after new servers are connected and synced */
119
  ZRECONFIGINPROGRESS = -121  /*!< Reconfiguration requested while another reconfiguration is currently in progress. This is currently
119
  ZRECONFIGINPROGRESS = -121,  /*!< Reconfiguration requested while another reconfiguration is currently in progress. This is currently
120
                                       not supported. Please retry. */
120
                                       not supported. Please retry. */

    
   
121
  ZEPHEMERALONLOCALSESSION = -122 /*!< Attempt to create ephemeral node on a local session */
121
};
122
};
122

    
   
123

   
123
#ifdef __cplusplus
124
#ifdef __cplusplus
124
extern "C" {
125
extern "C" {
125
#endif
126
#endif
[+20] [20] 1799 lines
/src/java/main/org/apache/zookeeper/KeeperException.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/cli/CreateCommand.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/Request.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/SessionTracker.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/SessionTrackerImpl.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/TraceFormatter.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/CommitProcessor.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/FollowerRequestProcessor.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/LeaderRequestProcessor.java
New File
 
/src/java/main/org/apache/zookeeper/server/quorum/LeaderSessionTracker.java
New File
 
/src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/Learner.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/LearnerSessionTracker.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/LearnerZooKeeperServer.java
Revision 1463329 New Change
 
/src/java/main/org/apache/zookeeper/server/quorum/LocalSessionTracker.java
New File
 
  1. /src/c/include/zookeeper.h: Loading...
  2. /src/java/main/org/apache/zookeeper/KeeperException.java: Loading...
  3. /src/java/main/org/apache/zookeeper/cli/CreateCommand.java: Loading...
  4. /src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java: Loading...
  5. /src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java: Loading...
  6. /src/java/main/org/apache/zookeeper/server/Request.java: Loading...
  7. /src/java/main/org/apache/zookeeper/server/SessionTracker.java: Loading...
  8. /src/java/main/org/apache/zookeeper/server/SessionTrackerImpl.java: Loading...
  9. /src/java/main/org/apache/zookeeper/server/TraceFormatter.java: Loading...
  10. /src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java: Loading...
  11. /src/java/main/org/apache/zookeeper/server/quorum/CommitProcessor.java: Loading...
  12. /src/java/main/org/apache/zookeeper/server/quorum/FollowerRequestProcessor.java: Loading...
  13. /src/java/main/org/apache/zookeeper/server/quorum/LeaderRequestProcessor.java: Loading...
  14. /src/java/main/org/apache/zookeeper/server/quorum/LeaderSessionTracker.java: Loading...
  15. /src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java: Loading...
  16. /src/java/main/org/apache/zookeeper/server/quorum/Learner.java: Loading...
  17. /src/java/main/org/apache/zookeeper/server/quorum/LearnerHandler.java: Loading...
  18. /src/java/main/org/apache/zookeeper/server/quorum/LearnerSessionTracker.java: Loading...
  19. /src/java/main/org/apache/zookeeper/server/quorum/LearnerZooKeeperServer.java: Loading...
  20. /src/java/main/org/apache/zookeeper/server/quorum/LocalSessionTracker.java: Loading...
This diff has been split across 2 pages: 1 2 >