{"action":"created","comment":{"url":"https://api.github.com/repos/kaaproject/kaa/pulls/comments/34150381","id":34150381,"diff_hunk":"@@ -431,27 +478,87 @@ kaa_error_t kaa_bootstrap_manager_on_access_point_failed(kaa_bootstrap_manager_t\n \n         operations_access_points->current_access_points =\n                 kaa_list_next(operations_access_points->current_access_points);\n-        access_point = (kaa_access_point_t *)kaa_list_get_data(\n-                            operations_access_points->current_access_points);\n+\n+        access_point = (kaa_access_point_t *)kaa_list_get_data(operations_access_points->current_access_points);\n+\n+        if (!access_point)\n+            execute_failover = true;\n+    }\n+    if (execute_failover) {\n+        kaa_bootstrap_manager_schedule_failover(self, access_point, protocol_id, type);\n     }\n \n-    if (access_point) {\n+    if (access_point && !execute_failover) {\n         kaa_channel_manager_on_new_access_point(self->channel_manager\n                                               , protocol_id\n                                               , type\n                                               , access_point);\n-        return KAA_ERR_NONE;\n+        return KAA_ERR_EVENT_NOT_ATTACHED;\n     } else if (type == KAA_SERVER_OPERATIONS) {\n         KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, \"Could not find next Operations access point \"\n-                \"(protocol: id=0x%08X, version=%u). Going to sync...\"\n+                \"(protocol: id=0x%08X, version=%u)\"\n                 , protocol_id->id, protocol_id->version);\n-        do_sync(self);\n     } else if (type == KAA_SERVER_BOOTSTRAP) {\n         KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, \"Could not find next Bootstrap access point \"\n-                \"(protocol: id=0x%08X, version=%u). Try to sync later...\"\n+                \"(protocol: id=0x%08X, version=%u)\"\n                 , protocol_id->id, protocol_id->version);\n     }\n \n     return KAA_ERR_NOT_FOUND;\n }\n \n+bool kaa_bootstrap_manager_process_failover(kaa_bootstrap_manager_t *self)\n+{\n+    KAA_RETURN_IF_NIL2(self, self->kaa_context->failover_strategy, false);\n+\n+    kaa_failover_decision_t decision = kaa_failover_strategy_on_failover(self->kaa_context->failover_strategy);\n+    if(decision.action == KAA_NOOP)\n+       return false;\n+    kaa_error_t error_code = KAA_ERR_NONE;\n+    kaa_time_t current_time = KAA_TIME();\n+    if (!self->failover_meta_info.next_execution_time) {\n+        if (self->next_operations_request_time && current_time >= self->next_operations_request_time) {\n+            KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, \"Response bootstrap time expired.\");\n+            kaa_bootstrap_access_points_t * acc_point = (kaa_bootstrap_access_points_t *) kaa_list_get_data(kaa_list_begin(self->bootstrap_access_points));\n+            error_code = kaa_bootstrap_manager_on_access_point_failed(self, &acc_point->protocol_id, KAA_SERVER_BOOTSTRAP);\n+            self->next_operations_request_time = 0;\n+            if (error_code == KAA_ERR_EVENT_NOT_ATTACHED) {\n+                do_sync(self);\n+                return false;\n+            }\n+            return true;\n+        } else {\n+            return false;\n+        }\n+    }\n+\n+    if (current_time >= self->failover_meta_info.next_execution_time) {\n+        KAA_LOG_INFO(self->logger, KAA_ERR_NONE, \"Executing failover strategy...\");\n+        switch (self->failover_meta_info.server) {\n+        case KAA_SERVER_BOOTSTRAP:\n+            KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, \"Processing failover of bootstraps\");\n+            kaa_channel_manager_on_new_access_point(self->channel_manager, &self->failover_meta_info.protocol_id, self->failover_meta_info.server, self->failover_meta_info.acess_point);\n+            break;\n+        case KAA_SERVER_OPERATIONS:\n+            KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, \"Processing failover of operations\");\n+            error_code = do_sync(self);\n+            if (error_code) {\n+                KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, \"Failed to connect to bootstrap\");","path":"client/client-multi/client-c/src/kaa/kaa_bootstrap_manager.c","position":281,"original_position":281,"commit_id":"7bcd0f24dd18c761d431d3d0dc51360931a8ce1a","original_commit_id":"7bcd0f24dd18c761d431d3d0dc51360931a8ce1a","user":{"login":"dyosick","id":712449,"avatar_url":"https://avatars.githubusercontent.com/u/712449?v=3","gravatar_id":"","url":"https://api.github.com/users/dyosick","html_url":"https://github.com/dyosick","followers_url":"https://api.github.com/users/dyosick/followers","following_url":"https://api.github.com/users/dyosick/following{/other_user}","gists_url":"https://api.github.com/users/dyosick/gists{/gist_id}","starred_url":"https://api.github.com/users/dyosick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dyosick/subscriptions","organizations_url":"https://api.github.com/users/dyosick/orgs","repos_url":"https://api.github.com/users/dyosick/repos","events_url":"https://api.github.com/users/dyosick/events{/privacy}","received_events_url":"https://api.github.com/users/dyosick/received_events","type":"User","site_admin":false},"body":"TRACE?","created_at":"2015-07-08T14:03:37Z","updated_at":"2015-07-08T14:03:37Z","html_url":"https://github.com/kaaproject/kaa/pull/265#discussion_r34150381","pull_request_url":"https://api.github.com/repos/kaaproject/kaa/pulls/265","_links":{"self":{"href":"https://api.github.com/repos/kaaproject/kaa/pulls/comments/34150381"},"html":{"href":"https://github.com/kaaproject/kaa/pull/265#discussion_r34150381"},"pull_request":{"href":"https://api.github.com/repos/kaaproject/kaa/pulls/265"}}},"pull_request":{"url":"https://api.github.com/repos/kaaproject/kaa/pulls/265","id":39268222,"html_url":"https://github.com/kaaproject/kaa/pull/265","diff_url":"https://github.com/kaaproject/kaa/pull/265.diff","patch_url":"https://github.com/kaaproject/kaa/pull/265.patch","issue_url":"https://api.github.com/repos/kaaproject/kaa/issues/265","number":265,"state":"open","locked":false,"title":"feature/KAA-559","user":{"login":"GamovCoder","id":9300235,"avatar_url":"https://avatars.githubusercontent.com/u/9300235?v=3","gravatar_id":"","url":"https://api.github.com/users/GamovCoder","html_url":"https://github.com/GamovCoder","followers_url":"https://api.github.com/users/GamovCoder/followers","following_url":"https://api.github.com/users/GamovCoder/following{/other_user}","gists_url":"https://api.github.com/users/GamovCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/GamovCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GamovCoder/subscriptions","organizations_url":"https://api.github.com/users/GamovCoder/orgs","repos_url":"https://api.github.com/users/GamovCoder/repos","events_url":"https://api.github.com/users/GamovCoder/events{/privacy}","received_events_url":"https://api.github.com/users/GamovCoder/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-06T13:37:46Z","updated_at":"2015-07-08T14:03:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b9eeab9b55d8f4e7b705c37ce15f87210475c58","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kaaproject/kaa/pulls/265/commits","review_comments_url":"https://api.github.com/repos/kaaproject/kaa/pulls/265/comments","review_comment_url":"https://api.github.com/repos/kaaproject/kaa/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kaaproject/kaa/issues/265/comments","statuses_url":"https://api.github.com/repos/kaaproject/kaa/statuses/7bcd0f24dd18c761d431d3d0dc51360931a8ce1a","head":{"label":"kaaproject:feature/KAA-559","ref":"feature/KAA-559","sha":"7bcd0f24dd18c761d431d3d0dc51360931a8ce1a","user":{"login":"kaaproject","id":6984613,"avatar_url":"https://avatars.githubusercontent.com/u/6984613?v=3","gravatar_id":"","url":"https://api.github.com/users/kaaproject","html_url":"https://github.com/kaaproject","followers_url":"https://api.github.com/users/kaaproject/followers","following_url":"https://api.github.com/users/kaaproject/following{/other_user}","gists_url":"https://api.github.com/users/kaaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/kaaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaaproject/subscriptions","organizations_url":"https://api.github.com/users/kaaproject/orgs","repos_url":"https://api.github.com/users/kaaproject/repos","events_url":"https://api.github.com/users/kaaproject/events{/privacy}","received_events_url":"https://api.github.com/users/kaaproject/received_events","type":"Organization","site_admin":false},"repo":{"id":17839346,"name":"kaa","full_name":"kaaproject/kaa","owner":{"login":"kaaproject","id":6984613,"avatar_url":"https://avatars.githubusercontent.com/u/6984613?v=3","gravatar_id":"","url":"https://api.github.com/users/kaaproject","html_url":"https://github.com/kaaproject","followers_url":"https://api.github.com/users/kaaproject/followers","following_url":"https://api.github.com/users/kaaproject/following{/other_user}","gists_url":"https://api.github.com/users/kaaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/kaaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaaproject/subscriptions","organizations_url":"https://api.github.com/users/kaaproject/orgs","repos_url":"https://api.github.com/users/kaaproject/repos","events_url":"https://api.github.com/users/kaaproject/events{/privacy}","received_events_url":"https://api.github.com/users/kaaproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kaaproject/kaa","description":"Kaa open-source middleware platform for building, managing, and integrating connected products with the Internet of Everything.","fork":false,"url":"https://api.github.com/repos/kaaproject/kaa","forks_url":"https://api.github.com/repos/kaaproject/kaa/forks","keys_url":"https://api.github.com/repos/kaaproject/kaa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaaproject/kaa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaaproject/kaa/teams","hooks_url":"https://api.github.com/repos/kaaproject/kaa/hooks","issue_events_url":"https://api.github.com/repos/kaaproject/kaa/issues/events{/number}","events_url":"https://api.github.com/repos/kaaproject/kaa/events","assignees_url":"https://api.github.com/repos/kaaproject/kaa/assignees{/user}","branches_url":"https://api.github.com/repos/kaaproject/kaa/branches{/branch}","tags_url":"https://api.github.com/repos/kaaproject/kaa/tags","blobs_url":"https://api.github.com/repos/kaaproject/kaa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaaproject/kaa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaaproject/kaa/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaaproject/kaa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaaproject/kaa/statuses/{sha}","languages_url":"https://api.github.com/repos/kaaproject/kaa/languages","stargazers_url":"https://api.github.com/repos/kaaproject/kaa/stargazers","contributors_url":"https://api.github.com/repos/kaaproject/kaa/contributors","subscribers_url":"https://api.github.com/repos/kaaproject/kaa/subscribers","subscription_url":"https://api.github.com/repos/kaaproject/kaa/subscription","commits_url":"https://api.github.com/repos/kaaproject/kaa/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaaproject/kaa/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaaproject/kaa/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaaproject/kaa/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaaproject/kaa/contents/{+path}","compare_url":"https://api.github.com/repos/kaaproject/kaa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaaproject/kaa/merges","archive_url":"https://api.github.com/repos/kaaproject/kaa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaaproject/kaa/downloads","issues_url":"https://api.github.com/repos/kaaproject/kaa/issues{/number}","pulls_url":"https://api.github.com/repos/kaaproject/kaa/pulls{/number}","milestones_url":"https://api.github.com/repos/kaaproject/kaa/milestones{/number}","notifications_url":"https://api.github.com/repos/kaaproject/kaa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaaproject/kaa/labels{/name}","releases_url":"https://api.github.com/repos/kaaproject/kaa/releases{/id}","created_at":"2014-03-17T18:48:31Z","updated_at":"2015-07-07T13:15:35Z","pushed_at":"2015-07-08T13:17:34Z","git_url":"git://github.com/kaaproject/kaa.git","ssh_url":"git@github.com:kaaproject/kaa.git","clone_url":"https://github.com/kaaproject/kaa.git","svn_url":"https://github.com/kaaproject/kaa","homepage":"http://www.kaaproject.org","size":145356,"stargazers_count":111,"watchers_count":111,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":21,"mirror_url":null,"open_issues_count":5,"forks":21,"open_issues":5,"watchers":111,"default_branch":"master"}},"base":{"label":"kaaproject:master","ref":"master","sha":"f72c9f2291e30b506ed6e03fca05ad57f61d9506","user":{"login":"kaaproject","id":6984613,"avatar_url":"https://avatars.githubusercontent.com/u/6984613?v=3","gravatar_id":"","url":"https://api.github.com/users/kaaproject","html_url":"https://github.com/kaaproject","followers_url":"https://api.github.com/users/kaaproject/followers","following_url":"https://api.github.com/users/kaaproject/following{/other_user}","gists_url":"https://api.github.com/users/kaaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/kaaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaaproject/subscriptions","organizations_url":"https://api.github.com/users/kaaproject/orgs","repos_url":"https://api.github.com/users/kaaproject/repos","events_url":"https://api.github.com/users/kaaproject/events{/privacy}","received_events_url":"https://api.github.com/users/kaaproject/received_events","type":"Organization","site_admin":false},"repo":{"id":17839346,"name":"kaa","full_name":"kaaproject/kaa","owner":{"login":"kaaproject","id":6984613,"avatar_url":"https://avatars.githubusercontent.com/u/6984613?v=3","gravatar_id":"","url":"https://api.github.com/users/kaaproject","html_url":"https://github.com/kaaproject","followers_url":"https://api.github.com/users/kaaproject/followers","following_url":"https://api.github.com/users/kaaproject/following{/other_user}","gists_url":"https://api.github.com/users/kaaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/kaaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaaproject/subscriptions","organizations_url":"https://api.github.com/users/kaaproject/orgs","repos_url":"https://api.github.com/users/kaaproject/repos","events_url":"https://api.github.com/users/kaaproject/events{/privacy}","received_events_url":"https://api.github.com/users/kaaproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kaaproject/kaa","description":"Kaa open-source middleware platform for building, managing, and integrating connected products with the Internet of Everything.","fork":false,"url":"https://api.github.com/repos/kaaproject/kaa","forks_url":"https://api.github.com/repos/kaaproject/kaa/forks","keys_url":"https://api.github.com/repos/kaaproject/kaa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaaproject/kaa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaaproject/kaa/teams","hooks_url":"https://api.github.com/repos/kaaproject/kaa/hooks","issue_events_url":"https://api.github.com/repos/kaaproject/kaa/issues/events{/number}","events_url":"https://api.github.com/repos/kaaproject/kaa/events","assignees_url":"https://api.github.com/repos/kaaproject/kaa/assignees{/user}","branches_url":"https://api.github.com/repos/kaaproject/kaa/branches{/branch}","tags_url":"https://api.github.com/repos/kaaproject/kaa/tags","blobs_url":"https://api.github.com/repos/kaaproject/kaa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaaproject/kaa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaaproject/kaa/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaaproject/kaa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaaproject/kaa/statuses/{sha}","languages_url":"https://api.github.com/repos/kaaproject/kaa/languages","stargazers_url":"https://api.github.com/repos/kaaproject/kaa/stargazers","contributors_url":"https://api.github.com/repos/kaaproject/kaa/contributors","subscribers_url":"https://api.github.com/repos/kaaproject/kaa/subscribers","subscription_url":"https://api.github.com/repos/kaaproject/kaa/subscription","commits_url":"https://api.github.com/repos/kaaproject/kaa/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaaproject/kaa/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaaproject/kaa/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaaproject/kaa/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaaproject/kaa/contents/{+path}","compare_url":"https://api.github.com/repos/kaaproject/kaa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaaproject/kaa/merges","archive_url":"https://api.github.com/repos/kaaproject/kaa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaaproject/kaa/downloads","issues_url":"https://api.github.com/repos/kaaproject/kaa/issues{/number}","pulls_url":"https://api.github.com/repos/kaaproject/kaa/pulls{/number}","milestones_url":"https://api.github.com/repos/kaaproject/kaa/milestones{/number}","notifications_url":"https://api.github.com/repos/kaaproject/kaa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaaproject/kaa/labels{/name}","releases_url":"https://api.github.com/repos/kaaproject/kaa/releases{/id}","created_at":"2014-03-17T18:48:31Z","updated_at":"2015-07-07T13:15:35Z","pushed_at":"2015-07-08T13:17:34Z","git_url":"git://github.com/kaaproject/kaa.git","ssh_url":"git@github.com:kaaproject/kaa.git","clone_url":"https://github.com/kaaproject/kaa.git","svn_url":"https://github.com/kaaproject/kaa","homepage":"http://www.kaaproject.org","size":145356,"stargazers_count":111,"watchers_count":111,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":21,"mirror_url":null,"open_issues_count":5,"forks":21,"open_issues":5,"watchers":111,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kaaproject/kaa/pulls/265"},"html":{"href":"https://github.com/kaaproject/kaa/pull/265"},"issue":{"href":"https://api.github.com/repos/kaaproject/kaa/issues/265"},"comments":{"href":"https://api.github.com/repos/kaaproject/kaa/issues/265/comments"},"review_comments":{"href":"https://api.github.com/repos/kaaproject/kaa/pulls/265/comments"},"review_comment":{"href":"https://api.github.com/repos/kaaproject/kaa/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kaaproject/kaa/pulls/265/commits"},"statuses":{"href":"https://api.github.com/repos/kaaproject/kaa/statuses/7bcd0f24dd18c761d431d3d0dc51360931a8ce1a"}}}}