{"action":"created","comment":{"url":"https://api.github.com/repos/kelda/hdfs/pulls/comments/156238121","pull_request_review_id":82682884,"id":156238121,"diff_hunk":"@@ -0,0 +1,118 @@\n+const fs = require('fs');\n+const path = require('path');\n+const kelda = require('kelda');\n+\n+/**\n+ * Replaces the keys defined by `vars` with their corresponding values in\n+ * `template`. A variable is denoted in the template using {{key}}.\n+ *\n+ * @param {string} template A template containing variables to replace.\n+ * @param {Object.<string, string>} vars Maps string variables to the value\n+ *     that they should be replaced with.\n+ * @returns {string} `template` with all of the variables replaced.\n+ */\n+function applyTemplate(templateArg, vars) {\n+  let template = templateArg;\n+  Object.keys(vars).forEach((k) => {\n+    if (typeof k === 'string') {\n+      template = template.replace(`{{${k}}}`, vars[k]);\n+    }\n+  });\n+  return template;\n+}\n+\n+class HDFS {\n+  /**\n+   * Creates a HDFS cluster. The cluster will incude a collection of datanodes (which are\n+   * containers that store data), and a single namenode that manages the cluster.\n+   */\n+  constructor(nDatanodes) {\n+    const image = new kelda.Image('kelda/hdfs');\n+\n+    // The port that datanodes and external services use to communicate with the namenode.\n+    // This blueprint uses 8020 rather than 9000, which is the most commonly used port for HDFS,\n+    // because some Kelda internal traffic uses port 9000.\n+    this.hdfsPort = 8020;\n+\n+    this.namenode = new kelda.Container('hdfs-namenode', image, {\n+      command: ['sh', '-c',\n+        // Start by formatting the namenode. This needs to be done here (and not in the\n+        // Dockerfile) because it needs to be done after the configuration files have\n+        // been added to the container.\n+        'hdfs namenode -format && ' +\n+        // This script could also start the namenode by using 'hdfs namenode'; we don't\n+        // do that beause the web UI assumes that the logs are in /hadoop/logs (and\n+        // includes an interface to browse the files at that location), so we use the\n+        // hadoop-daemon.sh function to start the namenode and place the logs in the\n+        // expected location, and then tail those logs so that 'kelda logs' also shows\n+        // the datanode log output.\n+        '/hadoop/sbin/hadoop-daemon.sh --script \"$bin/hdfs\" start namenode && ' +\n+        'tail -f /hadoop/logs/*'],\n+    });\n+\n+    this.datanodes = [];\n+    for (let i = 0; i < nDatanodes; i += 1) {\n+      this.datanodes.push(new kelda.Container('hdfs-datanode', image, {\n+        command: ['sh', '-c',\n+          // As above, use the hadoo-daemon.sh script to start the datanode so that","path":"hdfs.js","position":57,"original_position":57,"commit_id":"7667d9d88a2ada8a97d43ab4814c9351e5d11300","original_commit_id":"7667d9d88a2ada8a97d43ab4814c9351e5d11300","user":{"login":"HongjianZhang","id":6889543,"avatar_url":"https://avatars2.githubusercontent.com/u/6889543?v=4","gravatar_id":"","url":"https://api.github.com/users/HongjianZhang","html_url":"https://github.com/HongjianZhang","followers_url":"https://api.github.com/users/HongjianZhang/followers","following_url":"https://api.github.com/users/HongjianZhang/following{/other_user}","gists_url":"https://api.github.com/users/HongjianZhang/gists{/gist_id}","starred_url":"https://api.github.com/users/HongjianZhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HongjianZhang/subscriptions","organizations_url":"https://api.github.com/users/HongjianZhang/orgs","repos_url":"https://api.github.com/users/HongjianZhang/repos","events_url":"https://api.github.com/users/HongjianZhang/events{/privacy}","received_events_url":"https://api.github.com/users/HongjianZhang/received_events","type":"User","site_admin":false},"body":"Do you mean`hadoop-daemon.sh`?","created_at":"2017-12-12T00:04:20Z","updated_at":"2017-12-12T00:04:20Z","html_url":"https://github.com/kelda/hdfs/pull/1#discussion_r156238121","pull_request_url":"https://api.github.com/repos/kelda/hdfs/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/kelda/hdfs/pulls/comments/156238121"},"html":{"href":"https://github.com/kelda/hdfs/pull/1#discussion_r156238121"},"pull_request":{"href":"https://api.github.com/repos/kelda/hdfs/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/kelda/hdfs/pulls/1","id":157686505,"html_url":"https://github.com/kelda/hdfs/pull/1","diff_url":"https://github.com/kelda/hdfs/pull/1.diff","patch_url":"https://github.com/kelda/hdfs/pull/1.patch","issue_url":"https://api.github.com/repos/kelda/hdfs/issues/1","number":1,"state":"open","locked":false,"title":"hdfs: Add functionality to boot an HDFS cluster","user":{"login":"kayousterhout","id":1108612,"avatar_url":"https://avatars3.githubusercontent.com/u/1108612?v=4","gravatar_id":"","url":"https://api.github.com/users/kayousterhout","html_url":"https://github.com/kayousterhout","followers_url":"https://api.github.com/users/kayousterhout/followers","following_url":"https://api.github.com/users/kayousterhout/following{/other_user}","gists_url":"https://api.github.com/users/kayousterhout/gists{/gist_id}","starred_url":"https://api.github.com/users/kayousterhout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kayousterhout/subscriptions","organizations_url":"https://api.github.com/users/kayousterhout/orgs","repos_url":"https://api.github.com/users/kayousterhout/repos","events_url":"https://api.github.com/users/kayousterhout/events{/privacy}","received_events_url":"https://api.github.com/users/kayousterhout/received_events","type":"User","site_admin":false},"body":"This commit adds a blueprint, Dockerfile, and config files\r\nthat together can be used to launch an HDFS cluster.\r\n\r\nThis commit does not add functionality to allow other services\r\nto connect to HDFS to read or write data; that functionality\r\nwill be added in a later commit.","created_at":"2017-12-11T22:18:12Z","updated_at":"2017-12-12T00:04:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5dc7deb9b3b089afeb7fc047c898b07659c45ef4","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/kelda/hdfs/pulls/1/commits","review_comments_url":"https://api.github.com/repos/kelda/hdfs/pulls/1/comments","review_comment_url":"https://api.github.com/repos/kelda/hdfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kelda/hdfs/issues/1/comments","statuses_url":"https://api.github.com/repos/kelda/hdfs/statuses/7667d9d88a2ada8a97d43ab4814c9351e5d11300","head":{"label":"kayousterhout:basic","ref":"basic","sha":"7667d9d88a2ada8a97d43ab4814c9351e5d11300","user":{"login":"kayousterhout","id":1108612,"avatar_url":"https://avatars3.githubusercontent.com/u/1108612?v=4","gravatar_id":"","url":"https://api.github.com/users/kayousterhout","html_url":"https://github.com/kayousterhout","followers_url":"https://api.github.com/users/kayousterhout/followers","following_url":"https://api.github.com/users/kayousterhout/following{/other_user}","gists_url":"https://api.github.com/users/kayousterhout/gists{/gist_id}","starred_url":"https://api.github.com/users/kayousterhout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kayousterhout/subscriptions","organizations_url":"https://api.github.com/users/kayousterhout/orgs","repos_url":"https://api.github.com/users/kayousterhout/repos","events_url":"https://api.github.com/users/kayousterhout/events{/privacy}","received_events_url":"https://api.github.com/users/kayousterhout/received_events","type":"User","site_admin":false},"repo":{"id":113914186,"name":"kelda-hdfs","full_name":"kayousterhout/kelda-hdfs","owner":{"login":"kayousterhout","id":1108612,"avatar_url":"https://avatars3.githubusercontent.com/u/1108612?v=4","gravatar_id":"","url":"https://api.github.com/users/kayousterhout","html_url":"https://github.com/kayousterhout","followers_url":"https://api.github.com/users/kayousterhout/followers","following_url":"https://api.github.com/users/kayousterhout/following{/other_user}","gists_url":"https://api.github.com/users/kayousterhout/gists{/gist_id}","starred_url":"https://api.github.com/users/kayousterhout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kayousterhout/subscriptions","organizations_url":"https://api.github.com/users/kayousterhout/orgs","repos_url":"https://api.github.com/users/kayousterhout/repos","events_url":"https://api.github.com/users/kayousterhout/events{/privacy}","received_events_url":"https://api.github.com/users/kayousterhout/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kayousterhout/kelda-hdfs","description":"Start a HDFS cluster using Kelda","fork":true,"url":"https://api.github.com/repos/kayousterhout/kelda-hdfs","forks_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/forks","keys_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/teams","hooks_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/hooks","issue_events_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/issues/events{/number}","events_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/events","assignees_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/assignees{/user}","branches_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/branches{/branch}","tags_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/tags","blobs_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/statuses/{sha}","languages_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/languages","stargazers_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/stargazers","contributors_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/contributors","subscribers_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/subscribers","subscription_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/subscription","commits_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/contents/{+path}","compare_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/merges","archive_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/downloads","issues_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/issues{/number}","pulls_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/pulls{/number}","milestones_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/milestones{/number}","notifications_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/labels{/name}","releases_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/releases{/id}","deployments_url":"https://api.github.com/repos/kayousterhout/kelda-hdfs/deployments","created_at":"2017-12-11T22:12:59Z","updated_at":"2017-12-11T22:13:15Z","pushed_at":"2017-12-11T22:18:03Z","git_url":"git://github.com/kayousterhout/kelda-hdfs.git","ssh_url":"git@github.com:kayousterhout/kelda-hdfs.git","clone_url":"https://github.com/kayousterhout/kelda-hdfs.git","svn_url":"https://github.com/kayousterhout/kelda-hdfs","homepage":null,"size":6,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kelda:master","ref":"master","sha":"2e3eee0ee9964922acc21b0ceebc0d0fda5fc068","user":{"login":"kelda","id":25753912,"avatar_url":"https://avatars2.githubusercontent.com/u/25753912?v=4","gravatar_id":"","url":"https://api.github.com/users/kelda","html_url":"https://github.com/kelda","followers_url":"https://api.github.com/users/kelda/followers","following_url":"https://api.github.com/users/kelda/following{/other_user}","gists_url":"https://api.github.com/users/kelda/gists{/gist_id}","starred_url":"https://api.github.com/users/kelda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelda/subscriptions","organizations_url":"https://api.github.com/users/kelda/orgs","repos_url":"https://api.github.com/users/kelda/repos","events_url":"https://api.github.com/users/kelda/events{/privacy}","received_events_url":"https://api.github.com/users/kelda/received_events","type":"Organization","site_admin":false},"repo":{"id":113514175,"name":"hdfs","full_name":"kelda/hdfs","owner":{"login":"kelda","id":25753912,"avatar_url":"https://avatars2.githubusercontent.com/u/25753912?v=4","gravatar_id":"","url":"https://api.github.com/users/kelda","html_url":"https://github.com/kelda","followers_url":"https://api.github.com/users/kelda/followers","following_url":"https://api.github.com/users/kelda/following{/other_user}","gists_url":"https://api.github.com/users/kelda/gists{/gist_id}","starred_url":"https://api.github.com/users/kelda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelda/subscriptions","organizations_url":"https://api.github.com/users/kelda/orgs","repos_url":"https://api.github.com/users/kelda/repos","events_url":"https://api.github.com/users/kelda/events{/privacy}","received_events_url":"https://api.github.com/users/kelda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kelda/hdfs","description":"Start a HDFS cluster using Kelda","fork":false,"url":"https://api.github.com/repos/kelda/hdfs","forks_url":"https://api.github.com/repos/kelda/hdfs/forks","keys_url":"https://api.github.com/repos/kelda/hdfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kelda/hdfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kelda/hdfs/teams","hooks_url":"https://api.github.com/repos/kelda/hdfs/hooks","issue_events_url":"https://api.github.com/repos/kelda/hdfs/issues/events{/number}","events_url":"https://api.github.com/repos/kelda/hdfs/events","assignees_url":"https://api.github.com/repos/kelda/hdfs/assignees{/user}","branches_url":"https://api.github.com/repos/kelda/hdfs/branches{/branch}","tags_url":"https://api.github.com/repos/kelda/hdfs/tags","blobs_url":"https://api.github.com/repos/kelda/hdfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kelda/hdfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kelda/hdfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/kelda/hdfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kelda/hdfs/statuses/{sha}","languages_url":"https://api.github.com/repos/kelda/hdfs/languages","stargazers_url":"https://api.github.com/repos/kelda/hdfs/stargazers","contributors_url":"https://api.github.com/repos/kelda/hdfs/contributors","subscribers_url":"https://api.github.com/repos/kelda/hdfs/subscribers","subscription_url":"https://api.github.com/repos/kelda/hdfs/subscription","commits_url":"https://api.github.com/repos/kelda/hdfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/kelda/hdfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/kelda/hdfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/kelda/hdfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/kelda/hdfs/contents/{+path}","compare_url":"https://api.github.com/repos/kelda/hdfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kelda/hdfs/merges","archive_url":"https://api.github.com/repos/kelda/hdfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kelda/hdfs/downloads","issues_url":"https://api.github.com/repos/kelda/hdfs/issues{/number}","pulls_url":"https://api.github.com/repos/kelda/hdfs/pulls{/number}","milestones_url":"https://api.github.com/repos/kelda/hdfs/milestones{/number}","notifications_url":"https://api.github.com/repos/kelda/hdfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kelda/hdfs/labels{/name}","releases_url":"https://api.github.com/repos/kelda/hdfs/releases{/id}","deployments_url":"https://api.github.com/repos/kelda/hdfs/deployments","created_at":"2017-12-08T00:54:18Z","updated_at":"2017-12-08T00:54:18Z","pushed_at":"2017-12-11T22:18:13Z","git_url":"git://github.com/kelda/hdfs.git","ssh_url":"git@github.com:kelda/hdfs.git","clone_url":"https://github.com/kelda/hdfs.git","svn_url":"https://github.com/kelda/hdfs","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kelda/hdfs/pulls/1"},"html":{"href":"https://github.com/kelda/hdfs/pull/1"},"issue":{"href":"https://api.github.com/repos/kelda/hdfs/issues/1"},"comments":{"href":"https://api.github.com/repos/kelda/hdfs/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/kelda/hdfs/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/kelda/hdfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kelda/hdfs/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/kelda/hdfs/statuses/7667d9d88a2ada8a97d43ab4814c9351e5d11300"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"HongjianZhang"}}