{"action":"created","comment":{"url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/comments/26151080","id":26151080,"diff_hunk":"@@ -0,0 +1,179 @@\n+---\n+layout: page\n+title: Capturing Events with Flume\n+---\n+\n+Once you have an [Events dataset][events], you can create a web application that captures session events.\n+\n+This example shows how you can send log information via Flume to your Hadoop database using a JSP and custom servlet running on Tomcat.\n+\n+[events]:{{site.baseurl}}/tutorials/create-events-dataset.html\n+\n+## Configuring Flume\n+\n+These are the steps to configure Flume to channel log information directly to the `events` dataset. You first generate the configuration information using the Kite command-line interface, copy the results, paste them in the Flume configuration file, and then restart Flume.\n+\n+1. In a terminal window, type `kite-dataset flume-config --channel-type memory events`.\n+1. Copy the output from the terminal window.\n+1. Open Cloudera Manager.\n+1. Under __Status__, click the link to __Flume__.\n+1. Choose the __Configuration__ tab.\n+1. Click __Agent Base Group__.\n+1. Right-click the Configuration File text area and choose __Select All__.\n+1. Right-click the Configuration File text area and choose __Paste__.\n+1. Click __Save Changes__.\n+1. From the __Actions__ menu, choose __Restart__, and confirm the action.\n+\n+Flume is now configured to receive logging events and record them in the `events` dataset.\n+\n+## Creating Web Application Pages\n+\n+These JSP and servlet examples create message events that can be captured by Flume.\n+\n+## index.jsp\n+\n+The default landing page for the web application is `index.jsp`. It defines a form with fields for an arbitrary User ID and a message. The __Send__ button submits the input values to the Tomcat server.\n+\n+```JSP\n+<html>\n+  <head>\n+    <title>Kite Example</title>\n+  <head>\n+  <body>\n+    <h2>Kite Example</h2>\n+    <form name=\"input\" action=\"send\" method=\"get\">\n+        User ID: <input type=\"text\" name=\"user_id\" value=\"1\">\n+        Message: <input type=\"text\" name=\"message\" value=\"Hello!\">\n+        <input type=\"submit\" value=\"Send\">\n+    </form>\n+  </body>\n+</html>\n+```\n+\n+## LoggingServlet\n+\n+When you submit a message from the JSP, the LoggingServlet receives and processes the request. The following is mostly standard servlet code, with some notes about application-specific snippets.\n+\n+```Java\n+package org.kitesdk.examples.demo;\n+```\n+\n+The servlet parses information from the request to create a StandardEvent object. However, you won't find any source code for `org.kitesdk.data.event.StandardEvent`. During the Maven build, the avro-maven-plugin runs before the compile phase. Any `.avsc` file in the `/main/avro` folder is defined as a Java class. The autogenerated classes have  the methods required to build corresponding Avro `SpecificRecord` objects of that type. `SpecificRecord` objects permit efficient access to object fields.\n+\n+```Java\n+\n+import org.kitesdk.data.event.StandardEvent;\n+import java.io.IOException;\n+import java.io.PrintWriter;\n+import javax.servlet.ServletException;\n+import javax.servlet.http.HttpServlet;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+\n+```\n+\n+This example sends Log4j messages directly to the Hive data sink via Flume.\n+\n+```Java\n+import org.apache.log4j.Logger;\n+\n+public class LoggingServlet extends HttpServlet {\n+\n+  private final Logger logger = Logger.getLogger(LoggingServlet.class);\n+\n+  @Override\n+  protected void doGet(HttpServletRequest request, HttpServletResponse\n+      response) throws ServletException, IOException {\n+\n+    response.setContentType(\"text/html\");\n+```    \n+\n+Create a PrintWriter instance to write the response page.\n+\n+```Java\n+  PrintWriter pw = response.getWriter();\n+\n+    pw.println(\"<html>\");\n+    pw.println(\"<head><title>Kite Example</title></head>\");\n+    pw.println(\"<body>\");\n+```\n+\n+Get the user ID and message values from the servlet request.\n+\n+```Java\n+    String userId = request.getParameter(\"user_id\");\n+    String message = request.getParameter(\"message\");\n+```\n+\n+If there's no message, don't create a log entry.\n+\n+```Java\n+    if (message == null) {\n+      pw.println(\"<p>No message specified.</p>\");\n+\n+```\n+\n+Otherwise, print the message at the top of the page body.\n+\n+```Java\n+    } else {\n+      pw.println(\"<p>Message: \" + message + \"</p>\");\n+      \n+```\n+\n+Create a new StandardEvent builder.\n+\n+```Java\n+      StandardEvent event = StandardEvent.newBuilder()\n+```\n+The event initiator is a user on the server. The event is a web message. These can be set as string literals, because the event initiator and event name are always the same.","path":"tutorials/flume-capture-events.md","position":129,"original_position":129,"commit_id":"16e423ce36afab49db4af82e087bea1d4a564ab8","original_commit_id":"16e423ce36afab49db4af82e087bea1d4a564ab8","user":{"login":"DennisDawson","id":6788473,"avatar_url":"https://avatars.githubusercontent.com/u/6788473?v=3","gravatar_id":"","url":"https://api.github.com/users/DennisDawson","html_url":"https://github.com/DennisDawson","followers_url":"https://api.github.com/users/DennisDawson/followers","following_url":"https://api.github.com/users/DennisDawson/following{/other_user}","gists_url":"https://api.github.com/users/DennisDawson/gists{/gist_id}","starred_url":"https://api.github.com/users/DennisDawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DennisDawson/subscriptions","organizations_url":"https://api.github.com/users/DennisDawson/orgs","repos_url":"https://api.github.com/users/DennisDawson/repos","events_url":"https://api.github.com/users/DennisDawson/events{/privacy}","received_events_url":"https://api.github.com/users/DennisDawson/received_events","type":"User","site_admin":false},"body":"Changed to \"user on the client.\"","created_at":"2015-03-10T18:29:45Z","updated_at":"2015-03-10T18:29:45Z","html_url":"https://github.com/kite-sdk/kite-docs/pull/79#discussion_r26151080","pull_request_url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79","_links":{"self":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/comments/26151080"},"html":{"href":"https://github.com/kite-sdk/kite-docs/pull/79#discussion_r26151080"},"pull_request":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79"}}},"pull_request":{"url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79","id":30514967,"html_url":"https://github.com/kite-sdk/kite-docs/pull/79","diff_url":"https://github.com/kite-sdk/kite-docs/pull/79.diff","patch_url":"https://github.com/kite-sdk/kite-docs/pull/79.patch","issue_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues/79","number":79,"state":"open","locked":false,"title":"CDK-29, CDK-466, CDK-827: Include use of CLI flume-config.","user":{"login":"DennisDawson","id":6788473,"avatar_url":"https://avatars.githubusercontent.com/u/6788473?v=3","gravatar_id":"","url":"https://api.github.com/users/DennisDawson","html_url":"https://github.com/DennisDawson","followers_url":"https://api.github.com/users/DennisDawson/followers","following_url":"https://api.github.com/users/DennisDawson/following{/other_user}","gists_url":"https://api.github.com/users/DennisDawson/gists{/gist_id}","starred_url":"https://api.github.com/users/DennisDawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DennisDawson/subscriptions","organizations_url":"https://api.github.com/users/DennisDawson/orgs","repos_url":"https://api.github.com/users/DennisDawson/repos","events_url":"https://api.github.com/users/DennisDawson/events{/privacy}","received_events_url":"https://api.github.com/users/DennisDawson/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-04T23:15:10Z","updated_at":"2015-03-10T18:29:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38aae47e86b3927aaa002a4293ad9f27a23cda52","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79/commits","review_comments_url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79/comments","review_comment_url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues/79/comments","statuses_url":"https://api.github.com/repos/kite-sdk/kite-docs/statuses/16e423ce36afab49db4af82e087bea1d4a564ab8","head":{"label":"kite-sdk:addGenerateEventsTutorial","ref":"addGenerateEventsTutorial","sha":"16e423ce36afab49db4af82e087bea1d4a564ab8","user":{"login":"kite-sdk","id":5732728,"avatar_url":"https://avatars.githubusercontent.com/u/5732728?v=3","gravatar_id":"","url":"https://api.github.com/users/kite-sdk","html_url":"https://github.com/kite-sdk","followers_url":"https://api.github.com/users/kite-sdk/followers","following_url":"https://api.github.com/users/kite-sdk/following{/other_user}","gists_url":"https://api.github.com/users/kite-sdk/gists{/gist_id}","starred_url":"https://api.github.com/users/kite-sdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kite-sdk/subscriptions","organizations_url":"https://api.github.com/users/kite-sdk/orgs","repos_url":"https://api.github.com/users/kite-sdk/repos","events_url":"https://api.github.com/users/kite-sdk/events{/privacy}","received_events_url":"https://api.github.com/users/kite-sdk/received_events","type":"Organization","site_admin":false},"repo":{"id":21282660,"name":"kite-docs","full_name":"kite-sdk/kite-docs","owner":{"login":"kite-sdk","id":5732728,"avatar_url":"https://avatars.githubusercontent.com/u/5732728?v=3","gravatar_id":"","url":"https://api.github.com/users/kite-sdk","html_url":"https://github.com/kite-sdk","followers_url":"https://api.github.com/users/kite-sdk/followers","following_url":"https://api.github.com/users/kite-sdk/following{/other_user}","gists_url":"https://api.github.com/users/kite-sdk/gists{/gist_id}","starred_url":"https://api.github.com/users/kite-sdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kite-sdk/subscriptions","organizations_url":"https://api.github.com/users/kite-sdk/orgs","repos_url":"https://api.github.com/users/kite-sdk/repos","events_url":"https://api.github.com/users/kite-sdk/events{/privacy}","received_events_url":"https://api.github.com/users/kite-sdk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kite-sdk/kite-docs","description":"Kite documentation and tutorials","fork":false,"url":"https://api.github.com/repos/kite-sdk/kite-docs","forks_url":"https://api.github.com/repos/kite-sdk/kite-docs/forks","keys_url":"https://api.github.com/repos/kite-sdk/kite-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kite-sdk/kite-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kite-sdk/kite-docs/teams","hooks_url":"https://api.github.com/repos/kite-sdk/kite-docs/hooks","issue_events_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues/events{/number}","events_url":"https://api.github.com/repos/kite-sdk/kite-docs/events","assignees_url":"https://api.github.com/repos/kite-sdk/kite-docs/assignees{/user}","branches_url":"https://api.github.com/repos/kite-sdk/kite-docs/branches{/branch}","tags_url":"https://api.github.com/repos/kite-sdk/kite-docs/tags","blobs_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kite-sdk/kite-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/kite-sdk/kite-docs/languages","stargazers_url":"https://api.github.com/repos/kite-sdk/kite-docs/stargazers","contributors_url":"https://api.github.com/repos/kite-sdk/kite-docs/contributors","subscribers_url":"https://api.github.com/repos/kite-sdk/kite-docs/subscribers","subscription_url":"https://api.github.com/repos/kite-sdk/kite-docs/subscription","commits_url":"https://api.github.com/repos/kite-sdk/kite-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/kite-sdk/kite-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/kite-sdk/kite-docs/contents/{+path}","compare_url":"https://api.github.com/repos/kite-sdk/kite-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kite-sdk/kite-docs/merges","archive_url":"https://api.github.com/repos/kite-sdk/kite-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kite-sdk/kite-docs/downloads","issues_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues{/number}","pulls_url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/kite-sdk/kite-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/kite-sdk/kite-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kite-sdk/kite-docs/labels{/name}","releases_url":"https://api.github.com/repos/kite-sdk/kite-docs/releases{/id}","created_at":"2014-06-27T16:54:57Z","updated_at":"2015-02-25T01:01:47Z","pushed_at":"2015-03-06T00:06:15Z","git_url":"git://github.com/kite-sdk/kite-docs.git","ssh_url":"git@github.com:kite-sdk/kite-docs.git","clone_url":"https://github.com/kite-sdk/kite-docs.git","svn_url":"https://github.com/kite-sdk/kite-docs","homepage":null,"size":2308,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":2,"forks":8,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"kite-sdk:master","ref":"master","sha":"137b9bc7e123f50c668e9a4dd76e92b8ecebbb6f","user":{"login":"kite-sdk","id":5732728,"avatar_url":"https://avatars.githubusercontent.com/u/5732728?v=3","gravatar_id":"","url":"https://api.github.com/users/kite-sdk","html_url":"https://github.com/kite-sdk","followers_url":"https://api.github.com/users/kite-sdk/followers","following_url":"https://api.github.com/users/kite-sdk/following{/other_user}","gists_url":"https://api.github.com/users/kite-sdk/gists{/gist_id}","starred_url":"https://api.github.com/users/kite-sdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kite-sdk/subscriptions","organizations_url":"https://api.github.com/users/kite-sdk/orgs","repos_url":"https://api.github.com/users/kite-sdk/repos","events_url":"https://api.github.com/users/kite-sdk/events{/privacy}","received_events_url":"https://api.github.com/users/kite-sdk/received_events","type":"Organization","site_admin":false},"repo":{"id":21282660,"name":"kite-docs","full_name":"kite-sdk/kite-docs","owner":{"login":"kite-sdk","id":5732728,"avatar_url":"https://avatars.githubusercontent.com/u/5732728?v=3","gravatar_id":"","url":"https://api.github.com/users/kite-sdk","html_url":"https://github.com/kite-sdk","followers_url":"https://api.github.com/users/kite-sdk/followers","following_url":"https://api.github.com/users/kite-sdk/following{/other_user}","gists_url":"https://api.github.com/users/kite-sdk/gists{/gist_id}","starred_url":"https://api.github.com/users/kite-sdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kite-sdk/subscriptions","organizations_url":"https://api.github.com/users/kite-sdk/orgs","repos_url":"https://api.github.com/users/kite-sdk/repos","events_url":"https://api.github.com/users/kite-sdk/events{/privacy}","received_events_url":"https://api.github.com/users/kite-sdk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kite-sdk/kite-docs","description":"Kite documentation and tutorials","fork":false,"url":"https://api.github.com/repos/kite-sdk/kite-docs","forks_url":"https://api.github.com/repos/kite-sdk/kite-docs/forks","keys_url":"https://api.github.com/repos/kite-sdk/kite-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kite-sdk/kite-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kite-sdk/kite-docs/teams","hooks_url":"https://api.github.com/repos/kite-sdk/kite-docs/hooks","issue_events_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues/events{/number}","events_url":"https://api.github.com/repos/kite-sdk/kite-docs/events","assignees_url":"https://api.github.com/repos/kite-sdk/kite-docs/assignees{/user}","branches_url":"https://api.github.com/repos/kite-sdk/kite-docs/branches{/branch}","tags_url":"https://api.github.com/repos/kite-sdk/kite-docs/tags","blobs_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kite-sdk/kite-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/kite-sdk/kite-docs/languages","stargazers_url":"https://api.github.com/repos/kite-sdk/kite-docs/stargazers","contributors_url":"https://api.github.com/repos/kite-sdk/kite-docs/contributors","subscribers_url":"https://api.github.com/repos/kite-sdk/kite-docs/subscribers","subscription_url":"https://api.github.com/repos/kite-sdk/kite-docs/subscription","commits_url":"https://api.github.com/repos/kite-sdk/kite-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/kite-sdk/kite-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/kite-sdk/kite-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/kite-sdk/kite-docs/contents/{+path}","compare_url":"https://api.github.com/repos/kite-sdk/kite-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kite-sdk/kite-docs/merges","archive_url":"https://api.github.com/repos/kite-sdk/kite-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kite-sdk/kite-docs/downloads","issues_url":"https://api.github.com/repos/kite-sdk/kite-docs/issues{/number}","pulls_url":"https://api.github.com/repos/kite-sdk/kite-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/kite-sdk/kite-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/kite-sdk/kite-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kite-sdk/kite-docs/labels{/name}","releases_url":"https://api.github.com/repos/kite-sdk/kite-docs/releases{/id}","created_at":"2014-06-27T16:54:57Z","updated_at":"2015-02-25T01:01:47Z","pushed_at":"2015-03-06T00:06:15Z","git_url":"git://github.com/kite-sdk/kite-docs.git","ssh_url":"git@github.com:kite-sdk/kite-docs.git","clone_url":"https://github.com/kite-sdk/kite-docs.git","svn_url":"https://github.com/kite-sdk/kite-docs","homepage":null,"size":2308,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":2,"forks":8,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79"},"html":{"href":"https://github.com/kite-sdk/kite-docs/pull/79"},"issue":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/issues/79"},"comments":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/issues/79/comments"},"review_comments":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79/comments"},"review_comment":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/pulls/79/commits"},"statuses":{"href":"https://api.github.com/repos/kite-sdk/kite-docs/statuses/16e423ce36afab49db4af82e087bea1d4a564ab8"}}}}