You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by clay teahouse <cl...@gmail.com> on 2015/01/24 07:01:05 UTC
passing objects to bolts through Config
Hi,
I am trying to pass some objects to the bolts through config, but I am not
having much success. These objects are hashmap and arrarylists. I am
assuming these are serializable. Any idea what could be wrong?
thanks,
Clay
Re: passing objects to bolts through Config
Posted by Susheel Kumar Gadalay <sk...@gmail.com>.
I think you have to use
ObjectType obj = (objectType) context.get("objectname");
not
ObjectType obj = (objectType) stormConfig.get("objectname");
On 1/24/15, clay teahouse <cl...@gmail.com> wrote:
> Any feedback on what the issue could be would be appreciated.
> I am getting an instance of Config and add my static objects to it and
> want to access these objects in bolt's prepare method.
> Config config = new Config();
> config.put("objectname", objectinstance);
>
> StormSubmitter.submitTopology(topologyname, config,
> builder.createTopology());
>
> And in bolt's prepare method, I try to extract the object.
>
> prepare(Map stormConfig,TopologyContext context) {
>
> ObjectType obj = (objectType) stormConfig.get("objectname");
>
> }
>
> Object type is either String or ArrayList or HashMap.
>
>
> On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <cl...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am trying to pass some objects to the bolts through config, but I am
>> not
>> having much success. These objects are hashmap and arrarylists. I am
>> assuming these are serializable. Any idea what could be wrong?
>>
>> thanks,
>> Clay
>>
>>
>
Re: passing objects to bolts through Config
Posted by clay teahouse <cl...@gmail.com>.
John -- can you explain how you do it? Is the approach different from what
I am doing?
On Sat, Jan 24, 2015 at 10:33 AM, John Reilly <jr...@inconspicuous.org> wrote:
> Adding a hashmap to the storm config works for me.
>
> On Sat, Jan 24, 2015 at 08:29 Irek Khasyanov <qu...@gmail.com> wrote:
>
>> Why you need to use storm's config? Use it only for storm configuration,
>> not for your topology.
>>
>> On 24 January 2015 at 19:17, clay teahouse <cl...@gmail.com>
>> wrote:
>>
>>> Thanks Irek. So you are passing the config through the bolt's
>>> constructor. I was trying to use storm's config object to pass my own
>>> config around.
>>>
>>> On Sat, Jan 24, 2015 at 10:10 AM, Irek Khasyanov <qu...@gmail.com>
>>> wrote:
>>>
>>>> Well, I'm using this code:
>>>>
>>>> public EventsBatchBolt(TopologyConfig config, long emitFrequency,
>>>> TimeUnit unit) {
>>>> super(emitFrequency, unit);
>>>> topologyConfig = config;
>>>> }
>>>>
>>>> And where I submitting topology, I have:
>>>>
>>>> builder.setBolt("event_batch", new EventsBatchBolt(topologyConfig, 10,
>>>> TimeUnit.SECONDS), 1)
>>>>
>>>> TopologyConfig is just generic class with my configuration
>>>>
>>>> On 24 January 2015 at 18:59, clay teahouse <cl...@gmail.com>
>>>> wrote:
>>>>
>>>>> Any feedback on what the issue could be would be appreciated.
>>>>> I am getting an instance of Config and add my static objects to it
>>>>> and want to access these objects in bolt's prepare method.
>>>>> Config config = new Config();
>>>>> config.put("objectname", objectinstance);
>>>>>
>>>>> StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
>>>>>
>>>>> And in bolt's prepare method, I try to extract the object.
>>>>>
>>>>> prepare(Map stormConfig,TopologyContext context) {
>>>>>
>>>>> ObjectType obj = (objectType) stormConfig.get("objectname");
>>>>>
>>>>> }
>>>>>
>>>>> Object type is either String or ArrayList or HashMap.
>>>>>
>>>>>
>>>>> On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <
>>>>> clayteahouse@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to pass some objects to the bolts through config, but I
>>>>>> am not having much success. These objects are hashmap and arrarylists. I am
>>>>>> assuming these are serializable. Any idea what could be wrong?
>>>>>>
>>>>>> thanks,
>>>>>> Clay
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> With best regards, Irek Khasyanov.
>>>>
>>>
>>>
>>
>>
>> --
>> With best regards, Irek Khasyanov.
>>
>
Re: passing objects to bolts through Config
Posted by John Reilly <jr...@inconspicuous.org>.
Adding a hashmap to the storm config works for me.
On Sat, Jan 24, 2015 at 08:29 Irek Khasyanov <qu...@gmail.com> wrote:
> Why you need to use storm's config? Use it only for storm configuration,
> not for your topology.
>
> On 24 January 2015 at 19:17, clay teahouse <cl...@gmail.com> wrote:
>
>> Thanks Irek. So you are passing the config through the bolt's
>> constructor. I was trying to use storm's config object to pass my own
>> config around.
>>
>> On Sat, Jan 24, 2015 at 10:10 AM, Irek Khasyanov <qu...@gmail.com>
>> wrote:
>>
>>> Well, I'm using this code:
>>>
>>> public EventsBatchBolt(TopologyConfig config, long emitFrequency,
>>> TimeUnit unit) {
>>> super(emitFrequency, unit);
>>> topologyConfig = config;
>>> }
>>>
>>> And where I submitting topology, I have:
>>>
>>> builder.setBolt("event_batch", new EventsBatchBolt(topologyConfig, 10,
>>> TimeUnit.SECONDS), 1)
>>>
>>> TopologyConfig is just generic class with my configuration
>>>
>>> On 24 January 2015 at 18:59, clay teahouse <cl...@gmail.com>
>>> wrote:
>>>
>>>> Any feedback on what the issue could be would be appreciated.
>>>> I am getting an instance of Config and add my static objects to it and
>>>> want to access these objects in bolt's prepare method.
>>>> Config config = new Config();
>>>> config.put("objectname", objectinstance);
>>>>
>>>> StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
>>>>
>>>> And in bolt's prepare method, I try to extract the object.
>>>>
>>>> prepare(Map stormConfig,TopologyContext context) {
>>>>
>>>> ObjectType obj = (objectType) stormConfig.get("objectname");
>>>>
>>>> }
>>>>
>>>> Object type is either String or ArrayList or HashMap.
>>>>
>>>>
>>>> On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <clayteahouse@gmail.com
>>>> > wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to pass some objects to the bolts through config, but I am
>>>>> not having much success. These objects are hashmap and arrarylists. I am
>>>>> assuming these are serializable. Any idea what could be wrong?
>>>>>
>>>>> thanks,
>>>>> Clay
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> With best regards, Irek Khasyanov.
>>>
>>
>>
>
>
> --
> With best regards, Irek Khasyanov.
>
Re: passing objects to bolts through Config
Posted by clay teahouse <cl...@gmail.com>.
Irek -- My reasons are that I don't want to deal with two different config
objects and I want to deal with the config object in the prepare method.
But I am considering both options (via constructor and prepare method). I
am considering a singleton in the prepare method. But this might be an
overkill.
On Sat, Jan 24, 2015 at 10:28 AM, Irek Khasyanov <qu...@gmail.com> wrote:
> Why you need to use storm's config? Use it only for storm configuration,
> not for your topology.
>
> On 24 January 2015 at 19:17, clay teahouse <cl...@gmail.com> wrote:
>
>> Thanks Irek. So you are passing the config through the bolt's
>> constructor. I was trying to use storm's config object to pass my own
>> config around.
>>
>> On Sat, Jan 24, 2015 at 10:10 AM, Irek Khasyanov <qu...@gmail.com>
>> wrote:
>>
>>> Well, I'm using this code:
>>>
>>> public EventsBatchBolt(TopologyConfig config, long emitFrequency,
>>> TimeUnit unit) {
>>> super(emitFrequency, unit);
>>> topologyConfig = config;
>>> }
>>>
>>> And where I submitting topology, I have:
>>>
>>> builder.setBolt("event_batch", new EventsBatchBolt(topologyConfig, 10,
>>> TimeUnit.SECONDS), 1)
>>>
>>> TopologyConfig is just generic class with my configuration
>>>
>>> On 24 January 2015 at 18:59, clay teahouse <cl...@gmail.com>
>>> wrote:
>>>
>>>> Any feedback on what the issue could be would be appreciated.
>>>> I am getting an instance of Config and add my static objects to it and
>>>> want to access these objects in bolt's prepare method.
>>>> Config config = new Config();
>>>> config.put("objectname", objectinstance);
>>>>
>>>> StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
>>>>
>>>> And in bolt's prepare method, I try to extract the object.
>>>>
>>>> prepare(Map stormConfig,TopologyContext context) {
>>>>
>>>> ObjectType obj = (objectType) stormConfig.get("objectname");
>>>>
>>>> }
>>>>
>>>> Object type is either String or ArrayList or HashMap.
>>>>
>>>>
>>>> On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <clayteahouse@gmail.com
>>>> > wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to pass some objects to the bolts through config, but I am
>>>>> not having much success. These objects are hashmap and arrarylists. I am
>>>>> assuming these are serializable. Any idea what could be wrong?
>>>>>
>>>>> thanks,
>>>>> Clay
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> With best regards, Irek Khasyanov.
>>>
>>
>>
>
>
> --
> With best regards, Irek Khasyanov.
>
Re: passing objects to bolts through Config
Posted by Irek Khasyanov <qu...@gmail.com>.
Why you need to use storm's config? Use it only for storm configuration,
not for your topology.
On 24 January 2015 at 19:17, clay teahouse <cl...@gmail.com> wrote:
> Thanks Irek. So you are passing the config through the bolt's constructor.
> I was trying to use storm's config object to pass my own config around.
>
> On Sat, Jan 24, 2015 at 10:10 AM, Irek Khasyanov <qu...@gmail.com> wrote:
>
>> Well, I'm using this code:
>>
>> public EventsBatchBolt(TopologyConfig config, long emitFrequency,
>> TimeUnit unit) {
>> super(emitFrequency, unit);
>> topologyConfig = config;
>> }
>>
>> And where I submitting topology, I have:
>>
>> builder.setBolt("event_batch", new EventsBatchBolt(topologyConfig, 10,
>> TimeUnit.SECONDS), 1)
>>
>> TopologyConfig is just generic class with my configuration
>>
>> On 24 January 2015 at 18:59, clay teahouse <cl...@gmail.com>
>> wrote:
>>
>>> Any feedback on what the issue could be would be appreciated.
>>> I am getting an instance of Config and add my static objects to it and
>>> want to access these objects in bolt's prepare method.
>>> Config config = new Config();
>>> config.put("objectname", objectinstance);
>>>
>>> StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
>>>
>>> And in bolt's prepare method, I try to extract the object.
>>>
>>> prepare(Map stormConfig,TopologyContext context) {
>>>
>>> ObjectType obj = (objectType) stormConfig.get("objectname");
>>>
>>> }
>>>
>>> Object type is either String or ArrayList or HashMap.
>>>
>>>
>>> On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <cl...@gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to pass some objects to the bolts through config, but I am
>>>> not having much success. These objects are hashmap and arrarylists. I am
>>>> assuming these are serializable. Any idea what could be wrong?
>>>>
>>>> thanks,
>>>> Clay
>>>>
>>>>
>>>
>>
>>
>> --
>> With best regards, Irek Khasyanov.
>>
>
>
--
With best regards, Irek Khasyanov.
Re: passing objects to bolts through Config
Posted by clay teahouse <cl...@gmail.com>.
Thanks Irek. So you are passing the config through the bolt's constructor.
I was trying to use storm's config object to pass my own config around.
On Sat, Jan 24, 2015 at 10:10 AM, Irek Khasyanov <qu...@gmail.com> wrote:
> Well, I'm using this code:
>
> public EventsBatchBolt(TopologyConfig config, long emitFrequency, TimeUnit
> unit) {
> super(emitFrequency, unit);
> topologyConfig = config;
> }
>
> And where I submitting topology, I have:
>
> builder.setBolt("event_batch", new EventsBatchBolt(topologyConfig, 10,
> TimeUnit.SECONDS), 1)
>
> TopologyConfig is just generic class with my configuration
>
> On 24 January 2015 at 18:59, clay teahouse <cl...@gmail.com> wrote:
>
>> Any feedback on what the issue could be would be appreciated.
>> I am getting an instance of Config and add my static objects to it and
>> want to access these objects in bolt's prepare method.
>> Config config = new Config();
>> config.put("objectname", objectinstance);
>>
>> StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
>>
>> And in bolt's prepare method, I try to extract the object.
>>
>> prepare(Map stormConfig,TopologyContext context) {
>>
>> ObjectType obj = (objectType) stormConfig.get("objectname");
>>
>> }
>>
>> Object type is either String or ArrayList or HashMap.
>>
>>
>> On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <cl...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to pass some objects to the bolts through config, but I am
>>> not having much success. These objects are hashmap and arrarylists. I am
>>> assuming these are serializable. Any idea what could be wrong?
>>>
>>> thanks,
>>> Clay
>>>
>>>
>>
>
>
> --
> With best regards, Irek Khasyanov.
>
Re: passing objects to bolts through Config
Posted by Irek Khasyanov <qu...@gmail.com>.
Well, I'm using this code:
public EventsBatchBolt(TopologyConfig config, long emitFrequency, TimeUnit
unit) {
super(emitFrequency, unit);
topologyConfig = config;
}
And where I submitting topology, I have:
builder.setBolt("event_batch", new EventsBatchBolt(topologyConfig, 10,
TimeUnit.SECONDS), 1)
TopologyConfig is just generic class with my configuration
On 24 January 2015 at 18:59, clay teahouse <cl...@gmail.com> wrote:
> Any feedback on what the issue could be would be appreciated.
> I am getting an instance of Config and add my static objects to it and
> want to access these objects in bolt's prepare method.
> Config config = new Config();
> config.put("objectname", objectinstance);
>
> StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
>
> And in bolt's prepare method, I try to extract the object.
>
> prepare(Map stormConfig,TopologyContext context) {
>
> ObjectType obj = (objectType) stormConfig.get("objectname");
>
> }
>
> Object type is either String or ArrayList or HashMap.
>
>
> On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <cl...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am trying to pass some objects to the bolts through config, but I am
>> not having much success. These objects are hashmap and arrarylists. I am
>> assuming these are serializable. Any idea what could be wrong?
>>
>> thanks,
>> Clay
>>
>>
>
--
With best regards, Irek Khasyanov.
Re: passing objects to bolts through Config
Posted by clay teahouse <cl...@gmail.com>.
Any feedback on what the issue could be would be appreciated.
I am getting an instance of Config and add my static objects to it and
want to access these objects in bolt's prepare method.
Config config = new Config();
config.put("objectname", objectinstance);
StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
And in bolt's prepare method, I try to extract the object.
prepare(Map stormConfig,TopologyContext context) {
ObjectType obj = (objectType) stormConfig.get("objectname");
}
Object type is either String or ArrayList or HashMap.
On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <cl...@gmail.com>
wrote:
> Hi,
>
> I am trying to pass some objects to the bolts through config, but I am not
> having much success. These objects are hashmap and arrarylists. I am
> assuming these are serializable. Any idea what could be wrong?
>
> thanks,
> Clay
>
>
Re: passing objects to bolts through Config
Posted by clay teahouse <cl...@gmail.com>.
Any feedback on what the issue could be would be appreciated.
I am getting an instance of Config and add my static objects to it and
want to access these objects in bolt's prepare method.
Config config = new Config();
config.put("objectname", objectinstance);
StormSubmitter.submitTopology(topologyname, config, builder.createTopology());
And in bolt's prepare method, I try to extract the object.
prepare(Map stormConfig,TopologyContext context) {
ObjectType obj = (objectType) stormConfig.get("objectname");
}
Object type is either String or ArrayList or HashMap.
On Sat, Jan 24, 2015 at 12:01 AM, clay teahouse <cl...@gmail.com>
wrote:
> Hi,
>
> I am trying to pass some objects to the bolts through config, but I am not
> having much success. These objects are hashmap and arrarylists. I am
> assuming these are serializable. Any idea what could be wrong?
>
> thanks,
> Clay
>
>