{"id":1458,"date":"2016-12-18T21:23:00","date_gmt":"2016-12-18T21:23:00","guid":{"rendered":"http:\/\/62.131.51.129\/?p=1458"},"modified":"2016-12-18T21:23:00","modified_gmt":"2016-12-18T21:23:00","slug":"flume-sending-data-via-stream","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=1458","title":{"rendered":"Flume: sending data via stream"},"content":{"rendered":"<p>It is possible to capture streaming data in HDFS files. A tool to do this is Flume. The idea is that we have 3 elements: sources that provide a stream, a channel that transports the stream and a sink where the stream ends in a file.<br \/>\nThis can already be seen if we look at the config file:<\/p>\n<pre>agent1.sources = netcat-source\nagent1.sinks = hdfs-sink\nagent1.channels = memory-channel\n\n# Describe\/configure the source\nagent1.sources.netcat-source.type = netcat\nagent1.sources.netcat-source.bind = 192.168.2.60\nagent1.sources.netcat-source.port = 12345\nagent1.sources.netcat-source.channels = memory-channel\n# Describe the sink\nagent1.sinks.hdfs-sink.type = hdfs\nagent1.sinks.hdfs-sink.hdfs.path = \/loudacre\/webtom\/\nagent1.sinks.hdfs-sink.channel = memory-channel\nagent1.sinks.hdfs-sink.hdfs.fileType = DataStream\n# Use a channel which buffers events in memory\nagent1.channels.memory-channel.type = memory\nagent1.channels.memory-channel.capacity = 10000\nagent1.channels.memory-channel.transactionCapacity = 10000\n<\/pre>\n<p>It all starts with a source that is a netcat stream that is sent to port 12345. The source is labelled &#8220;sources&#8221;. Then we have a sink that is labelled as &#8220;hdfs-sink&#8221;. Finally, we have the channel that is labelled &#8220;memory-channel&#8221;. This &#8220;memory-channel&#8221; is also mentioned in the sources as the channel that is used to send the stream into and it is mentioned in the sink as the faucet that delivers the data.<br \/>\nOn another machine, we start the netcat stream with:<\/p>\n<pre>\ntype \"C:\\Program Files (x86)\\netcat\\readme.txt\" |   \"C:\\Program Files (x86)\\netcat\\nc.exe\"  192.168.2.60 12345\n<\/pre>\n<p>This sends the content of a file as stream to a netcat proces that sends the stream to host 192.168.2.60 with port 12345. Exactly these sources were mentioned in the config file as the source of the stream.<br \/>\nThe flume process is started with<\/p>\n<pre>\nflume-ng agent --conf \/etc\/flume-ng\/conf --conf-file home\/training\/training_materials\/dev1\/exercises\/flume\/solution\/bonus_netcat_tom.conf --name agent1 -Dflume.root.logger=INFO,console\n<\/pre>\n<p>We may see the data being received in files of HDFS:<br \/>\n<a href=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2016\/12\/Untitled-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1462\" src=\"http:\/\/62.131.51.129\/wp-content\/uploads\/2016\/12\/Untitled-10.png\" alt=\"\" width=\"829\" height=\"450\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is possible to capture streaming data in HDFS files. A tool to do this is Flume. The idea is that we have 3 elements: sources that provide a stream, a channel that transports the stream and a sink where the stream ends in a file. This can already be seen if we look at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1459,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1458","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/1458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1458"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/1458\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1458"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}