Hi Andrew,
Thanks a lot for the response!
While reproducing the case, I found that: If I set
CacheWriteSynchronizatoinMode to FULL_ASYNC, EntryProcessorException is
ignored. But if I set it PRIMARY_SYNC, then the EntryProcessorException will
be thrown.
Is it intentional that under FULL_ASYNC the exception will be ignored?
Should it be that Exception will be thrown when the CacheEntryProcessor
eventually ran?
Here is the sample code:
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.*;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
public class Main {
public static void main(String[] args) {
class IncrementOddEntryProcessor implements
CacheEntryProcessor<String, Integer, Object> {
public Object process(MutableEntry<String, Integer> entry,
Object... arguments) throws EntryProcessorException {
Integer value = entry.getValue();
if (value % 2 == 0) {
throw new EntryProcessorException("can't operates on
even number");
} else {
entry.setValue(value + 1);
return null;
}
}
}
IgniteConfiguration igniteCfg = new IgniteConfiguration()
.setGridLogger(new Slf4jLogger())
.setIgniteInstanceName("testinstance");
Ignite ignite = Ignition.getOrStart(igniteCfg);
try {
CacheConfiguration<String, Integer> cacheCfg = new
CacheConfiguration<String, Integer>()
.setName("testcache")
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setRebalanceMode(CacheRebalanceMode.ASYNC)
.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC)
.setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_SAFE);
IgniteCache<String, Integer> cache =
ignite.createCache(cacheCfg);
cache.put("1", 1);
cache.put("2", 2);
cache.invoke("1", new IncrementOddEntryProcessor());
cache.invoke("2", new IncrementOddEntryProcessor());
System.out.println(cache.get("1"));
System.out.println(cache.get("2"));
} finally {
ignite.close();
}
}
}
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/