{"action":"created","comment":{"url":"https://api.github.com/repos/openvstorage/alba/pulls/comments/56329548","id":56329548,"diff_hunk":"@@ -0,0 +1,163 @@\n+(*\n+Copyright 2016 iNuron NV\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+     http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*)\n+\n+open Prelude\n+open Lwt.Infix\n+\n+type alba_fragment_cache_bucket_strategy =\n+  | OneOnOne of alba_fragment_cache_bucket_strategy_one_on_one [@name \"1-to-1\"]\n+[@@deriving yojson, show]\n+\n+ and alba_fragment_cache_bucket_strategy_one_on_one = {\n+     preset : string;\n+     prefix : string;\n+   } [@@deriving yojson, show]\n+\n+class alba_cache\n+        ~albamgr_cfg_ref\n+        ~bucket_strategy\n+        ~nested_fragment_cache\n+        ~manifest_cache_size\n+        ~albamgr_connection_pool_size\n+        ~nsm_host_connection_pool_size\n+        ~osd_connection_pool_size\n+        ~osd_timeout\n+        ~tls_config\n+  =\n+  let tcp_keepalive = Tcp_keepalive2.default in\n+  let albamgr_pool =\n+    Remotes.Pool.Albamgr.make\n+      ~size:albamgr_connection_pool_size\n+      albamgr_cfg_ref\n+      tls_config\n+      Buffer_pool.default_buffer_pool\n+      ~tcp_keepalive\n+  in\n+  let mgr_access =\n+    new Albamgr_client.client (new Albamgr_access.basic_mgr_pooled albamgr_pool)\n+  in\n+  let base_client = new Alba_base_client.client\n+                        nested_fragment_cache\n+                        ~mgr_access\n+                        ~manifest_cache_size\n+                        ~bad_fragment_callback:(fun alba_client\n+                                                    ~namespace_id\n+                                                    ~object_id ~object_name\n+                                                    ~chunk_id ~fragment_id\n+                                                    ~location -> ())\n+                        ~nsm_host_connection_pool_size\n+                        ~osd_connection_pool_size\n+                        ~osd_timeout\n+                        ~default_osd_priority:Osd.High\n+                        ~tls_config\n+                        ~tcp_keepalive\n+                        ~use_fadvise:true\n+  in\n+  let client = new Alba_client.alba_client base_client in\n+  let make_object_name ~bid ~name =\n+    serialize\n+      (Llio.pair_to\n+         Llio.int32_to\n+         Llio.string_to)\n+      (bid, name)\n+  in\n+  let with_namespace bid f =\n+    match bucket_strategy with\n+    | OneOnOne { prefix;\n+                 preset; } ->\n+       let namespace = prefix ^ (serialize ~buf_size:4 Llio.int32_to bid) in\n+       Lwt.catch\n+         (fun () -> f namespace)\n+         (fun exn ->\n+          client # create_namespace ~namespace ~preset_name:(Some preset) () >>= fun _ ->\n+          f namespace)\n+  in\n+  object(self :# Fragment_cache.cache)\n+    method add bid name blob =\n+      Lwt.catch\n+        (fun () ->\n+         with_namespace\n+           bid\n+           (fun namespace ->\n+            client # upload_object_from_bytes\n+                   ~namespace\n+                   ~object_name:(make_object_name ~bid ~name)\n+                   ~object_data:blob\n+                   ~checksum_o:None\n+                   ~allow_overwrite:Nsm_model.Unconditionally >>= fun _ ->\n+            Lwt.return_unit))\n+        (fun exn ->\n+         Lwt_log.debug_f ~exn \"Exception while adding object to alba fragment cache\")\n+\n+    method lookup bid name =\n+      Lwt.catch\n+        (fun () ->\n+         with_namespace\n+           bid\n+           (fun namespace ->\n+            client # download_object_to_bytes\n+                   ~object_name:(make_object_name ~bid ~name)\n+                   ~namespace\n+                   ~consistent_read:false\n+                   ~should_cache:true))\n+        (fun exn ->\n+         Lwt_log.debug_f ~exn \"Exception during alba fragment cache lookup\" >>= fun () ->\n+         Lwt.return_none)\n+\n+    method lookup2 bid name object_slices =\n+      Lwt.catch\n+        (fun () ->\n+         with_namespace\n+           bid\n+           (fun namespace ->\n+            client # nsm_host_access # with_namespace_id\n+                   ~namespace\n+                   (fun namespace_id ->\n+                    base_client # download_object_slices'\n+                                ~namespace_id\n+                                ~object_name:(make_object_name ~bid ~name)\n+                                ~object_slices:(List.map","path":"ocaml/src/fragment_cache_alba.ml","position":null,"original_position":132,"commit_id":"a9d95ad38a8934a28b6ff45626734a8c04e23ec6","original_commit_id":"2b3f342b4a3f966f0675a361eac2360ac08a5513","user":{"login":"domsj","id":89326,"avatar_url":"https://avatars.githubusercontent.com/u/89326?v=3","gravatar_id":"","url":"https://api.github.com/users/domsj","html_url":"https://github.com/domsj","followers_url":"https://api.github.com/users/domsj/followers","following_url":"https://api.github.com/users/domsj/following{/other_user}","gists_url":"https://api.github.com/users/domsj/gists{/gist_id}","starred_url":"https://api.github.com/users/domsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domsj/subscriptions","organizations_url":"https://api.github.com/users/domsj/orgs","repos_url":"https://api.github.com/users/domsj/repos","events_url":"https://api.github.com/users/domsj/events{/privacy}","received_events_url":"https://api.github.com/users/domsj/received_events","type":"User","site_admin":false},"body":"I think the 'unduly heavy' description is an exaggeration, regardless I've added another commit.","created_at":"2016-03-16T13:10:17Z","updated_at":"2016-03-16T13:10:17Z","html_url":"https://github.com/openvstorage/alba/pull/170#discussion_r56329548","pull_request_url":"https://api.github.com/repos/openvstorage/alba/pulls/170","_links":{"self":{"href":"https://api.github.com/repos/openvstorage/alba/pulls/comments/56329548"},"html":{"href":"https://github.com/openvstorage/alba/pull/170#discussion_r56329548"},"pull_request":{"href":"https://api.github.com/repos/openvstorage/alba/pulls/170"}}},"pull_request":{"url":"https://api.github.com/repos/openvstorage/alba/pulls/170","id":62418169,"html_url":"https://github.com/openvstorage/alba/pull/170","diff_url":"https://github.com/openvstorage/alba/pull/170.diff","patch_url":"https://github.com/openvstorage/alba/pull/170.patch","issue_url":"https://api.github.com/repos/openvstorage/alba/issues/170","number":170,"state":"open","locked":false,"title":"Alba accelerated alba","user":{"login":"domsj","id":89326,"avatar_url":"https://avatars.githubusercontent.com/u/89326?v=3","gravatar_id":"","url":"https://api.github.com/users/domsj","html_url":"https://github.com/domsj","followers_url":"https://api.github.com/users/domsj/followers","following_url":"https://api.github.com/users/domsj/following{/other_user}","gists_url":"https://api.github.com/users/domsj/gists{/gist_id}","starred_url":"https://api.github.com/users/domsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domsj/subscriptions","organizations_url":"https://api.github.com/users/domsj/orgs","repos_url":"https://api.github.com/users/domsj/repos","events_url":"https://api.github.com/users/domsj/events{/privacy}","received_events_url":"https://api.github.com/users/domsj/received_events","type":"User","site_admin":false},"body":"This pull request allows using e.g. a flash based alba as a fragment cache for a hard disk based alba.\r\n\r\nSome more (related) changes are still to come in further pull requests:\r\n- cache eviction\r\n- extra statistics for the proxy\r\n- configure cache on read/write behavior\r\n- partial reads on the asds when no fragment cache is configured\r\n- attempt to remove items from the fragment cache when removing/overwriting an object","created_at":"2016-03-10T16:39:26Z","updated_at":"2016-03-16T13:10:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f23342bba11f9c97f2751024ac9bd1cba3a8b176","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openvstorage/alba/pulls/170/commits","review_comments_url":"https://api.github.com/repos/openvstorage/alba/pulls/170/comments","review_comment_url":"https://api.github.com/repos/openvstorage/alba/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openvstorage/alba/issues/170/comments","statuses_url":"https://api.github.com/repos/openvstorage/alba/statuses/a9d95ad38a8934a28b6ff45626734a8c04e23ec6","head":{"label":"openvstorage:alba-fragment-cache","ref":"alba-fragment-cache","sha":"a9d95ad38a8934a28b6ff45626734a8c04e23ec6","user":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"repo":{"id":38867740,"name":"alba","full_name":"openvstorage/alba","owner":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openvstorage/alba","description":"Open vStorage alternate backend creates a replicated or flexible network raid’ed  object storage backend out of Seagate Kinetic drives and local disk supporting compression, encryption.","fork":false,"url":"https://api.github.com/repos/openvstorage/alba","forks_url":"https://api.github.com/repos/openvstorage/alba/forks","keys_url":"https://api.github.com/repos/openvstorage/alba/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openvstorage/alba/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openvstorage/alba/teams","hooks_url":"https://api.github.com/repos/openvstorage/alba/hooks","issue_events_url":"https://api.github.com/repos/openvstorage/alba/issues/events{/number}","events_url":"https://api.github.com/repos/openvstorage/alba/events","assignees_url":"https://api.github.com/repos/openvstorage/alba/assignees{/user}","branches_url":"https://api.github.com/repos/openvstorage/alba/branches{/branch}","tags_url":"https://api.github.com/repos/openvstorage/alba/tags","blobs_url":"https://api.github.com/repos/openvstorage/alba/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openvstorage/alba/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openvstorage/alba/git/refs{/sha}","trees_url":"https://api.github.com/repos/openvstorage/alba/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openvstorage/alba/statuses/{sha}","languages_url":"https://api.github.com/repos/openvstorage/alba/languages","stargazers_url":"https://api.github.com/repos/openvstorage/alba/stargazers","contributors_url":"https://api.github.com/repos/openvstorage/alba/contributors","subscribers_url":"https://api.github.com/repos/openvstorage/alba/subscribers","subscription_url":"https://api.github.com/repos/openvstorage/alba/subscription","commits_url":"https://api.github.com/repos/openvstorage/alba/commits{/sha}","git_commits_url":"https://api.github.com/repos/openvstorage/alba/git/commits{/sha}","comments_url":"https://api.github.com/repos/openvstorage/alba/comments{/number}","issue_comment_url":"https://api.github.com/repos/openvstorage/alba/issues/comments{/number}","contents_url":"https://api.github.com/repos/openvstorage/alba/contents/{+path}","compare_url":"https://api.github.com/repos/openvstorage/alba/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openvstorage/alba/merges","archive_url":"https://api.github.com/repos/openvstorage/alba/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openvstorage/alba/downloads","issues_url":"https://api.github.com/repos/openvstorage/alba/issues{/number}","pulls_url":"https://api.github.com/repos/openvstorage/alba/pulls{/number}","milestones_url":"https://api.github.com/repos/openvstorage/alba/milestones{/number}","notifications_url":"https://api.github.com/repos/openvstorage/alba/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openvstorage/alba/labels{/name}","releases_url":"https://api.github.com/repos/openvstorage/alba/releases{/id}","deployments_url":"https://api.github.com/repos/openvstorage/alba/deployments","created_at":"2015-07-10T07:40:52Z","updated_at":"2016-01-11T14:23:24Z","pushed_at":"2016-03-16T13:09:54Z","git_url":"git://github.com/openvstorage/alba.git","ssh_url":"git@github.com:openvstorage/alba.git","clone_url":"https://github.com/openvstorage/alba.git","svn_url":"https://github.com/openvstorage/alba","homepage":"","size":19824,"stargazers_count":7,"watchers_count":7,"language":"OCaml","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":7,"default_branch":"master"}},"base":{"label":"openvstorage:master","ref":"master","sha":"7a912f4be301f8d113f31f267ef9ea7599a8dc64","user":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"repo":{"id":38867740,"name":"alba","full_name":"openvstorage/alba","owner":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openvstorage/alba","description":"Open vStorage alternate backend creates a replicated or flexible network raid’ed  object storage backend out of Seagate Kinetic drives and local disk supporting compression, encryption.","fork":false,"url":"https://api.github.com/repos/openvstorage/alba","forks_url":"https://api.github.com/repos/openvstorage/alba/forks","keys_url":"https://api.github.com/repos/openvstorage/alba/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openvstorage/alba/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openvstorage/alba/teams","hooks_url":"https://api.github.com/repos/openvstorage/alba/hooks","issue_events_url":"https://api.github.com/repos/openvstorage/alba/issues/events{/number}","events_url":"https://api.github.com/repos/openvstorage/alba/events","assignees_url":"https://api.github.com/repos/openvstorage/alba/assignees{/user}","branches_url":"https://api.github.com/repos/openvstorage/alba/branches{/branch}","tags_url":"https://api.github.com/repos/openvstorage/alba/tags","blobs_url":"https://api.github.com/repos/openvstorage/alba/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openvstorage/alba/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openvstorage/alba/git/refs{/sha}","trees_url":"https://api.github.com/repos/openvstorage/alba/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openvstorage/alba/statuses/{sha}","languages_url":"https://api.github.com/repos/openvstorage/alba/languages","stargazers_url":"https://api.github.com/repos/openvstorage/alba/stargazers","contributors_url":"https://api.github.com/repos/openvstorage/alba/contributors","subscribers_url":"https://api.github.com/repos/openvstorage/alba/subscribers","subscription_url":"https://api.github.com/repos/openvstorage/alba/subscription","commits_url":"https://api.github.com/repos/openvstorage/alba/commits{/sha}","git_commits_url":"https://api.github.com/repos/openvstorage/alba/git/commits{/sha}","comments_url":"https://api.github.com/repos/openvstorage/alba/comments{/number}","issue_comment_url":"https://api.github.com/repos/openvstorage/alba/issues/comments{/number}","contents_url":"https://api.github.com/repos/openvstorage/alba/contents/{+path}","compare_url":"https://api.github.com/repos/openvstorage/alba/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openvstorage/alba/merges","archive_url":"https://api.github.com/repos/openvstorage/alba/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openvstorage/alba/downloads","issues_url":"https://api.github.com/repos/openvstorage/alba/issues{/number}","pulls_url":"https://api.github.com/repos/openvstorage/alba/pulls{/number}","milestones_url":"https://api.github.com/repos/openvstorage/alba/milestones{/number}","notifications_url":"https://api.github.com/repos/openvstorage/alba/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openvstorage/alba/labels{/name}","releases_url":"https://api.github.com/repos/openvstorage/alba/releases{/id}","deployments_url":"https://api.github.com/repos/openvstorage/alba/deployments","created_at":"2015-07-10T07:40:52Z","updated_at":"2016-01-11T14:23:24Z","pushed_at":"2016-03-16T13:09:54Z","git_url":"git://github.com/openvstorage/alba.git","ssh_url":"git@github.com:openvstorage/alba.git","clone_url":"https://github.com/openvstorage/alba.git","svn_url":"https://github.com/openvstorage/alba","homepage":"","size":19824,"stargazers_count":7,"watchers_count":7,"language":"OCaml","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openvstorage/alba/pulls/170"},"html":{"href":"https://github.com/openvstorage/alba/pull/170"},"issue":{"href":"https://api.github.com/repos/openvstorage/alba/issues/170"},"comments":{"href":"https://api.github.com/repos/openvstorage/alba/issues/170/comments"},"review_comments":{"href":"https://api.github.com/repos/openvstorage/alba/pulls/170/comments"},"review_comment":{"href":"https://api.github.com/repos/openvstorage/alba/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openvstorage/alba/pulls/170/commits"},"statuses":{"href":"https://api.github.com/repos/openvstorage/alba/statuses/a9d95ad38a8934a28b6ff45626734a8c04e23ec6"}}}}