{"action":"created","issue":{"url":"https://api.github.com/repos/hawkular/hawkular-metrics/issues/481","repository_url":"https://api.github.com/repos/hawkular/hawkular-metrics","labels_url":"https://api.github.com/repos/hawkular/hawkular-metrics/issues/481/labels{/name}","comments_url":"https://api.github.com/repos/hawkular/hawkular-metrics/issues/481/comments","events_url":"https://api.github.com/repos/hawkular/hawkular-metrics/issues/481/events","html_url":"https://github.com/hawkular/hawkular-metrics/pull/481","id":148320027,"number":481,"title":"HWKMETRICS-330 Update filter to be async","user":{"login":"tsegismont","id":1500598,"avatar_url":"https://avatars.githubusercontent.com/u/1500598?v=3","gravatar_id":"","url":"https://api.github.com/users/tsegismont","html_url":"https://github.com/tsegismont","followers_url":"https://api.github.com/users/tsegismont/followers","following_url":"https://api.github.com/users/tsegismont/following{/other_user}","gists_url":"https://api.github.com/users/tsegismont/gists{/gist_id}","starred_url":"https://api.github.com/users/tsegismont/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsegismont/subscriptions","organizations_url":"https://api.github.com/users/tsegismont/orgs","repos_url":"https://api.github.com/users/tsegismont/repos","events_url":"https://api.github.com/users/tsegismont/events{/privacy}","received_events_url":"https://api.github.com/users/tsegismont/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-14T10:39:14Z","updated_at":"2016-04-14T10:56:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hawkular/hawkular-metrics/pulls/481","html_url":"https://github.com/hawkular/hawkular-metrics/pull/481","diff_url":"https://github.com/hawkular/hawkular-metrics/pull/481.diff","patch_url":"https://github.com/hawkular/hawkular-metrics/pull/481.patch"},"body":"HWKMETRICS-330 Update filter to be async\n\nA bit of context first. Hawkular Metrics is a reactive application and\ncalls to a blocking API should be avoided as much as possible.\n\nThe Openshift integration library had a servlet filter mechanism to\nauthenticate users. The filter code used the JDK's HTTP client to call\nKubernetes' master server. While this was alright has a first\nimplementation (in order to provide the feature as quickly as possible),\nit is a serious limitation to reach our performance goals.\n\nThere were two problems to tackle:\n1. choose an async HTTP client API\n2. make the filter code asynchronous\n\nFor the HTTP client, I considered a few options: Netty, vert.x,\nUndertow. I picked undertow because it does not add a new dependency,\nwe can reuse the io threads (instead of creating yet another thread\npool). The downside is that the Undertow client API is low-level (no pool\nimplementation) and not well documented.\n\nFor the filter code, my first try was to use servlet async API from the\nfilter. But RestEasy throws an exception because it wants start the\nasync exchange itself. I wrote to the resteasy-user list but got no\nreply. And even if we had a fix, we would have to wait for a new\nRestEasy and Wildfly release. So I wrote an Undertow extension which is\nexecuted in io threads  *before* the servlet handler is involved.\n\nThe implementation consists in pooling Undertow HTTP client connections and\nfilering the Metrics client requests (only dispatch to the servlet\nhandler if the user is authenticated).\n\nWhile working on the implementation I had to find a way to share the\nMetricsRegistry between the webapp code and the authenticator code. So\nthere's a MetricsRegistry provider class in core-util now.\n\nAlso, I enhanced the Gatling scenario file to support multiple\nauthentication mechanisms (none, Hawkular integration, Openshift\nhtpasswd file, Openshift token). I took the opportunity to document the\nscenario options in the project README.\n\nNote that performance enhancements will be more visible in environments\nwhere Kubernetes reponse time is minimal."},"comment":{"url":"https://api.github.com/repos/hawkular/hawkular-metrics/issues/comments/209879006","html_url":"https://github.com/hawkular/hawkular-metrics/pull/481#issuecomment-209879006","issue_url":"https://api.github.com/repos/hawkular/hawkular-metrics/issues/481","id":209879006,"user":{"login":"tsegismont","id":1500598,"avatar_url":"https://avatars.githubusercontent.com/u/1500598?v=3","gravatar_id":"","url":"https://api.github.com/users/tsegismont","html_url":"https://github.com/tsegismont","followers_url":"https://api.github.com/users/tsegismont/followers","following_url":"https://api.github.com/users/tsegismont/following{/other_user}","gists_url":"https://api.github.com/users/tsegismont/gists{/gist_id}","starred_url":"https://api.github.com/users/tsegismont/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsegismont/subscriptions","organizations_url":"https://api.github.com/users/tsegismont/orgs","repos_url":"https://api.github.com/users/tsegismont/repos","events_url":"https://api.github.com/users/tsegismont/events{/privacy}","received_events_url":"https://api.github.com/users/tsegismont/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T10:56:36Z","updated_at":"2016-04-14T10:56:36Z","body":"@mwringe @burmanm this is Openshift related, would you mind to review? Thank you guys."}}