zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hanm <...@git.apache.org>
Subject [GitHub] zookeeper pull request #195: ZOOKEEPER-2725: Promote local session to global...
Date Sun, 19 Mar 2017 03:39:07 GMT
Github user hanm commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/195#discussion_r106797306
  
    --- Diff: src/java/main/org/apache/zookeeper/server/quorum/QuorumZooKeeperServer.java
---
    @@ -62,18 +64,40 @@ public Request checkUpgradeSession(Request request)
             // This is called by the request processor thread (either follower
             // or observer request processor), which is unique to a learner.
             // So will not be called concurrently by two threads.
    -        if (request.type != OpCode.create ||
    +        if ((request.type != OpCode.create && request.type != OpCode.create2
&& request.type != OpCode.multi) ||
                 !upgradeableSessionTracker.isLocalSession(request.sessionId)) {
                 return null;
             }
    -        CreateRequest createRequest = new CreateRequest();
    -        request.request.rewind();
    -        ByteBufferInputStream.byteBuffer2Record(request.request, createRequest);
    -        request.request.rewind();
    -        CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags());
    -        if (!createMode.isEphemeral()) {
    -            return null;
    +
    +        if (OpCode.multi == request.type) {
    +            MultiTransactionRecord multiTransactionRecord = new MultiTransactionRecord();
    +            request.request.rewind();
    +            ByteBufferInputStream.byteBuffer2Record(request.request, multiTransactionRecord);
    +            request.request.rewind();
    +            boolean containsEphemeralCreate = false;
    +            for (Op op : multiTransactionRecord) {
    +                if (op.getType() == OpCode.create || op.getType() == OpCode.create2)
{
    +                    CreateRequest createRequest = (CreateRequest)op.toRequestRecord();
    +                    CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags());
    +                    if (createMode.isEphemeral()) {
    +                        containsEphemeralCreate = true;
    --- End diff --
    
    I think we can just return null here (or break the loop) - there is no need to check rest
of ops because as long as there is an ephemeral / create we'd upgrade session?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message