Apache storm 从喷口输出采集器向DRPC请求传递值?

Apache storm 从喷口输出采集器向DRPC请求传递值?,apache-storm,trident,Apache Storm,Trident,我正在尝试实施Trident+DRPC。我设计的拓扑不会无限期地运行。我有两个独立的类,一个用于喷口实现,另一个用于实现DRPC和Trident。我的喷口类(一个延伸虹膜喷口的喷口)发出客户的id。i、 e public class TriSpout implements IRichSpout{ //some logic here spoutOutputCollector.emit(new Values(id)) } 现在,我从另一个类中的输出收集器获得了值,该类使用DRPC实

我正在尝试实施Trident+DRPC。我设计的拓扑不会无限期地运行。我有两个独立的类,一个用于喷口实现,另一个用于实现DRPC和Trident。我的喷口类(一个延伸虹膜喷口的喷口)发出客户的id。i、 e

public class TriSpout implements IRichSpout{
  //some logic here
    spoutOutputCollector.emit(new Values(id))
  }
现在,我从另一个类中的输出收集器获得了值,该类使用DRPC实现了Trident

public class TriDrpc{

    .....
    TriSpout spout=new TriSpout1();        
    TridentTopology topology = new TridentTopology();  
    TridentState wordCounts =
          topology.newStream("spout1",spout)
            .parallelismHint(1)
            .each(new Fields("id"), new Compute(), new Fields("value"))
            .persistentAggregate(new MemoryMapState.Factory(),
                                 new Count(), new Fields("count"))   
drpc拓扑定义如下所示

topology.newDRPCStream("Calc", drpc)
         .each(new Fields("args"), new Split(), new Fields("word"))                
         .stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"));         
public static void main(String[] args) throws Exception {
    Config conf = new Config(); 

    if (args.length == 0) {
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("Calculator", conf,   buildTopology(drpc));          
    System.out.println("DRPC RESULT: "
                + drpc.execute("Calc", "id"));
    Thread.sleep(1000);

    } else {
        conf.setNumWorkers(8);
        StormSubmitter.submitTopology(args[0], conf, buildTopology(null));
    }
}
DRPC请求如下

topology.newDRPCStream("Calc", drpc)
         .each(new Fields("args"), new Split(), new Fields("word"))                
         .stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"));         
public static void main(String[] args) throws Exception {
    Config conf = new Config(); 

    if (args.length == 0) {
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("Calculator", conf,   buildTopology(drpc));          
    System.out.println("DRPC RESULT: "
                + drpc.execute("Calc", "id"));
    Thread.sleep(1000);

    } else {
        conf.setNumWorkers(8);
        StormSubmitter.submitTopology(args[0], conf, buildTopology(null));
    }
}
现在在上述代码中,在DRPC请求中,即

System.out.println("DRPC RESULT: " + drpc.execute("Calc", "id"));
“id”
应该与喷口发出的id相同,即我想知道哪个客户有使用此id的活动帐户,因此我需要发送喷口发出的所有id的DRPC请求。现在DRPC在main类中,如何在不手动指定id的情况下将喷口发出的值传递给DRPC请求

有人能帮忙吗

使用新信息编辑

更新 现在你的问题更清楚了,谢谢

因此,您需要处理DRPC的拓扑喷口发出的相同ID的DRPC请求

实现这一点的唯一方法是将从喷口发出的ID持久化到Storm外部持久存储(例如,RDMS或分布式hashmap)

这样,在提交拓扑以在Storm群集上执行后,就可以轮询持久存储以获取新ID,并为每个新ID执行DRPC请求

原始答案 我想我不明白这个问题。您是否正在尝试使用来自同一DRPC拓扑的喷口输出的请求ID参数执行Storm DRPC请求?我不认为这是一个有效的和有意使用的DRPC拓扑。您最好使用普通拓扑

DRPC拓扑用于有限计算,而普通拓扑用于连续计算。DRPC调用接受DRPC拓扑的名称,以及一组用于计算DRPC调用结果的输入参数。普通的Storm(或Trident)拓扑只是无限期地运行,计算某种结果并将其持久化


我希望这有帮助。如果没有,请更好地重新表述您的问题,因为您的问题并不十分清楚。

您好,我设计的拓扑结构没有冗余,因此喷口只会发出有限数量的id。我想使用DRPC请求检查所有这些id(项目要求)但是我不知道如何将输出从spout(一个单独的类)传递到DRPC execute方法。另外,除了github之外,你知道我可以从哪个链接详细了解Storm DRPC…关于Storm文档,不幸的是,我的经验是,官方文档(Storm项目的wiki)有点缺乏例子和详细的解释。此外,Trident目前完全缺乏Javadoc文档,因此实际上目前可用的最佳文档可能是GitHub上提供的各种示例和演示项目。我真诚地建议你买一些风暴书籍,有一些更新的,他们应该是最新的关于三叉戟和英里数比官方文件。