You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by aosmakoff <al...@macquarie.com> on 2016/09/06 06:05:19 UTC

Re: Cannot recreate cache after cache.destroy()

Val, the suggested workaround did work. This tells me though that somewhere
in your copy constructor for CacheConfiguration you are using a *shallow*
copy of the statefull content. 
Thanks for your help,
Alex  



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Cannot-recreate-cache-after-cache-destroy-tp7291p7537.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Cannot recreate cache after cache.destroy()

Posted by vkulichenko <va...@gmail.com>.
Hi Alex,

You're right. I created a ticket for this issue:
https://issues.apache.org/jira/browse/IGNITE-3957

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Cannot-recreate-cache-after-cache-destroy-tp7291p7881.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Cannot recreate cache after cache.destroy()

Posted by aosmakoff <al...@macquarie.com>.
Hi Val,
We discovered that in the test above following your suggestion the cache
gets recreated and however the part swapped to the disk has not been
cleared. The file is still there after cache.destroy() gets called. The
cache swapSize does not go to 0 either. The newly created cache allows new
values but when it starts swapping to disk the file grows. Below is the test
case we've used:
	@Test
	public void testItemSearch() throws Exception {
		IgniteCache<WorkspaceItemKey, WorkspaceItem> cache =
igniteNode.cache("workspace");
		WorkspaceDao workspaceDao = new WorkspaceDaoImpl(cache);
		Long workspaceId = 1L;
		List<AbstractAuditable&lt;Long>> objects = createTestObjects(1000);
		workspaceDao.insertItems(workspaceId, objects); //uses cache.putAll();
		
		//CacheConfiguration cacheCfg = new
CacheConfiguration(cache.getConfiguration(CacheConfiguration.class));
		CacheConfiguration oldConfig =
cache.getConfiguration(CacheConfiguration.class);
		CacheConfiguration cacheCfg = new CacheConfiguration();
		cacheCfg.setName("workspace");
		cacheCfg.setIndexedTypes(WorkspaceItemKey.class,WorkspaceItem.class);
		LruEvictionPolicy evictPlc = new LruEvictionPolicy();
		evictPlc.setMaxSize(100);
		cacheCfg.setEvictionPolicy(evictPlc);
		cacheCfg.setCacheMode(oldConfig.getCacheMode());
		cacheCfg.setAtomicityMode(oldConfig.getAtomicityMode());
		cacheCfg.setRebalanceMode(oldConfig.getRebalanceMode());
	
cacheCfg.setWriteSynchronizationMode(oldConfig.getWriteSynchronizationMode());
		cacheCfg.setBackups(oldConfig.getBackups());
		cacheCfg.setSwapEnabled(oldConfig.isSwapEnabled());
		cacheCfg.setStartSize(oldConfig.getStartSize());
		
		
		cache.destroy();
		
		cache = null;
		try {
			cache = igniteNode.getOrCreateCache(cacheCfg);
			System.out.println("Closed=" + cache.isClosed());
	
			workspaceDao = new WorkspaceDaoImpl(cache);
			workspaceDao.insertItems(workspaceId, objects); //uses cache.putAll();
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		System.out.println("Inserted");
	}
  



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Cannot-recreate-cache-after-cache-destroy-tp7291p7787.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Cannot recreate cache after cache.destroy()

Posted by vkulichenko <va...@gmail.com>.
Alex,

Yes, there is no deep copy and this is correct because the copy constructors
are more for internal usage. You should avoid using it in your code.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Cannot-recreate-cache-after-cache-destroy-tp7291p7560.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.