Hazelcast file persistence (MapStore implementation)

拈花ヽ惹草 提交于 2019-12-12 21:55:02

问题


I am using Hazelcast for clustered data distribution. I read in the documentation about data persistence, using the interfaces MapStore and MapLoader. I need to implement these interfaces and write the class name in the hazelcast.xml file.

Is there any example of implementation of these interfaces for file persistence with hazelcast? Does anyone know about any source code or jar file that I can download and work with?

Thanks


回答1:


You can implement your own just using ObjectOutputStream and ObjectInputStream.

You can create a directory with map's name. store(key, value) operation creates a file with name key.dat, with content of serialized value. load(key) method reads "key.dat" file into an object and returns.

Here usage examples of ObjectOutputStream and ObjectInputStream

http://www.mkyong.com/java/how-to-write-an-object-to-file-in-java/

http://www.mkyong.com/java/how-to-read-an-object-from-file-in-java/

Then you should add this implementation class to your class path and set it in your hazelcast.xml



来源:https://stackoverflow.com/questions/10453559/hazelcast-file-persistence-mapstore-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!