{"action":"created","comment":{"url":"https://api.github.com/repos/Netflix/eureka/pulls/comments/24693023","id":24693023,"diff_hunk":"@@ -0,0 +1,170 @@\n+package com.netflix.eureka2.client.interest;\n+\n+import java.util.Collections;\n+import java.util.Map;\n+import java.util.Set;\n+import java.util.concurrent.ConcurrentHashMap;\n+\n+import com.netflix.eureka2.interests.ChangeNotification;\n+import com.netflix.eureka2.interests.Interest;\n+import com.netflix.eureka2.interests.MultipleInterests;\n+import com.netflix.eureka2.interests.StreamStateNotification;\n+import com.netflix.eureka2.interests.StreamStateNotification.BufferingState;\n+import com.netflix.eureka2.utils.rx.PauseableSubject;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+import rx.Notification;\n+import rx.Observable;\n+import rx.Observable.OnSubscribe;\n+import rx.Subscriber;\n+import rx.functions.Action0;\n+import rx.functions.Func1;\n+import rx.subjects.PublishSubject;\n+\n+/**\n+ * @author Tomasz Bak\n+ */\n+public class BatchingRegistryImpl<T> implements BatchingRegistry<T> {\n+\n+    private static final Logger logger = LoggerFactory.getLogger(BatchingRegistryImpl.class);\n+\n+    private final Map<Interest<T>, BufferingState> interestsBufferingState =\n+            new ConcurrentHashMap<Interest<T>, BufferingState>();\n+\n+    private final PauseableSubject<Boolean> updatesSubject = PauseableSubject.create();\n+\n+    /**\n+     * As channels may reconnect, and this object is scoped to an {@link com.netflix.eureka2.interests.IndexRegistry}\n+     * we need to handle multiple subscriptions from subsequent channels, with state cleanup.\n+     * If the change notification stream from channel terminates, clean the state, and start over from the\n+     * new channel.\n+     */\n+    private final PublishSubject<Observable<ChangeNotification<T>>> notificationSources = PublishSubject.create();\n+\n+    public BatchingRegistryImpl() {\n+        notificationSources.switchMap(\n+                new Func1<Observable<ChangeNotification<T>>, Observable<Boolean>>() {\n+                    @Override\n+                    public Observable<Boolean> call(Observable<ChangeNotification<T>> notifications) {\n+                        return notifications.map(new Func1<ChangeNotification<T>, Boolean>() {\n+                            @Override\n+                            public Boolean call(ChangeNotification<T> notification) {","path":"eureka2-client/src/main/java/com/netflix/eureka2/client/interest/BatchingRegistryImpl.java","position":51,"original_position":51,"commit_id":"fe2350c8212d412b6ae14f785532952c568b42f0","original_commit_id":"fe2350c8212d412b6ae14f785532952c568b42f0","user":{"login":"tbak","id":728768,"avatar_url":"https://avatars.githubusercontent.com/u/728768?v=3","gravatar_id":"","url":"https://api.github.com/users/tbak","html_url":"https://github.com/tbak","followers_url":"https://api.github.com/users/tbak/followers","following_url":"https://api.github.com/users/tbak/following{/other_user}","gists_url":"https://api.github.com/users/tbak/gists{/gist_id}","starred_url":"https://api.github.com/users/tbak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbak/subscriptions","organizations_url":"https://api.github.com/users/tbak/orgs","repos_url":"https://api.github.com/users/tbak/repos","events_url":"https://api.github.com/users/tbak/events{/privacy}","received_events_url":"https://api.github.com/users/tbak/received_events","type":"User","site_admin":false},"body":"Makes sense for consistency with other places.","created_at":"2015-02-13T20:13:46Z","updated_at":"2015-02-13T20:13:46Z","html_url":"https://github.com/Netflix/eureka/pull/403#discussion_r24693023","pull_request_url":"https://api.github.com/repos/Netflix/eureka/pulls/403","_links":{"self":{"href":"https://api.github.com/repos/Netflix/eureka/pulls/comments/24693023"},"html":{"href":"https://github.com/Netflix/eureka/pull/403#discussion_r24693023"},"pull_request":{"href":"https://api.github.com/repos/Netflix/eureka/pulls/403"}}},"pull_request":{"url":"https://api.github.com/repos/Netflix/eureka/pulls/403","id":28847608,"html_url":"https://github.com/Netflix/eureka/pull/403","diff_url":"https://github.com/Netflix/eureka/pull/403.diff","patch_url":"https://github.com/Netflix/eureka/pull/403.patch","issue_url":"https://api.github.com/repos/Netflix/eureka/issues/403","number":403,"state":"open","locked":false,"title":"2.x Implementation of interest channel state propagation (enhancement #384)","user":{"login":"tbak","id":728768,"avatar_url":"https://avatars.githubusercontent.com/u/728768?v=3","gravatar_id":"","url":"https://api.github.com/users/tbak","html_url":"https://github.com/tbak","followers_url":"https://api.github.com/users/tbak/followers","following_url":"https://api.github.com/users/tbak/following{/other_user}","gists_url":"https://api.github.com/users/tbak/gists{/gist_id}","starred_url":"https://api.github.com/users/tbak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbak/subscriptions","organizations_url":"https://api.github.com/users/tbak/orgs","repos_url":"https://api.github.com/users/tbak/repos","events_url":"https://api.github.com/users/tbak/events{/privacy}","received_events_url":"https://api.github.com/users/tbak/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-06T22:28:22Z","updated_at":"2015-02-13T20:13:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82c78c9594291b7b71e7dc28ea330958efe1fe9b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Netflix/eureka/pulls/403/commits","review_comments_url":"https://api.github.com/repos/Netflix/eureka/pulls/403/comments","review_comment_url":"https://api.github.com/repos/Netflix/eureka/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Netflix/eureka/issues/403/comments","statuses_url":"https://api.github.com/repos/Netflix/eureka/statuses/fe2350c8212d412b6ae14f785532952c568b42f0","head":{"label":"tbak:features/interest_channel_with_state_propagation2","ref":"features/interest_channel_with_state_propagation2","sha":"fe2350c8212d412b6ae14f785532952c568b42f0","user":{"login":"tbak","id":728768,"avatar_url":"https://avatars.githubusercontent.com/u/728768?v=3","gravatar_id":"","url":"https://api.github.com/users/tbak","html_url":"https://github.com/tbak","followers_url":"https://api.github.com/users/tbak/followers","following_url":"https://api.github.com/users/tbak/following{/other_user}","gists_url":"https://api.github.com/users/tbak/gists{/gist_id}","starred_url":"https://api.github.com/users/tbak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbak/subscriptions","organizations_url":"https://api.github.com/users/tbak/orgs","repos_url":"https://api.github.com/users/tbak/repos","events_url":"https://api.github.com/users/tbak/events{/privacy}","received_events_url":"https://api.github.com/users/tbak/received_events","type":"User","site_admin":false},"repo":{"id":21827017,"name":"eureka","full_name":"tbak/eureka","owner":{"login":"tbak","id":728768,"avatar_url":"https://avatars.githubusercontent.com/u/728768?v=3","gravatar_id":"","url":"https://api.github.com/users/tbak","html_url":"https://github.com/tbak","followers_url":"https://api.github.com/users/tbak/followers","following_url":"https://api.github.com/users/tbak/following{/other_user}","gists_url":"https://api.github.com/users/tbak/gists{/gist_id}","starred_url":"https://api.github.com/users/tbak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbak/subscriptions","organizations_url":"https://api.github.com/users/tbak/orgs","repos_url":"https://api.github.com/users/tbak/repos","events_url":"https://api.github.com/users/tbak/events{/privacy}","received_events_url":"https://api.github.com/users/tbak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tbak/eureka","description":"AWS Service registry for resilient mid-tier load balancing and failover.","fork":true,"url":"https://api.github.com/repos/tbak/eureka","forks_url":"https://api.github.com/repos/tbak/eureka/forks","keys_url":"https://api.github.com/repos/tbak/eureka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tbak/eureka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tbak/eureka/teams","hooks_url":"https://api.github.com/repos/tbak/eureka/hooks","issue_events_url":"https://api.github.com/repos/tbak/eureka/issues/events{/number}","events_url":"https://api.github.com/repos/tbak/eureka/events","assignees_url":"https://api.github.com/repos/tbak/eureka/assignees{/user}","branches_url":"https://api.github.com/repos/tbak/eureka/branches{/branch}","tags_url":"https://api.github.com/repos/tbak/eureka/tags","blobs_url":"https://api.github.com/repos/tbak/eureka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tbak/eureka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tbak/eureka/git/refs{/sha}","trees_url":"https://api.github.com/repos/tbak/eureka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tbak/eureka/statuses/{sha}","languages_url":"https://api.github.com/repos/tbak/eureka/languages","stargazers_url":"https://api.github.com/repos/tbak/eureka/stargazers","contributors_url":"https://api.github.com/repos/tbak/eureka/contributors","subscribers_url":"https://api.github.com/repos/tbak/eureka/subscribers","subscription_url":"https://api.github.com/repos/tbak/eureka/subscription","commits_url":"https://api.github.com/repos/tbak/eureka/commits{/sha}","git_commits_url":"https://api.github.com/repos/tbak/eureka/git/commits{/sha}","comments_url":"https://api.github.com/repos/tbak/eureka/comments{/number}","issue_comment_url":"https://api.github.com/repos/tbak/eureka/issues/comments/{number}","contents_url":"https://api.github.com/repos/tbak/eureka/contents/{+path}","compare_url":"https://api.github.com/repos/tbak/eureka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tbak/eureka/merges","archive_url":"https://api.github.com/repos/tbak/eureka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tbak/eureka/downloads","issues_url":"https://api.github.com/repos/tbak/eureka/issues{/number}","pulls_url":"https://api.github.com/repos/tbak/eureka/pulls{/number}","milestones_url":"https://api.github.com/repos/tbak/eureka/milestones{/number}","notifications_url":"https://api.github.com/repos/tbak/eureka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tbak/eureka/labels{/name}","releases_url":"https://api.github.com/repos/tbak/eureka/releases{/id}","created_at":"2014-07-14T16:37:46Z","updated_at":"2015-02-10T18:32:07Z","pushed_at":"2015-02-12T17:25:37Z","git_url":"git://github.com/tbak/eureka.git","ssh_url":"git@github.com:tbak/eureka.git","clone_url":"https://github.com/tbak/eureka.git","svn_url":"https://github.com/tbak/eureka","homepage":"","size":7942,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Netflix:2.x","ref":"2.x","sha":"a3069d972f67e35e4e5137f776b107174f132c5b","user":{"login":"Netflix","id":913567,"avatar_url":"https://avatars.githubusercontent.com/u/913567?v=3","gravatar_id":"","url":"https://api.github.com/users/Netflix","html_url":"https://github.com/Netflix","followers_url":"https://api.github.com/users/Netflix/followers","following_url":"https://api.github.com/users/Netflix/following{/other_user}","gists_url":"https://api.github.com/users/Netflix/gists{/gist_id}","starred_url":"https://api.github.com/users/Netflix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Netflix/subscriptions","organizations_url":"https://api.github.com/users/Netflix/orgs","repos_url":"https://api.github.com/users/Netflix/repos","events_url":"https://api.github.com/users/Netflix/events{/privacy}","received_events_url":"https://api.github.com/users/Netflix/received_events","type":"Organization","site_admin":false},"repo":{"id":5198041,"name":"eureka","full_name":"Netflix/eureka","owner":{"login":"Netflix","id":913567,"avatar_url":"https://avatars.githubusercontent.com/u/913567?v=3","gravatar_id":"","url":"https://api.github.com/users/Netflix","html_url":"https://github.com/Netflix","followers_url":"https://api.github.com/users/Netflix/followers","following_url":"https://api.github.com/users/Netflix/following{/other_user}","gists_url":"https://api.github.com/users/Netflix/gists{/gist_id}","starred_url":"https://api.github.com/users/Netflix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Netflix/subscriptions","organizations_url":"https://api.github.com/users/Netflix/orgs","repos_url":"https://api.github.com/users/Netflix/repos","events_url":"https://api.github.com/users/Netflix/events{/privacy}","received_events_url":"https://api.github.com/users/Netflix/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Netflix/eureka","description":"AWS Service registry for resilient mid-tier load balancing and failover.","fork":false,"url":"https://api.github.com/repos/Netflix/eureka","forks_url":"https://api.github.com/repos/Netflix/eureka/forks","keys_url":"https://api.github.com/repos/Netflix/eureka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Netflix/eureka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Netflix/eureka/teams","hooks_url":"https://api.github.com/repos/Netflix/eureka/hooks","issue_events_url":"https://api.github.com/repos/Netflix/eureka/issues/events{/number}","events_url":"https://api.github.com/repos/Netflix/eureka/events","assignees_url":"https://api.github.com/repos/Netflix/eureka/assignees{/user}","branches_url":"https://api.github.com/repos/Netflix/eureka/branches{/branch}","tags_url":"https://api.github.com/repos/Netflix/eureka/tags","blobs_url":"https://api.github.com/repos/Netflix/eureka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Netflix/eureka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Netflix/eureka/git/refs{/sha}","trees_url":"https://api.github.com/repos/Netflix/eureka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Netflix/eureka/statuses/{sha}","languages_url":"https://api.github.com/repos/Netflix/eureka/languages","stargazers_url":"https://api.github.com/repos/Netflix/eureka/stargazers","contributors_url":"https://api.github.com/repos/Netflix/eureka/contributors","subscribers_url":"https://api.github.com/repos/Netflix/eureka/subscribers","subscription_url":"https://api.github.com/repos/Netflix/eureka/subscription","commits_url":"https://api.github.com/repos/Netflix/eureka/commits{/sha}","git_commits_url":"https://api.github.com/repos/Netflix/eureka/git/commits{/sha}","comments_url":"https://api.github.com/repos/Netflix/eureka/comments{/number}","issue_comment_url":"https://api.github.com/repos/Netflix/eureka/issues/comments/{number}","contents_url":"https://api.github.com/repos/Netflix/eureka/contents/{+path}","compare_url":"https://api.github.com/repos/Netflix/eureka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Netflix/eureka/merges","archive_url":"https://api.github.com/repos/Netflix/eureka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Netflix/eureka/downloads","issues_url":"https://api.github.com/repos/Netflix/eureka/issues{/number}","pulls_url":"https://api.github.com/repos/Netflix/eureka/pulls{/number}","milestones_url":"https://api.github.com/repos/Netflix/eureka/milestones{/number}","notifications_url":"https://api.github.com/repos/Netflix/eureka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Netflix/eureka/labels{/name}","releases_url":"https://api.github.com/repos/Netflix/eureka/releases{/id}","created_at":"2012-07-26T22:23:07Z","updated_at":"2015-02-13T19:08:05Z","pushed_at":"2015-02-12T23:32:39Z","git_url":"git://github.com/Netflix/eureka.git","ssh_url":"git@github.com:Netflix/eureka.git","clone_url":"https://github.com/Netflix/eureka.git","svn_url":"https://github.com/Netflix/eureka","homepage":"","size":12825,"stargazers_count":759,"watchers_count":759,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":161,"mirror_url":null,"open_issues_count":23,"forks":161,"open_issues":23,"watchers":759,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Netflix/eureka/pulls/403"},"html":{"href":"https://github.com/Netflix/eureka/pull/403"},"issue":{"href":"https://api.github.com/repos/Netflix/eureka/issues/403"},"comments":{"href":"https://api.github.com/repos/Netflix/eureka/issues/403/comments"},"review_comments":{"href":"https://api.github.com/repos/Netflix/eureka/pulls/403/comments"},"review_comment":{"href":"https://api.github.com/repos/Netflix/eureka/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Netflix/eureka/pulls/403/commits"},"statuses":{"href":"https://api.github.com/repos/Netflix/eureka/statuses/fe2350c8212d412b6ae14f785532952c568b42f0"}}}}