Hi Matt,
I've tried the following code based on your configuration and it works.
public static void main(String[] args) throws Exception {
Ignite ignite = Ignition.start(createIgniteConfiguration());
IgniteCache cache1 =
ignite.getOrCreateCache(createULConfiguration("test-cache-1"));
// upload 10_000 keys
for (int i = 0; i < 10_000; ++i)
cache1.put(i, i);
// remove all keys
cache1.removeAll();
Thread.sleep(10_000);
ignite.close();
}
private static CacheConfiguration createULConfiguration(String name) {
CacheConfiguration<String, Integer> cacheConfig = new
CacheConfiguration<>();
cacheConfig.setName(name);
cacheConfig.setCacheMode(CacheMode.PARTITIONED);
cacheConfig.setBackups(2);
cacheConfig.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheConfig.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cacheConfig.setWriteBehindEnabled(true);
cacheConfig.setWriteBehindBatchSize(512);
cacheConfig.setWriteBehindFlushSize(10240);
cacheConfig.setWriteBehindFlushFrequency(5_000);
cacheConfig.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheStoreExample.class));
cacheConfig.setReadThrough(true);
cacheConfig.setWriteThrough(true);
return cacheConfig;
}
public static class CacheStoreExample extends CacheStoreAdapter<Object,
Object> {
private Map store = new HashMap();
@Override public Object load(Object key) throws CacheLoaderException
{
return store.get(key);
}
@Override public void write(Cache.Entry entry) throws
CacheWriterException {
store.put(entry.getKey(), entry.getValue());
}
@Override public void delete(Object key) throws CacheWriterException
{
store.remove(key);
}
@Override public void deleteAll(Collection<?> keys) {
System.out.println("CacheStoreExample::deleteAll(), keys.size="
+ keys.size() + " Thread=" + Thread.currentThread().getName());
for (Object k : keys)
store.remove(k);
}
}
The output is following
-----------------------------------------------------------
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=512
Thread=flusher-0-#44%test-grid%
CacheStoreExample::deleteAll(), keys.size=272
Thread=flusher-0-#44%test-grid%
[18:16:53] Ignite node stopped OK [name=test-grid, uptime=00:00:05:083]
So, all 10_000 keys were removed.
Thanks!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/