{"action":"created","comment":{"url":"https://api.github.com/repos/influxdb/influxdb/pulls/comments/26414578","id":26414578,"diff_hunk":"@@ -92,25 +126,67 @@ func (b *Broker) Open(path string, u *url.URL) error {\n \t}\n \tb.path = path\n \n-\t// Require a non-blank connection address.\n-\tif u == nil {\n-\t\treturn ErrConnectionAddressRequired\n+\t// Ensure root directory exists.\n+\tif err := os.MkdirAll(path, 0700); err != nil {\n+\t\tb.close()\n+\t\treturn fmt.Errorf(\"mkdir: %s\", err)\n+\t}\n+\n+\t// Open meta file.\n+\tmeta, err := bolt.Open(b.metaPath(), 0600, &bolt.Options{Timeout: 1 * time.Second})\n+\tif err != nil {\n+\t\tb.close()\n+\t\treturn fmt.Errorf(\"open meta: %s\", err)\n \t}\n+\tb.meta = meta\n \n-\t// Read meta data from snapshot.\n-\tif err := b.load(); err != nil {\n+\t// Initialize data from meta store.\n+\tif err := b.meta.Update(func(tx *bolt.Tx) error {\n+\t\ttx.CreateBucketIfNotExists([]byte(\"meta\"))\n+\n+\t\t// Read in index from meta store, if set.\n+\t\tif v := tx.Bucket([]byte(\"meta\")).Get([]byte(\"index\")); v != nil {\n+\t\t\tb.index = btou64(v)\n+\t\t}\n+\n+\t\treturn nil\n+\t}); err != nil {\n \t\t_ = b.close()\n \t\treturn err\n \t}\n \n-\t// Open underlying raft log.\n-\tif err := b.log.Open(filepath.Join(path, \"raft\")); err != nil {\n-\t\treturn fmt.Errorf(\"raft: %s\", err)\n+\t// Read all topic metadata into memory.\n+\tif err := b.openTopics(); err != nil {\n+\t\tb.close()\n+\t\treturn fmt.Errorf(\"open topics: %s\", err)\n+\t}\n+\n+\treturn nil\n+}\n+\n+// loadTopics reads all topic metadata into memory.\n+func (b *Broker) openTopics() error {\n+\t// Read all topics from the broker directory.\n+\ttopics, err := ReadTopics(b.path)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"read topics: %s\", err)\n \t}\n \n-\t// Copy connection URL.\n-\tb.log.URL = &url.URL{}\n-\t*b.log.URL = *u\n+\t// Open each topic and append to the map.\n+\tb.topics = make(map[uint64]*Topic)\n+\tfor _, t := range topics {\n+\t\tif err := t.Open(); err != nil {\n+\t\t\treturn fmt.Errorf(\"open topic: id=%d, err=%s\", t.id, err)\n+\t\t}\n+\t\tb.topics[t.id] = t\n+\t}\n+\n+\t// Retrieve the highest index across all topics.","path":"messaging/broker.go","position":218,"original_position":218,"commit_id":"8e813ec351b6874ec18408a06180ddcfc1942c2c","original_commit_id":"8e813ec351b6874ec18408a06180ddcfc1942c2c","user":{"login":"otoolep","id":536312,"avatar_url":"https://avatars.githubusercontent.com/u/536312?v=3","gravatar_id":"","url":"https://api.github.com/users/otoolep","html_url":"https://github.com/otoolep","followers_url":"https://api.github.com/users/otoolep/followers","following_url":"https://api.github.com/users/otoolep/following{/other_user}","gists_url":"https://api.github.com/users/otoolep/gists{/gist_id}","starred_url":"https://api.github.com/users/otoolep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otoolep/subscriptions","organizations_url":"https://api.github.com/users/otoolep/orgs","repos_url":"https://api.github.com/users/otoolep/repos","events_url":"https://api.github.com/users/otoolep/events{/privacy}","received_events_url":"https://api.github.com/users/otoolep/received_events","type":"User","site_admin":false},"body":"Couldn't we just do this as part of the loop above?","created_at":"2015-03-13T19:10:18Z","updated_at":"2015-03-13T19:10:18Z","html_url":"https://github.com/influxdb/influxdb/pull/1935#discussion_r26414578","pull_request_url":"https://api.github.com/repos/influxdb/influxdb/pulls/1935","_links":{"self":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/comments/26414578"},"html":{"href":"https://github.com/influxdb/influxdb/pull/1935#discussion_r26414578"},"pull_request":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/1935"}}},"pull_request":{"url":"https://api.github.com/repos/influxdb/influxdb/pulls/1935","id":31087143,"html_url":"https://github.com/influxdb/influxdb/pull/1935","diff_url":"https://github.com/influxdb/influxdb/pull/1935.diff","patch_url":"https://github.com/influxdb/influxdb/pull/1935.patch","issue_url":"https://api.github.com/repos/influxdb/influxdb/issues/1935","number":1935,"state":"open","locked":false,"title":"Stateless broker","user":{"login":"benbjohnson","id":118015,"avatar_url":"https://avatars.githubusercontent.com/u/118015?v=3","gravatar_id":"","url":"https://api.github.com/users/benbjohnson","html_url":"https://github.com/benbjohnson","followers_url":"https://api.github.com/users/benbjohnson/followers","following_url":"https://api.github.com/users/benbjohnson/following{/other_user}","gists_url":"https://api.github.com/users/benbjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/benbjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbjohnson/subscriptions","organizations_url":"https://api.github.com/users/benbjohnson/orgs","repos_url":"https://api.github.com/users/benbjohnson/repos","events_url":"https://api.github.com/users/benbjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/benbjohnson/received_events","type":"User","site_admin":false},"body":"## Overview\r\n\r\nThis pull request removes replicas and subscriptions from the brokers and makes much more simplistic. It also removes cluster-wide sequential reads and instead uses per-topic sequential reads. There is still a global unique index though.","created_at":"2015-03-12T23:14:29Z","updated_at":"2015-03-13T19:10:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c2782847be8a17b2dd797432c30baee09152533b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/influxdb/influxdb/pulls/1935/commits","review_comments_url":"https://api.github.com/repos/influxdb/influxdb/pulls/1935/comments","review_comment_url":"https://api.github.com/repos/influxdb/influxdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdb/influxdb/issues/1935/comments","statuses_url":"https://api.github.com/repos/influxdb/influxdb/statuses/8e813ec351b6874ec18408a06180ddcfc1942c2c","head":{"label":"influxdb:stateless-broker","ref":"stateless-broker","sha":"8e813ec351b6874ec18408a06180ddcfc1942c2c","user":{"login":"influxdb","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdb","html_url":"https://github.com/influxdb","followers_url":"https://api.github.com/users/influxdb/followers","following_url":"https://api.github.com/users/influxdb/following{/other_user}","gists_url":"https://api.github.com/users/influxdb/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdb/subscriptions","organizations_url":"https://api.github.com/users/influxdb/orgs","repos_url":"https://api.github.com/users/influxdb/repos","events_url":"https://api.github.com/users/influxdb/events{/privacy}","received_events_url":"https://api.github.com/users/influxdb/received_events","type":"Organization","site_admin":false},"repo":{"id":13124802,"name":"influxdb","full_name":"influxdb/influxdb","owner":{"login":"influxdb","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdb","html_url":"https://github.com/influxdb","followers_url":"https://api.github.com/users/influxdb/followers","following_url":"https://api.github.com/users/influxdb/following{/other_user}","gists_url":"https://api.github.com/users/influxdb/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdb/subscriptions","organizations_url":"https://api.github.com/users/influxdb/orgs","repos_url":"https://api.github.com/users/influxdb/repos","events_url":"https://api.github.com/users/influxdb/events{/privacy}","received_events_url":"https://api.github.com/users/influxdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdb/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":false,"url":"https://api.github.com/repos/influxdb/influxdb","forks_url":"https://api.github.com/repos/influxdb/influxdb/forks","keys_url":"https://api.github.com/repos/influxdb/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdb/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdb/influxdb/teams","hooks_url":"https://api.github.com/repos/influxdb/influxdb/hooks","issue_events_url":"https://api.github.com/repos/influxdb/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/influxdb/influxdb/events","assignees_url":"https://api.github.com/repos/influxdb/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/influxdb/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/influxdb/influxdb/tags","blobs_url":"https://api.github.com/repos/influxdb/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdb/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdb/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdb/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdb/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdb/influxdb/languages","stargazers_url":"https://api.github.com/repos/influxdb/influxdb/stargazers","contributors_url":"https://api.github.com/repos/influxdb/influxdb/contributors","subscribers_url":"https://api.github.com/repos/influxdb/influxdb/subscribers","subscription_url":"https://api.github.com/repos/influxdb/influxdb/subscription","commits_url":"https://api.github.com/repos/influxdb/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdb/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdb/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdb/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdb/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/influxdb/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdb/influxdb/merges","archive_url":"https://api.github.com/repos/influxdb/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdb/influxdb/downloads","issues_url":"https://api.github.com/repos/influxdb/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/influxdb/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdb/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdb/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdb/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/influxdb/influxdb/releases{/id}","created_at":"2013-09-26T14:31:10Z","updated_at":"2015-03-13T17:46:56Z","pushed_at":"2015-03-13T17:09:42Z","git_url":"git://github.com/influxdb/influxdb.git","ssh_url":"git@github.com:influxdb/influxdb.git","clone_url":"https://github.com/influxdb/influxdb.git","svn_url":"https://github.com/influxdb/influxdb","homepage":"http://influxdb.com","size":37972,"stargazers_count":4729,"watchers_count":4729,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":397,"mirror_url":null,"open_issues_count":341,"forks":397,"open_issues":341,"watchers":4729,"default_branch":"master"}},"base":{"label":"influxdb:master","ref":"master","sha":"aecb9b5fa3a3adbbc83512c2eabb74284b5e1abb","user":{"login":"influxdb","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdb","html_url":"https://github.com/influxdb","followers_url":"https://api.github.com/users/influxdb/followers","following_url":"https://api.github.com/users/influxdb/following{/other_user}","gists_url":"https://api.github.com/users/influxdb/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdb/subscriptions","organizations_url":"https://api.github.com/users/influxdb/orgs","repos_url":"https://api.github.com/users/influxdb/repos","events_url":"https://api.github.com/users/influxdb/events{/privacy}","received_events_url":"https://api.github.com/users/influxdb/received_events","type":"Organization","site_admin":false},"repo":{"id":13124802,"name":"influxdb","full_name":"influxdb/influxdb","owner":{"login":"influxdb","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdb","html_url":"https://github.com/influxdb","followers_url":"https://api.github.com/users/influxdb/followers","following_url":"https://api.github.com/users/influxdb/following{/other_user}","gists_url":"https://api.github.com/users/influxdb/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdb/subscriptions","organizations_url":"https://api.github.com/users/influxdb/orgs","repos_url":"https://api.github.com/users/influxdb/repos","events_url":"https://api.github.com/users/influxdb/events{/privacy}","received_events_url":"https://api.github.com/users/influxdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdb/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":false,"url":"https://api.github.com/repos/influxdb/influxdb","forks_url":"https://api.github.com/repos/influxdb/influxdb/forks","keys_url":"https://api.github.com/repos/influxdb/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdb/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdb/influxdb/teams","hooks_url":"https://api.github.com/repos/influxdb/influxdb/hooks","issue_events_url":"https://api.github.com/repos/influxdb/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/influxdb/influxdb/events","assignees_url":"https://api.github.com/repos/influxdb/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/influxdb/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/influxdb/influxdb/tags","blobs_url":"https://api.github.com/repos/influxdb/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdb/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdb/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdb/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdb/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdb/influxdb/languages","stargazers_url":"https://api.github.com/repos/influxdb/influxdb/stargazers","contributors_url":"https://api.github.com/repos/influxdb/influxdb/contributors","subscribers_url":"https://api.github.com/repos/influxdb/influxdb/subscribers","subscription_url":"https://api.github.com/repos/influxdb/influxdb/subscription","commits_url":"https://api.github.com/repos/influxdb/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdb/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdb/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdb/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdb/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/influxdb/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdb/influxdb/merges","archive_url":"https://api.github.com/repos/influxdb/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdb/influxdb/downloads","issues_url":"https://api.github.com/repos/influxdb/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/influxdb/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdb/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdb/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdb/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/influxdb/influxdb/releases{/id}","created_at":"2013-09-26T14:31:10Z","updated_at":"2015-03-13T17:46:56Z","pushed_at":"2015-03-13T17:09:42Z","git_url":"git://github.com/influxdb/influxdb.git","ssh_url":"git@github.com:influxdb/influxdb.git","clone_url":"https://github.com/influxdb/influxdb.git","svn_url":"https://github.com/influxdb/influxdb","homepage":"http://influxdb.com","size":37972,"stargazers_count":4729,"watchers_count":4729,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":397,"mirror_url":null,"open_issues_count":341,"forks":397,"open_issues":341,"watchers":4729,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/1935"},"html":{"href":"https://github.com/influxdb/influxdb/pull/1935"},"issue":{"href":"https://api.github.com/repos/influxdb/influxdb/issues/1935"},"comments":{"href":"https://api.github.com/repos/influxdb/influxdb/issues/1935/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/1935/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdb/influxdb/pulls/1935/commits"},"statuses":{"href":"https://api.github.com/repos/influxdb/influxdb/statuses/8e813ec351b6874ec18408a06180ddcfc1942c2c"}}}}