{"action":"created","comment":{"url":"https://api.github.com/repos/apache/flink/pulls/comments/198431042","pull_request_review_id":132358001,"id":198431042,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODQzMTA0Mg==","diff_hunk":"@@ -0,0 +1,99 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.flink.runtime.state.ttl;\n+\n+import org.apache.flink.util.Preconditions;\n+import org.apache.flink.util.function.SupplierWithException;\n+import org.apache.flink.util.function.ThrowingConsumer;\n+import org.apache.flink.util.function.ThrowingRunnable;\n+\n+/**\n+ * Base class for TTL logic wrappers.\n+ *\n+ * @param <T> Type of originally wrapped object\n+ */\n+abstract class AbstractTtlDecorator<T> {\n+\tfinal T original;\n+\tfinal TtlConfig config;\n+\tfinal TtlTimeProvider timeProvider;\n+\tfinal boolean updateTsOnRead;\n+\tfinal boolean returnExpired;\n+\tfinal long ttl;\n+\n+\tAbstractTtlDecorator(\n+\t\tT original,\n+\t\tTtlConfig config,\n+\t\tTtlTimeProvider timeProvider) {\n+\t\tPreconditions.checkNotNull(original);\n+\t\tPreconditions.checkNotNull(config);\n+\t\tPreconditions.checkNotNull(timeProvider);\n+\t\tPreconditions.checkArgument(config.getTtlUpdateType() != TtlUpdateType.Disabled,\n+\t\t\t\"State does not need to be wrapped with TTL if it is configured as disabled.\");\n+\t\tthis.original = original;\n+\t\tthis.config = config;\n+\t\tthis.timeProvider = timeProvider;\n+\t\tthis.updateTsOnRead = config.getTtlUpdateType() == TtlUpdateType.OnReadAndWrite;\n+\t\tthis.returnExpired = config.getStateVisibility() == TtlStateVisibility.Relaxed;\n+\t\tthis.ttl = config.getTtl().toMilliseconds();\n+\t}\n+\n+\t<V> V getUnexpried(TtlValue<V> ttlValue) {\n+\t\treturn ttlValue == null || (expired(ttlValue) && !returnExpired) ? null : ttlValue.getUserValue();\n+\t}\n+\n+\t<V> boolean expired(TtlValue<V> ttlValue) {\n+\t\treturn ttlValue != null && ttlValue.getExpirationTimestamp() <= timeProvider.currentTimestamp();\n+\t}\n+\n+\t<V> TtlValue<V> wrapWithTs(V value) {","path":"flink-runtime/src/main/java/org/apache/flink/runtime/state/ttl/AbstractTtlDecorator.java","position":64,"original_position":64,"commit_id":"6cb57807a0a46e1657099adeb3a466039f1b379f","original_commit_id":"6cb57807a0a46e1657099adeb3a466039f1b379f","user":{"login":"azagrebin","id":10573485,"node_id":"MDQ6VXNlcjEwNTczNDg1","avatar_url":"https://avatars3.githubusercontent.com/u/10573485?v=4","gravatar_id":"","url":"https://api.github.com/users/azagrebin","html_url":"https://github.com/azagrebin","followers_url":"https://api.github.com/users/azagrebin/followers","following_url":"https://api.github.com/users/azagrebin/following{/other_user}","gists_url":"https://api.github.com/users/azagrebin/gists{/gist_id}","starred_url":"https://api.github.com/users/azagrebin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azagrebin/subscriptions","organizations_url":"https://api.github.com/users/azagrebin/orgs","repos_url":"https://api.github.com/users/azagrebin/repos","events_url":"https://api.github.com/users/azagrebin/events{/privacy}","received_events_url":"https://api.github.com/users/azagrebin/received_events","type":"User","site_admin":false},"body":"It actually wraps with expiration timestamp, TTL is not stored with value.","created_at":"2018-06-27T09:43:41Z","updated_at":"2018-06-27T09:43:41Z","html_url":"https://github.com/apache/flink/pull/6186#discussion_r198431042","pull_request_url":"https://api.github.com/repos/apache/flink/pulls/6186","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/198431042"},"html":{"href":"https://github.com/apache/flink/pull/6186#discussion_r198431042"},"pull_request":{"href":"https://api.github.com/repos/apache/flink/pulls/6186"}},"in_reply_to_id":197460522},"pull_request":{"url":"https://api.github.com/repos/apache/flink/pulls/6186","id":196088381,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MDg4Mzgx","html_url":"https://github.com/apache/flink/pull/6186","diff_url":"https://github.com/apache/flink/pull/6186.diff","patch_url":"https://github.com/apache/flink/pull/6186.patch","issue_url":"https://api.github.com/repos/apache/flink/issues/6186","number":6186,"state":"open","locked":false,"title":"[FLINK-9514,FLINK-9515,FLINK-9516] State ttl wrappers","user":{"login":"azagrebin","id":10573485,"node_id":"MDQ6VXNlcjEwNTczNDg1","avatar_url":"https://avatars3.githubusercontent.com/u/10573485?v=4","gravatar_id":"","url":"https://api.github.com/users/azagrebin","html_url":"https://github.com/azagrebin","followers_url":"https://api.github.com/users/azagrebin/followers","following_url":"https://api.github.com/users/azagrebin/following{/other_user}","gists_url":"https://api.github.com/users/azagrebin/gists{/gist_id}","starred_url":"https://api.github.com/users/azagrebin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azagrebin/subscriptions","organizations_url":"https://api.github.com/users/azagrebin/orgs","repos_url":"https://api.github.com/users/azagrebin/repos","events_url":"https://api.github.com/users/azagrebin/events{/privacy}","received_events_url":"https://api.github.com/users/azagrebin/received_events","type":"User","site_admin":false},"body":"## What is the purpose of the change\r\n\r\nThis PR introduces TTL logic wrappers for state objects.\r\n\r\n## Brief change log\r\n\r\nAdded\r\n  - sketch of TtlConfig\r\n  - AbstractTtlWrapper and AbstractTtlState\r\n  - concrete TTL wrappers for state objects\r\n\r\n## Verifying this change\r\n\r\nUnit tests for state objects TTL wrappers\r\n\r\n## Does this pull request potentially affect one of the following parts:\r\n\r\n  - Dependencies (does it add or upgrade a dependency): (no)\r\n  - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)\r\n  - The serializers: (no)\r\n  - The runtime per-record code paths (performance sensitive): (no)\r\n  - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)\r\n  - The S3 file system connector: (no)\r\n\r\n## Documentation\r\n\r\n  - Does this pull request introduce a new feature? (yes)\r\n  - If yes, how is the feature documented? (not applicable at this step)\r\n","created_at":"2018-06-20T10:15:44Z","updated_at":"2018-06-27T09:43:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f074c476a7dbf67db9b78bb1a03957a751397ef5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/flink/pulls/6186/commits","review_comments_url":"https://api.github.com/repos/apache/flink/pulls/6186/comments","review_comment_url":"https://api.github.com/repos/apache/flink/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/flink/issues/6186/comments","statuses_url":"https://api.github.com/repos/apache/flink/statuses/6cb57807a0a46e1657099adeb3a466039f1b379f","head":{"label":"azagrebin:FLINK-9515","ref":"FLINK-9515","sha":"6cb57807a0a46e1657099adeb3a466039f1b379f","user":{"login":"azagrebin","id":10573485,"node_id":"MDQ6VXNlcjEwNTczNDg1","avatar_url":"https://avatars3.githubusercontent.com/u/10573485?v=4","gravatar_id":"","url":"https://api.github.com/users/azagrebin","html_url":"https://github.com/azagrebin","followers_url":"https://api.github.com/users/azagrebin/followers","following_url":"https://api.github.com/users/azagrebin/following{/other_user}","gists_url":"https://api.github.com/users/azagrebin/gists{/gist_id}","starred_url":"https://api.github.com/users/azagrebin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azagrebin/subscriptions","organizations_url":"https://api.github.com/users/azagrebin/orgs","repos_url":"https://api.github.com/users/azagrebin/repos","events_url":"https://api.github.com/users/azagrebin/events{/privacy}","received_events_url":"https://api.github.com/users/azagrebin/received_events","type":"User","site_admin":false},"repo":{"id":127914721,"node_id":"MDEwOlJlcG9zaXRvcnkxMjc5MTQ3MjE=","name":"flink","full_name":"azagrebin/flink","owner":{"login":"azagrebin","id":10573485,"node_id":"MDQ6VXNlcjEwNTczNDg1","avatar_url":"https://avatars3.githubusercontent.com/u/10573485?v=4","gravatar_id":"","url":"https://api.github.com/users/azagrebin","html_url":"https://github.com/azagrebin","followers_url":"https://api.github.com/users/azagrebin/followers","following_url":"https://api.github.com/users/azagrebin/following{/other_user}","gists_url":"https://api.github.com/users/azagrebin/gists{/gist_id}","starred_url":"https://api.github.com/users/azagrebin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azagrebin/subscriptions","organizations_url":"https://api.github.com/users/azagrebin/orgs","repos_url":"https://api.github.com/users/azagrebin/repos","events_url":"https://api.github.com/users/azagrebin/events{/privacy}","received_events_url":"https://api.github.com/users/azagrebin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/azagrebin/flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/azagrebin/flink","forks_url":"https://api.github.com/repos/azagrebin/flink/forks","keys_url":"https://api.github.com/repos/azagrebin/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/azagrebin/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/azagrebin/flink/teams","hooks_url":"https://api.github.com/repos/azagrebin/flink/hooks","issue_events_url":"https://api.github.com/repos/azagrebin/flink/issues/events{/number}","events_url":"https://api.github.com/repos/azagrebin/flink/events","assignees_url":"https://api.github.com/repos/azagrebin/flink/assignees{/user}","branches_url":"https://api.github.com/repos/azagrebin/flink/branches{/branch}","tags_url":"https://api.github.com/repos/azagrebin/flink/tags","blobs_url":"https://api.github.com/repos/azagrebin/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/azagrebin/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/azagrebin/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/azagrebin/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/azagrebin/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/azagrebin/flink/languages","stargazers_url":"https://api.github.com/repos/azagrebin/flink/stargazers","contributors_url":"https://api.github.com/repos/azagrebin/flink/contributors","subscribers_url":"https://api.github.com/repos/azagrebin/flink/subscribers","subscription_url":"https://api.github.com/repos/azagrebin/flink/subscription","commits_url":"https://api.github.com/repos/azagrebin/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/azagrebin/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/azagrebin/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/azagrebin/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/azagrebin/flink/contents/{+path}","compare_url":"https://api.github.com/repos/azagrebin/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/azagrebin/flink/merges","archive_url":"https://api.github.com/repos/azagrebin/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/azagrebin/flink/downloads","issues_url":"https://api.github.com/repos/azagrebin/flink/issues{/number}","pulls_url":"https://api.github.com/repos/azagrebin/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/azagrebin/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/azagrebin/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/azagrebin/flink/labels{/name}","releases_url":"https://api.github.com/repos/azagrebin/flink/releases{/id}","deployments_url":"https://api.github.com/repos/azagrebin/flink/deployments","created_at":"2018-04-03T13:44:01Z","updated_at":"2018-05-08T13:09:18Z","pushed_at":"2018-06-22T11:56:44Z","git_url":"git://github.com/azagrebin/flink.git","ssh_url":"git@github.com:azagrebin/flink.git","clone_url":"https://github.com/azagrebin/flink.git","svn_url":"https://github.com/azagrebin/flink","homepage":null,"size":157064,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"2d6972d40541f953aa66fe556d5b27eb2fb536c6","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":20587599,"node_id":"MDEwOlJlcG9zaXRvcnkyMDU4NzU5OQ==","name":"flink","full_name":"apache/flink","owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/flink","forks_url":"https://api.github.com/repos/apache/flink/forks","keys_url":"https://api.github.com/repos/apache/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/flink/teams","hooks_url":"https://api.github.com/repos/apache/flink/hooks","issue_events_url":"https://api.github.com/repos/apache/flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/flink/events","assignees_url":"https://api.github.com/repos/apache/flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/flink/tags","blobs_url":"https://api.github.com/repos/apache/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/flink/languages","stargazers_url":"https://api.github.com/repos/apache/flink/stargazers","contributors_url":"https://api.github.com/repos/apache/flink/contributors","subscribers_url":"https://api.github.com/repos/apache/flink/subscribers","subscription_url":"https://api.github.com/repos/apache/flink/subscription","commits_url":"https://api.github.com/repos/apache/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/flink/merges","archive_url":"https://api.github.com/repos/apache/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/flink/downloads","issues_url":"https://api.github.com/repos/apache/flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/flink/releases{/id}","deployments_url":"https://api.github.com/repos/apache/flink/deployments","created_at":"2014-06-07T07:00:10Z","updated_at":"2018-06-27T09:27:17Z","pushed_at":"2018-06-27T09:41:51Z","git_url":"git://github.com/apache/flink.git","ssh_url":"git@github.com:apache/flink.git","clone_url":"https://github.com/apache/flink.git","svn_url":"https://github.com/apache/flink","homepage":null,"size":157651,"stargazers_count":3874,"watchers_count":3874,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2618,"mirror_url":null,"archived":false,"open_issues_count":374,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2618,"open_issues":374,"watchers":3874,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/6186"},"html":{"href":"https://github.com/apache/flink/pull/6186"},"issue":{"href":"https://api.github.com/repos/apache/flink/issues/6186"},"comments":{"href":"https://api.github.com/repos/apache/flink/issues/6186/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/flink/pulls/6186/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/flink/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/flink/pulls/6186/commits"},"statuses":{"href":"https://api.github.com/repos/apache/flink/statuses/6cb57807a0a46e1657099adeb3a466039f1b379f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"azagrebin"}}