You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by "Alexei Scherbakov (JIRA)" <ji...@apache.org> on 2016/07/19 10:52:20 UTC
[jira] [Created] (IGNITE-3505) BinaryObject keys can't be reused
because of partition caching.
Alexei Scherbakov created IGNITE-3505:
-----------------------------------------
Summary: BinaryObject keys can't be reused because of partition caching.
Key: IGNITE-3505
URL: https://issues.apache.org/jira/browse/IGNITE-3505
Project: Ignite
Issue Type: Bug
Affects Versions: 1.6
Reporter: Alexei Scherbakov
Assignee: Denis Magda
Fix For: 1.7
BinaryObject can't be reused as key between caches because it's
actual implementation BinaryObjectImpl implements KeyCacheObject and
due to the fact caches partition, which is not recalculated later.
See org.apache.ignite.internal.processors.cache.GridCacheAffinityManager.partition:
{code}
if (key instanceof KeyCacheObject && ((KeyCacheObject)key).partition() != -1)
return ((KeyCacheObject)key).partition();
{code}
The issue can be reproduced with the following code:
{code}
public static void main(String[] args) throws IgniteException {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(new TcpDiscoveryVmIpFinder(true)));
Ignite ignite = Ignition.start(cfg);
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);
IgniteCache<BinaryObject, BinaryObject> cache2 =
ignite.getOrCreateCache(cfg2);
BinaryObjectBuilder keyBuilder = ignite.binary().builder("keyType")
.setField("F1", "V1").hashCode("V1".hashCode());
BinaryObjectBuilder valBuilder = ignite.binary().builder("valueType")
.setField("F2", "V2")
.setField("F3", "V3");
BinaryObject key = keyBuilder.build();
BinaryObject val = valBuilder.build();
cache1.put(key, val);
cache2.put(key, val); // error
System.out.println(cache1.get(key)); // error
System.out.println(cache2.get(key));
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)