是否有可能保留一个地图存储,并在榛子中使用多个地图 [英] Is there a possibility to keep a single map store and use for multiple maps in hazelcast
问题描述
到目前为止,我有10张地图,每个地图使用地图商店,所以使用10个地图类(即)在实施MapStore的所有10个类中。它在维护中造成了复杂性。
所以我做的是,我保留了一个通用的地图商店,并为所有的地图实现了同一个类,它有能力接受它,为了说明,我做了一些类似
Map1 - com.test.GenericMapStore
Map2 - com.test.GenericMapStore
Map3 - com.test.GenericMapStore
...
Map10 - com.test.GenericMapStore
它如上所述被映射,但是对于存储中的方法,storeAll,loadAllKeys,loadAll可以检查对象的实例并找到mapName - --- 不是很好的方式
但是对于像delete这样的方法,deleteAll,load - 我没有任何线索来找到mapName, / p>
请告诉我像所有地图一样使用singleMapStore?
所以我需要一个地图商店实现,对于mapstore中的所有方法,我需要传递名为mapName的PARAM,所以如果我有通用的实现,我可以利用它只需在所有方法中使用MAP NAME参数,
示例:
Store(String key,对象对象,String mapName),
...
StoreAll(Map,String mapName),
delete(String key,String mapName)
delete(集合键,String mapName)
如果有一种方法已经可用,请告诉我...
谢谢榛子团队,,,你ppl正在做的很好的工作...很多apprecaiated ...
感谢和问候,
哈利
您应该可以使用 MapStoreFactory
( docs )。
MapStoreFactory用地图名称调用,您可以将该名称传递给GenericMapStore。
在MapStoreFactory中:
$ b $ new mapStore(mapName,props){return new GenericMapStore(mapName); b
public MapLoader newMapStore
}
然后在GenericMapStore中,每个操作都将具有mapName。
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
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.
这篇关于是否有可能保留一个地图存储,并在榛子中使用多个地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!