/** * Creates and initializes a Subscriber that reads from the DRPC servers. Intended to be used inside a Storm * spout in a Storm topology. * * @param config The config containing the String function in {@link DRPCConfig#DRPC_FUNCTION}, the Storm configuration * {@link Map} as {@link com.yahoo.bullet.storm.BulletStormConfig#STORM_CONFIG} and the Storm * {@link TopologyContext} as {@link com.yahoo.bullet.storm.BulletStormConfig#STORM_CONTEXT}. * @param maxUnCommittedQueries The maximum number of queries that can be read without committing them. */ public DRPCQuerySubscriber(BulletConfig config, int maxUnCommittedQueries) { super(maxUnCommittedQueries); collector = new DRPCOutputCollector(); emittedIDs = new HashMap<>(); // Get the Storm Config that has all the relevant cluster settings and properties Map stormConfig = config.getRequiredConfigAs(DRPCConfig.STORM_CONFIG, Map.class); // Get the TopologyContext TopologyContext context = config.getRequiredConfigAs(DRPCConfig.STORM_CONTEXT, TopologyContext.class); // Wrap the collector in a SpoutOutputCollector (it just delegates to the underlying DRPCOutputCollector) SpoutOutputCollector spoutOutputCollector = new SpoutOutputCollector(collector); // Get the DRPC function we should subscribe to String function = config.getRequiredConfigAs(DRPCConfig.DRPC_FUNCTION, String.class); spout = new DRPCSpout(function); spout.open(stormConfig, context, spoutOutputCollector); }
/** * Creates and initializes a Subscriber that reads from the DRPC servers. Intended to be used inside a Storm * spout in a Storm topology. * * @param config The config containing the String function in {@link DRPCConfig#DRPC_FUNCTION}, the Storm configuration * {@link Map} as {@link com.yahoo.bullet.storm.BulletStormConfig#STORM_CONFIG} and the Storm * {@link TopologyContext} as {@link com.yahoo.bullet.storm.BulletStormConfig#STORM_CONTEXT}. * @param maxUnCommittedQueries The maximum number of queries that can be read without committing them. */ public DRPCQuerySubscriber(BulletConfig config, int maxUnCommittedQueries) { super(maxUnCommittedQueries); collector = new DRPCOutputCollector(); emittedIDs = new HashMap<>(); // Get the Storm Config that has all the relevant cluster settings and properties Map stormConfig = config.getRequiredConfigAs(DRPCConfig.STORM_CONFIG, Map.class); // Get the TopologyContext TopologyContext context = config.getRequiredConfigAs(DRPCConfig.STORM_CONTEXT, TopologyContext.class); // Wrap the collector in a SpoutOutputCollector (it just delegates to the underlying DRPCOutputCollector) SpoutOutputCollector spoutOutputCollector = new SpoutOutputCollector(collector); // Get the DRPC function we should subscribe to String function = config.getRequiredConfigAs(DRPCConfig.DRPC_FUNCTION, String.class); spout = new DRPCSpout(function); spout.open(stormConfig, context, spoutOutputCollector); }