Tormenta是Storm分布式计算机系统的Scala扩展包。Tormenta在Storm的Kafka和Kestrelspouts消息上添加了一个安全类型的包装器。此安全类型允许用户推送映射消息和筛选转换信息到spout消息层上去。
代码示例:
import com.twitter.tormenta.scheme._import com.twitter.tormenta.spout._// produces strings:val scheme: Scheme[String] = Scheme { bytes => Some(new String(bytes)) }// produces integers w/ string length:val mappedScheme: Scheme[Int] = scheme.map(_.length)// filters out all tuples less than 5:val filteredScheme: Scheme[Int] = mappedScheme.filter(_ > 5)// produces lengths for input strings > length of 5val spout: KestrelSpout[Int] = new KestrelSpout(filteredScheme, hostSeq, "spout")
评论