Storm拓扑调优实战
1. 拓扑组件实现
在实时数据处理中,我们需要构建一系列的拓扑组件来完成特定的任务,如查找推荐销售、查询销售详情以及保存推荐销售信息等。以下是这些组件的具体实现。
1.1 查找推荐销售
public class FindRecommendedSales extends BaseBasicBolt {
private final static int TIMEOUT = 200;
private FlashSaleRecommendationClient client;
@Override
public void prepare(Map config,
TopologyContext context) {
client = new FlashSaleRecommendationClient(TIMEOUT);
}
@Override
public void execute(Tuple tuple,
BasicOutputCollector outputCollector) {
String customerId = tuple.getStringByField("customer");
try {
List<String> sales = client.findSalesFor(customerId);
if (!sales.isEmpty()) {
outputCollector.emit(new Values(
超级会员免费看
订阅专栏 解锁全文

968

被折叠的 条评论
为什么被折叠?



