{"action":"created","comment":{"url":"https://api.github.com/repos/Metaswitch/sprout/pulls/comments/23767044","id":23767044,"diff_hunk":"@@ -369,179 +399,40 @@ void RegStore::expire_subscriptions(AoR* aor_data,\n /// Serialize the contents of an AoR.\n std::string RegStore::Connector::serialize_aor(AoR* aor_data)\n {\n-  std::ostringstream oss(std::ostringstream::out|std::ostringstream::binary);\n-\n-  int num_bindings = aor_data->bindings().size();\n-  LOG_DEBUG(\"Serialize %d bindings\", num_bindings);\n-  oss.write((const char *)&num_bindings, sizeof(int));\n-\n-  for (AoR::Bindings::const_iterator i = aor_data->bindings().begin();\n-       i != aor_data->bindings().end();\n-       ++i)\n-  {\n-    LOG_DEBUG(\"  Binding %s\", i->first.c_str());\n-    oss << i->first << '\\0';\n-\n-    AoR::Binding* b = i->second;\n-    oss << b->_uri << '\\0';\n-    oss << b->_cid << '\\0';\n-    oss.write((const char *)&b->_cseq, sizeof(int));\n-    oss.write((const char *)&b->_expires, sizeof(int));\n-    oss.write((const char *)&b->_priority, sizeof(int));\n-    int num_params = b->_params.size();\n-    oss.write((const char *)&num_params, sizeof(int));\n-    for (std::map<std::string, std::string>::const_iterator i = b->_params.begin();\n-         i != b->_params.end();\n-         ++i)\n-    {\n-      oss << i->first << '\\0' << i->second << '\\0';\n-    }\n-    int num_path_hdrs = b->_path_headers.size();\n-    oss.write((const char *)&num_path_hdrs, sizeof(int));\n-    for (std::list<std::string>::const_iterator i = b->_path_headers.begin();\n-         i != b->_path_headers.end();\n-         ++i)\n-    {\n-      oss << *i << '\\0';\n-    }\n-    oss << b->_timer_id << '\\0';\n-    oss << b->_private_id << '\\0';\n-    oss.write((const char *)&b->_emergency_registration, sizeof(int));\n-  }\n-\n-  int num_subscriptions = aor_data->subscriptions().size();\n-  LOG_DEBUG(\"Serialize %d subscriptions\", num_subscriptions);\n-  oss.write((const char *)&num_subscriptions, sizeof(int));\n-\n-  for (AoR::Subscriptions::const_iterator i = aor_data->subscriptions().begin();\n-       i != aor_data->subscriptions().end();\n-       ++i)\n-  {\n-    LOG_DEBUG(\"  Subscription %s\", i->first.c_str());\n-    oss << i->first << '\\0';\n-\n-    AoR::Subscription* s = i->second;\n-    oss << s->_req_uri << '\\0';\n-    oss << s->_from_uri << '\\0';\n-    oss << s->_from_tag << '\\0';\n-    oss << s->_to_uri << '\\0';\n-    oss << s->_to_tag << '\\0';\n-    oss << s->_cid << '\\0';\n-    int num_routes = s->_route_uris.size();\n-    LOG_DEBUG(\"    number of routes = %d\", num_routes);\n-    oss.write((const char *)&num_routes, sizeof(int));\n-    for (std::list<std::string>::const_iterator i = s->_route_uris.begin();\n-         i != s->_route_uris.end();\n-         ++i)\n-    {\n-      oss << *i << '\\0';\n-    }\n-    oss.write((const char *)&s->_expires, sizeof(int));\n-  }\n-\n-  oss.write((const char *)&aor_data->_notify_cseq, sizeof(int));\n-\n-  return oss.str();\n+  return _serializer->serialize_aor(aor_data);\n }\n \n \n /// Deserialize the contents of an AoR\n RegStore::AoR* RegStore::Connector::deserialize_aor(const std::string& aor_id, const std::string& s)\n {\n-  std::istringstream iss(s, std::istringstream::in|std::istringstream::binary);\n-\n-  AoR* aor_data = new AoR(aor_id);\n-\n-  int num_bindings;\n-  iss.read((char *)&num_bindings, sizeof(int));\n-  LOG_DEBUG(\"Deserialize %d bindings\", num_bindings);\n+  AoR* aor = NULL;\n \n-  for (int ii = 0; ii < num_bindings; ++ii)\n+  for(std::vector<SerializerDeserializer*>::iterator it = _deserializers.begin();\n+      it != _deserializers.end();\n+      ++it)\n   {\n-    // Extract the binding identifier into a string.\n-    std::string binding_id;\n-    getline(iss, binding_id, '\\0');\n-    LOG_DEBUG(\"  Binding %s\", binding_id.c_str());\n-\n-    AoR::Binding* b = aor_data->get_binding(binding_id);\n-\n-    // Now extract the various fixed binding parameters.\n-    getline(iss, b->_uri, '\\0');\n-    getline(iss, b->_cid, '\\0');\n-    iss.read((char *)&b->_cseq, sizeof(int));\n-    iss.read((char *)&b->_expires, sizeof(int));\n+    SerializerDeserializer* deserializer = *it;\n \n-    iss.read((char *)&b->_priority, sizeof(int));\n+    LOG_DEBUG(\"Try to deserialize record with '%s' deserializer\",","path":"sprout/regstore.cpp","position":177,"original_position":177,"commit_id":"eda21271814ff8ca9e095c609dc9a9d4fc91346e","original_commit_id":"eda21271814ff8ca9e095c609dc9a9d4fc91346e","user":{"login":"eleanor-merry","id":5425325,"avatar_url":"https://avatars.githubusercontent.com/u/5425325?v=3","gravatar_id":"","url":"https://api.github.com/users/eleanor-merry","html_url":"https://github.com/eleanor-merry","followers_url":"https://api.github.com/users/eleanor-merry/followers","following_url":"https://api.github.com/users/eleanor-merry/following{/other_user}","gists_url":"https://api.github.com/users/eleanor-merry/gists{/gist_id}","starred_url":"https://api.github.com/users/eleanor-merry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eleanor-merry/subscriptions","organizations_url":"https://api.github.com/users/eleanor-merry/orgs","repos_url":"https://api.github.com/users/eleanor-merry/repos","events_url":"https://api.github.com/users/eleanor-merry/events{/privacy}","received_events_url":"https://api.github.com/users/eleanor-merry/received_events","type":"User","site_admin":false},"body":"These debug logs would be more helpful if they included the aor_id","created_at":"2015-01-29T13:34:07Z","updated_at":"2015-01-29T13:34:07Z","html_url":"https://github.com/Metaswitch/sprout/pull/926#discussion_r23767044","pull_request_url":"https://api.github.com/repos/Metaswitch/sprout/pulls/926","_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/sprout/pulls/comments/23767044"},"html":{"href":"https://github.com/Metaswitch/sprout/pull/926#discussion_r23767044"},"pull_request":{"href":"https://api.github.com/repos/Metaswitch/sprout/pulls/926"}}},"pull_request":{"url":"https://api.github.com/repos/Metaswitch/sprout/pulls/926","id":28269663,"html_url":"https://github.com/Metaswitch/sprout/pull/926","diff_url":"https://github.com/Metaswitch/sprout/pull/926.diff","patch_url":"https://github.com/Metaswitch/sprout/pull/926.patch","issue_url":"https://api.github.com/repos/Metaswitch/sprout/issues/926","number":926,"state":"open","locked":false,"title":"[Reviewer: Ellie] Memcached schema upgrade","user":{"login":"AlexHockey","id":4903205,"avatar_url":"https://avatars.githubusercontent.com/u/4903205?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexHockey","html_url":"https://github.com/AlexHockey","followers_url":"https://api.github.com/users/AlexHockey/followers","following_url":"https://api.github.com/users/AlexHockey/following{/other_user}","gists_url":"https://api.github.com/users/AlexHockey/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexHockey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexHockey/subscriptions","organizations_url":"https://api.github.com/users/AlexHockey/orgs","repos_url":"https://api.github.com/users/AlexHockey/repos","events_url":"https://api.github.com/users/AlexHockey/events{/privacy}","received_events_url":"https://api.github.com/users/AlexHockey/received_events","type":"User","site_admin":false},"body":"Hi Ellie, please can you review my changes to migrate Sprout's RegStore to using JSON for its records. \r\n\r\nThis PR contains the bulk of the changes. These should match the design you reviewed, with two changes (which we discussed):\r\n\r\n* I haven't implemented the change to produce two different packages based on a built time option (this is not needed for the Project Clearwater release plan). \r\n* We want to continue use the binary format for the time being. As our packages never supply `--memcached-write-format` I have done this by simply defaulting the write format to binary. \r\n\r\n## Testing\r\n\r\n* UTs - in this PR.\r\n* Live tests - I am currently running through the live test plan. This is as you reviewed but with the build-time options test removed, and a couple of tests to check the config option is honored when specified. \r\n\r\n## Docs\r\n\r\nI plan to write the upgrade instructions (for future release notes). I will send these to you for review when I have written them. \r\n\r\n","created_at":"2015-01-29T10:57:17Z","updated_at":"2015-01-29T13:34:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db9cc522b99b6a5e446accd1ef8214ab35019a28","assignee":{"login":"eleanor-merry","id":5425325,"avatar_url":"https://avatars.githubusercontent.com/u/5425325?v=3","gravatar_id":"","url":"https://api.github.com/users/eleanor-merry","html_url":"https://github.com/eleanor-merry","followers_url":"https://api.github.com/users/eleanor-merry/followers","following_url":"https://api.github.com/users/eleanor-merry/following{/other_user}","gists_url":"https://api.github.com/users/eleanor-merry/gists{/gist_id}","starred_url":"https://api.github.com/users/eleanor-merry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eleanor-merry/subscriptions","organizations_url":"https://api.github.com/users/eleanor-merry/orgs","repos_url":"https://api.github.com/users/eleanor-merry/repos","events_url":"https://api.github.com/users/eleanor-merry/events{/privacy}","received_events_url":"https://api.github.com/users/eleanor-merry/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Metaswitch/sprout/pulls/926/commits","review_comments_url":"https://api.github.com/repos/Metaswitch/sprout/pulls/926/comments","review_comment_url":"https://api.github.com/repos/Metaswitch/sprout/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Metaswitch/sprout/issues/926/comments","statuses_url":"https://api.github.com/repos/Metaswitch/sprout/statuses/eda21271814ff8ca9e095c609dc9a9d4fc91346e","head":{"label":"Metaswitch:memcached_schema_upgrade","ref":"memcached_schema_upgrade","sha":"eda21271814ff8ca9e095c609dc9a9d4fc91346e","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":9887542,"name":"sprout","full_name":"Metaswitch/sprout","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/sprout","description":"sprout and bono, the Clearwater SIP router and edge proxy","fork":false,"url":"https://api.github.com/repos/Metaswitch/sprout","forks_url":"https://api.github.com/repos/Metaswitch/sprout/forks","keys_url":"https://api.github.com/repos/Metaswitch/sprout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/sprout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/sprout/teams","hooks_url":"https://api.github.com/repos/Metaswitch/sprout/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/sprout/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/sprout/events","assignees_url":"https://api.github.com/repos/Metaswitch/sprout/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/sprout/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/sprout/tags","blobs_url":"https://api.github.com/repos/Metaswitch/sprout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/sprout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/sprout/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/sprout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/sprout/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/sprout/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/sprout/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/sprout/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/sprout/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/sprout/subscription","commits_url":"https://api.github.com/repos/Metaswitch/sprout/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/sprout/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/sprout/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/sprout/issues/comments/{number}","contents_url":"https://api.github.com/repos/Metaswitch/sprout/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/sprout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/sprout/merges","archive_url":"https://api.github.com/repos/Metaswitch/sprout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/sprout/downloads","issues_url":"https://api.github.com/repos/Metaswitch/sprout/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/sprout/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/sprout/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/sprout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/sprout/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/sprout/releases{/id}","created_at":"2013-05-06T13:37:07Z","updated_at":"2015-01-21T08:04:04Z","pushed_at":"2015-01-29T11:55:11Z","git_url":"git://github.com/Metaswitch/sprout.git","ssh_url":"git@github.com:Metaswitch/sprout.git","clone_url":"https://github.com/Metaswitch/sprout.git","svn_url":"https://github.com/Metaswitch/sprout","homepage":null,"size":31948,"stargazers_count":12,"watchers_count":12,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":78,"forks":20,"open_issues":78,"watchers":12,"default_branch":"dev"}},"base":{"label":"Metaswitch:dev","ref":"dev","sha":"ea8e618c769f0cbdf273691592badcba7983c1ba","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":9887542,"name":"sprout","full_name":"Metaswitch/sprout","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/sprout","description":"sprout and bono, the Clearwater SIP router and edge proxy","fork":false,"url":"https://api.github.com/repos/Metaswitch/sprout","forks_url":"https://api.github.com/repos/Metaswitch/sprout/forks","keys_url":"https://api.github.com/repos/Metaswitch/sprout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/sprout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/sprout/teams","hooks_url":"https://api.github.com/repos/Metaswitch/sprout/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/sprout/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/sprout/events","assignees_url":"https://api.github.com/repos/Metaswitch/sprout/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/sprout/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/sprout/tags","blobs_url":"https://api.github.com/repos/Metaswitch/sprout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/sprout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/sprout/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/sprout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/sprout/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/sprout/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/sprout/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/sprout/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/sprout/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/sprout/subscription","commits_url":"https://api.github.com/repos/Metaswitch/sprout/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/sprout/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/sprout/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/sprout/issues/comments/{number}","contents_url":"https://api.github.com/repos/Metaswitch/sprout/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/sprout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/sprout/merges","archive_url":"https://api.github.com/repos/Metaswitch/sprout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/sprout/downloads","issues_url":"https://api.github.com/repos/Metaswitch/sprout/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/sprout/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/sprout/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/sprout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/sprout/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/sprout/releases{/id}","created_at":"2013-05-06T13:37:07Z","updated_at":"2015-01-21T08:04:04Z","pushed_at":"2015-01-29T11:55:11Z","git_url":"git://github.com/Metaswitch/sprout.git","ssh_url":"git@github.com:Metaswitch/sprout.git","clone_url":"https://github.com/Metaswitch/sprout.git","svn_url":"https://github.com/Metaswitch/sprout","homepage":null,"size":31948,"stargazers_count":12,"watchers_count":12,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":78,"forks":20,"open_issues":78,"watchers":12,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/sprout/pulls/926"},"html":{"href":"https://github.com/Metaswitch/sprout/pull/926"},"issue":{"href":"https://api.github.com/repos/Metaswitch/sprout/issues/926"},"comments":{"href":"https://api.github.com/repos/Metaswitch/sprout/issues/926/comments"},"review_comments":{"href":"https://api.github.com/repos/Metaswitch/sprout/pulls/926/comments"},"review_comment":{"href":"https://api.github.com/repos/Metaswitch/sprout/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Metaswitch/sprout/pulls/926/commits"},"statuses":{"href":"https://api.github.com/repos/Metaswitch/sprout/statuses/eda21271814ff8ca9e095c609dc9a9d4fc91346e"}}}}