{"action":"created","comment":{"url":"https://api.github.com/repos/bluebore/bfs/pulls/comments/65063434","id":65063434,"diff_hunk":"@@ -489,6 +521,67 @@ std::string NameSpace::NormalizePath(const std::string& path) {\n     return ret;\n }\n \n+void NameSpace::TailLog(const std::string& logstr) {\n+    NameServerLog log;\n+    if(!log.ParseFromString(logstr)) {\n+        LOG(FATAL, \"Parse log fail: %s\", common::DebugString(logstr).c_str());\n+    }\n+    for (int i = 0; i < log.entries_size(); i++) {\n+        const NsLogEntry& entry = log.entries(i);\n+        int type = entry.type();\n+        leveldb::Status s;\n+        if (type == kSyncWrite) {\n+            s = db_->Put(leveldb::WriteOptions(), entry.key(), entry.value());\n+        } else if (type == kSyncDelete) {\n+            s = db_->Delete(leveldb::WriteOptions(), entry.key());\n+        }\n+        if (!s.ok()) {\n+            LOG(FATAL, \"TailLog failed\");\n+        }\n+    }\n+}\n+\n+uint32_t NameSpace::EncodeLog(NameServerLog* log, int32_t type,\n+                              const std::string& key, const std::string& value) {\n+    if (log == NULL) {\n+        return 0;\n+    }\n+    NsLogEntry* entry = log->add_entries();\n+    entry->set_type(type);\n+    entry->set_key(key);\n+    entry->set_value(value);\n+    return entry->ByteSize();\n+}\n+/*\n+bool NameSpace::RecoverLog() {","path":"src/nameserver/namespace.cc","position":261,"original_position":261,"commit_id":"147302627d59681ce6bd2c6afa825f2b78ccc679","original_commit_id":"147302627d59681ce6bd2c6afa825f2b78ccc679","user":{"login":"bluebore","id":6851389,"avatar_url":"https://avatars.githubusercontent.com/u/6851389?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebore","html_url":"https://github.com/bluebore","followers_url":"https://api.github.com/users/bluebore/followers","following_url":"https://api.github.com/users/bluebore/following{/other_user}","gists_url":"https://api.github.com/users/bluebore/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebore/subscriptions","organizations_url":"https://api.github.com/users/bluebore/orgs","repos_url":"https://api.github.com/users/bluebore/repos","events_url":"https://api.github.com/users/bluebore/events{/privacy}","received_events_url":"https://api.github.com/users/bluebore/received_events","type":"User","site_admin":false},"body":"@lylei ","created_at":"2016-05-30T12:10:52Z","updated_at":"2016-05-30T12:10:52Z","html_url":"https://github.com/bluebore/bfs/pull/280#discussion_r65063434","pull_request_url":"https://api.github.com/repos/bluebore/bfs/pulls/280","_links":{"self":{"href":"https://api.github.com/repos/bluebore/bfs/pulls/comments/65063434"},"html":{"href":"https://github.com/bluebore/bfs/pull/280#discussion_r65063434"},"pull_request":{"href":"https://api.github.com/repos/bluebore/bfs/pulls/280"}}},"pull_request":{"url":"https://api.github.com/repos/bluebore/bfs/pulls/280","id":70086997,"html_url":"https://github.com/bluebore/bfs/pull/280","diff_url":"https://github.com/bluebore/bfs/pull/280.diff","patch_url":"https://github.com/bluebore/bfs/pull/280.patch","issue_url":"https://api.github.com/repos/bluebore/bfs/issues/280","number":280,"state":"open","locked":false,"title":"NameServer HA","user":{"login":"bluebore","id":6851389,"avatar_url":"https://avatars.githubusercontent.com/u/6851389?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebore","html_url":"https://github.com/bluebore","followers_url":"https://api.github.com/users/bluebore/followers","following_url":"https://api.github.com/users/bluebore/following{/other_user}","gists_url":"https://api.github.com/users/bluebore/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebore/subscriptions","organizations_url":"https://api.github.com/users/bluebore/orgs","repos_url":"https://api.github.com/users/bluebore/repos","events_url":"https://api.github.com/users/bluebore/events{/privacy}","received_events_url":"https://api.github.com/users/bluebore/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-14T09:14:13Z","updated_at":"2016-05-30T12:10:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24492fa203453dfa739237831c2c3f4745f6cebb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bluebore/bfs/pulls/280/commits","review_comments_url":"https://api.github.com/repos/bluebore/bfs/pulls/280/comments","review_comment_url":"https://api.github.com/repos/bluebore/bfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bluebore/bfs/issues/280/comments","statuses_url":"https://api.github.com/repos/bluebore/bfs/statuses/147302627d59681ce6bd2c6afa825f2b78ccc679","head":{"label":"bluebore:ha","ref":"ha","sha":"147302627d59681ce6bd2c6afa825f2b78ccc679","user":{"login":"bluebore","id":6851389,"avatar_url":"https://avatars.githubusercontent.com/u/6851389?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebore","html_url":"https://github.com/bluebore","followers_url":"https://api.github.com/users/bluebore/followers","following_url":"https://api.github.com/users/bluebore/following{/other_user}","gists_url":"https://api.github.com/users/bluebore/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebore/subscriptions","organizations_url":"https://api.github.com/users/bluebore/orgs","repos_url":"https://api.github.com/users/bluebore/repos","events_url":"https://api.github.com/users/bluebore/events{/privacy}","received_events_url":"https://api.github.com/users/bluebore/received_events","type":"User","site_admin":false},"repo":{"id":26562172,"name":"bfs","full_name":"bluebore/bfs","owner":{"login":"bluebore","id":6851389,"avatar_url":"https://avatars.githubusercontent.com/u/6851389?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebore","html_url":"https://github.com/bluebore","followers_url":"https://api.github.com/users/bluebore/followers","following_url":"https://api.github.com/users/bluebore/following{/other_user}","gists_url":"https://api.github.com/users/bluebore/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebore/subscriptions","organizations_url":"https://api.github.com/users/bluebore/orgs","repos_url":"https://api.github.com/users/bluebore/repos","events_url":"https://api.github.com/users/bluebore/events{/privacy}","received_events_url":"https://api.github.com/users/bluebore/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bluebore/bfs","description":"The Baidu File System.","fork":false,"url":"https://api.github.com/repos/bluebore/bfs","forks_url":"https://api.github.com/repos/bluebore/bfs/forks","keys_url":"https://api.github.com/repos/bluebore/bfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bluebore/bfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bluebore/bfs/teams","hooks_url":"https://api.github.com/repos/bluebore/bfs/hooks","issue_events_url":"https://api.github.com/repos/bluebore/bfs/issues/events{/number}","events_url":"https://api.github.com/repos/bluebore/bfs/events","assignees_url":"https://api.github.com/repos/bluebore/bfs/assignees{/user}","branches_url":"https://api.github.com/repos/bluebore/bfs/branches{/branch}","tags_url":"https://api.github.com/repos/bluebore/bfs/tags","blobs_url":"https://api.github.com/repos/bluebore/bfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bluebore/bfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bluebore/bfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/bluebore/bfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bluebore/bfs/statuses/{sha}","languages_url":"https://api.github.com/repos/bluebore/bfs/languages","stargazers_url":"https://api.github.com/repos/bluebore/bfs/stargazers","contributors_url":"https://api.github.com/repos/bluebore/bfs/contributors","subscribers_url":"https://api.github.com/repos/bluebore/bfs/subscribers","subscription_url":"https://api.github.com/repos/bluebore/bfs/subscription","commits_url":"https://api.github.com/repos/bluebore/bfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/bluebore/bfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/bluebore/bfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/bluebore/bfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/bluebore/bfs/contents/{+path}","compare_url":"https://api.github.com/repos/bluebore/bfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bluebore/bfs/merges","archive_url":"https://api.github.com/repos/bluebore/bfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bluebore/bfs/downloads","issues_url":"https://api.github.com/repos/bluebore/bfs/issues{/number}","pulls_url":"https://api.github.com/repos/bluebore/bfs/pulls{/number}","milestones_url":"https://api.github.com/repos/bluebore/bfs/milestones{/number}","notifications_url":"https://api.github.com/repos/bluebore/bfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bluebore/bfs/labels{/name}","releases_url":"https://api.github.com/repos/bluebore/bfs/releases{/id}","deployments_url":"https://api.github.com/repos/bluebore/bfs/deployments","created_at":"2014-11-13T00:00:29Z","updated_at":"2016-05-23T07:40:20Z","pushed_at":"2016-05-30T09:09:23Z","git_url":"git://github.com/bluebore/bfs.git","ssh_url":"git@github.com:bluebore/bfs.git","clone_url":"https://github.com/bluebore/bfs.git","svn_url":"https://github.com/bluebore/bfs","homepage":"","size":4751,"stargazers_count":32,"watchers_count":32,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":49,"forks":21,"open_issues":49,"watchers":32,"default_branch":"master"}},"base":{"label":"bluebore:master","ref":"master","sha":"91c5166ec685e81b4e4e90f0650ec4f40ae6d40e","user":{"login":"bluebore","id":6851389,"avatar_url":"https://avatars.githubusercontent.com/u/6851389?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebore","html_url":"https://github.com/bluebore","followers_url":"https://api.github.com/users/bluebore/followers","following_url":"https://api.github.com/users/bluebore/following{/other_user}","gists_url":"https://api.github.com/users/bluebore/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebore/subscriptions","organizations_url":"https://api.github.com/users/bluebore/orgs","repos_url":"https://api.github.com/users/bluebore/repos","events_url":"https://api.github.com/users/bluebore/events{/privacy}","received_events_url":"https://api.github.com/users/bluebore/received_events","type":"User","site_admin":false},"repo":{"id":26562172,"name":"bfs","full_name":"bluebore/bfs","owner":{"login":"bluebore","id":6851389,"avatar_url":"https://avatars.githubusercontent.com/u/6851389?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebore","html_url":"https://github.com/bluebore","followers_url":"https://api.github.com/users/bluebore/followers","following_url":"https://api.github.com/users/bluebore/following{/other_user}","gists_url":"https://api.github.com/users/bluebore/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebore/subscriptions","organizations_url":"https://api.github.com/users/bluebore/orgs","repos_url":"https://api.github.com/users/bluebore/repos","events_url":"https://api.github.com/users/bluebore/events{/privacy}","received_events_url":"https://api.github.com/users/bluebore/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bluebore/bfs","description":"The Baidu File System.","fork":false,"url":"https://api.github.com/repos/bluebore/bfs","forks_url":"https://api.github.com/repos/bluebore/bfs/forks","keys_url":"https://api.github.com/repos/bluebore/bfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bluebore/bfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bluebore/bfs/teams","hooks_url":"https://api.github.com/repos/bluebore/bfs/hooks","issue_events_url":"https://api.github.com/repos/bluebore/bfs/issues/events{/number}","events_url":"https://api.github.com/repos/bluebore/bfs/events","assignees_url":"https://api.github.com/repos/bluebore/bfs/assignees{/user}","branches_url":"https://api.github.com/repos/bluebore/bfs/branches{/branch}","tags_url":"https://api.github.com/repos/bluebore/bfs/tags","blobs_url":"https://api.github.com/repos/bluebore/bfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bluebore/bfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bluebore/bfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/bluebore/bfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bluebore/bfs/statuses/{sha}","languages_url":"https://api.github.com/repos/bluebore/bfs/languages","stargazers_url":"https://api.github.com/repos/bluebore/bfs/stargazers","contributors_url":"https://api.github.com/repos/bluebore/bfs/contributors","subscribers_url":"https://api.github.com/repos/bluebore/bfs/subscribers","subscription_url":"https://api.github.com/repos/bluebore/bfs/subscription","commits_url":"https://api.github.com/repos/bluebore/bfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/bluebore/bfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/bluebore/bfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/bluebore/bfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/bluebore/bfs/contents/{+path}","compare_url":"https://api.github.com/repos/bluebore/bfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bluebore/bfs/merges","archive_url":"https://api.github.com/repos/bluebore/bfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bluebore/bfs/downloads","issues_url":"https://api.github.com/repos/bluebore/bfs/issues{/number}","pulls_url":"https://api.github.com/repos/bluebore/bfs/pulls{/number}","milestones_url":"https://api.github.com/repos/bluebore/bfs/milestones{/number}","notifications_url":"https://api.github.com/repos/bluebore/bfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bluebore/bfs/labels{/name}","releases_url":"https://api.github.com/repos/bluebore/bfs/releases{/id}","deployments_url":"https://api.github.com/repos/bluebore/bfs/deployments","created_at":"2014-11-13T00:00:29Z","updated_at":"2016-05-23T07:40:20Z","pushed_at":"2016-05-30T09:09:23Z","git_url":"git://github.com/bluebore/bfs.git","ssh_url":"git@github.com:bluebore/bfs.git","clone_url":"https://github.com/bluebore/bfs.git","svn_url":"https://github.com/bluebore/bfs","homepage":"","size":4751,"stargazers_count":32,"watchers_count":32,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":49,"forks":21,"open_issues":49,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bluebore/bfs/pulls/280"},"html":{"href":"https://github.com/bluebore/bfs/pull/280"},"issue":{"href":"https://api.github.com/repos/bluebore/bfs/issues/280"},"comments":{"href":"https://api.github.com/repos/bluebore/bfs/issues/280/comments"},"review_comments":{"href":"https://api.github.com/repos/bluebore/bfs/pulls/280/comments"},"review_comment":{"href":"https://api.github.com/repos/bluebore/bfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bluebore/bfs/pulls/280/commits"},"statuses":{"href":"https://api.github.com/repos/bluebore/bfs/statuses/147302627d59681ce6bd2c6afa825f2b78ccc679"}}}}
{"actor":{"display_login":"bluebore"}}