# Trident Spouts
## Trident spouts
像在 vanilla Storm API 中, spouts 是 Trident topology 中的 source of streams (streams 的來源). 在 vanilla Storm spouts 之上, Trident 為更復雜的 spouts 提供了額外的 API .
您的 how you source your data streams (數據流的來源)和 how you update state (e.g. databases) based on those data streams (基于這些數據流更新狀態(例如數據庫))之間存在著一個不可分割的聯系. 請參閱 [Trident state doc](Trident-state.html) , 以了解此信息 - 了解此聯系對于了解可用的 spout 選項是至關重要的.
Regular Storm spouts 將是 Trident topology 中的 non-transactional spouts . 要使用 regular Storm IRichSpout, 請在 TridentTopology 中創建如下 stream :
```
TridentTopology topology = new TridentTopology();
topology.newStream("myspoutid", new MyRichSpout());
```
Trident topology 中的所有 spouts 都需要為該流提供 unique identifier (唯一的標識符) - 該 identifier 在集群上運行的所有 topologies 中必須是唯一的. Trident 將使用此 identifier 來存儲 Zookeeper 中 spout 消耗的 metadata (元數據), 包括 txid 和與 spout 相關聯的任何 metadata (元數據).
您可以通過以下配置選項配置 spout metadata 的 Zookeeper 存儲:
1. `transactional.zookeeper.servers`: Zookeeper hostnames 列表
2. `transactional.zookeeper.port`: Zookeeper 集群的端口
3. `transactional.zookeeper.root`: Zookeeper 中存儲 Metadata 的根目錄. Metadata 將存儲在路徑 <root path="">/</root>
## Pipelining
默認情況下, Trident 一次處理 single batch (一個批次), 等待批次成功或失敗, 然后再嘗試處理 another batch (另一批次). 您可以通過 pipelining the batches 獲得 significantly higher throughput (明顯更高的吞吐量)并降低每個 batch (批處理)的延遲. 您可以使用 "topology.max.spout.pending" 屬性同時處理要處理的 maximum amount of batches (最大批處理量).
即使在同時處理 multiple batches (多個批次)的同時, Trident 也會在 topology 中將任何 state updates 按照 batches 的順序排序. 例如, 假設您正在對數據庫進行全局計數聚合. 這個想法是, 當您更新數據庫中 batch 1 的計數時, 您仍然可以計算 batch 2 到 10 的部分計數. Trident 將不會移動到 batch 2 的 state updates (狀態更新), 直到狀態更新為 batch 1 已成功. 這對于實現 exactly-once (一次且僅一次)處理語義非常重要, 如 [Trident state doc](Trident-state.html) 中的大綱.
## Trident spout types
以下是可用的以下 spout API:
1. [ITridentSpout](http://github.com/apache/storm/blob/master%0A/storm-core/src/jvm/org/apache/storm/trident/spout/ITridentSpout.java): 最通用的 API , 可以支持 transactional 或 opaque transactional semantics (語義). 一般來說, 您將直接使用此 API 的一種 partitioned (分區)風格, 而不是使用此 API .
2. [IBatchSpout](http://github.com/apache/storm/blob/master%0A/storm-core/src/jvm/org/apache/storm/trident/spout/IBatchSpout.java): 一次發送 batches of tuples 的 non-transactional spout .
3. [IPartitionedTridentSpout](http://github.com/apache/storm/blob/master%0A/storm-core/src/jvm/org/apache/storm/trident/spout/IPartitionedTridentSpout.java): 從 partitioned data source (分區數據源)讀取的 transactional spout (像 Kafka 服務器集群)
4. [IOpaquePartitionedTridentSpout](http://github.com/apache/storm/blob/master%0A/storm-core/src/jvm/org/apache/storm/trident/spout/IOpaquePartitionedTridentSpout.java): 一個從 partitioned data source (分區數據源)讀取的 opaque transactional spout .
而且, 像本教程開頭所提到的, 你也可以使用常規的 IRichSpout .
- Storm 基礎
- 概念
- Scheduler(調度器)
- Configuration
- Guaranteeing Message Processing
- 守護進程容錯
- 命令行客戶端
- Storm UI REST API
- 理解 Storm Topology 的 Parallelism(并行度)
- FAQ
- Layers on Top of Storm
- Storm Trident
- Trident 教程
- Trident API 綜述
- Trident State
- Trident Spouts
- Trident RAS API
- Storm SQL
- Storm SQL 集成
- Storm SQL 示例
- Storm SQL 語言參考
- Storm SQL 內部實現
- Flux
- Storm 安裝和部署
- 設置Storm集群
- 本地模式
- 疑難解答
- 在生產集群上運行 Topology
- Maven
- 安全地運行 Apache Storm
- CGroup Enforcement
- Pacemaker
- 資源感知調度器 (Resource Aware Scheduler)
- 用于分析 Storm 的各種內部行為的 Metrics
- Windows 用戶指南
- Storm 中級
- 序列化
- 常見 Topology 模式
- Clojure DSL
- 使用沒有jvm的語言編輯storm
- Distributed RPC
- Transactional Topologies
- Hooks
- Storm Metrics
- Storm 狀態管理
- Windowing Support in Core Storm
- Joining Streams in Storm Core
- Storm Distributed Cache API
- Storm 調試
- 動態日志級別設置
- Storm Logs
- 動態員工分析
- 拓撲事件檢查器
- Storm 與外部系統, 以及其它庫的集成
- Storm Kafka Integration
- Storm Kafka 集成(0.10.x+)
- Storm HBase Integration
- Storm HDFS Integration
- Storm Hive 集成
- Storm Solr 集成
- Storm Cassandra 集成
- Storm JDBC 集成
- Storm JMS 集成
- Storm Redis 集成
- Azue Event Hubs 集成
- Storm Elasticsearch 集成
- Storm MQTT(Message Queuing Telemetry Transport, 消息隊列遙測傳輸) 集成
- Storm MongoDB 集成
- Storm OpenTSDB 集成
- Storm Kinesis 集成
- Storm Druid 集成
- Storm and Kestrel
- Container, Resource Management System Integration
- Storm 高級
- 針對 Storm 定義一個不是 JVM 的 DSL
- 多語言協議
- Storm 內部實現
- 翻譯進度