Add cache at runtime to GridGain / reconfigure GridGain at runtime

冷暖自知 提交于 2019-12-08 09:50:35

问题


Is there a means of reconfiguring the GridCacheConfiguration at runtime for GridGain?

The end goal is to be able to add a grid cache at runtime after having started up the Grid.

final GridConfiguration gridConfiguration = new GridConfiguration();
gridConfiguration.setMarshaller(new GridOptimizedMarshaller());
Grid grid = GridGain.start(gridConfiguration);
...

<later on>
GridCacheConfiguration newCacheConfig = ...; //defines newConfig
grid.configuration().setCacheConfiguration(newCacheConfig);

grid.cache("newConfig"); // <-- throws a cache not defined error!

回答1:


Adding caches usually has to do with handling different data types (generics), which GridGain addresses with GridCacheProjections, like so:

GridCacheProjection<Integer, MyType> prj = cache.projection(Integer.class, MyType.class);

You can create as many different projection from the same cache as needed. In addition to specifying data types, you can also use projections to turn cache flags on and off, or to provide filtered view for the cache with projection filters.



来源:https://stackoverflow.com/questions/23880168/add-cache-at-runtime-to-gridgain-reconfigure-gridgain-at-runtime

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