Hi,

Currently you have to make a copy of BinaryObject for each cache operation
because it's not immutable and internally caches some information for
performance reasons.

Do you have a real case then you need to put a lot of binary object keys to
multiple caches?

BTW, if you are using BinaryObject key with only single standard java type
it's simpler to just use the type as a cache key.

2016-07-18 16:07 GMT+03:00 pragmaticbigdata <[email protected]>:

> I am using ignite version 1.6. In my use case I have two caches with the
> below configuration
>
>         CacheConfiguration<BinaryObject, BinaryObject> cfg1 = new
> CacheConfiguration<>("Cache 1");
>         cfg1.setCacheMode(CacheMode.PARTITIONED);
>         cfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>
>         IgniteCache<BinaryObject, BinaryObject> cache1 =
> ignite.getOrCreateCache(cfg1).withKeepBinary();
>
>         CacheConfiguration<BinaryObject, BinaryObject> cfg2 = new
> CacheConfiguration<>("Cache 2");
>         cfg2.setCacheMode(CacheMode.REPLICATED);
>
> cfg2.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
> //using the default PRIMARY_SYNC write synchronization works fine
>         IgniteCache<BinaryObject, BinaryObject> cache2 =
> ignite.getOrCreateCache(cfg2);
>
>
> When adding a BinaryObject to the second cache, Ignite *fails when calling
> cache2.put()*. The code to add data to the cache is
>
>             BinaryObjectBuilder keyBuilder =
> ignite.binary().builder("keyType")
>                     .setField("F1", "V1").hashCode("V1".hashCode());
>
>             BinaryObjectBuilder valueBuilder =
> ignite.binary().builder("valueType)
>                     .setField("F2", "V2")
>                     .setField("F3", "V3");
>
>             BinaryObject key = keyBuilder.build();
>             BinaryObject value = valueBuilder.build();
>
>             cache1.put(key, value);
>             cache2.put(key, value);
>
> If FULL_SYNC write synchronization is turned off (default PRIMARY_SYNC),
> the
> write works fine. Also if a copy of the BinaryObject is made before adding
> to cache2, the put method succeeds. Can someone have a look and let me know
> what could be missing?
>
> The exception is as below.
>
> java.lang.AssertionError: Affinity partition is out of range [part=667,
> partitions=512]
>         at
>
> org.apache.ignite.internal.processors.affinity.GridAffinityAssignment.get(GridAffinityAssignment.java:149)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.nodes(GridDhtPartitionTopologyImpl.java:827)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateFuture.mapKey(GridNearAtomicUpdateFuture.java:1031)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateFuture.mapUpdate(GridNearAtomicUpdateFuture.java:867)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateFuture.map(GridNearAtomicUpdateFuture.java:689)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateFuture.mapOnTopology(GridNearAtomicUpdateFuture.java:544)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFuture.java:202)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$22.apply(GridDhtAtomicCache.java:1007)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$22.apply(GridDhtAtomicCache.java:1005)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.asyncOp(GridDhtAtomicCache.java:703)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAsync0(GridDhtAtomicCache.java:1005)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.putAsync0(GridDhtAtomicCache.java:475)
>         at
>
> org.apache.ignite.internal.processors.cache.GridCacheAdapter.putAsync(GridCacheAdapter.java:2506)
>         at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put(GridDhtAtomicCache.java:452)
>         at
>
> org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2180)
>         at
>
> org.apache.ignite.internal.processors.cache.IgniteCacheProxy.put(IgniteCacheProxy.java:1165)
>
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Adding-a-binary-object-to-two-caches-fails-with-FULL-SYNC-write-mode-configured-for-the-replicated-ce-tp6343.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>



-- 

Best regards,
Alexei Scherbakov

Reply via email to