GitHub PullRequestReviewCommentEvent at 2014-11-19 17:10:57
Repository: ds
Actor: thatskriptkid
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/irqlevel/ds/pulls/comments/20590355","id":20590355,"diff_hunk":"@@ -11,43 +12,82 @@\n \n #include <crtlib/include/crtlib.h>\n #include <utils/ucrt/include/ucrt.h>\n+#include <include/ds_cl.h> /* client lib */\n+\n+/* Temp defines */\n+#define CON_NUM  3\n \n int main(int argc, const char *argv[])\n {\n-\tint err = DS_E_BUF_SMALL;\n-\tstruct ds_obj_id *obj_id;\n-\n-\tprintf(\"This is ds client\\n\");\n-\n-\t/* \n-\t * set CLOG log path : NULL and log name ds_client.log\n-\t * NULL means use current working dir as path\n-\t */\n-\tucrt_log_set_path(NULL, \"ds_client.log\");\n-\t/* set CLOG log level */\n-\tucrt_log_set_level(CL_DBG);\n+\t\tint err = DS_E_BUF_SMALL;\n+\t\tint i,j;\n+\t\tstruct object obj;\n+\t\t/*\n+\t\t * Create an array for connections \n+\t\t * In future there will be function for dynamic allocation\n+\t\t * every time computer connects to the network and becomes neighbour\n+\t\t * con_handle struct will be added */\n+\t\t */\n+\t\tstruct con_handle con[CON_NUMBER]; \n+\t\t/* \n+\t     * set CLOG log path : NULL and log name ds_client.log\n+\t     * NULL means use current working dir as path\n+\t     */\n+\t\tucrt_log_set_path(NULL, \"ds_client.log\");\n+\t\t/* set CLOG log level */\n+\t\tucrt_log_set_level(CL_DBG);\n \n-\tCLOG(CL_INF, \"Hello from ds client\");\n-\t/* translate error code to string description */\n-\tCLOG(CL_INF, \"err %x - %s\", err, ds_error(err));\n-\t/* run sha256 test from crtlib */\n-\t__sha256_test();\n-\n-\t/* generate object id and output it */\n-\tobj_id = ds_obj_id_gen();\n-\tif (!obj_id) {\n-\t\tCLOG(CL_ERR, \"cant generate obj id\");\n-\t} else {\n-\t\tchar *obj_id_s = ds_obj_id_to_str(obj_id);\n-\t\tif (!obj_id_s) {\n-\t\t\tCLOG(CL_ERR, \"cant convert obj id to str\");\n+\t\tCLOG(CL_INF, \"Hello from ds client\");\n+\t\t/* translate error code to string description */\n+\t\tCLOG(CL_INF, \"err %x - %s\", err, ds_error(err));\n+\t\t\n+\t\t/* Create maximum available connections */\n+\t\tfor(i=0;i<CON_NUM;i++)\n+\t\t\t\tif (con_handle_init(&con[i]))\n+\t\t\t\t\t\tCLOG(CL_ERR, \"create connection number %d failed\",i);\n+\t\t\n+\t\t/* Connect to two neighbours in network group */\n+\t\tds_connect(&con[0],\"192.168.1.200\",9999);\n+\t\tds_connect(&con[1],\"192.168.1.245\",8700);\n+\t\t\n+\t\t/* generate object id and output it */\n+\t\tobj.id = ds_obj_id_gen();\n+\t\tif (!obj.id) {\n+\t\t\t\tCLOG(CL_ERR, \"cant generate obj id\");\n \t\t} else {\n-\t\t\t/* Log obj id */\n-\t\t\tCLOG(CL_INF, \"generated obj id %s\", obj_id_s);\n-\t\t\tcrt_free(obj_id_s);\n+\t\t\t\tchar *obj_id_s = ds_obj_id_to_str(obj.id);\n+\t\t\t\tif (!obj_id_s) {\n+\t\t\t\t\t\tCLOG(CL_ERR, \"cant convert obj id to str\");\n+\t\t        } else {\n+\t\t\t\t\t\t/* Log obj id */\n+\t\t\t\t\t\tCLOG(CL_INF, \"generated obj id %s\", obj_id_s);\n+\t\t\t\t\t\tcrt_free(obj_id_s);\n+\t\t        }\n \t\t}\n-\t\tcrt_free(obj_id);\n-\t}\n-\n-\treturn 0;\n+\t\t\n+\t\t/* Fill object data | lenght is 50*/\n+\t\tobj.data = \"teststringteststringteststringteststringteststring\";\n+\t\tobj.size = sizeof(obj.data);\n+\t\tobj.data_off = 0;\n+\t\t/* Allocate space for half object on one server \n+\t\t * using first connection and on another\n+\t\t * Host number 0 holds first half \n+\t\t * Host number 1 holds second\n+\t\t */\n+\t\tif(ds_create_object(&con[0],obj.id,(sizeof(obj.data)/2)))\n+\t\t\t\tCLOG(CL_ERR, \"cant reserve space for object on storage\");\n+\t\tif(ds_create_object(&con[1],obj.id,(sizeof(obj.data)/2)))\n+\t\t\t\tCLOG(CL_ERR, \"cant reserve space for object on storage\");\n+\t\t\t\t\t\t\t\t\t\t\t\t\n+\t\t/* Send half object to first node */\n+\t\tds_put_object(&con[0],obj.id,obj.data,(obj.size/2),&obj.data_off);\n+\t\t/* Send half object to second node */\n+\t\tds_put_object(&con[1],obj.id,obj.data,(obj.size/2),&obj.data_off);\n+\t\t\n+\t\tcrt_free(obj.id);","path":"utils/ds_client/ds_client.c","position":null,"original_position":121,"commit_id":"fd1f37373e5e5716cc8678cd645a3a8e28c35b14","original_commit_id":"e6f9d1541c74a03b266e76467850048d95e41725","user":{"login":"thatskriptkid","id":8300184,"avatar_url":"https://avatars.githubusercontent.com/u/8300184?v=3","gravatar_id":"","url":"https://api.github.com/users/thatskriptkid","html_url":"https://github.com/thatskriptkid","followers_url":"https://api.github.com/users/thatskriptkid/followers","following_url":"https://api.github.com/users/thatskriptkid/following{/other_user}","gists_url":"https://api.github.com/users/thatskriptkid/gists{/gist_id}","starred_url":"https://api.github.com/users/thatskriptkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatskriptkid/subscriptions","organizations_url":"https://api.github.com/users/thatskriptkid/orgs","repos_url":"https://api.github.com/users/thatskriptkid/repos","events_url":"https://api.github.com/users/thatskriptkid/events{/privacy}","received_events_url":"https://api.github.com/users/thatskriptkid/received_events","type":"User","site_admin":false},"body":"Исправил","created_at":"2014-11-19T17:10:57Z","updated_at":"2014-11-19T17:10:57Z","html_url":"https://github.com/irqlevel/ds/pull/3#discussion_r20590355","pull_request_url":"https://api.github.com/repos/irqlevel/ds/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/irqlevel/ds/pulls/comments/20590355"},"html":{"href":"https://github.com/irqlevel/ds/pull/3#discussion_r20590355"},"pull_request":{"href":"https://api.github.com/repos/irqlevel/ds/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/irqlevel/ds/pulls/3","id":24502253,"html_url":"https://github.com/irqlevel/ds/pull/3","diff_url":"https://github.com/irqlevel/ds/pull/3.diff","patch_url":"https://github.com/irqlevel/ds/pull/3.patch","issue_url":"https://api.github.com/repos/irqlevel/ds/issues/3","number":3,"state":"open","locked":false,"title":"Клиентский код","user":{"login":"thatskriptkid","id":8300184,"avatar_url":"https://avatars.githubusercontent.com/u/8300184?v=3","gravatar_id":"","url":"https://api.github.com/users/thatskriptkid","html_url":"https://github.com/thatskriptkid","followers_url":"https://api.github.com/users/thatskriptkid/followers","following_url":"https://api.github.com/users/thatskriptkid/following{/other_user}","gists_url":"https://api.github.com/users/thatskriptkid/gists{/gist_id}","starred_url":"https://api.github.com/users/thatskriptkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatskriptkid/subscriptions","organizations_url":"https://api.github.com/users/thatskriptkid/orgs","repos_url":"https://api.github.com/users/thatskriptkid/repos","events_url":"https://api.github.com/users/thatskriptkid/events{/privacy}","received_events_url":"https://api.github.com/users/thatskriptkid/received_events","type":"User","site_admin":false},"body":"Начал писать библиотеку с интерфейсом, которую будет использовать клиент. В папке ds/utils/ds_client/ создал папку lib. Код прокомментировал. \r\n1. КЛиентская библиотека находится в папке ds/utils/ds_client/lib и называется ds_cl.c. В ней пока реализованны функции - инициализация соединения con_handle_init(), подключение к хосту ds_connect(struct con_handle *con,char *ip,int port), отправка объекта на сервер ds_put_object(struct con_handle *con,struct ds_obj_id id, void *data, uint32_t data_size, uint64_t *off). В функции ds_put_object() объект нарезается на ds_packets (куски объекта) и по очереди отправляются на сервер.\r\n2. Отредактировал код клиента ds/utils/ds_client/ds_client.c. Моделировалась такая ситуация. У клиента создается массив подключений struct con_handle, объект struct object. В цикле, клиент инициализирует три подключения для трех хостов. Потом он подключается к двум хостам ds_connect().  В obj.id заносится сгенерированный id. В obj.data записывается тестовая строка из 50 символов, офсет выставлен в начало (0). Дальше клиент хочет хранить половину объекта на одном хосте, вторую на другом .Он вызывает два раза ds_create_object (функция еще не готова) для резервирования места, размером (sizeof(obj.data_size)/2). Далее вызывается ds_put_object(), в нем половина объекта делится на 5 частей и отправляется на сервер, и потом еще раз для оптравки другой половины другому клиенту. Все куски имеют внутри себя id объекта, размер данных и смещение относительно начала, поэтому из этих кусков можно легко собрать объект заново. В конце клиент сбрасывает все соединения.\r\n3. Хидер библиотеки ds_cl положил в /include, чтобы сервер мог видеть структуры. В ds_cl.h находятся определения для соединения con_handle, частей объектов ds_packet, объект object.\r\n4. В папке ds/utils/ds_client/lib создал файл cl_crt.c, в котором реализованны функции crt_malloc,crt_free,... для юзерспейс.\r\n5. В папке ds/utils/ds_client/lib создал файл random.c, в котором реализована функция ds_random_buf_read() для чтения данных из /dev/urandom в юзерспейс.\r\n","created_at":"2014-11-16T14:07:55Z","updated_at":"2014-11-19T17:10:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ade3774cced14df135347a1ee3990742eb8c2bab","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/irqlevel/ds/pulls/3/commits","review_comments_url":"https://api.github.com/repos/irqlevel/ds/pulls/3/comments","review_comment_url":"https://api.github.com/repos/irqlevel/ds/pulls/comments/{number}","comments_url":"https://api.github.com/repos/irqlevel/ds/issues/3/comments","statuses_url":"https://api.github.com/repos/irqlevel/ds/statuses/fd1f37373e5e5716cc8678cd645a3a8e28c35b14","head":{"label":"thatskriptkid:master","ref":"master","sha":"fd1f37373e5e5716cc8678cd645a3a8e28c35b14","user":{"login":"thatskriptkid","id":8300184,"avatar_url":"https://avatars.githubusercontent.com/u/8300184?v=3","gravatar_id":"","url":"https://api.github.com/users/thatskriptkid","html_url":"https://github.com/thatskriptkid","followers_url":"https://api.github.com/users/thatskriptkid/followers","following_url":"https://api.github.com/users/thatskriptkid/following{/other_user}","gists_url":"https://api.github.com/users/thatskriptkid/gists{/gist_id}","starred_url":"https://api.github.com/users/thatskriptkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatskriptkid/subscriptions","organizations_url":"https://api.github.com/users/thatskriptkid/orgs","repos_url":"https://api.github.com/users/thatskriptkid/repos","events_url":"https://api.github.com/users/thatskriptkid/events{/privacy}","received_events_url":"https://api.github.com/users/thatskriptkid/received_events","type":"User","site_admin":false},"repo":{"id":26670295,"name":"ds","full_name":"thatskriptkid/ds","owner":{"login":"thatskriptkid","id":8300184,"avatar_url":"https://avatars.githubusercontent.com/u/8300184?v=3","gravatar_id":"","url":"https://api.github.com/users/thatskriptkid","html_url":"https://github.com/thatskriptkid","followers_url":"https://api.github.com/users/thatskriptkid/followers","following_url":"https://api.github.com/users/thatskriptkid/following{/other_user}","gists_url":"https://api.github.com/users/thatskriptkid/gists{/gist_id}","starred_url":"https://api.github.com/users/thatskriptkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatskriptkid/subscriptions","organizations_url":"https://api.github.com/users/thatskriptkid/orgs","repos_url":"https://api.github.com/users/thatskriptkid/repos","events_url":"https://api.github.com/users/thatskriptkid/events{/privacy}","received_events_url":"https://api.github.com/users/thatskriptkid/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thatskriptkid/ds","description":"linux kernel distributed persistent object store","fork":true,"url":"https://api.github.com/repos/thatskriptkid/ds","forks_url":"https://api.github.com/repos/thatskriptkid/ds/forks","keys_url":"https://api.github.com/repos/thatskriptkid/ds/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thatskriptkid/ds/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thatskriptkid/ds/teams","hooks_url":"https://api.github.com/repos/thatskriptkid/ds/hooks","issue_events_url":"https://api.github.com/repos/thatskriptkid/ds/issues/events{/number}","events_url":"https://api.github.com/repos/thatskriptkid/ds/events","assignees_url":"https://api.github.com/repos/thatskriptkid/ds/assignees{/user}","branches_url":"https://api.github.com/repos/thatskriptkid/ds/branches{/branch}","tags_url":"https://api.github.com/repos/thatskriptkid/ds/tags","blobs_url":"https://api.github.com/repos/thatskriptkid/ds/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thatskriptkid/ds/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thatskriptkid/ds/git/refs{/sha}","trees_url":"https://api.github.com/repos/thatskriptkid/ds/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thatskriptkid/ds/statuses/{sha}","languages_url":"https://api.github.com/repos/thatskriptkid/ds/languages","stargazers_url":"https://api.github.com/repos/thatskriptkid/ds/stargazers","contributors_url":"https://api.github.com/repos/thatskriptkid/ds/contributors","subscribers_url":"https://api.github.com/repos/thatskriptkid/ds/subscribers","subscription_url":"https://api.github.com/repos/thatskriptkid/ds/subscription","commits_url":"https://api.github.com/repos/thatskriptkid/ds/commits{/sha}","git_commits_url":"https://api.github.com/repos/thatskriptkid/ds/git/commits{/sha}","comments_url":"https://api.github.com/repos/thatskriptkid/ds/comments{/number}","issue_comment_url":"https://api.github.com/repos/thatskriptkid/ds/issues/comments/{number}","contents_url":"https://api.github.com/repos/thatskriptkid/ds/contents/{+path}","compare_url":"https://api.github.com/repos/thatskriptkid/ds/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thatskriptkid/ds/merges","archive_url":"https://api.github.com/repos/thatskriptkid/ds/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thatskriptkid/ds/downloads","issues_url":"https://api.github.com/repos/thatskriptkid/ds/issues{/number}","pulls_url":"https://api.github.com/repos/thatskriptkid/ds/pulls{/number}","milestones_url":"https://api.github.com/repos/thatskriptkid/ds/milestones{/number}","notifications_url":"https://api.github.com/repos/thatskriptkid/ds/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thatskriptkid/ds/labels{/name}","releases_url":"https://api.github.com/repos/thatskriptkid/ds/releases{/id}","created_at":"2014-11-15T05:23:00Z","updated_at":"2014-11-19T16:17:39Z","pushed_at":"2014-11-19T16:17:39Z","git_url":"git://github.com/thatskriptkid/ds.git","ssh_url":"git@github.com:thatskriptkid/ds.git","clone_url":"https://github.com/thatskriptkid/ds.git","svn_url":"https://github.com/thatskriptkid/ds","homepage":null,"size":1049,"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":"irqlevel:master","ref":"master","sha":"fd0cfbebcf4b3dd716200659c6e83fa1d3045b9f","user":{"login":"irqlevel","id":6997173,"avatar_url":"https://avatars.githubusercontent.com/u/6997173?v=3","gravatar_id":"","url":"https://api.github.com/users/irqlevel","html_url":"https://github.com/irqlevel","followers_url":"https://api.github.com/users/irqlevel/followers","following_url":"https://api.github.com/users/irqlevel/following{/other_user}","gists_url":"https://api.github.com/users/irqlevel/gists{/gist_id}","starred_url":"https://api.github.com/users/irqlevel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irqlevel/subscriptions","organizations_url":"https://api.github.com/users/irqlevel/orgs","repos_url":"https://api.github.com/users/irqlevel/repos","events_url":"https://api.github.com/users/irqlevel/events{/privacy}","received_events_url":"https://api.github.com/users/irqlevel/received_events","type":"User","site_admin":false},"repo":{"id":25922969,"name":"ds","full_name":"irqlevel/ds","owner":{"login":"irqlevel","id":6997173,"avatar_url":"https://avatars.githubusercontent.com/u/6997173?v=3","gravatar_id":"","url":"https://api.github.com/users/irqlevel","html_url":"https://github.com/irqlevel","followers_url":"https://api.github.com/users/irqlevel/followers","following_url":"https://api.github.com/users/irqlevel/following{/other_user}","gists_url":"https://api.github.com/users/irqlevel/gists{/gist_id}","starred_url":"https://api.github.com/users/irqlevel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irqlevel/subscriptions","organizations_url":"https://api.github.com/users/irqlevel/orgs","repos_url":"https://api.github.com/users/irqlevel/repos","events_url":"https://api.github.com/users/irqlevel/events{/privacy}","received_events_url":"https://api.github.com/users/irqlevel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/irqlevel/ds","description":"linux kernel distributed persistent object store","fork":false,"url":"https://api.github.com/repos/irqlevel/ds","forks_url":"https://api.github.com/repos/irqlevel/ds/forks","keys_url":"https://api.github.com/repos/irqlevel/ds/keys{/key_id}","collaborators_url":"https://api.github.com/repos/irqlevel/ds/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/irqlevel/ds/teams","hooks_url":"https://api.github.com/repos/irqlevel/ds/hooks","issue_events_url":"https://api.github.com/repos/irqlevel/ds/issues/events{/number}","events_url":"https://api.github.com/repos/irqlevel/ds/events","assignees_url":"https://api.github.com/repos/irqlevel/ds/assignees{/user}","branches_url":"https://api.github.com/repos/irqlevel/ds/branches{/branch}","tags_url":"https://api.github.com/repos/irqlevel/ds/tags","blobs_url":"https://api.github.com/repos/irqlevel/ds/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/irqlevel/ds/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/irqlevel/ds/git/refs{/sha}","trees_url":"https://api.github.com/repos/irqlevel/ds/git/trees{/sha}","statuses_url":"https://api.github.com/repos/irqlevel/ds/statuses/{sha}","languages_url":"https://api.github.com/repos/irqlevel/ds/languages","stargazers_url":"https://api.github.com/repos/irqlevel/ds/stargazers","contributors_url":"https://api.github.com/repos/irqlevel/ds/contributors","subscribers_url":"https://api.github.com/repos/irqlevel/ds/subscribers","subscription_url":"https://api.github.com/repos/irqlevel/ds/subscription","commits_url":"https://api.github.com/repos/irqlevel/ds/commits{/sha}","git_commits_url":"https://api.github.com/repos/irqlevel/ds/git/commits{/sha}","comments_url":"https://api.github.com/repos/irqlevel/ds/comments{/number}","issue_comment_url":"https://api.github.com/repos/irqlevel/ds/issues/comments/{number}","contents_url":"https://api.github.com/repos/irqlevel/ds/contents/{+path}","compare_url":"https://api.github.com/repos/irqlevel/ds/compare/{base}...{head}","merges_url":"https://api.github.com/repos/irqlevel/ds/merges","archive_url":"https://api.github.com/repos/irqlevel/ds/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/irqlevel/ds/downloads","issues_url":"https://api.github.com/repos/irqlevel/ds/issues{/number}","pulls_url":"https://api.github.com/repos/irqlevel/ds/pulls{/number}","milestones_url":"https://api.github.com/repos/irqlevel/ds/milestones{/number}","notifications_url":"https://api.github.com/repos/irqlevel/ds/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/irqlevel/ds/labels{/name}","releases_url":"https://api.github.com/repos/irqlevel/ds/releases{/id}","created_at":"2014-10-29T13:49:43Z","updated_at":"2014-11-12T12:55:08Z","pushed_at":"2014-11-14T10:08:00Z","git_url":"git://github.com/irqlevel/ds.git","ssh_url":"git@github.com:irqlevel/ds.git","clone_url":"https://github.com/irqlevel/ds.git","svn_url":"https://github.com/irqlevel/ds","homepage":null,"size":1644,"stargazers_count":2,"watchers_count":2,"language":"C","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":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/irqlevel/ds/pulls/3"},"html":{"href":"https://github.com/irqlevel/ds/pull/3"},"issue":{"href":"https://api.github.com/repos/irqlevel/ds/issues/3"},"comments":{"href":"https://api.github.com/repos/irqlevel/ds/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/irqlevel/ds/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/irqlevel/ds/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/irqlevel/ds/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/irqlevel/ds/statuses/fd1f37373e5e5716cc8678cd645a3a8e28c35b14"}}}}