{"action":"created","comment":{"url":"https://api.github.com/repos/baidu/tera/pulls/comments/57134340","id":57134340,"diff_hunk":"@@ -59,18 +60,43 @@ class FlashEnv : public EnvWrapper{\n \n     virtual Env* CacheEnv() { return posix_env_; }\n \n+    Env* BaseEnv() { return dfs_env_; }\n+\n     /// flash path for local flash cache\n     static void SetFlashPath(const std::string& path, bool vanish_allowed);\n     static const std::string& FlashPath(const std::string& fname);\n+    static const bool VanishAllowed() {\n+        return vanish_allowed_;\n+    }\n     static const std::vector<std::string>& GetFlashPaths() {\n         return flash_paths_;\n     }\n \n+    /// copy to local\n+    static void SetIfForceReadFromCache(bool force);\n+    static bool ForceReadFromCache();\n+    static void SetUpdateFlashThreadNumber(int thread_num);\n+\n+    bool FlashFileIdentical(const std::string& fname, uint64_t fsize);\n+    void ScheduleUpdateFlash(const std::string& fname, uint64_t fsize, int64_t priority);\n+    void UpdateFlashFile(const std::string& fname, uint64_t fsize);\n+\n private:\n     Env* dfs_env_;\n     Env* posix_env_;\n+\n     static std::vector<std::string> flash_paths_;\n     static bool vanish_allowed_;\n+\n+    static bool force_read_from_cache_;","path":"src/leveldb/include/leveldb/env_flash.h","position":40,"original_position":40,"commit_id":"60212e22fe3e0d6e7ef35c58b5e60bda0d2a9c1c","original_commit_id":"60212e22fe3e0d6e7ef35c58b5e60bda0d2a9c1c","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-03-23T10:07:22Z","updated_at":"2016-03-23T10:07:22Z","html_url":"https://github.com/baidu/tera/pull/775#discussion_r57134340","pull_request_url":"https://api.github.com/repos/baidu/tera/pulls/775","_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments/57134340"},"html":{"href":"https://github.com/baidu/tera/pull/775#discussion_r57134340"},"pull_request":{"href":"https://api.github.com/repos/baidu/tera/pulls/775"}}},"pull_request":{"url":"https://api.github.com/repos/baidu/tera/pulls/775","id":62041091,"html_url":"https://github.com/baidu/tera/pull/775","diff_url":"https://github.com/baidu/tera/pull/775.diff","patch_url":"https://github.com/baidu/tera/pull/775.patch","issue_url":"https://api.github.com/repos/baidu/tera/issues/775","number":775,"state":"open","locked":false,"title":"update flash_env: copy to local background and read dfs temporary ","user":{"login":"00k","id":9716419,"avatar_url":"https://avatars.githubusercontent.com/u/9716419?v=3","gravatar_id":"","url":"https://api.github.com/users/00k","html_url":"https://github.com/00k","followers_url":"https://api.github.com/users/00k/followers","following_url":"https://api.github.com/users/00k/following{/other_user}","gists_url":"https://api.github.com/users/00k/gists{/gist_id}","starred_url":"https://api.github.com/users/00k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/00k/subscriptions","organizations_url":"https://api.github.com/users/00k/orgs","repos_url":"https://api.github.com/users/00k/repos","events_url":"https://api.github.com/users/00k/events{/privacy}","received_events_url":"https://api.github.com/users/00k/received_events","type":"User","site_admin":false},"body":"#212\r\nopen file：\r\n1. 如果FLAG_force_read_from_cache为true，copy to local\r\n2. 如果local file size == dfs file size，open local file； 否则，open dfs file，并向线程池注册copy to local任务，优先级是1\r\nread file：\r\n1. 如果local file没有打开，且没有其他线程正在打开，且距上次尝试打开过了30秒，检查local file size，如果不等于dfs file size，提高copy to local任务优先级，提高数等于期间read次数；否则，打开local file\r\n2. 如果local file打开，read local file，否则read dfs file\r\ncopy to local：\r\n1. 执行copy\r\n2. 如果失败，重新向线程池注册copy to local任务，60秒后执行，优先级为原来的一半","created_at":"2016-03-08T08:52:16Z","updated_at":"2016-03-23T10:07:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e61357a866618f444883754ea8931e3be0fd006","assignee":{"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},"milestone":null,"commits_url":"https://api.github.com/repos/baidu/tera/pulls/775/commits","review_comments_url":"https://api.github.com/repos/baidu/tera/pulls/775/comments","review_comment_url":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}","comments_url":"https://api.github.com/repos/baidu/tera/issues/775/comments","statuses_url":"https://api.github.com/repos/baidu/tera/statuses/60212e22fe3e0d6e7ef35c58b5e60bda0d2a9c1c","head":{"label":"00k:copytolocal","ref":"copytolocal","sha":"60212e22fe3e0d6e7ef35c58b5e60bda0d2a9c1c","user":{"login":"00k","id":9716419,"avatar_url":"https://avatars.githubusercontent.com/u/9716419?v=3","gravatar_id":"","url":"https://api.github.com/users/00k","html_url":"https://github.com/00k","followers_url":"https://api.github.com/users/00k/followers","following_url":"https://api.github.com/users/00k/following{/other_user}","gists_url":"https://api.github.com/users/00k/gists{/gist_id}","starred_url":"https://api.github.com/users/00k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/00k/subscriptions","organizations_url":"https://api.github.com/users/00k/orgs","repos_url":"https://api.github.com/users/00k/repos","events_url":"https://api.github.com/users/00k/events{/privacy}","received_events_url":"https://api.github.com/users/00k/received_events","type":"User","site_admin":false},"repo":{"id":32000292,"name":"tera","full_name":"00k/tera","owner":{"login":"00k","id":9716419,"avatar_url":"https://avatars.githubusercontent.com/u/9716419?v=3","gravatar_id":"","url":"https://api.github.com/users/00k","html_url":"https://github.com/00k","followers_url":"https://api.github.com/users/00k/followers","following_url":"https://api.github.com/users/00k/following{/other_user}","gists_url":"https://api.github.com/users/00k/gists{/gist_id}","starred_url":"https://api.github.com/users/00k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/00k/subscriptions","organizations_url":"https://api.github.com/users/00k/orgs","repos_url":"https://api.github.com/users/00k/repos","events_url":"https://api.github.com/users/00k/events{/privacy}","received_events_url":"https://api.github.com/users/00k/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/00k/tera","description":"A distributed table storage system.","fork":true,"url":"https://api.github.com/repos/00k/tera","forks_url":"https://api.github.com/repos/00k/tera/forks","keys_url":"https://api.github.com/repos/00k/tera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/00k/tera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/00k/tera/teams","hooks_url":"https://api.github.com/repos/00k/tera/hooks","issue_events_url":"https://api.github.com/repos/00k/tera/issues/events{/number}","events_url":"https://api.github.com/repos/00k/tera/events","assignees_url":"https://api.github.com/repos/00k/tera/assignees{/user}","branches_url":"https://api.github.com/repos/00k/tera/branches{/branch}","tags_url":"https://api.github.com/repos/00k/tera/tags","blobs_url":"https://api.github.com/repos/00k/tera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/00k/tera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/00k/tera/git/refs{/sha}","trees_url":"https://api.github.com/repos/00k/tera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/00k/tera/statuses/{sha}","languages_url":"https://api.github.com/repos/00k/tera/languages","stargazers_url":"https://api.github.com/repos/00k/tera/stargazers","contributors_url":"https://api.github.com/repos/00k/tera/contributors","subscribers_url":"https://api.github.com/repos/00k/tera/subscribers","subscription_url":"https://api.github.com/repos/00k/tera/subscription","commits_url":"https://api.github.com/repos/00k/tera/commits{/sha}","git_commits_url":"https://api.github.com/repos/00k/tera/git/commits{/sha}","comments_url":"https://api.github.com/repos/00k/tera/comments{/number}","issue_comment_url":"https://api.github.com/repos/00k/tera/issues/comments{/number}","contents_url":"https://api.github.com/repos/00k/tera/contents/{+path}","compare_url":"https://api.github.com/repos/00k/tera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/00k/tera/merges","archive_url":"https://api.github.com/repos/00k/tera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/00k/tera/downloads","issues_url":"https://api.github.com/repos/00k/tera/issues{/number}","pulls_url":"https://api.github.com/repos/00k/tera/pulls{/number}","milestones_url":"https://api.github.com/repos/00k/tera/milestones{/number}","notifications_url":"https://api.github.com/repos/00k/tera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/00k/tera/labels{/name}","releases_url":"https://api.github.com/repos/00k/tera/releases{/id}","deployments_url":"https://api.github.com/repos/00k/tera/deployments","created_at":"2015-03-11T05:36:34Z","updated_at":"2016-01-11T03:35:16Z","pushed_at":"2016-03-23T09:45:15Z","git_url":"git://github.com/00k/tera.git","ssh_url":"git@github.com:00k/tera.git","clone_url":"https://github.com/00k/tera.git","svn_url":"https://github.com/00k/tera","homepage":"","size":13201,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"baidu:master","ref":"master","sha":"bcea05365eedca337c06cdb0f24ae53bd1252d6b","user":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"repo":{"id":18129915,"name":"tera","full_name":"baidu/tera","owner":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/baidu/tera","description":"A distributed, elastic, structured database.","fork":false,"url":"https://api.github.com/repos/baidu/tera","forks_url":"https://api.github.com/repos/baidu/tera/forks","keys_url":"https://api.github.com/repos/baidu/tera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baidu/tera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baidu/tera/teams","hooks_url":"https://api.github.com/repos/baidu/tera/hooks","issue_events_url":"https://api.github.com/repos/baidu/tera/issues/events{/number}","events_url":"https://api.github.com/repos/baidu/tera/events","assignees_url":"https://api.github.com/repos/baidu/tera/assignees{/user}","branches_url":"https://api.github.com/repos/baidu/tera/branches{/branch}","tags_url":"https://api.github.com/repos/baidu/tera/tags","blobs_url":"https://api.github.com/repos/baidu/tera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baidu/tera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baidu/tera/git/refs{/sha}","trees_url":"https://api.github.com/repos/baidu/tera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baidu/tera/statuses/{sha}","languages_url":"https://api.github.com/repos/baidu/tera/languages","stargazers_url":"https://api.github.com/repos/baidu/tera/stargazers","contributors_url":"https://api.github.com/repos/baidu/tera/contributors","subscribers_url":"https://api.github.com/repos/baidu/tera/subscribers","subscription_url":"https://api.github.com/repos/baidu/tera/subscription","commits_url":"https://api.github.com/repos/baidu/tera/commits{/sha}","git_commits_url":"https://api.github.com/repos/baidu/tera/git/commits{/sha}","comments_url":"https://api.github.com/repos/baidu/tera/comments{/number}","issue_comment_url":"https://api.github.com/repos/baidu/tera/issues/comments{/number}","contents_url":"https://api.github.com/repos/baidu/tera/contents/{+path}","compare_url":"https://api.github.com/repos/baidu/tera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baidu/tera/merges","archive_url":"https://api.github.com/repos/baidu/tera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baidu/tera/downloads","issues_url":"https://api.github.com/repos/baidu/tera/issues{/number}","pulls_url":"https://api.github.com/repos/baidu/tera/pulls{/number}","milestones_url":"https://api.github.com/repos/baidu/tera/milestones{/number}","notifications_url":"https://api.github.com/repos/baidu/tera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baidu/tera/labels{/name}","releases_url":"https://api.github.com/repos/baidu/tera/releases{/id}","deployments_url":"https://api.github.com/repos/baidu/tera/deployments","created_at":"2014-03-26T07:22:05Z","updated_at":"2016-03-17T06:00:29Z","pushed_at":"2016-03-23T10:05:56Z","git_url":"git://github.com/baidu/tera.git","ssh_url":"git@github.com:baidu/tera.git","clone_url":"https://github.com/baidu/tera.git","svn_url":"https://github.com/baidu/tera","homepage":"","size":16781,"stargazers_count":364,"watchers_count":364,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":127,"mirror_url":null,"open_issues_count":131,"forks":127,"open_issues":131,"watchers":364,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/775"},"html":{"href":"https://github.com/baidu/tera/pull/775"},"issue":{"href":"https://api.github.com/repos/baidu/tera/issues/775"},"comments":{"href":"https://api.github.com/repos/baidu/tera/issues/775/comments"},"review_comments":{"href":"https://api.github.com/repos/baidu/tera/pulls/775/comments"},"review_comment":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/baidu/tera/pulls/775/commits"},"statuses":{"href":"https://api.github.com/repos/baidu/tera/statuses/60212e22fe3e0d6e7ef35c58b5e60bda0d2a9c1c"}}}}