I need to add that in the next scenario AffinityImpl will be used (not
AffinityProxy) and the code throws NPE too.

ignite.getOrCreateCache(new CacheConfiguration("myCache"));

Affinity<Object> affinity = ignite.affinity("myCache");

affinity.mapPartitionToNode(0); // All ok.

ignite2.cache("myCache").destroy();

affinity.mapPartitionToNode(0); // NPE.

This case looks like an exception for me, so I need to change my opinion
and I vote for throwing a special exception if cache does not exists.

-- Artem --

On Thu, Nov 12, 2015 at 4:01 PM, Artem Shutak <[email protected]> wrote:

> Igniters,
>
> I'm working on https://issues.apache.org/jira/browse/IGNITE-1355.
>
> I want to hear a community opinion what should do Ignite in case when user
> uses Affinity for nonexistent cache? Current implementation returns
> AffinityProxy on a call of Ignite.affinity("nonexistent_cache") and
> AffinityProxy throws NPE on a call of any method if cache has not been
> created yet.
>
> I see next possible decisions:
> - Ignite.affinity("nonexistent_cache") can return 'null' instead of
> AffinityProxy like Ignite does it for Ignite.cache("nonexistent_cache").
> But it breaks backward compatibility.
> - AffinityProxy methods can return a special value like 0 for
> 'partitions()' method  and empty array for 'primaryPartitions(ClusterNode)'
> method.
> - AffinityProxy methods can throw Exception that cache does not exist.
>
> I vote for the second one.
>
> Thoughts?
>
> Thanks,
> -- Artem --
>

Reply via email to