{"action":"created","comment":{"url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/comments/37053999","id":37053999,"diff_hunk":"@@ -51,18 +63,96 @@ class TcpServer(listenAddress: String, port: Int,\n       context.system.shutdown()\n \n     case c @ Connected(remote, local) =>\n-      log.debug(s\"Incoming connection, creating a connection handler! $remote $local\")\n       activityLog.recordConnection()\n-      val handler = context.actorOf(Props(classOf[ConnectionHandler],\n+      val handler = context.actorOf(Props(classOf[ConnectionHandler], sender(),\n         (af: ActorRefFactory, tcpConnection: ActorRef, msgFactory: CqlMessageFactory) => af.actorOf(Props(classOf[QueryHandler], tcpConnection, primedResults, msgFactory, activityLog)),\n         (af: ActorRefFactory, tcpConnection: ActorRef, msgFactory: CqlMessageFactory, prepareHandler: ActorRef) => af.actorOf(Props(classOf[BatchHandler], tcpConnection, msgFactory, activityLog, prepareHandler)),\n         (af: ActorRefFactory, tcpConnection: ActorRef, msgFactory: CqlMessageFactory) => af.actorOf(Props(classOf[RegisterHandler], tcpConnection, msgFactory)),\n         (af: ActorRefFactory, tcpConnection: ActorRef, msgFactory: CqlMessageFactory) => af.actorOf(Props(classOf[OptionsHandler], tcpConnection, msgFactory)),\n         preparedHandler,\n-        executeHandler,\n-        (af: ActorRefFactory, tcpConnection: ActorRef) => af.actorOf(Props(classOf[TcpConnectionWrapper], tcpConnection)))\n-      )\n+        executeHandler),\n+      name = s\"${remote.getAddress.getHostAddress}:${remote.getPort}\")\n       log.debug(s\"Sending register with connection handler $handler\")\n       sender ! Register(handler)\n+\n+    case GetClientConnections(hostOption, portOption) => {\n+      val matchingClients = findChildren(hostOption, portOption).map(actorToConnection)\n+      val response = ClientConnections(matchingClients)\n+      sender ! response\n+    }\n+\n+    case c: SendCommandToClient => {","path":"server/src/main/scala/org/scassandra/server/actors/TcpServer.scala","position":64,"original_position":64,"commit_id":"bdb62d98d42ff8d5323f916b811600ab728a4609","original_commit_id":"bdb62d98d42ff8d5323f916b811600ab728a4609","user":{"login":"tolbertam","id":6889771,"avatar_url":"https://avatars.githubusercontent.com/u/6889771?v=3","gravatar_id":"","url":"https://api.github.com/users/tolbertam","html_url":"https://github.com/tolbertam","followers_url":"https://api.github.com/users/tolbertam/followers","following_url":"https://api.github.com/users/tolbertam/following{/other_user}","gists_url":"https://api.github.com/users/tolbertam/gists{/gist_id}","starred_url":"https://api.github.com/users/tolbertam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tolbertam/subscriptions","organizations_url":"https://api.github.com/users/tolbertam/orgs","repos_url":"https://api.github.com/users/tolbertam/repos","events_url":"https://api.github.com/users/tolbertam/events{/privacy}","received_events_url":"https://api.github.com/users/tolbertam/received_events","type":"User","site_admin":false},"body":"SendCommandToClient messages have a `command` field bound to them that dictates what Tcp command to send to ConnectionHandler, it then sends it to each actor matching the host/port criteria and then when all responses are received sends a response back to the sender.","created_at":"2015-08-14T07:11:21Z","updated_at":"2015-08-14T07:11:21Z","html_url":"https://github.com/tolbertam/scassandra-server/pull/1#discussion_r37053999","pull_request_url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/comments/37053999"},"html":{"href":"https://github.com/tolbertam/scassandra-server/pull/1#discussion_r37053999"},"pull_request":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1","id":42429217,"html_url":"https://github.com/tolbertam/scassandra-server/pull/1","diff_url":"https://github.com/tolbertam/scassandra-server/pull/1.diff","patch_url":"https://github.com/tolbertam/scassandra-server/pull/1.patch","issue_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues/1","number":1,"state":"open","locked":false,"title":"[wip] [#100] Initial commit support to kill individual connections.","user":{"login":"tolbertam","id":6889771,"avatar_url":"https://avatars.githubusercontent.com/u/6889771?v=3","gravatar_id":"","url":"https://api.github.com/users/tolbertam","html_url":"https://github.com/tolbertam","followers_url":"https://api.github.com/users/tolbertam/followers","following_url":"https://api.github.com/users/tolbertam/following{/other_user}","gists_url":"https://api.github.com/users/tolbertam/gists{/gist_id}","starred_url":"https://api.github.com/users/tolbertam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tolbertam/subscriptions","organizations_url":"https://api.github.com/users/tolbertam/orgs","repos_url":"https://api.github.com/users/tolbertam/repos","events_url":"https://api.github.com/users/tolbertam/events{/privacy}","received_events_url":"https://api.github.com/users/tolbertam/received_events","type":"User","site_admin":false},"body":"Creating this PR early to illicit since this adds a new API.  Fortunately since spray is awesome it won't be difficult to make changes to the API if we decide to change it.   This is an initial stab at an API for killing connections.  At the moment I have the server side implementation working with a REST API endpoint named `/clients`.   I'll next be working on the capability to toggle refusal of accepting connections and after that I will add functionality to the java-client once we feel comfortable with the API.  I based this on feature/92, but will rebase and properly open against the main scassandra repo once 92 is merged into master.\r\n\r\nThe API is currently pretty simple.  To get a list of all connections, execute `GET /clients`, i.e.:\r\n\r\n    $ curl http://127.0.0.1:8043/clients\r\n    {\r\n      \"connections\": [{\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57518\r\n      }, {\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57519\r\n      }, {\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57520\r\n      }]\r\n\r\nYou can also optionally filter on host address and port, i.e. `GET /clients/127.0.0.1` or `GET /clients/127.0.0.1/57520`:\r\n\r\n    curl http://127.0.0.1:8043/clients/127.0.0.1/57520\r\n    {\r\n      \"connections\": [{\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57520\r\n      }]\r\n    }\r\n\r\nConnections may be closed by executing a `DELETE` on the same endpoint, this also supports targeting all client connections, by host, or by port, i.e.:\r\n\r\n    $ curl -X DELETE http://127.0.0.1:8043/clients/127.0.0.1\r\n    {\r\n      \"closed_connections\": [{\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57518\r\n      }, {\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57519\r\n      }, {\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57520\r\n      }]\r\n\r\nYou can also pass in a 'type' parameter on DELETE to specify the type of Close command that will be sent.  This supports 'close' (default behavior) which fully closes the socket, 'halfclose' which sends a FIN and allows the client to close the socket on its end, and 'reset' which aborts the connection by sending a TCP RST.\r\n\r\n    $ curl -X DELETE http://127.0.0.1:8043/clients/127.0.0.1/57540?type=reset\r\n    {\r\n      \"reset_connections\": [{\r\n        \"host\": \"127.0.0.1\",\r\n        \"port\": 57540\r\n      }]\r\n    }\r\n\r\nThe API needs to be updated to return a '404' when no connections are found for both GET and DELETE.","created_at":"2015-08-14T07:05:24Z","updated_at":"2015-08-14T07:11:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8102c2042880e348355ff9dd8de7fbc3bb3b0097","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1/commits","review_comments_url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1/comments","review_comment_url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues/1/comments","statuses_url":"https://api.github.com/repos/tolbertam/scassandra-server/statuses/bdb62d98d42ff8d5323f916b811600ab728a4609","head":{"label":"tolbertam:feature/100","ref":"feature/100","sha":"bdb62d98d42ff8d5323f916b811600ab728a4609","user":{"login":"tolbertam","id":6889771,"avatar_url":"https://avatars.githubusercontent.com/u/6889771?v=3","gravatar_id":"","url":"https://api.github.com/users/tolbertam","html_url":"https://github.com/tolbertam","followers_url":"https://api.github.com/users/tolbertam/followers","following_url":"https://api.github.com/users/tolbertam/following{/other_user}","gists_url":"https://api.github.com/users/tolbertam/gists{/gist_id}","starred_url":"https://api.github.com/users/tolbertam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tolbertam/subscriptions","organizations_url":"https://api.github.com/users/tolbertam/orgs","repos_url":"https://api.github.com/users/tolbertam/repos","events_url":"https://api.github.com/users/tolbertam/events{/privacy}","received_events_url":"https://api.github.com/users/tolbertam/received_events","type":"User","site_admin":false},"repo":{"id":32164498,"name":"scassandra-server","full_name":"tolbertam/scassandra-server","owner":{"login":"tolbertam","id":6889771,"avatar_url":"https://avatars.githubusercontent.com/u/6889771?v=3","gravatar_id":"","url":"https://api.github.com/users/tolbertam","html_url":"https://github.com/tolbertam","followers_url":"https://api.github.com/users/tolbertam/followers","following_url":"https://api.github.com/users/tolbertam/following{/other_user}","gists_url":"https://api.github.com/users/tolbertam/gists{/gist_id}","starred_url":"https://api.github.com/users/tolbertam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tolbertam/subscriptions","organizations_url":"https://api.github.com/users/tolbertam/orgs","repos_url":"https://api.github.com/users/tolbertam/repos","events_url":"https://api.github.com/users/tolbertam/events{/privacy}","received_events_url":"https://api.github.com/users/tolbertam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tolbertam/scassandra-server","description":"scassandra server","fork":true,"url":"https://api.github.com/repos/tolbertam/scassandra-server","forks_url":"https://api.github.com/repos/tolbertam/scassandra-server/forks","keys_url":"https://api.github.com/repos/tolbertam/scassandra-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tolbertam/scassandra-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tolbertam/scassandra-server/teams","hooks_url":"https://api.github.com/repos/tolbertam/scassandra-server/hooks","issue_events_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues/events{/number}","events_url":"https://api.github.com/repos/tolbertam/scassandra-server/events","assignees_url":"https://api.github.com/repos/tolbertam/scassandra-server/assignees{/user}","branches_url":"https://api.github.com/repos/tolbertam/scassandra-server/branches{/branch}","tags_url":"https://api.github.com/repos/tolbertam/scassandra-server/tags","blobs_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tolbertam/scassandra-server/statuses/{sha}","languages_url":"https://api.github.com/repos/tolbertam/scassandra-server/languages","stargazers_url":"https://api.github.com/repos/tolbertam/scassandra-server/stargazers","contributors_url":"https://api.github.com/repos/tolbertam/scassandra-server/contributors","subscribers_url":"https://api.github.com/repos/tolbertam/scassandra-server/subscribers","subscription_url":"https://api.github.com/repos/tolbertam/scassandra-server/subscription","commits_url":"https://api.github.com/repos/tolbertam/scassandra-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/tolbertam/scassandra-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/tolbertam/scassandra-server/contents/{+path}","compare_url":"https://api.github.com/repos/tolbertam/scassandra-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tolbertam/scassandra-server/merges","archive_url":"https://api.github.com/repos/tolbertam/scassandra-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tolbertam/scassandra-server/downloads","issues_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues{/number}","pulls_url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls{/number}","milestones_url":"https://api.github.com/repos/tolbertam/scassandra-server/milestones{/number}","notifications_url":"https://api.github.com/repos/tolbertam/scassandra-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tolbertam/scassandra-server/labels{/name}","releases_url":"https://api.github.com/repos/tolbertam/scassandra-server/releases{/id}","created_at":"2015-03-13T15:41:24Z","updated_at":"2015-07-17T11:31:13Z","pushed_at":"2015-08-14T07:05:25Z","git_url":"git://github.com/tolbertam/scassandra-server.git","ssh_url":"git@github.com:tolbertam/scassandra-server.git","clone_url":"https://github.com/tolbertam/scassandra-server.git","svn_url":"https://github.com/tolbertam/scassandra-server","homepage":null,"size":4642,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"tolbertam:feature/92","ref":"feature/92","sha":"051f6ac1c85706edd6c8955eff11da15810ae455","user":{"login":"tolbertam","id":6889771,"avatar_url":"https://avatars.githubusercontent.com/u/6889771?v=3","gravatar_id":"","url":"https://api.github.com/users/tolbertam","html_url":"https://github.com/tolbertam","followers_url":"https://api.github.com/users/tolbertam/followers","following_url":"https://api.github.com/users/tolbertam/following{/other_user}","gists_url":"https://api.github.com/users/tolbertam/gists{/gist_id}","starred_url":"https://api.github.com/users/tolbertam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tolbertam/subscriptions","organizations_url":"https://api.github.com/users/tolbertam/orgs","repos_url":"https://api.github.com/users/tolbertam/repos","events_url":"https://api.github.com/users/tolbertam/events{/privacy}","received_events_url":"https://api.github.com/users/tolbertam/received_events","type":"User","site_admin":false},"repo":{"id":32164498,"name":"scassandra-server","full_name":"tolbertam/scassandra-server","owner":{"login":"tolbertam","id":6889771,"avatar_url":"https://avatars.githubusercontent.com/u/6889771?v=3","gravatar_id":"","url":"https://api.github.com/users/tolbertam","html_url":"https://github.com/tolbertam","followers_url":"https://api.github.com/users/tolbertam/followers","following_url":"https://api.github.com/users/tolbertam/following{/other_user}","gists_url":"https://api.github.com/users/tolbertam/gists{/gist_id}","starred_url":"https://api.github.com/users/tolbertam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tolbertam/subscriptions","organizations_url":"https://api.github.com/users/tolbertam/orgs","repos_url":"https://api.github.com/users/tolbertam/repos","events_url":"https://api.github.com/users/tolbertam/events{/privacy}","received_events_url":"https://api.github.com/users/tolbertam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tolbertam/scassandra-server","description":"scassandra server","fork":true,"url":"https://api.github.com/repos/tolbertam/scassandra-server","forks_url":"https://api.github.com/repos/tolbertam/scassandra-server/forks","keys_url":"https://api.github.com/repos/tolbertam/scassandra-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tolbertam/scassandra-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tolbertam/scassandra-server/teams","hooks_url":"https://api.github.com/repos/tolbertam/scassandra-server/hooks","issue_events_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues/events{/number}","events_url":"https://api.github.com/repos/tolbertam/scassandra-server/events","assignees_url":"https://api.github.com/repos/tolbertam/scassandra-server/assignees{/user}","branches_url":"https://api.github.com/repos/tolbertam/scassandra-server/branches{/branch}","tags_url":"https://api.github.com/repos/tolbertam/scassandra-server/tags","blobs_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tolbertam/scassandra-server/statuses/{sha}","languages_url":"https://api.github.com/repos/tolbertam/scassandra-server/languages","stargazers_url":"https://api.github.com/repos/tolbertam/scassandra-server/stargazers","contributors_url":"https://api.github.com/repos/tolbertam/scassandra-server/contributors","subscribers_url":"https://api.github.com/repos/tolbertam/scassandra-server/subscribers","subscription_url":"https://api.github.com/repos/tolbertam/scassandra-server/subscription","commits_url":"https://api.github.com/repos/tolbertam/scassandra-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/tolbertam/scassandra-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/tolbertam/scassandra-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/tolbertam/scassandra-server/contents/{+path}","compare_url":"https://api.github.com/repos/tolbertam/scassandra-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tolbertam/scassandra-server/merges","archive_url":"https://api.github.com/repos/tolbertam/scassandra-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tolbertam/scassandra-server/downloads","issues_url":"https://api.github.com/repos/tolbertam/scassandra-server/issues{/number}","pulls_url":"https://api.github.com/repos/tolbertam/scassandra-server/pulls{/number}","milestones_url":"https://api.github.com/repos/tolbertam/scassandra-server/milestones{/number}","notifications_url":"https://api.github.com/repos/tolbertam/scassandra-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tolbertam/scassandra-server/labels{/name}","releases_url":"https://api.github.com/repos/tolbertam/scassandra-server/releases{/id}","created_at":"2015-03-13T15:41:24Z","updated_at":"2015-07-17T11:31:13Z","pushed_at":"2015-08-14T07:05:25Z","git_url":"git://github.com/tolbertam/scassandra-server.git","ssh_url":"git@github.com:tolbertam/scassandra-server.git","clone_url":"https://github.com/tolbertam/scassandra-server.git","svn_url":"https://github.com/tolbertam/scassandra-server","homepage":null,"size":4642,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1"},"html":{"href":"https://github.com/tolbertam/scassandra-server/pull/1"},"issue":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/issues/1"},"comments":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/tolbertam/scassandra-server/statuses/bdb62d98d42ff8d5323f916b811600ab728a4609"}}}}