Persistence Hazelcast (load from/store to DB)

1,228 views
Skip to first unread message

dngfng

unread,
Oct 28, 2010, 3:30:57 AM10/28/10
to Hazelcast
Hi,

I am just starting to evaluate Hazelcast, I really like the concept,
however I am having troube figuring out how to configure the
connections to our DB. To allow Hazelcast (as described in the
Documentation) to load from / store the in Memory Maps to a DB.

"Hazelcast allows you to load and store the distributed map entries
from/to a persistent datastore such as relational database."
http://www.hazelcast.com/documentation.jsp#MapPersistence

It goes on to show the configurations required to configure a Map to
be loaded from/stored to a DB, however I can't figure out where you
define the DB settings (drivers, url, port, user, password, etc...).

Many thanks in advanced.

Rowdy Rednose

unread,
Oct 28, 2010, 4:29:45 AM10/28/10
to Hazelcast
You need to implement the MapStore or MapLoader interface yourself,
implementing details like JDBC access (or e.g. writing/reading a flat
file). It isn't provided out of the box - and I actually like it that
way, as it is very flexible, although a built-in flat file persistence
as a default would definitely be a nice to have...

Fuad Malikov

unread,
Oct 28, 2010, 4:32:47 AM10/28/10
to haze...@googlegroups.com
Also if your mapstore will also implement
com.hazelcast.core.MapLoaderLifecycleSupport then Hazelcast will call
you with init method and pass the properties of mapstore. Where you
can define your custom properties; dbname, user, pass and etc.

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.
>
>

--

@fuadm

Stephan Knitelius

unread,
Oct 28, 2010, 4:45:33 AM10/28/10
to haze...@googlegroups.com
Thanks for the quick replay, I agree with you that the DIY approach for MapLoader
and MapStore is really handy.

Will try that out later using OJB.

Just one more question, if I was to implement a MapLoader (UserLoader) and MapStore (UserStore) would this xml configuration be correct?
<hazelcast>
<map name="user">
<map-store enabled="true">
<class-name>com.xxx.demo.UserStore</class-name>
<write-delay-seconds>0</write-delay-seconds>
</map-store>
<map-load enabled="true">
<class-name>com.xxx.demo.UserLoader</class-name>
</map-store>
</map>
</hazelcast>
Thanks in advanced.


Stephan Knitelius

unread,
Oct 28, 2010, 4:46:37 AM10/28/10
to haze...@googlegroups.com
upps - spotted an error in my own xml already:

<hazelcast>
<map name="user">

<map-store enabled="true">
<class-name>com.xxx.demo.UserStore</class-name>
<write-delay-seconds>0</write-delay-seconds>
</map-store>
<map-load enabled="true">
<class-name>com.xxx.demo.UserLoader</class-name>
        </map-load>
</map>

</hazelcast>


Mit freundlichen Grüßen,

Stephan Knitelius
______________________________________
Alteburger Str. 274
50968 Köln / Cologne
Deutschland / Germany
ste...@knitelius.com

Fuad Malikov

unread,
Oct 28, 2010, 4:51:29 AM10/28/10
to haze...@googlegroups.com
Map Store already implements Map Loader, so no need to specify map
loader separately.

--

@fuadm

Stephan Knitelius

unread,
Oct 28, 2010, 5:08:03 AM10/28/10
to haze...@googlegroups.com
Ah - thank you for pointing this out.
Was already going to ask why there is no MapStoreLifecycleSupport Interface.

So I could build the following implementation of a MapStore:

-> UserStoreImpl implements MapStore, MapStoreLifecycleSupport

I can't quite make out where Hazelcast will be able to obtain the properties from for init, or are these simply the properties defined for hazelcast?
Reply all
Reply to author
Forward
0 new messages