{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/comments/91555159","pull_request_review_id":12065145,"id":91555159,"diff_hunk":"@@ -0,0 +1,112 @@\n+package poller\n+\n+import (\n+\t\"fmt\"\n+\t\"sync\"\n+\t\"time\"\n+)\n+\n+// type HTTPPollInfo struct {\n+// \tInterval time.Duration\n+// \tTimeout  time.Duration\n+// \tID       string\n+// \tURL      string\n+// \tHandler  handler.Handler\n+// }\n+\n+type HeapPollInfo struct {\n+\tInfo HTTPPollInfo\n+\tNext time.Time\n+}\n+\n+// Heap implements a Heap from Introduction to Algorithms (Cormen et al). A Heap allows fase access of the maximum object, in this case the latest Next time, and O(log(n)) insert. This Heap is specifically designed to be used as a Priority Queue.\n+type Heap struct {\n+\tm        sync.Mutex\n+\tinfo     []HeapPollInfo\n+\tPollerID int64\n+}\n+\n+func left(i int) int {\n+\treturn 2*i + 1\n+}\n+\n+func right(i int) int {\n+\treturn 2*i + 2\n+}\n+\n+// TODO benchmark directly replacing this, to see if Go inlines the function call\n+func parent(i int) int {\n+\treturn (i - 1) / 2\n+}\n+\n+func (h *Heap) heapify(i int) {\n+\tl := left(i)\n+\tr := right(i)\n+\tvar largest int\n+\tif l < len(h.info) && h.info[i].Next.After(h.info[l].Next) {\n+\t\tlargest = l\n+\t} else {\n+\t\tlargest = i\n+\t}\n+\n+\tif r < len(h.info) && h.info[largest].Next.After(h.info[r].Next) {\n+\t\tlargest = r\n+\t}\n+\n+\tif largest != i {\n+\t\th.info[i], h.info[largest] = h.info[largest], h.info[i]\n+\t\th.heapify(largest)\n+\t}\n+}\n+\n+func (h *Heap) increaseKey(i int, key HeapPollInfo) {\n+\tif h.info[i].Next.After(key.Next) {\n+\t\tpanic(\"Poll.Heap.increaseKey got key smaller than index\")\n+\t}\n+\n+\th.info[i] = key\n+\n+\tfor i > 0 && h.info[parent(i)].Next.After(h.info[i].Next) {\n+\t\th.info[i], h.info[parent(i)] = h.info[parent(i)], h.info[i]\n+\t\ti = parent(i)\n+\t}\n+}\n+\n+// Pop gets the latest time from the heap. Implements Algorithms HEAP-EXTRACT-MAX.\n+// Returns the info with the latest time, and false if the heap is empty.\n+func (h *Heap) Pop() (HeapPollInfo, bool) {\n+\th.m.Lock()\n+\tdefer h.m.Unlock()\n+\tif len(h.info) == 0 {\n+\t\treturn HeapPollInfo{}, false\n+\t}\n+\tmax := h.info[0]\n+\th.info[0] = h.info[len(h.info)-1]\n+\th.info = h.info[:len(h.info)-1]\n+\th.heapify(0)\n+\tif max.Info.ID == \"odol-atsec-jac-04\" {\n+\t\tfmt.Printf(\"httpPoll %v Heap.Pop id %v next %v\\n\", h.PollerID, max.Info.ID, max.Next)\n+\t}\n+\treturn max, true\n+}\n+\n+// Pop gets the latest time from the heap. Implements Algorithms MAX-HEAP-INSERT.\n+// TODO make threadsafe\n+func (h *Heap) Push(key HeapPollInfo) {\n+\th.m.Lock()\n+\tdefer h.m.Unlock()\n+\tif key.Info.ID == \"odol-atsec-jac-04\" {\n+\t\tfmt.Printf(\"httpPoll %v Heap.Push id %v next %v\\n\", h.PollerID, key.Info.ID, key.Next)\n+\t}\n+\th.info = append(h.info, HeapPollInfo{Next: time.Unix(1<<63-1, 0)})\n+\th.increaseKey(len(h.info)-1, key)\n+}\n+\n+// debug\n+func (h *Heap) Sprint() string {","path":"traffic_monitor/experimental/common/poller/heap.go","position":null,"original_position":106,"commit_id":"d8a0277a4f60752d39f280423ac20ca78effc44e","original_commit_id":"0a7ffb6672cf2b1cc3d1d945c7eacc892d017f8f","user":{"login":"rob05c","id":5113421,"avatar_url":"https://avatars.githubusercontent.com/u/5113421?v=3","gravatar_id":"","url":"https://api.github.com/users/rob05c","html_url":"https://github.com/rob05c","followers_url":"https://api.github.com/users/rob05c/followers","following_url":"https://api.github.com/users/rob05c/following{/other_user}","gists_url":"https://api.github.com/users/rob05c/gists{/gist_id}","starred_url":"https://api.github.com/users/rob05c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rob05c/subscriptions","organizations_url":"https://api.github.com/users/rob05c/orgs","repos_url":"https://api.github.com/users/rob05c/repos","events_url":"https://api.github.com/users/rob05c/events{/privacy}","received_events_url":"https://api.github.com/users/rob05c/received_events","type":"User","site_admin":false},"body":"No. Done.","created_at":"2016-12-08T16:47:56Z","updated_at":"2016-12-08T16:47:56Z","html_url":"https://github.com/apache/incubator-trafficcontrol/pull/99#discussion_r91555159","pull_request_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/comments/91555159"},"html":{"href":"https://github.com/apache/incubator-trafficcontrol/pull/99#discussion_r91555159"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99","id":94663298,"html_url":"https://github.com/apache/incubator-trafficcontrol/pull/99","diff_url":"https://github.com/apache/incubator-trafficcontrol/pull/99.diff","patch_url":"https://github.com/apache/incubator-trafficcontrol/pull/99.patch","issue_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/issues/99","number":99,"state":"open","locked":false,"title":"Fix statHistory to be newest-first","user":{"login":"rob05c","id":5113421,"avatar_url":"https://avatars.githubusercontent.com/u/5113421?v=3","gravatar_id":"","url":"https://api.github.com/users/rob05c","html_url":"https://github.com/rob05c","followers_url":"https://api.github.com/users/rob05c/followers","following_url":"https://api.github.com/users/rob05c/following{/other_user}","gists_url":"https://api.github.com/users/rob05c/gists{/gist_id}","starred_url":"https://api.github.com/users/rob05c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rob05c/subscriptions","organizations_url":"https://api.github.com/users/rob05c/orgs","repos_url":"https://api.github.com/users/rob05c/repos","events_url":"https://api.github.com/users/rob05c/events{/privacy}","received_events_url":"https://api.github.com/users/rob05c/received_events","type":"User","site_admin":false},"body":"Fixes statHistory to be newest-first, and fixes readers to expect the\r\nsame. It was oldest-first, with inconsistent reader expectations.\r\n\r\nFixes total bandwidth to include mids, which appears to match TM 1.0.\r\n\r\nFixes a result error check to check the real Error, instead of\r\nPrecomputedData's Errors, and fixes the Result PrecomptuedData\r\nmember to not be anonymous, requiring explicit access, to prevent\r\nthis kind of accident again.\r\n\r\nFixes srvhttp to include the proper content type header for files.","created_at":"2016-11-21T17:46:04Z","updated_at":"2016-12-08T16:47:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06681848ca437c340c42a691fc9179a3181e689a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/issues/99/comments","statuses_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/statuses/d8a0277a4f60752d39f280423ac20ca78effc44e","head":{"label":"rob05c:tm2","ref":"tm2","sha":"d8a0277a4f60752d39f280423ac20ca78effc44e","user":{"login":"rob05c","id":5113421,"avatar_url":"https://avatars.githubusercontent.com/u/5113421?v=3","gravatar_id":"","url":"https://api.github.com/users/rob05c","html_url":"https://github.com/rob05c","followers_url":"https://api.github.com/users/rob05c/followers","following_url":"https://api.github.com/users/rob05c/following{/other_user}","gists_url":"https://api.github.com/users/rob05c/gists{/gist_id}","starred_url":"https://api.github.com/users/rob05c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rob05c/subscriptions","organizations_url":"https://api.github.com/users/rob05c/orgs","repos_url":"https://api.github.com/users/rob05c/repos","events_url":"https://api.github.com/users/rob05c/events{/privacy}","received_events_url":"https://api.github.com/users/rob05c/received_events","type":"User","site_admin":false},"repo":{"id":71181197,"name":"incubator-trafficcontrol","full_name":"rob05c/incubator-trafficcontrol","owner":{"login":"rob05c","id":5113421,"avatar_url":"https://avatars.githubusercontent.com/u/5113421?v=3","gravatar_id":"","url":"https://api.github.com/users/rob05c","html_url":"https://github.com/rob05c","followers_url":"https://api.github.com/users/rob05c/followers","following_url":"https://api.github.com/users/rob05c/following{/other_user}","gists_url":"https://api.github.com/users/rob05c/gists{/gist_id}","starred_url":"https://api.github.com/users/rob05c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rob05c/subscriptions","organizations_url":"https://api.github.com/users/rob05c/orgs","repos_url":"https://api.github.com/users/rob05c/repos","events_url":"https://api.github.com/users/rob05c/events{/privacy}","received_events_url":"https://api.github.com/users/rob05c/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rob05c/incubator-trafficcontrol","description":"Mirror of Apache Traffic Control (incubating)","fork":true,"url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol","forks_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/forks","keys_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/teams","hooks_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/hooks","issue_events_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/issues/events{/number}","events_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/events","assignees_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/assignees{/user}","branches_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/branches{/branch}","tags_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/tags","blobs_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/git/refs{/sha}","trees_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/statuses/{sha}","languages_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/languages","stargazers_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/stargazers","contributors_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/contributors","subscribers_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/subscribers","subscription_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/subscription","commits_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/commits{/sha}","git_commits_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/git/commits{/sha}","comments_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/comments{/number}","issue_comment_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/issues/comments{/number}","contents_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/contents/{+path}","compare_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/merges","archive_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/downloads","issues_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/issues{/number}","pulls_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/pulls{/number}","milestones_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/milestones{/number}","notifications_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/labels{/name}","releases_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/releases{/id}","deployments_url":"https://api.github.com/repos/rob05c/incubator-trafficcontrol/deployments","created_at":"2016-10-17T21:05:38Z","updated_at":"2016-10-17T21:05:45Z","pushed_at":"2016-12-08T16:47:35Z","git_url":"git://github.com/rob05c/incubator-trafficcontrol.git","ssh_url":"git@github.com:rob05c/incubator-trafficcontrol.git","clone_url":"https://github.com/rob05c/incubator-trafficcontrol.git","svn_url":"https://github.com/rob05c/incubator-trafficcontrol","homepage":null,"size":50297,"stargazers_count":0,"watchers_count":0,"language":"Perl","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"21f90c164119553d931c5f53950c53e9b7af1f33","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":67198520,"name":"incubator-trafficcontrol","full_name":"apache/incubator-trafficcontrol","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-trafficcontrol","description":"Mirror of Apache Traffic Control (incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-trafficcontrol","forks_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/forks","keys_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/teams","hooks_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/events","assignees_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/tags","blobs_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/subscription","commits_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/merges","archive_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/downloads","issues_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-trafficcontrol/deployments","created_at":"2016-09-02T07:00:06Z","updated_at":"2016-12-06T11:10:11Z","pushed_at":"2016-12-08T16:47:36Z","git_url":"git://github.com/apache/incubator-trafficcontrol.git","ssh_url":"git@github.com:apache/incubator-trafficcontrol.git","clone_url":"https://github.com/apache/incubator-trafficcontrol.git","svn_url":"https://github.com/apache/incubator-trafficcontrol","homepage":null,"size":51198,"stargazers_count":12,"watchers_count":12,"language":"Perl","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":29,"mirror_url":"git://git.apache.org/incubator-trafficcontrol.git","open_issues_count":9,"forks":29,"open_issues":9,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99"},"html":{"href":"https://github.com/apache/incubator-trafficcontrol/pull/99"},"issue":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/issues/99"},"comments":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/issues/99/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/pulls/99/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-trafficcontrol/statuses/d8a0277a4f60752d39f280423ac20ca78effc44e"}}}}
{"actor":{"display_login":"rob05c"}}