<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Storm新特性之Flux Flux是Storm版本0.10.0中的新組件,主要目的是為了方便拓撲的開發與部署。原先在開發Storm拓撲的時候整個拓撲的結構都是硬編碼寫在代碼中的,當要對其進行修改時,需要修改代碼并重新編譯和打包,這是一件繁瑣和痛苦的事情,Flux解決了這一問題。 ### 特性 下面是Flux提供的所有的特性: * 容易配置和部署拓撲(包括Storm和Trident) * 支持變更已存在的拓撲 * 通過YAML文件來定義Spouts和Bolts,甚至可以支持Storm的其他組件,如storm-kafka/storm-hdfs/storm-hbase等 * 容易支持多語言協議組件 * 方便在不同環境中切換 ### 使用 想要用Flux最簡單的方法就是添加Maven依賴,然后打包成一個胖jar文件。依賴配置如下: ~~~ <!-- include Flux and user dependencies in the shaded jar --> <dependencies> <!-- Flux include --> <dependency> <groupId>org.apache.storm</groupId> <artifactId>flux-core</artifactId> <version>${storm.version}</version> </dependency> <!-- add user dependencies here... --> </dependencies> <!-- create a fat jar that includes all dependencies --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <configuration> <createDependencyReducedPom>true</createDependencyReducedPom> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>org.apache.storm.flux.Flux</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build> ~~~ 接下來是YAML文件的定義,一個拓撲的定義需要包括以下的部分: 1. 拓撲名 2. 拓撲組件的列表 3. spouts、bolts、stream,或者是一個可以提供`org.apache.storm.generated.StormTopology`實例的JVM類。 下面是YAML文件實例: ~~~ name: "yaml-topology" config: topology.workers: 1 # spout definitions spouts: - id: "spout-1" className: "org.apache.storm.testing.TestWordSpout" parallelism: 1 # bolt definitions bolts: - id: "bolt-1" className: "org.apache.storm.testing.TestWordCounter" parallelism: 1 - id: "bolt-2" className: "org.apache.storm.flux.wrappers.bolts.LogInfoBolt" parallelism: 1 #stream definitions streams: - name: "spout-1 --> bolt-1" # name isn't used (placeholder for logging, UI, etc.) from: "spout-1" to: "bolt-1" grouping: type: FIELDS args: ["word"] - name: "bolt-1 --> bolt2" from: "bolt-1" to: "bolt-2" grouping: type: SHUFFLE ~~~ 在有了jar文件和YAML文件后就可以通過以下的命令運行Flux拓撲了,其中`myTopology-0.1.0-SNAPSHOT.jar`是打包后的jar文件,`org.apache.storm.flux.Flux`是Flux的入口類,`--local`表示是在本地運行拓撲,`my_config.yaml`使YAML配置文件。 ~~~ storm jar myTopology-0.1.0-SNAPSHOT.jar org.apache.storm.flux.Flux --local my_config.yaml ~~~ ### 其他特性詳解 ### 不同環境切換 在不同的環境中運行拓撲需要不一樣的配置,如開發環境和生產環境,這些環境中切換一般不會改變拓撲的結構,只是要修改主機、端口號和并行度等。如果用兩份不一樣的YAML文件來進行會產生不必要的重復,Flux可以通過.properites文件來加載不同的環境變量。只需要添加`--filter`參數即可: ~~~ torm jar myTopology-0.1.0-SNAPSHOT.jar org.apache.storm.flux.Flux --local my_config.yaml --filter dev.properties ~~~ 以YAML文件中的Kafka主機為例,YAML文件修改如下: ~~~ - id: "zkHosts" className: "org.apache.storm.kafka.ZkHosts" constructorArgs: - "${kafka.zookeeper.hosts}" ~~~ 而dev.properties問價如下: ~~~ kafka.zookeeper.hosts: localhost:2181 ~~~ > 注:YAML文件中也可以解析系統環境變量${ENV-VARIABLE} ### 多語言協議的支持 多語言特性的支持比較簡單,只需要修改YAML文件中構造參數,如下面是一個由Python寫成的bolts: ~~~ bolts: - id: "splitsentence" className: "org.apache.storm.flux.bolts.GenericShellBolt" constructorArgs: # command line - ["python", "splitsentence.py"] # output fields - ["word"] parallelism: 1 ~~~ ###  展望 Flux雖然可以加方便拓撲的修改與部署,但這仍然不支持動態的修改拓撲結構,在修改拓撲時仍要中斷并重啟。不過現在在開發中的幾個特性有望改善這個情況。 本文由 DRFish([http://www.drfish.me/](http://www.drfish.me/))原創,轉載請寫明原鏈接,謝謝。 參考內容:?[Flux github](https://github.com/apache/storm/blob/a4f9f8bc5b4ca85de487a0a868e519ddcb94e852/external/flux/README.md)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看