Hi,

Looks like it is ok.

Ignite have next sync modes full_sync, primary_sync, full_Async.
You can detect failure from user thread if it happens on synchronous phase.

FULL_SYNC: cache operation return control to user thread after operation
has been applied on primary and all backups.
All exceptions occurs during operation will be propagated to user.

With primary_sync, cache operation return control to user thread after
operation has been applied on primary. Backups will be updated in async way.
Only exceptions which occurs during primary operation will be propagated to
user. Exceptions from backups will be ignored as nobody waits for backup
operation results.

With full_Ascync, cache operation return control to user thread immediately
after request has been sent to primary. All, Primary and backup will be
updates in async way.
Only exceptions, which occurs during sending request to primary node, will
be propagated to user. Others will be ignored as nobody waits for backup
operation results.



On Wed, Jun 6, 2018 at 7:24 PM, haotian.chen <haotian.c...@blackrock.com>
wrote:

> 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/
>



-- 
Best regards,
Andrey V. Mashenkov

Reply via email to