{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/che/pulls/comments/80686662","pull_request_review_id":1726337,"id":80686662,"diff_hunk":"@@ -0,0 +1,114 @@\n+/*******************************************************************************\n+ * Copyright (c) 2012-2016 Codenvy, S.A.\n+ * All rights reserved. This program and the accompanying materials\n+ * are made available under the terms of the Eclipse Public License v1.0\n+ * which accompanies this distribution, and is available at\n+ * http://www.eclipse.org/legal/epl-v10.html\n+ *\n+ * Contributors:\n+ *   Codenvy, S.A. - initial API and implementation\n+ *******************************************************************************/\n+package org.eclipse.che.api.agent.server;\n+\n+import org.eclipse.che.api.core.BadRequestException;\n+import org.eclipse.che.api.core.ConflictException;\n+import org.eclipse.che.api.core.ForbiddenException;\n+import org.eclipse.che.api.core.NotFoundException;\n+import org.eclipse.che.api.core.ServerException;\n+import org.eclipse.che.api.core.UnauthorizedException;\n+import org.eclipse.che.api.core.model.machine.Machine;\n+import org.eclipse.che.api.core.model.machine.Server;\n+import org.eclipse.che.api.core.rest.HttpJsonRequest;\n+import org.eclipse.che.api.core.rest.HttpJsonRequestFactory;\n+import org.eclipse.che.api.core.rest.HttpJsonResponse;\n+import org.eclipse.che.api.machine.shared.Constants;\n+import org.eclipse.che.api.workspace.shared.dto.WsAgentHealthStateDto;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import javax.inject.Inject;\n+import javax.inject.Named;\n+import javax.inject.Singleton;\n+import javax.ws.rs.HttpMethod;\n+import java.io.IOException;\n+import java.util.Map;\n+\n+import static javax.ws.rs.core.Response.Status.NOT_FOUND;\n+import static javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE;\n+import static org.eclipse.che.api.machine.shared.Constants.WSAGENT_REFERENCE;\n+import static org.eclipse.che.dto.server.DtoFactory.newDto;\n+\n+/**\n+ * Mechanism for checking workspace agent's state.\n+ *\n+ * @author Vitalii Parfonov\n+ * @author Valeriy Svydenko\n+ */\n+@Singleton\n+public class WsAgentHealthCheckerImpl implements WsAgentHealthChecker {\n+    private static final String WS_AGENT_SERVER_NOT_FOUND_ERROR = \"Workspace agent server not found in dev machine.\";\n+\n+    protected static final Logger LOG = LoggerFactory.getLogger(WsAgentHealthCheckerImpl.class);\n+\n+    private final HttpJsonRequestFactory httpJsonRequestFactory;\n+    private final int                    wsAgentPingConnectionTimeoutMs;\n+\n+    @Inject\n+    public WsAgentHealthCheckerImpl(HttpJsonRequestFactory httpJsonRequestFactory,\n+                                    @Named(\"machine.ws_agent.ping_conn_timeout_ms\") int wsAgentPingConnectionTimeoutMs) {\n+        this.httpJsonRequestFactory = httpJsonRequestFactory;\n+        this.wsAgentPingConnectionTimeoutMs = wsAgentPingConnectionTimeoutMs;\n+    }\n+\n+    @Override\n+    public WsAgentHealthStateDto check(Machine machine) throws NotFoundException,\n+                                                               ServerException,\n+                                                               ForbiddenException,\n+                                                               BadRequestException,\n+                                                               UnauthorizedException,\n+                                                               ConflictException {\n+        final Map<String, ? extends Server> servers = machine.getRuntime().getServers();\n+        Server wsAgent = null;\n+        for (Server server : servers.values()) {\n+            if (WSAGENT_REFERENCE.equals(server.getRef())) {\n+                wsAgent = server;","path":"wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/agent/server/WsAgentHealthCheckerImpl.java","position":74,"original_position":74,"commit_id":"097e51e69a256fede87d8a1e007f61e6edc364bc","original_commit_id":"097e51e69a256fede87d8a1e007f61e6edc364bc","user":{"login":"vparfonov","id":1636592,"avatar_url":"https://avatars.githubusercontent.com/u/1636592?v=3","gravatar_id":"","url":"https://api.github.com/users/vparfonov","html_url":"https://github.com/vparfonov","followers_url":"https://api.github.com/users/vparfonov/followers","following_url":"https://api.github.com/users/vparfonov/following{/other_user}","gists_url":"https://api.github.com/users/vparfonov/gists{/gist_id}","starred_url":"https://api.github.com/users/vparfonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vparfonov/subscriptions","organizations_url":"https://api.github.com/users/vparfonov/orgs","repos_url":"https://api.github.com/users/vparfonov/repos","events_url":"https://api.github.com/users/vparfonov/events{/privacy}","received_events_url":"https://api.github.com/users/vparfonov/received_events","type":"User","site_admin":false},"body":"+1","created_at":"2016-09-27T13:07:15Z","updated_at":"2016-09-27T13:07:15Z","html_url":"https://github.com/eclipse/che/pull/2530#discussion_r80686662","pull_request_url":"https://api.github.com/repos/eclipse/che/pulls/2530","_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments/80686662"},"html":{"href":"https://github.com/eclipse/che/pull/2530#discussion_r80686662"},"pull_request":{"href":"https://api.github.com/repos/eclipse/che/pulls/2530"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/che/pulls/2530","id":86181469,"html_url":"https://github.com/eclipse/che/pull/2530","diff_url":"https://github.com/eclipse/che/pull/2530.diff","patch_url":"https://github.com/eclipse/che/pull/2530.patch","issue_url":"https://api.github.com/repos/eclipse/che/issues/2530","number":2530,"state":"open","locked":false,"title":"CHE-2369: add a mechanism which checks state of the ws agent","user":{"login":"svor","id":1271546,"avatar_url":"https://avatars.githubusercontent.com/u/1271546?v=3","gravatar_id":"","url":"https://api.github.com/users/svor","html_url":"https://github.com/svor","followers_url":"https://api.github.com/users/svor/followers","following_url":"https://api.github.com/users/svor/following{/other_user}","gists_url":"https://api.github.com/users/svor/gists{/gist_id}","starred_url":"https://api.github.com/users/svor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svor/subscriptions","organizations_url":"https://api.github.com/users/svor/orgs","repos_url":"https://api.github.com/users/svor/repos","events_url":"https://api.github.com/users/svor/events{/privacy}","received_events_url":"https://api.github.com/users/svor/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\nAdds a service which periodically pings ws agent and notify a user when something is happened.\r\n\r\n### What issues does this PR fix or reference?\r\nhttps://github.com/eclipse/che/issues/2369\r\n\r\n### Previous behavior\r\nWhen ws agent stops responding a user don't get any response about this and don't know what is happened.\r\n\r\n### PR type\r\n- [x] Minor change = no change to existing features or docs\r\n- [ ] Major change = changes existing features or docs\r\n\r\n### Minor change checklist\r\n- [ ] New API required?\r\n- [ ] API updated\r\n- [x] Tests provided / updated\r\n- [x] Tests passed\r\n\r\n@vparfonov please take a look","created_at":"2016-09-21T15:05:51Z","updated_at":"2016-09-27T13:07:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"30e81ef356c64cc5b5405a6f63ed22208fe37293","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/che/pulls/2530/commits","review_comments_url":"https://api.github.com/repos/eclipse/che/pulls/2530/comments","review_comment_url":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/che/issues/2530/comments","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/097e51e69a256fede87d8a1e007f61e6edc364bc","head":{"label":"eclipse:CHE-1988","ref":"CHE-1988","sha":"097e51e69a256fede87d8a1e007f61e6edc364bc","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":32935745,"name":"che","full_name":"eclipse/che","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/che","description":"Eclipse Che: Next-generation Eclipse IDE.  Open source workspace server and cloud IDE.","fork":false,"url":"https://api.github.com/repos/eclipse/che","forks_url":"https://api.github.com/repos/eclipse/che/forks","keys_url":"https://api.github.com/repos/eclipse/che/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/che/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/che/teams","hooks_url":"https://api.github.com/repos/eclipse/che/hooks","issue_events_url":"https://api.github.com/repos/eclipse/che/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/che/events","assignees_url":"https://api.github.com/repos/eclipse/che/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/che/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/che/tags","blobs_url":"https://api.github.com/repos/eclipse/che/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/che/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/che/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/che/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/che/languages","stargazers_url":"https://api.github.com/repos/eclipse/che/stargazers","contributors_url":"https://api.github.com/repos/eclipse/che/contributors","subscribers_url":"https://api.github.com/repos/eclipse/che/subscribers","subscription_url":"https://api.github.com/repos/eclipse/che/subscription","commits_url":"https://api.github.com/repos/eclipse/che/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/che/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/che/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/che/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/che/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/che/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/che/merges","archive_url":"https://api.github.com/repos/eclipse/che/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/che/downloads","issues_url":"https://api.github.com/repos/eclipse/che/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/che/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/che/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/che/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/che/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/che/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/che/deployments","created_at":"2015-03-26T15:31:01Z","updated_at":"2016-09-27T03:54:27Z","pushed_at":"2016-09-27T12:59:58Z","git_url":"git://github.com/eclipse/che.git","ssh_url":"git@github.com:eclipse/che.git","clone_url":"https://github.com/eclipse/che.git","svn_url":"https://github.com/eclipse/che","homepage":"http://eclipse.org/che","size":52499,"stargazers_count":3215,"watchers_count":3215,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":524,"mirror_url":null,"open_issues_count":301,"forks":524,"open_issues":301,"watchers":3215,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"6e3aa1c49ef25c171cd01bcb8bcda1ad2a4a8b90","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":32935745,"name":"che","full_name":"eclipse/che","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/che","description":"Eclipse Che: Next-generation Eclipse IDE.  Open source workspace server and cloud IDE.","fork":false,"url":"https://api.github.com/repos/eclipse/che","forks_url":"https://api.github.com/repos/eclipse/che/forks","keys_url":"https://api.github.com/repos/eclipse/che/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/che/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/che/teams","hooks_url":"https://api.github.com/repos/eclipse/che/hooks","issue_events_url":"https://api.github.com/repos/eclipse/che/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/che/events","assignees_url":"https://api.github.com/repos/eclipse/che/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/che/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/che/tags","blobs_url":"https://api.github.com/repos/eclipse/che/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/che/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/che/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/che/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/che/languages","stargazers_url":"https://api.github.com/repos/eclipse/che/stargazers","contributors_url":"https://api.github.com/repos/eclipse/che/contributors","subscribers_url":"https://api.github.com/repos/eclipse/che/subscribers","subscription_url":"https://api.github.com/repos/eclipse/che/subscription","commits_url":"https://api.github.com/repos/eclipse/che/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/che/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/che/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/che/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/che/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/che/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/che/merges","archive_url":"https://api.github.com/repos/eclipse/che/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/che/downloads","issues_url":"https://api.github.com/repos/eclipse/che/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/che/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/che/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/che/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/che/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/che/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/che/deployments","created_at":"2015-03-26T15:31:01Z","updated_at":"2016-09-27T03:54:27Z","pushed_at":"2016-09-27T12:59:58Z","git_url":"git://github.com/eclipse/che.git","ssh_url":"git@github.com:eclipse/che.git","clone_url":"https://github.com/eclipse/che.git","svn_url":"https://github.com/eclipse/che","homepage":"http://eclipse.org/che","size":52499,"stargazers_count":3215,"watchers_count":3215,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":524,"mirror_url":null,"open_issues_count":301,"forks":524,"open_issues":301,"watchers":3215,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/2530"},"html":{"href":"https://github.com/eclipse/che/pull/2530"},"issue":{"href":"https://api.github.com/repos/eclipse/che/issues/2530"},"comments":{"href":"https://api.github.com/repos/eclipse/che/issues/2530/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/che/pulls/2530/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/che/pulls/2530/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/che/statuses/097e51e69a256fede87d8a1e007f61e6edc364bc"}}}}
{"actor":{"display_login":"vparfonov"}}