{"action":"created","comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/42613899","id":42613899,"diff_hunk":"@@ -18,47 +18,106 @@\n package main\n \n import (\n+\t\"flag\"\n \t\"fmt\"\n+\t\"io\"\n \t\"os\"\n+\t\"path/filepath\"\n \n+\t\"github.com/cockroachdb/cockroach/util/log\"\n \t\"github.com/cockroachdb/cockroach/util/stop\"\n )\n \n+var maxEpoch = flag.Int(\"maxEpoch\", 10000, \"Maximum epoch to simulate.\")\n+var actionOutputFile = flag.String(\"action\", \"\", \"Output file that shows all actions taken in cluster.\")\n+var epochOutputFile = flag.String(\"epoch\", \"\", \"Output file that shows stats for all epochs.\")\n+var startingNodes = flag.Int(\"startingNodes\", 3, \"Number of initial nodes in the cluster.\")\n+var scriptInputFile = flag.String(\"script\", \"default.script\", \"Input script file to describe simulated actions.\")\n+\n func main() {\n \tstopper := stop.NewStopper()\n \tdefer stopper.Stop()\n \n+\tflag.Parse()\n+\t// Give the flags some boundaries.\n+\tif *startingNodes < 0 {\n+\t\t*startingNodes = 0\n+\t}\n+\tif *maxEpoch < 0 {\n+\t\t*maxEpoch = 0\n+\t}\n+\n+\t// Clean the output file strings so they can be compared easily or set them\n+\t// to nil if there is no file.\n+\tif len(*actionOutputFile) > 0 {\n+\t\t*actionOutputFile = filepath.Clean(*actionOutputFile)\n+\t} else {\n+\t\tactionOutputFile = nil\n+\t}\n+\tif len(*epochOutputFile) > 0 {\n+\t\t*epochOutputFile = filepath.Clean(*epochOutputFile)\n+\t} else {\n+\t\tepochOutputFile = nil\n+\t}\n+\t*scriptInputFile = filepath.Clean(*scriptInputFile)\n+\n \tfmt.Printf(\"A simulation of the cluster's rebalancing.\\n\\n\")","path":"storage/simulation/main.go","position":47,"original_position":47,"commit_id":"ebb5926a5b347c65ae7bbea17dc36d1672b3f614","original_commit_id":"ebb5926a5b347c65ae7bbea17dc36d1672b3f614","user":{"login":"tamird","id":1535036,"avatar_url":"https://avatars.githubusercontent.com/u/1535036?v=3","gravatar_id":"","url":"https://api.github.com/users/tamird","html_url":"https://github.com/tamird","followers_url":"https://api.github.com/users/tamird/followers","following_url":"https://api.github.com/users/tamird/following{/other_user}","gists_url":"https://api.github.com/users/tamird/gists{/gist_id}","starred_url":"https://api.github.com/users/tamird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamird/subscriptions","organizations_url":"https://api.github.com/users/tamird/orgs","repos_url":"https://api.github.com/users/tamird/repos","events_url":"https://api.github.com/users/tamird/events{/privacy}","received_events_url":"https://api.github.com/users/tamird/received_events","type":"User","site_admin":false},"body":"as stated elsewhere, embrace the dependency on `log`?","created_at":"2015-10-21T12:00:30Z","updated_at":"2015-10-21T12:00:30Z","html_url":"https://github.com/cockroachdb/cockroach/pull/2849#discussion_r42613899","pull_request_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849","_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/42613899"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/2849#discussion_r42613899"},"pull_request":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849"}}},"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849","id":47840612,"html_url":"https://github.com/cockroachdb/cockroach/pull/2849","diff_url":"https://github.com/cockroachdb/cockroach/pull/2849.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/2849.patch","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2849","number":2849,"state":"open","locked":false,"title":"SIM: Add scripted events.","user":{"login":"BramGruneir","id":1614265,"avatar_url":"https://avatars.githubusercontent.com/u/1614265?v=3","gravatar_id":"","url":"https://api.github.com/users/BramGruneir","html_url":"https://github.com/BramGruneir","followers_url":"https://api.github.com/users/BramGruneir/followers","following_url":"https://api.github.com/users/BramGruneir/following{/other_user}","gists_url":"https://api.github.com/users/BramGruneir/gists{/gist_id}","starred_url":"https://api.github.com/users/BramGruneir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BramGruneir/subscriptions","organizations_url":"https://api.github.com/users/BramGruneir/orgs","repos_url":"https://api.github.com/users/BramGruneir/repos","events_url":"https://api.github.com/users/BramGruneir/events{/privacy}","received_events_url":"https://api.github.com/users/BramGruneir/received_events","type":"User","site_admin":false},"body":"This PR adds scripted events to the simulation.  \r\nNext up will be a parser to take an input file and create a test case.","created_at":"2015-10-15T20:56:41Z","updated_at":"2015-10-21T12:00:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ffea48874f7c6e63e76c14cf28aa250da4c8bd7","assignee":{"login":"mrtracy","id":6969858,"avatar_url":"https://avatars.githubusercontent.com/u/6969858?v=3","gravatar_id":"","url":"https://api.github.com/users/mrtracy","html_url":"https://github.com/mrtracy","followers_url":"https://api.github.com/users/mrtracy/followers","following_url":"https://api.github.com/users/mrtracy/following{/other_user}","gists_url":"https://api.github.com/users/mrtracy/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtracy/subscriptions","organizations_url":"https://api.github.com/users/mrtracy/orgs","repos_url":"https://api.github.com/users/mrtracy/repos","events_url":"https://api.github.com/users/mrtracy/events{/privacy}","received_events_url":"https://api.github.com/users/mrtracy/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2849/comments","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/ebb5926a5b347c65ae7bbea17dc36d1672b3f614","head":{"label":"BramGruneir:sim","ref":"sim","sha":"ebb5926a5b347c65ae7bbea17dc36d1672b3f614","user":{"login":"BramGruneir","id":1614265,"avatar_url":"https://avatars.githubusercontent.com/u/1614265?v=3","gravatar_id":"","url":"https://api.github.com/users/BramGruneir","html_url":"https://github.com/BramGruneir","followers_url":"https://api.github.com/users/BramGruneir/followers","following_url":"https://api.github.com/users/BramGruneir/following{/other_user}","gists_url":"https://api.github.com/users/BramGruneir/gists{/gist_id}","starred_url":"https://api.github.com/users/BramGruneir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BramGruneir/subscriptions","organizations_url":"https://api.github.com/users/BramGruneir/orgs","repos_url":"https://api.github.com/users/BramGruneir/repos","events_url":"https://api.github.com/users/BramGruneir/events{/privacy}","received_events_url":"https://api.github.com/users/BramGruneir/received_events","type":"User","site_admin":false},"repo":{"id":44128781,"name":"cockroach","full_name":"BramGruneir/cockroach","owner":{"login":"BramGruneir","id":1614265,"avatar_url":"https://avatars.githubusercontent.com/u/1614265?v=3","gravatar_id":"","url":"https://api.github.com/users/BramGruneir","html_url":"https://github.com/BramGruneir","followers_url":"https://api.github.com/users/BramGruneir/followers","following_url":"https://api.github.com/users/BramGruneir/following{/other_user}","gists_url":"https://api.github.com/users/BramGruneir/gists{/gist_id}","starred_url":"https://api.github.com/users/BramGruneir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BramGruneir/subscriptions","organizations_url":"https://api.github.com/users/BramGruneir/orgs","repos_url":"https://api.github.com/users/BramGruneir/repos","events_url":"https://api.github.com/users/BramGruneir/events{/privacy}","received_events_url":"https://api.github.com/users/BramGruneir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BramGruneir/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":true,"url":"https://api.github.com/repos/BramGruneir/cockroach","forks_url":"https://api.github.com/repos/BramGruneir/cockroach/forks","keys_url":"https://api.github.com/repos/BramGruneir/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BramGruneir/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BramGruneir/cockroach/teams","hooks_url":"https://api.github.com/repos/BramGruneir/cockroach/hooks","issue_events_url":"https://api.github.com/repos/BramGruneir/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/BramGruneir/cockroach/events","assignees_url":"https://api.github.com/repos/BramGruneir/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/BramGruneir/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/BramGruneir/cockroach/tags","blobs_url":"https://api.github.com/repos/BramGruneir/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BramGruneir/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BramGruneir/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/BramGruneir/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BramGruneir/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/BramGruneir/cockroach/languages","stargazers_url":"https://api.github.com/repos/BramGruneir/cockroach/stargazers","contributors_url":"https://api.github.com/repos/BramGruneir/cockroach/contributors","subscribers_url":"https://api.github.com/repos/BramGruneir/cockroach/subscribers","subscription_url":"https://api.github.com/repos/BramGruneir/cockroach/subscription","commits_url":"https://api.github.com/repos/BramGruneir/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/BramGruneir/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/BramGruneir/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/BramGruneir/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/BramGruneir/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/BramGruneir/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BramGruneir/cockroach/merges","archive_url":"https://api.github.com/repos/BramGruneir/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BramGruneir/cockroach/downloads","issues_url":"https://api.github.com/repos/BramGruneir/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/BramGruneir/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/BramGruneir/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/BramGruneir/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BramGruneir/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/BramGruneir/cockroach/releases{/id}","created_at":"2015-10-12T19:17:30Z","updated_at":"2015-10-12T19:17:36Z","pushed_at":"2015-10-21T06:12:48Z","git_url":"git://github.com/BramGruneir/cockroach.git","ssh_url":"git@github.com:BramGruneir/cockroach.git","clone_url":"https://github.com/BramGruneir/cockroach.git","svn_url":"https://github.com/BramGruneir/cockroach","homepage":null,"size":42546,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"cockroachdb:master","ref":"master","sha":"9515804b66f4cfc125675aa45909559565ffbf40","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"name":"cockroach","full_name":"cockroachdb/cockroach","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","created_at":"2014-02-06T00:18:47Z","updated_at":"2015-10-21T08:54:22Z","pushed_at":"2015-10-21T06:12:48Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":null,"size":68509,"stargazers_count":5473,"watchers_count":5473,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":461,"mirror_url":null,"open_issues_count":203,"forks":461,"open_issues":203,"watchers":5473,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/2849"},"issue":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/2849"},"comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/2849/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2849/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/cockroach/statuses/ebb5926a5b347c65ae7bbea17dc36d1672b3f614"}}}}