{"action":"created","comment":{"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments/37249539","id":37249539,"diff_hunk":"@@ -961,6 +957,33 @@ DB.prototype.getTableSchema = function(domain, table) {\n };\n \n /**\n+ * Retrieve an array of unique datacenter IDs.\n+ */\n+DB.prototype._getDatacenters = function() {\n+    var self = this;\n+    var datacenters = new Set();\n+    var options = { prepare: true };\n+\n+    // Peer data-centers (from the perspective of the node we're querying).\n+    return self.client.execute_p(\"SELECT data_center FROM system.peers\", [], options)\n+    .then(function(res) {\n+        res.rows.forEach(function(row) {\n+            datacenters.add(row.data_center);\n+        });\n+\n+        // Local data-center (from the perspective of the queried node).\n+        return self.client.execute_p(\"SELECT data_center FROM system.local\", [], options);\n+    })\n+    .then(function(res) {\n+        res.rows.forEach(function(row) {\n+            datacenters.add(row.data_center);\n+        });\n+\n+        return Array.from(datacenters);\n+    });","path":"lib/db.js","position":69,"original_position":69,"commit_id":"3128968923aa8b6eaa17a5a02b59f3c9b0865a75","original_commit_id":"3128968923aa8b6eaa17a5a02b59f3c9b0865a75","user":{"login":"gwicke","id":1225898,"avatar_url":"https://avatars.githubusercontent.com/u/1225898?v=3","gravatar_id":"","url":"https://api.github.com/users/gwicke","html_url":"https://github.com/gwicke","followers_url":"https://api.github.com/users/gwicke/followers","following_url":"https://api.github.com/users/gwicke/following{/other_user}","gists_url":"https://api.github.com/users/gwicke/gists{/gist_id}","starred_url":"https://api.github.com/users/gwicke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwicke/subscriptions","organizations_url":"https://api.github.com/users/gwicke/orgs","repos_url":"https://api.github.com/users/gwicke/repos","events_url":"https://api.github.com/users/gwicke/events{/privacy}","received_events_url":"https://api.github.com/users/gwicke/received_events","type":"User","site_admin":false},"body":"As a sanity check, we should probably make sure that `self.conf.localDc` is always in this set. I suspect that will basically always be the case, but based on past experience with how the local system.peers table is (or isn't) updated, it shouldn't harm to make sure.","created_at":"2015-08-17T23:31:36Z","updated_at":"2015-08-17T23:31:36Z","html_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/138#discussion_r37249539","pull_request_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138","_links":{"self":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments/37249539"},"html":{"href":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/138#discussion_r37249539"},"pull_request":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138"}}},"pull_request":{"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138","id":42628167,"html_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/138","diff_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/138.diff","patch_url":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/138.patch","issue_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/138","number":138,"state":"open","locked":false,"title":"multi-datacenter replication","user":{"login":"eevans","id":64348,"avatar_url":"https://avatars.githubusercontent.com/u/64348?v=3","gravatar_id":"","url":"https://api.github.com/users/eevans","html_url":"https://github.com/eevans","followers_url":"https://api.github.com/users/eevans/followers","following_url":"https://api.github.com/users/eevans/following{/other_user}","gists_url":"https://api.github.com/users/eevans/gists{/gist_id}","starred_url":"https://api.github.com/users/eevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eevans/subscriptions","organizations_url":"https://api.github.com/users/eevans/orgs","repos_url":"https://api.github.com/users/eevans/repos","events_url":"https://api.github.com/users/eevans/events{/privacy}","received_events_url":"https://api.github.com/users/eevans/received_events","type":"User","site_admin":false},"body":"When creating new keyspaces, place 1 replia per data-center if durability is\r\n`low`, and 3 otherwise.\r\n\r\n*Note: I'd like to have tests for this, but I'm not sure how to go about that.  Suggestions welcome.*\r\n\r\nBug: https://phabricator.wikimedia.org/T108613","created_at":"2015-08-17T20:05:01Z","updated_at":"2015-08-17T23:31:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a2b5d86f1eda2e05d5b7b0e8d22bd732d1c587d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138/commits","review_comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138/comments","review_comment_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/138/comments","statuses_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/statuses/3128968923aa8b6eaa17a5a02b59f3c9b0865a75","head":{"label":"eevans:xdc","ref":"xdc","sha":"3128968923aa8b6eaa17a5a02b59f3c9b0865a75","user":{"login":"eevans","id":64348,"avatar_url":"https://avatars.githubusercontent.com/u/64348?v=3","gravatar_id":"","url":"https://api.github.com/users/eevans","html_url":"https://github.com/eevans","followers_url":"https://api.github.com/users/eevans/followers","following_url":"https://api.github.com/users/eevans/following{/other_user}","gists_url":"https://api.github.com/users/eevans/gists{/gist_id}","starred_url":"https://api.github.com/users/eevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eevans/subscriptions","organizations_url":"https://api.github.com/users/eevans/orgs","repos_url":"https://api.github.com/users/eevans/repos","events_url":"https://api.github.com/users/eevans/events{/privacy}","received_events_url":"https://api.github.com/users/eevans/received_events","type":"User","site_admin":false},"repo":{"id":31746867,"name":"restbase-mod-table-cassandra","full_name":"eevans/restbase-mod-table-cassandra","owner":{"login":"eevans","id":64348,"avatar_url":"https://avatars.githubusercontent.com/u/64348?v=3","gravatar_id":"","url":"https://api.github.com/users/eevans","html_url":"https://github.com/eevans","followers_url":"https://api.github.com/users/eevans/followers","following_url":"https://api.github.com/users/eevans/following{/other_user}","gists_url":"https://api.github.com/users/eevans/gists{/gist_id}","starred_url":"https://api.github.com/users/eevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eevans/subscriptions","organizations_url":"https://api.github.com/users/eevans/orgs","repos_url":"https://api.github.com/users/eevans/repos","events_url":"https://api.github.com/users/eevans/events{/privacy}","received_events_url":"https://api.github.com/users/eevans/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eevans/restbase-mod-table-cassandra","description":"Cassandra table storage backend for RESTBase","fork":true,"url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra","forks_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/forks","keys_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/teams","hooks_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/hooks","issue_events_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/issues/events{/number}","events_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/events","assignees_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/assignees{/user}","branches_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/branches{/branch}","tags_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/tags","blobs_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/refs{/sha}","trees_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/statuses/{sha}","languages_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/languages","stargazers_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/stargazers","contributors_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/contributors","subscribers_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/subscribers","subscription_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/subscription","commits_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/commits{/sha}","git_commits_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/git/commits{/sha}","comments_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/comments{/number}","issue_comment_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/issues/comments{/number}","contents_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/contents/{+path}","compare_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/merges","archive_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/downloads","issues_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/issues{/number}","pulls_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/pulls{/number}","milestones_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/milestones{/number}","notifications_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/labels{/name}","releases_url":"https://api.github.com/repos/eevans/restbase-mod-table-cassandra/releases{/id}","created_at":"2015-03-06T01:44:58Z","updated_at":"2015-03-06T01:44:58Z","pushed_at":"2015-08-17T20:03:18Z","git_url":"git://github.com/eevans/restbase-mod-table-cassandra.git","ssh_url":"git@github.com:eevans/restbase-mod-table-cassandra.git","clone_url":"https://github.com/eevans/restbase-mod-table-cassandra.git","svn_url":"https://github.com/eevans/restbase-mod-table-cassandra","homepage":"","size":948,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"wikimedia:master","ref":"master","sha":"50d2fef561e344b609d24799817e20ddae87e1b5","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":13256940,"name":"restbase-mod-table-cassandra","full_name":"wikimedia/restbase-mod-table-cassandra","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/restbase-mod-table-cassandra","description":"Cassandra table storage backend for RESTBase","fork":false,"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra","forks_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/forks","keys_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/teams","hooks_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/events","assignees_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/tags","blobs_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/languages","stargazers_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/subscription","commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/merges","archive_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/downloads","issues_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/releases{/id}","created_at":"2013-10-01T22:03:02Z","updated_at":"2015-05-08T17:21:43Z","pushed_at":"2015-08-17T20:05:02Z","git_url":"git://github.com/wikimedia/restbase-mod-table-cassandra.git","ssh_url":"git@github.com:wikimedia/restbase-mod-table-cassandra.git","clone_url":"https://github.com/wikimedia/restbase-mod-table-cassandra.git","svn_url":"https://github.com/wikimedia/restbase-mod-table-cassandra","homepage":"","size":2143,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138"},"html":{"href":"https://github.com/wikimedia/restbase-mod-table-cassandra/pull/138"},"issue":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/138"},"comments":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/issues/138/comments"},"review_comments":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138/comments"},"review_comment":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/pulls/138/commits"},"statuses":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-cassandra/statuses/3128968923aa8b6eaa17a5a02b59f3c9b0865a75"}}}}