storm學(xué)習(xí)第三天-storm與其他組件交互

storm如何把數(shù)據(jù)插入到elasticsearch

1 storm提供的例子

https://github.com/apache/storm/tree/master/external/storm-elasticsearch

代碼:

<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-elasticsearch</artifactId>
<version>1.1.0</version>
</dependency>

EsConfig esConfig = new EsConfig(clusterName, new String[]{"localhost:9300"});
EsTupleMapper tupleMapper = new DefaultEsTupleMapper();
EsIndexBolt indexBolt = new EsIndexBolt(esConfig, tupleMapper);

問題:依賴低版本的Elasticsearch 這個問題沒有解決
查看最新代碼已經(jīng)修復(fù)了 沒提供jar包
需要重新編譯storm1.10代碼 直接放棄了 采用下面方法

方法2 elasticsearch-hadoop

image.png

疑問?
僅僅支持hadoop嗎 storm支持嗎我要的是storm?

ES-Hadoop無縫打通了ES和Hadoop兩個非常優(yōu)秀的框架,我們既可以把HDFS的數(shù)據(jù)導(dǎo)入到ES里面做分析,也可以將es數(shù)據(jù)導(dǎo)出到HDFS上做備份,歸檔,其中值得一提的是ES-Hadoop全面的支持了Spark框架,
其中包括Spark(五角星那個上面中間位置)

  • 支持Hive(像蜜蜂的那個下面最左位置)
  • 支持Cascading(有五個豎線那個 上面最右位置)
    Cascading is the proven application development platform for
    building data applications on Hadoop.
  • Storm(閃電的那個)
  • 當(dāng)然還有標(biāo)準(zhǔn)的MapReduce,
    無論用那一個框架集成ES,都是非常簡潔的。
image.png

疑問:
為了使用這個jar 是否引用一系列相關(guān)的jar呀

經(jīng)過驗證不需要引入hadoop 但是json和http引入
折騰不起

     <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
       
   <dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.10</version>
  </dependency>
       
       
        <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch-hadoop -->
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch-hadoop</artifactId>
        <version>5.5.1</version>
    </dependency>
    
    <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.8.8</version>
    </dependency>
    
   <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>1.8.8</version>
    </dependency>
    
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-jaxrs</artifactId>
    <version>1.8.8</version>
</dependency>   
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-xc</artifactId>
    <version>1.8.8</version>
</dependency>

    
     <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.9.0</version>
    </dependency>
    
                  
      
   <!--
         <dependency>
          <groupId>org.apache.storm</groupId>
          <artifactId>storm-elasticsearch</artifactId>
          <version>1.1.0</version>
       </dependency>
       
       
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch-hadoop</artifactId>
            <version>5.5.1</version>
    </dependency>
    
     <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch-storm</artifactId>
            <version>5.5.1</version>
      </dependency>
      -->   
       <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>5.5.1</version>
        </dependency>

代碼實現(xiàn)

配置文件:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-hadoop</artifactId>
<version>5.5.1</version>
</dependency>

方法3 elasticsearch 官方提供的例子

<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-storm</artifactId>
<version>5.5.1</version>
</dependency>

閱讀代碼:
關(guān)鍵類:TransportClient

Elasticsearch uses standard RESTful APIs and JSON.
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
   .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
SearchResponse sr = client.prepareSearch()
 .setQuery(QueryBuilders.matchQuery("message", "myProduct"))
 .addAggregation(AggregationBuilders.terms("top_10_states")
 .field("state").size(10))
 .execute().actionGet();
client.close();

es Elasticsearch from Storm

image.png

http://blog.csdn.net/sunnyyoona/article/details/52860861

https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-mapping.html
https://www.elastic.co/guide/en/elasticsearch/reference/2.4/dynamic-field-mapping.html#date-detection
參考

storm連接kafka

//重點
Storm 如何來封裝kafka接口
class:DynamicPartitionConnections

[storm數(shù)據(jù)怎樣輸出到elasticsearch]

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,554評論 19 139
  • 我只是很喜歡那時的自己。
    林加加閱讀 171評論 0 0
  • 你還記得你第一次嚎啕大哭的場景嗎? 你若是個女人,就一定哭過。 而且,一定有過撕心裂肺,傷心絕望的痛哭。 無論是站...
    羋九閱讀 708評論 1 3
  • 1、揉捏風(fēng)池穴 取穴定位:位于頸后兩側(cè)枕骨下方,發(fā)際兩邊大筋外側(cè)的凹陷處。 按摩方法:被按摩者取坐位,按摩者站在被...
    松本靜閱讀 464評論 0 1
  • 簡書
    mortyu閱讀 184評論 0 0

友情鏈接更多精彩內(nèi)容