{"action":"created","comment":{"url":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/comments/88696179","pull_request_review_id":9263198,"id":88696179,"diff_hunk":"@@ -143,102 +142,147 @@ public void checkpointState() {\n     }\n \n     /**\n-     * Service an incoming token request.\n+     * Returns true if the txn commits.\n+     * If the request submits a timestamp (a global offset) that is less than one of the\n+     * global offsets of a stream specified in the request, then abort; otherwise commit.\n+     *\n+     * @param timestamp Read timestamp of the txn; in order to commit, no writes may be made past this\n+     *                  (global) timestamp on any streams touched by the txn.\n+     * @param streams   Read set of the txn.\n      */\n-    @ServerHandler(type=CorfuMsgType.TOKEN_REQ)\n-    public synchronized void tokenRequest(CorfuPayloadMsg<TokenRequest> msg,\n-                                          ChannelHandlerContext ctx, IServerRouter r) {\n-        TokenRequest req = msg.getPayload();\n-        if (req.getNumTokens() == 0) {\n-            long max = 0L;\n-            boolean hit = false;\n-            ImmutableMap.Builder<UUID, Long> streamsLastIssued = ImmutableMap.builder();\n-            for (UUID id : req.getStreams()) {\n-                lastLocalOffsetMap.compute(id, (k, v) -> {\n+    public boolean txnResolution(long timestamp, Set<UUID> streams) {\n+        // If the timestamp is -1L, then the transaction automatically commits.\n+        if (timestamp != -1L) {\n+            AtomicBoolean abort = new AtomicBoolean(false);\n+            for (UUID id : streams) {\n+                if (abort.get())\n+                    break;\n+                lastGlobalOffsetMap.compute(id, (k, v) -> {\n                     if (v == null) {\n-                        streamsLastIssued.put(k, -1L);\n                         return null;\n+                    } else {\n+                        if (v > timestamp) {\n+                            log.debug(\"Rejecting request due to {} > {} on stream {}\", v, timestamp, id);\n+                            abort.set(true);\n+                        }\n                     }\n-                    streamsLastIssued.put(k, v);\n                     return v;\n                 });\n-                Long lastIssued = lastIssuedMap.get(id);\n-                if (lastIssued != null) {\n-                    hit = true;\n-                }\n-                max = Math.max(max, lastIssued == null ? Long.MIN_VALUE : lastIssued);\n             }\n-            if (!hit) {\n-                max = -1L; //no token ever issued\n+            if (abort.get()) {\n+                return false;\n             }\n-            if (req.getStreams().size() == 0) {\n-                max = globalIndex.get() - 1;\n+        }\n+        return true;\n+    }\n+\n+    public void returnLatestOffsets(CorfuPayloadMsg<TokenRequest> msg,\n+                                    ChannelHandlerContext ctx, IServerRouter r) {\n+        TokenRequest req = msg.getPayload();\n+        // If no streams are specified in the request, this value returns the last global token issued.\n+        long latestGlobalOffset = 0L;","path":"infrastructure/src/main/java/org/corfudb/infrastructure/SequencerServer.java","position":99,"original_position":99,"commit_id":"78fbd84e6cca9aff040784d936c5cdf65ca4eab3","original_commit_id":"78fbd84e6cca9aff040784d936c5cdf65ca4eab3","user":{"login":"dahliamalkhi","id":5497591,"avatar_url":"https://avatars.githubusercontent.com/u/5497591?v=3","gravatar_id":"","url":"https://api.github.com/users/dahliamalkhi","html_url":"https://github.com/dahliamalkhi","followers_url":"https://api.github.com/users/dahliamalkhi/followers","following_url":"https://api.github.com/users/dahliamalkhi/following{/other_user}","gists_url":"https://api.github.com/users/dahliamalkhi/gists{/gist_id}","starred_url":"https://api.github.com/users/dahliamalkhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dahliamalkhi/subscriptions","organizations_url":"https://api.github.com/users/dahliamalkhi/orgs","repos_url":"https://api.github.com/users/dahliamalkhi/repos","events_url":"https://api.github.com/users/dahliamalkhi/events{/privacy}","received_events_url":"https://api.github.com/users/dahliamalkhi/received_events","type":"User","site_admin":false},"body":"initialize to -1L instead, and then no need to check \"hit\"","created_at":"2016-11-18T17:03:35Z","updated_at":"2016-11-18T17:03:35Z","html_url":"https://github.com/CorfuDB/CorfuDB/pull/290#discussion_r88696179","pull_request_url":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290","_links":{"self":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/comments/88696179"},"html":{"href":"https://github.com/CorfuDB/CorfuDB/pull/290#discussion_r88696179"},"pull_request":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290"}}},"pull_request":{"url":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290","id":94014094,"html_url":"https://github.com/CorfuDB/CorfuDB/pull/290","diff_url":"https://github.com/CorfuDB/CorfuDB/pull/290.diff","patch_url":"https://github.com/CorfuDB/CorfuDB/pull/290.patch","issue_url":"https://api.github.com/repos/CorfuDB/CorfuDB/issues/290","number":290,"state":"open","locked":false,"title":"Renaming and commenting the sequencer","user":{"login":"amytai","id":3322959,"avatar_url":"https://avatars.githubusercontent.com/u/3322959?v=3","gravatar_id":"","url":"https://api.github.com/users/amytai","html_url":"https://github.com/amytai","followers_url":"https://api.github.com/users/amytai/followers","following_url":"https://api.github.com/users/amytai/following{/other_user}","gists_url":"https://api.github.com/users/amytai/gists{/gist_id}","starred_url":"https://api.github.com/users/amytai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amytai/subscriptions","organizations_url":"https://api.github.com/users/amytai/orgs","repos_url":"https://api.github.com/users/amytai/repos","events_url":"https://api.github.com/users/amytai/events{/privacy}","received_events_url":"https://api.github.com/users/amytai/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-16T17:37:52Z","updated_at":"2016-11-18T17:13:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9c9bc3eda528f328bcaeb4ec78becfc73f42d77","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290/commits","review_comments_url":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290/comments","review_comment_url":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CorfuDB/CorfuDB/issues/290/comments","statuses_url":"https://api.github.com/repos/CorfuDB/CorfuDB/statuses/78fbd84e6cca9aff040784d936c5cdf65ca4eab3","head":{"label":"amytai:master","ref":"master","sha":"78fbd84e6cca9aff040784d936c5cdf65ca4eab3","user":{"login":"amytai","id":3322959,"avatar_url":"https://avatars.githubusercontent.com/u/3322959?v=3","gravatar_id":"","url":"https://api.github.com/users/amytai","html_url":"https://github.com/amytai","followers_url":"https://api.github.com/users/amytai/followers","following_url":"https://api.github.com/users/amytai/following{/other_user}","gists_url":"https://api.github.com/users/amytai/gists{/gist_id}","starred_url":"https://api.github.com/users/amytai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amytai/subscriptions","organizations_url":"https://api.github.com/users/amytai/orgs","repos_url":"https://api.github.com/users/amytai/repos","events_url":"https://api.github.com/users/amytai/events{/privacy}","received_events_url":"https://api.github.com/users/amytai/received_events","type":"User","site_admin":false},"repo":{"id":56518746,"name":"CorfuDB","full_name":"amytai/CorfuDB","owner":{"login":"amytai","id":3322959,"avatar_url":"https://avatars.githubusercontent.com/u/3322959?v=3","gravatar_id":"","url":"https://api.github.com/users/amytai","html_url":"https://github.com/amytai","followers_url":"https://api.github.com/users/amytai/followers","following_url":"https://api.github.com/users/amytai/following{/other_user}","gists_url":"https://api.github.com/users/amytai/gists{/gist_id}","starred_url":"https://api.github.com/users/amytai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amytai/subscriptions","organizations_url":"https://api.github.com/users/amytai/orgs","repos_url":"https://api.github.com/users/amytai/repos","events_url":"https://api.github.com/users/amytai/events{/privacy}","received_events_url":"https://api.github.com/users/amytai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amytai/CorfuDB","description":"A cluster consistency platform","fork":true,"url":"https://api.github.com/repos/amytai/CorfuDB","forks_url":"https://api.github.com/repos/amytai/CorfuDB/forks","keys_url":"https://api.github.com/repos/amytai/CorfuDB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amytai/CorfuDB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amytai/CorfuDB/teams","hooks_url":"https://api.github.com/repos/amytai/CorfuDB/hooks","issue_events_url":"https://api.github.com/repos/amytai/CorfuDB/issues/events{/number}","events_url":"https://api.github.com/repos/amytai/CorfuDB/events","assignees_url":"https://api.github.com/repos/amytai/CorfuDB/assignees{/user}","branches_url":"https://api.github.com/repos/amytai/CorfuDB/branches{/branch}","tags_url":"https://api.github.com/repos/amytai/CorfuDB/tags","blobs_url":"https://api.github.com/repos/amytai/CorfuDB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amytai/CorfuDB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amytai/CorfuDB/git/refs{/sha}","trees_url":"https://api.github.com/repos/amytai/CorfuDB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amytai/CorfuDB/statuses/{sha}","languages_url":"https://api.github.com/repos/amytai/CorfuDB/languages","stargazers_url":"https://api.github.com/repos/amytai/CorfuDB/stargazers","contributors_url":"https://api.github.com/repos/amytai/CorfuDB/contributors","subscribers_url":"https://api.github.com/repos/amytai/CorfuDB/subscribers","subscription_url":"https://api.github.com/repos/amytai/CorfuDB/subscription","commits_url":"https://api.github.com/repos/amytai/CorfuDB/commits{/sha}","git_commits_url":"https://api.github.com/repos/amytai/CorfuDB/git/commits{/sha}","comments_url":"https://api.github.com/repos/amytai/CorfuDB/comments{/number}","issue_comment_url":"https://api.github.com/repos/amytai/CorfuDB/issues/comments{/number}","contents_url":"https://api.github.com/repos/amytai/CorfuDB/contents/{+path}","compare_url":"https://api.github.com/repos/amytai/CorfuDB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amytai/CorfuDB/merges","archive_url":"https://api.github.com/repos/amytai/CorfuDB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amytai/CorfuDB/downloads","issues_url":"https://api.github.com/repos/amytai/CorfuDB/issues{/number}","pulls_url":"https://api.github.com/repos/amytai/CorfuDB/pulls{/number}","milestones_url":"https://api.github.com/repos/amytai/CorfuDB/milestones{/number}","notifications_url":"https://api.github.com/repos/amytai/CorfuDB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amytai/CorfuDB/labels{/name}","releases_url":"https://api.github.com/repos/amytai/CorfuDB/releases{/id}","deployments_url":"https://api.github.com/repos/amytai/CorfuDB/deployments","created_at":"2016-04-18T15:17:30Z","updated_at":"2016-11-11T19:55:58Z","pushed_at":"2016-11-18T00:58:51Z","git_url":"git://github.com/amytai/CorfuDB.git","ssh_url":"git@github.com:amytai/CorfuDB.git","clone_url":"https://github.com/amytai/CorfuDB.git","svn_url":"https://github.com/amytai/CorfuDB","homepage":"","size":817671,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CorfuDB:master","ref":"master","sha":"170b77d1b1f8b9788fa9f552ce63e0c21bee784b","user":{"login":"CorfuDB","id":10199273,"avatar_url":"https://avatars.githubusercontent.com/u/10199273?v=3","gravatar_id":"","url":"https://api.github.com/users/CorfuDB","html_url":"https://github.com/CorfuDB","followers_url":"https://api.github.com/users/CorfuDB/followers","following_url":"https://api.github.com/users/CorfuDB/following{/other_user}","gists_url":"https://api.github.com/users/CorfuDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CorfuDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CorfuDB/subscriptions","organizations_url":"https://api.github.com/users/CorfuDB/orgs","repos_url":"https://api.github.com/users/CorfuDB/repos","events_url":"https://api.github.com/users/CorfuDB/events{/privacy}","received_events_url":"https://api.github.com/users/CorfuDB/received_events","type":"Organization","site_admin":false},"repo":{"id":12960439,"name":"CorfuDB","full_name":"CorfuDB/CorfuDB","owner":{"login":"CorfuDB","id":10199273,"avatar_url":"https://avatars.githubusercontent.com/u/10199273?v=3","gravatar_id":"","url":"https://api.github.com/users/CorfuDB","html_url":"https://github.com/CorfuDB","followers_url":"https://api.github.com/users/CorfuDB/followers","following_url":"https://api.github.com/users/CorfuDB/following{/other_user}","gists_url":"https://api.github.com/users/CorfuDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CorfuDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CorfuDB/subscriptions","organizations_url":"https://api.github.com/users/CorfuDB/orgs","repos_url":"https://api.github.com/users/CorfuDB/repos","events_url":"https://api.github.com/users/CorfuDB/events{/privacy}","received_events_url":"https://api.github.com/users/CorfuDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CorfuDB/CorfuDB","description":"A cluster consistency platform","fork":false,"url":"https://api.github.com/repos/CorfuDB/CorfuDB","forks_url":"https://api.github.com/repos/CorfuDB/CorfuDB/forks","keys_url":"https://api.github.com/repos/CorfuDB/CorfuDB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CorfuDB/CorfuDB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CorfuDB/CorfuDB/teams","hooks_url":"https://api.github.com/repos/CorfuDB/CorfuDB/hooks","issue_events_url":"https://api.github.com/repos/CorfuDB/CorfuDB/issues/events{/number}","events_url":"https://api.github.com/repos/CorfuDB/CorfuDB/events","assignees_url":"https://api.github.com/repos/CorfuDB/CorfuDB/assignees{/user}","branches_url":"https://api.github.com/repos/CorfuDB/CorfuDB/branches{/branch}","tags_url":"https://api.github.com/repos/CorfuDB/CorfuDB/tags","blobs_url":"https://api.github.com/repos/CorfuDB/CorfuDB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CorfuDB/CorfuDB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CorfuDB/CorfuDB/git/refs{/sha}","trees_url":"https://api.github.com/repos/CorfuDB/CorfuDB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CorfuDB/CorfuDB/statuses/{sha}","languages_url":"https://api.github.com/repos/CorfuDB/CorfuDB/languages","stargazers_url":"https://api.github.com/repos/CorfuDB/CorfuDB/stargazers","contributors_url":"https://api.github.com/repos/CorfuDB/CorfuDB/contributors","subscribers_url":"https://api.github.com/repos/CorfuDB/CorfuDB/subscribers","subscription_url":"https://api.github.com/repos/CorfuDB/CorfuDB/subscription","commits_url":"https://api.github.com/repos/CorfuDB/CorfuDB/commits{/sha}","git_commits_url":"https://api.github.com/repos/CorfuDB/CorfuDB/git/commits{/sha}","comments_url":"https://api.github.com/repos/CorfuDB/CorfuDB/comments{/number}","issue_comment_url":"https://api.github.com/repos/CorfuDB/CorfuDB/issues/comments{/number}","contents_url":"https://api.github.com/repos/CorfuDB/CorfuDB/contents/{+path}","compare_url":"https://api.github.com/repos/CorfuDB/CorfuDB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CorfuDB/CorfuDB/merges","archive_url":"https://api.github.com/repos/CorfuDB/CorfuDB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CorfuDB/CorfuDB/downloads","issues_url":"https://api.github.com/repos/CorfuDB/CorfuDB/issues{/number}","pulls_url":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls{/number}","milestones_url":"https://api.github.com/repos/CorfuDB/CorfuDB/milestones{/number}","notifications_url":"https://api.github.com/repos/CorfuDB/CorfuDB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CorfuDB/CorfuDB/labels{/name}","releases_url":"https://api.github.com/repos/CorfuDB/CorfuDB/releases{/id}","deployments_url":"https://api.github.com/repos/CorfuDB/CorfuDB/deployments","created_at":"2013-09-19T22:02:36Z","updated_at":"2016-11-17T11:44:39Z","pushed_at":"2016-11-18T09:01:55Z","git_url":"git://github.com/CorfuDB/CorfuDB.git","ssh_url":"git@github.com:CorfuDB/CorfuDB.git","clone_url":"https://github.com/CorfuDB/CorfuDB.git","svn_url":"https://github.com/CorfuDB/CorfuDB","homepage":"","size":293294,"stargazers_count":101,"watchers_count":101,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"open_issues_count":62,"forks":26,"open_issues":62,"watchers":101,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290"},"html":{"href":"https://github.com/CorfuDB/CorfuDB/pull/290"},"issue":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/issues/290"},"comments":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/issues/290/comments"},"review_comments":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290/comments"},"review_comment":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/pulls/290/commits"},"statuses":{"href":"https://api.github.com/repos/CorfuDB/CorfuDB/statuses/78fbd84e6cca9aff040784d936c5cdf65ca4eab3"}}}}
{"actor":{"display_login":"dahliamalkhi"}}