Is there a possibility to keep a single map store and use for multiple maps in hazelcast

纵饮孤独 提交于 2019-12-12 13:27:15

问题


Currently am using Hazelcast and persistence database as Hbase,

So far I have 10 maps, for each map am using a map store, So Am using 10 mapstore classes (i.e) In all the 10 classes am implementing the MapStore. It creates a complexity in maintenance.

So What I did is, I kept a generic map store and implemented the same class for all the maps, It has the ability to accept it, To make it clear, I did something like

Map1 - com.test.GenericMapStore
Map2 - com.test.GenericMapStore
Map3 - com.test.GenericMapStore
...
Map10 - com.test.GenericMapStore

It gets mapped as above,

But for the methods in store, storeAll, loadAllKeys, loadAll am able to check the instance of object and find the mapName ---- Not a good way

But for methods like delete, deleteAll, load - I dont have any clue to find the mapName,

Pls tell me like any way to use a singleMapStore for all the maps???

So I need a map store implementation where, for all methods in mapstore, I need the PARAM called mapName to be passed, So In case, If I have common Implementation, I can make use of it just by using MAP NAME param in all the methods,

Example : Store(String key, Object object, String mapName), StoreAll(Map, String mapName), delete(String key, String mapName) delete(Collections keys, String mapName) ...

If there is a way already available, Pls do let me know...

Thanks hazelcast team,,, You ppl are doing the great job... Much Apprecaiated...

Thanks and Regards, Harry


回答1:


You should be able to achieve this with a MapStoreFactory (docs). The MapStoreFactory is called with the name of the map and you can pass that name into the GenericMapStore.

In you MapStoreFactory :

public MapLoader newMapStore(mapName, props) { 
    return new GenericMapStore(mapName); 
}

then in GenericMapStore you will have the mapName for each operation.



来源:https://stackoverflow.com/questions/26218732/is-there-a-possibility-to-keep-a-single-map-store-and-use-for-multiple-maps-in-h

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