{"action":"created","comment":{"url":"https://api.github.com/repos/zalando/nakadi/pulls/comments/67332453","id":67332453,"diff_hunk":"@@ -0,0 +1,53 @@\n+package de.zalando.aruha.nakadi.service.subscription.state;\n+\n+import de.zalando.aruha.nakadi.exceptions.NoStreamingSlotsAvailable;\n+import de.zalando.aruha.nakadi.service.subscription.model.Partition;\n+import de.zalando.aruha.nakadi.service.subscription.model.Session;\n+import java.io.IOException;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+public class StartingState extends State {\n+    private static final Logger LOG = LoggerFactory.getLogger(StartingState.class);\n+\n+    @Override\n+    public void onEnter() {\n+        getZk().runLocked(this::createSubscriptionLocked);\n+    }\n+\n+    /**\n+     * 1. Checks, that subscription node is present in zk. If not - creates it.\n+     * <p>\n+     * 2. Registers session.\n+     * <p>\n+     * 3. Switches to streaming state.\n+     */\n+    private void createSubscriptionLocked() {\n+        // check that subscription initialized in zk.\n+        if (getZk().createSubscription()) {\n+            // if not - create subscription node etc.\n+            getZk().fillEmptySubscription(getKafka().getSubscriptionOffsets());\n+        } else {\n+            final Session[] sessions = getZk().listSessions();\n+            final Partition[] partitions = getZk().listPartitions();\n+            if (sessions == null || partitions == null) {","path":"src/main/java/de/zalando/aruha/nakadi/service/subscription/state/StartingState.java","position":33,"original_position":33,"commit_id":"e072231d4ef60b4153ec955b1b15c8813f031323","original_commit_id":"e072231d4ef60b4153ec955b1b15c8813f031323","user":{"login":"v-stepanov","id":13309177,"avatar_url":"https://avatars.githubusercontent.com/u/13309177?v=3","gravatar_id":"","url":"https://api.github.com/users/v-stepanov","html_url":"https://github.com/v-stepanov","followers_url":"https://api.github.com/users/v-stepanov/followers","following_url":"https://api.github.com/users/v-stepanov/following{/other_user}","gists_url":"https://api.github.com/users/v-stepanov/gists{/gist_id}","starred_url":"https://api.github.com/users/v-stepanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/v-stepanov/subscriptions","organizations_url":"https://api.github.com/users/v-stepanov/orgs","repos_url":"https://api.github.com/users/v-stepanov/repos","events_url":"https://api.github.com/users/v-stepanov/events{/privacy}","received_events_url":"https://api.github.com/users/v-stepanov/received_events","type":"User","site_admin":false},"body":"I think you have some unnecessary null checks (not only here). I don't see any cases where that can be null.\r\nMoreover in Nakadi code we have a following null-policy:\r\nIf some method can return null - it should be marked as @Nullable. Everything else that is not marked @Nullable is considered nonnull by default and does not require null checks.","created_at":"2016-06-16T12:06:45Z","updated_at":"2016-06-16T12:06:45Z","html_url":"https://github.com/zalando/nakadi/pull/269#discussion_r67332453","pull_request_url":"https://api.github.com/repos/zalando/nakadi/pulls/269","_links":{"self":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/comments/67332453"},"html":{"href":"https://github.com/zalando/nakadi/pull/269#discussion_r67332453"},"pull_request":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/269"}}},"pull_request":{"url":"https://api.github.com/repos/zalando/nakadi/pulls/269","id":73068360,"html_url":"https://github.com/zalando/nakadi/pull/269","diff_url":"https://github.com/zalando/nakadi/pull/269.diff","patch_url":"https://github.com/zalando/nakadi/pull/269.patch","issue_url":"https://api.github.com/repos/zalando/nakadi/issues/269","number":269,"state":"open","locked":false,"title":"ARUHA-215 Subscription streaming","user":{"login":"antban","id":2656223,"avatar_url":"https://avatars.githubusercontent.com/u/2656223?v=3","gravatar_id":"","url":"https://api.github.com/users/antban","html_url":"https://github.com/antban","followers_url":"https://api.github.com/users/antban/followers","following_url":"https://api.github.com/users/antban/following{/other_user}","gists_url":"https://api.github.com/users/antban/gists{/gist_id}","starred_url":"https://api.github.com/users/antban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antban/subscriptions","organizations_url":"https://api.github.com/users/antban/orgs","repos_url":"https://api.github.com/users/antban/repos","events_url":"https://api.github.com/users/antban/events{/privacy}","received_events_url":"https://api.github.com/users/antban/received_events","type":"User","site_admin":false},"body":" - ***NOT*** tested\r\n - initial implementation\r\n - covers all the use cases.","created_at":"2016-06-08T15:29:15Z","updated_at":"2016-06-16T12:06:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c4bc136e801523b9900fdcf67467d0b5a97d26f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zalando/nakadi/pulls/269/commits","review_comments_url":"https://api.github.com/repos/zalando/nakadi/pulls/269/comments","review_comment_url":"https://api.github.com/repos/zalando/nakadi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zalando/nakadi/issues/269/comments","statuses_url":"https://api.github.com/repos/zalando/nakadi/statuses/e072231d4ef60b4153ec955b1b15c8813f031323","head":{"label":"zalando:ARUHA-215","ref":"ARUHA-215","sha":"e072231d4ef60b4153ec955b1b15c8813f031323","user":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"repo":{"id":44234368,"name":"nakadi","full_name":"zalando/nakadi","owner":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zalando/nakadi","description":"A distributed event bus that implements a RESTful API abstraction instead of Kafka-like queues","fork":false,"url":"https://api.github.com/repos/zalando/nakadi","forks_url":"https://api.github.com/repos/zalando/nakadi/forks","keys_url":"https://api.github.com/repos/zalando/nakadi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando/nakadi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando/nakadi/teams","hooks_url":"https://api.github.com/repos/zalando/nakadi/hooks","issue_events_url":"https://api.github.com/repos/zalando/nakadi/issues/events{/number}","events_url":"https://api.github.com/repos/zalando/nakadi/events","assignees_url":"https://api.github.com/repos/zalando/nakadi/assignees{/user}","branches_url":"https://api.github.com/repos/zalando/nakadi/branches{/branch}","tags_url":"https://api.github.com/repos/zalando/nakadi/tags","blobs_url":"https://api.github.com/repos/zalando/nakadi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando/nakadi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando/nakadi/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando/nakadi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando/nakadi/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando/nakadi/languages","stargazers_url":"https://api.github.com/repos/zalando/nakadi/stargazers","contributors_url":"https://api.github.com/repos/zalando/nakadi/contributors","subscribers_url":"https://api.github.com/repos/zalando/nakadi/subscribers","subscription_url":"https://api.github.com/repos/zalando/nakadi/subscription","commits_url":"https://api.github.com/repos/zalando/nakadi/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando/nakadi/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando/nakadi/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando/nakadi/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando/nakadi/contents/{+path}","compare_url":"https://api.github.com/repos/zalando/nakadi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando/nakadi/merges","archive_url":"https://api.github.com/repos/zalando/nakadi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando/nakadi/downloads","issues_url":"https://api.github.com/repos/zalando/nakadi/issues{/number}","pulls_url":"https://api.github.com/repos/zalando/nakadi/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando/nakadi/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando/nakadi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando/nakadi/labels{/name}","releases_url":"https://api.github.com/repos/zalando/nakadi/releases{/id}","deployments_url":"https://api.github.com/repos/zalando/nakadi/deployments","created_at":"2015-10-14T08:30:17Z","updated_at":"2016-06-15T10:10:42Z","pushed_at":"2016-06-16T12:00:18Z","git_url":"git://github.com/zalando/nakadi.git","ssh_url":"git@github.com:zalando/nakadi.git","clone_url":"https://github.com/zalando/nakadi.git","svn_url":"https://github.com/zalando/nakadi","homepage":"","size":2511,"stargazers_count":19,"watchers_count":19,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":29,"forks":17,"open_issues":29,"watchers":19,"default_branch":"nakadi-jvm"}},"base":{"label":"zalando:nakadi-jvm","ref":"nakadi-jvm","sha":"7fa7e21355c362a4f905f97068997c3719c0e9b3","user":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"repo":{"id":44234368,"name":"nakadi","full_name":"zalando/nakadi","owner":{"login":"zalando","id":1564818,"avatar_url":"https://avatars.githubusercontent.com/u/1564818?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando","html_url":"https://github.com/zalando","followers_url":"https://api.github.com/users/zalando/followers","following_url":"https://api.github.com/users/zalando/following{/other_user}","gists_url":"https://api.github.com/users/zalando/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando/subscriptions","organizations_url":"https://api.github.com/users/zalando/orgs","repos_url":"https://api.github.com/users/zalando/repos","events_url":"https://api.github.com/users/zalando/events{/privacy}","received_events_url":"https://api.github.com/users/zalando/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zalando/nakadi","description":"A distributed event bus that implements a RESTful API abstraction instead of Kafka-like queues","fork":false,"url":"https://api.github.com/repos/zalando/nakadi","forks_url":"https://api.github.com/repos/zalando/nakadi/forks","keys_url":"https://api.github.com/repos/zalando/nakadi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando/nakadi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando/nakadi/teams","hooks_url":"https://api.github.com/repos/zalando/nakadi/hooks","issue_events_url":"https://api.github.com/repos/zalando/nakadi/issues/events{/number}","events_url":"https://api.github.com/repos/zalando/nakadi/events","assignees_url":"https://api.github.com/repos/zalando/nakadi/assignees{/user}","branches_url":"https://api.github.com/repos/zalando/nakadi/branches{/branch}","tags_url":"https://api.github.com/repos/zalando/nakadi/tags","blobs_url":"https://api.github.com/repos/zalando/nakadi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando/nakadi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando/nakadi/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando/nakadi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando/nakadi/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando/nakadi/languages","stargazers_url":"https://api.github.com/repos/zalando/nakadi/stargazers","contributors_url":"https://api.github.com/repos/zalando/nakadi/contributors","subscribers_url":"https://api.github.com/repos/zalando/nakadi/subscribers","subscription_url":"https://api.github.com/repos/zalando/nakadi/subscription","commits_url":"https://api.github.com/repos/zalando/nakadi/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando/nakadi/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando/nakadi/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando/nakadi/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando/nakadi/contents/{+path}","compare_url":"https://api.github.com/repos/zalando/nakadi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando/nakadi/merges","archive_url":"https://api.github.com/repos/zalando/nakadi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando/nakadi/downloads","issues_url":"https://api.github.com/repos/zalando/nakadi/issues{/number}","pulls_url":"https://api.github.com/repos/zalando/nakadi/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando/nakadi/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando/nakadi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando/nakadi/labels{/name}","releases_url":"https://api.github.com/repos/zalando/nakadi/releases{/id}","deployments_url":"https://api.github.com/repos/zalando/nakadi/deployments","created_at":"2015-10-14T08:30:17Z","updated_at":"2016-06-15T10:10:42Z","pushed_at":"2016-06-16T12:00:18Z","git_url":"git://github.com/zalando/nakadi.git","ssh_url":"git@github.com:zalando/nakadi.git","clone_url":"https://github.com/zalando/nakadi.git","svn_url":"https://github.com/zalando/nakadi","homepage":"","size":2511,"stargazers_count":19,"watchers_count":19,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":29,"forks":17,"open_issues":29,"watchers":19,"default_branch":"nakadi-jvm"}},"_links":{"self":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/269"},"html":{"href":"https://github.com/zalando/nakadi/pull/269"},"issue":{"href":"https://api.github.com/repos/zalando/nakadi/issues/269"},"comments":{"href":"https://api.github.com/repos/zalando/nakadi/issues/269/comments"},"review_comments":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/269/comments"},"review_comment":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zalando/nakadi/pulls/269/commits"},"statuses":{"href":"https://api.github.com/repos/zalando/nakadi/statuses/e072231d4ef60b4153ec955b1b15c8813f031323"}}}}
{"actor":{"display_login":"v-stepanov"}}