1

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!
rbakhru
  • 61
  • 4
  • Do you need to have multiple caches for reasons other than stated in the answer? If yes, can you explain your use case? – Dmitriy May 27 '14 at 07:15

1 Answers1

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.

Dmitriy
  • 2,282
  • 1
  • 11
  • 7
  • My problem is I can't even get a cache created to run a projection because I'm trying to create the cache after calling grid.start(...) – rbakhru May 27 '14 at 11:15
  • @rbakhru I was suggesting that you add cache to configuration before start and create multiple projections form it after. Is there any reason why you cannot configure cache before GridGain start? – Dmitriy May 27 '14 at 15:14