zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "maoling (JIRA)" <j...@apache.org>
Subject [jira] [Created] (ZOOKEEPER-3506) correct the SessionTrackerImpl#initializeNextSession's java doc about how to generate the sessionId
Date Wed, 14 Aug 2019 08:48:00 GMT
maoling created ZOOKEEPER-3506:
----------------------------------

             Summary: correct the SessionTrackerImpl#initializeNextSession's java doc about
how to generate the sessionId
                 Key: ZOOKEEPER-3506
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3506
             Project: ZooKeeper
          Issue Type: Improvement
          Components: documentation, server
            Reporter: maoling
             Fix For: 3.6.0


 
{code:java}
/**
 * Generates an initial sessionId. High order byte is serverId, next 5
 * 5 bytes are from timestamp, and low order 2 bytes are 0s.
 */
public static long initializeNextSession(long id) {
    long nextSid;
    nextSid = (Time.currentElapsedTime() << 24) >>> 8;
    nextSid =  nextSid | (id <<56);
    if (nextSid == EphemeralType.CONTAINER_EPHEMERAL_OWNER) {
        ++nextSid;  // this is an unlikely edge case, but check it just in case
    }
    return nextSid;
}
{code}
 

 



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Mime
View raw message