Programmatic way to create new map without new instance

912 views
Skip to first unread message

Phinidy

unread,
Sep 16, 2010, 4:11:13 PM9/16/10
to Hazelcast
Is there a programmatic way to create anew map without creating a new
hazelcast instance ..?

Hazelcast hz = ... etc

hz.setMap("mapname1");
Map m = hz.getMap("mapname1")

?

Fuad Malikov

unread,
Sep 16, 2010, 4:18:04 PM9/16/10
to haze...@googlegroups.com
For a map to exist there should be at least one Hazelcast Instance. You can connect to Hazelcast cluster from Java client (which is not a member) and create a map.

HazelcastClient client = HazelcastClient.newHazelcastClient("dev", "dev-pass", "10.10.1.1:5701");
client.getMap("mapname1");

By the way HazelcastClient also implements HazelcastInstance interface. 

Fuad


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.


Phinidy

unread,
Sep 16, 2010, 4:21:54 PM9/16/10
to Hazelcast
is there a way to add a map to an already running instance?

On Sep 16, 3:18 pm, Fuad Malikov <f...@hazelcast.com> wrote:
> For a map to exist there should be at least one Hazelcast Instance. You can
> connect to Hazelcast cluster from Java client (which is not a member) and
> create a map.
>
> HazelcastClient client = HazelcastClient.newHazelcastClient("dev",
> "dev-pass", "10.10.1.1:5701");
> client.getMap("mapname1");
>
> By the way HazelcastClient also implements HazelcastInstance interface.
>
> Fuad
>
>
>
>
>
>
>
> On Thu, Sep 16, 2010 at 11:11 PM, Phinidy <nijee.tay...@gmail.com> wrote:
> > Is there a programmatic way to create  anew map without creating a new
> > hazelcast instance ..?
>
> > Hazelcast hz = ... etc
>
> > hz.setMap("mapname1");
> > Map m = hz.getMap("mapname1")
>
> > ?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Hazelcast" group.> To post to this group, send email tohaz...@googlegroups.com.
> > To unsubscribe from this group, send email to>hazelcast+...@googlegroups.com<hazelcast%2Bunsubscribe@googlegroups .com>
> > .

nijee taylor

unread,
Sep 16, 2010, 4:41:52 PM9/16/10
to Hazelcast
sorta like this 

Hazelcast.setMap("mapname1");    
Hazelcast.setMap("mapname2");   .. ??


To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.

Mehmet Dogan

unread,
Sep 17, 2010, 2:50:38 AM9/17/10
to haze...@googlegroups.com
no need to any "set" like method or no need to specify a map in configuration.

hazelcastInstance.getMap("myMap") already creates that map lazily if that does not exist in cluster.

Rafał Krupiński

unread,
Sep 17, 2010, 5:51:22 AM9/17/10
to haze...@googlegroups.com
On Fri, Sep 17, 2010 at 08:50, Mehmet Dogan <mehmet...@gmail.com> wrote:
> no need to any "set" like method or no need to specify a map in configuration.
>
> hazelcastInstance.getMap("myMap") already creates that map lazily if that does not exist in cluster.

BTW if I modify Config object, i.e. programatically add configuration
for a map, and then create that map, will other nodes know that
configuration?

--
Pozdrawiam / Best Regards
Rafal Krupinski

Mehmet Dogan

unread,
Sep 17, 2010, 8:35:19 AM9/17/10
to haze...@googlegroups.com
unfortunately not yet.
also it is not possible to change config in runtime, configuration can be set only on startup for now,
can not be change later, and every node should (must) have exactly same configuration.

but it is on plan (in short period) to be able to edit configuration on the fly and to acknowledge all nodes with that change.

nijee taylor

unread,
Sep 17, 2010, 1:15:24 PM9/17/10
to haze...@googlegroups.com
how expensive is that method vs creating new HZ instance...?

Mehmet Dogan

unread,
Sep 17, 2010, 2:10:27 PM9/17/10
to haze...@googlegroups.com
hmm, configuration change on runtime is not fully implemented yet, but it is required to be a cheap or "nearly cheap" operation.
creating a new instance is very expensive operation, and note that hazelcast assumes all nodes are identical and configs of all members should be same.
otherwise there may be unexpected behaviors..

@mm

Talip Ozturk

unread,
Sep 17, 2010, 6:04:34 PM9/17/10
to haze...@googlegroups.com
The idea here is that you should have a set of preconfigured type of
maps. Notice the '*' in the names of the maps.

<map name="lru-*">...

<map name="five-min-ttl-*">...

<map name="mapstore-aware-*>...

then you can create as many map as you want on the fly...

Hazelcast.getMap("lru-Jobs");
Hazelcast.getMap("five-min-ttl-Sessions");
Hazelcast.getMap("mapstore-aware-Orders");


Problem with the dynamic configuration and creation of the map is the
fact that you have to make sure that all nodes are using the exact
same config for the created map. What if the map is created on another
node with a totally different config already. It is a total mess!

twitter @oztalip

ser...@americasflorist.com

unread,
Sep 22, 2010, 1:06:05 PM9/22/10
to Hazelcast
does this apply to queues also ???

On Sep 17, 5:04 pm, Talip Ozturk <ta...@hazelcast.com> wrote:
> The idea here is that you should have a set of preconfigured type of
> maps. Notice the '*' in the names of the maps.
>
> <map name="lru-*">...
>
> <map name="five-min-ttl-*">...
>
> <map name="mapstore-aware-*>...
>
> then you can create as many map as you want on the fly...
>
> Hazelcast.getMap("lru-Jobs");
> Hazelcast.getMap("five-min-ttl-Sessions");
> Hazelcast.getMap("mapstore-aware-Orders");
>
> Problem with the dynamic configuration and creation of the map is the
> fact that you have to make sure that all nodes are using the exact
> same config for the created map. What if the map is created on another
> node with a totally different config already. It is a total mess!
>
> twitter @oztalip
>
>
>
>
>
>
>
> On Fri, Sep 17, 2010 at 9:10 PM, Mehmet Dogan <mehmetdog...@gmail.com> wrote:
> > hmm, configuration change on runtime is not fully implemented yet, but it is
> > required to be a cheap or "nearly cheap" operation.
> > creating a new instance is very expensive operation, and note that hazelcast
> > assumes all nodes are identical and configs of all members should be same.
> > otherwise there may be unexpected behaviors..
>
> > @mm
>
> > On Fri, Sep 17, 2010 at 20:15, nijee taylor <nijee.tay...@gmail.com> wrote:
>
> >> how expensive is that method vs creating new HZ instance...?
>
> >> On Fri, Sep 17, 2010 at 1:50 AM, Mehmet Dogan <mehmetdog...@gmail.com>
> >> wrote:
>
> >>> no need to any "set" like method or no need to specify a map in
> >>> configuration.
>
> >>> hazelcastInstance.getMap("myMap") already creates that map lazily if that
> >>> does not exist in cluster.
>
> >>> On Sep 16, 2010, at 11:41 PM, nijee taylor wrote:
>
> >>> > sorta like this
>
> >>> > Hazelcast.setMap("mapname1");
> >>> > Hazelcast.setMap("mapname2");   .. ??
>
> >>> > On Thu, Sep 16, 2010 at 3:21 PM, Phinidy <nijee.tay...@gmail.com>
> >>> > Groups "Hazelcast" group.>>> > To post to this group, send email tohaz...@googlegroups.com.
> >>> > To unsubscribe from this group, send email to>>> >hazelcast+...@googlegroups.com.
> >>> > For more options, visit this group at
> >>> >http://groups.google.com/group/hazelcast?hl=en.
>
> >>> > --
> >>> > You received this message because you are subscribed to the Google
> >>> > Groups "Hazelcast" group.>>> > To post to this group, send email tohaz...@googlegroups.com.
> >>> > To unsubscribe from this group, send email to>>> >hazelcast+...@googlegroups.com.
> >>> > For more options, visit this group at
> >>> >http://groups.google.com/group/hazelcast?hl=en.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Hazelcast" group.>>> To post to this group, send email tohaz...@googlegroups.com.
> >>> To unsubscribe from this group, send email to>>>hazelcast+...@googlegroups.com.
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/hazelcast?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Hazelcast" group.>> To post to this group, send email tohaz...@googlegroups.com.
> >> To unsubscribe from this group, send email to>>hazelcast+...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/hazelcast?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Hazelcast" group.> To post to this group, send email tohaz...@googlegroups.com.
> > To unsubscribe from this group, send email to>hazelcast+...@googlegroups.com.

Talip Ozturk

unread,
Sep 23, 2010, 3:53:36 AM9/23/10
to haze...@googlegroups.com
Yes. Same for queues.

twitter @oztalip

> To post to this group, send email to haze...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages