ÎÊÌâµ¼¶Á£º
ÈçºÎ¿ª·¢sink²å¼þ£¿
²å¼þ¿ª·¢Íê±ÏÈçºÎ¼ÓÈëµ½flumeÖУ¿
flume²å¼þ¿ª·¢Ò»°ã·ÖÈçϲ½Öè
1 ±àд²å¼þÀࣨSink/Source/Decorator£©ÏàÓ¦µÄ¼Ì³ÐflumeµÄ£¨EventSink.Base/ EventSource.Base/EventSinkDecorator<S>£©
Source±ØÐëʵÏÖËĸö·½·¨£º void open() throws IOException Event next() throws IOException void close() throws IOException ReportEvent getReport()
SinkºÍDecorator±ØÐëʵÏÖËĸö·½·¨£º voidopen() throws IOException void append(Event e) throws IOException void close() throws IOException ReportEvent getReport()
Ö÷Òª½éÉÜsink²å¼þµÄ¿ª·¢ append(Event e)·½·¨ÖеÄevent²ÎÊýÊÇflume¿ò¼Ü×Ô´øµÄÀ࣬ÈÕÖ¾ÎļþµÄÒ»ÐмǼ»áÔÚflume¿ò¼ÜÖзâ×°³ÉÒ»¸öevent£¬ÔÚappend·½·¨ÖжÔeventµÄ´¦Àí¾Í¿ÉÒÔµ±×öÊÇ´¦ÀíÈÕÖ¾ÎļþµÄÿһÐУ¬Event°üº¬µÄÁù¸öÊôÐÔÊÇ£º - Unixtimestamp ʱ¼ä´Á
- Nanosecondtimestamp
- Priority
- Sourcehost Ö÷»úµØÖ·£¨Õâ¸öµØÖ·ÊDzúÉúÈÕÖ¾µÄÎļþµØÖ·£©
- Body ÈÕÖ¾ÎļþµÄÒ»ÐÐ
- Metadatatable with an arbitrary number of attribute value pairs.
ÔÚsinkµÄ²å¼þÀàÖÐÒ»¶¨ÒªÊǼÓÈëÏÂÃæµÄ´úÂ룺
- public static List<Pair<String, SinkBuilder>> getSinkBuilders() {
- List<Pair<String, SinkBuilder>> builders = new ArrayList<Pair<String, SinkBuilder>>();
- builders.add(new Pair<String, SinkBuilder>("<font color="#0000ff">HBaseEventSinkV1</font>",builder()));
- return builders;
- }
¸´ÖÆ´úÂë
ÒòΪflumeµÄSinkFactoryImplÖÐÐèҪͨ¹ýÕâ·Ý·½·¨½«Ð´µÄ²å¼þÀà×¢²áµ½flume£¬Èç¹û²»Ð´»á±¨´í£¬"HBaseEventSinkV1" ¾ÍÊÇ×¢²áÃû ÒÔ¿ª·¢collectorµÄ²å¼þÀàΪÀý£¬Íê³É²å¼þÀàµÄ¿ª·¢Ö®ºó£¬½«²å¼þÀà´ò°ü·Ö±ð·Åµ½masterºÍcollectorÖ÷»úÉÏ£¨×¢£º¶à¸ömasterºÍ¶à¸öcollectorµÄÇé¿öÏÂÒª¶¼·ÅÖã¬×îºÃĿ¼¶¼Ò»Ñù£¬±ãÓÚÅäÖÃflume classpath£©¡£
½«¿ª·¢µÄjar°ü¼ÓÈëµ½flumeÖÐ ·½·¨Ò» : ½øÈëvi /etc/profile ÔÚÎļþÖмÓÈë exportFLUME_CLASSPATH = XXX/XX/XXX.jar ÔÚCALSSPATH µÄβ²¿¼ÓÈë:$FLUME_CLASSPATH , È»ºó±£´æÍ˳öºó£¬ÔÚÃüÁîÐÐÖ´ÐÐsh/etc/profile £¬Í¨¹ýÔÚÃüÁîÐÐÊäÈë flumeclasspath ²é¿´²å¼þjar°üÊÇ·ñÔÚÆäÖУ¬ÔÚÆäÖбíʾÅäÖÃÍê³É£¨×¢£º¿ª·¢²å¼þʱÒýÈëµÄjar°ü±ØÐ붼Äܹ»ÔÚflume classpathÏÂÕÒµ½£¬Èç¹ûÕÒ²»µ½µÄ»°Ïñ¼ÓÈë²å¼þ°üµÄ·½Ê½¼ÓÈ룩
·½·¨¶þ: ¼òµ¥µÄ·½·¨Êǽ«¿ª·¢µÄjar°üºÍÐèÒªÒýÈëµÄjar°üÖ±½Ó¸´ÖƵ½/usr/lib/flume/lib ÐÞ¸Äflume-site.xmlÎļþÈçÏÂËùʾ£º - <property>
- <name>flume.plugin.classes</name>
- <value>²å¼þÀàµÃȫ·¾¶Ãû£¨È磺hello.HelloWorldSink£© </value>
- <description>Comma separated list of plugin classes</description>
- </property>
¸´ÖÆ´úÂë
½«flume-site.xmlÎļþ·Åµ½master ºÍcollectorµÄ/etc/flume/conf Ï Æô¶¯¼¯ÈºÅäÖü´¿É
|