[ 
https://issues.apache.org/jira/browse/IGNITE-3133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15572235#comment-15572235
 ] 

Dmitriy Govorukhin commented on IGNITE-3133:
--------------------------------------------

Issue in code, because if use cache in clouse compute, cache will serialize 
too. See try { } scope.
{code:title=CacheNodeFilterExample.java|borderStyle=solid}
              ignite.compute().broadcast(new IgniteRunnable() {
                      @IgniteInstanceResource
                      Ignite ignite;

                      @Override public void run() {
                      IgniteTransactions txs = ignite.transactions();

                      try (Transaction tx = txs.txStart()) {

                        IgniteCache<Integer, Integer> cache = 
ignite.cache(RED_ONLY_CACHE);

                        cache.put(1, 2);
                        }

                        // Size must be 0 on the nodes where the cache is not 
deployed.
                        System.out.println("Red cache local size: " + 
cache.localSize());
                  }
              });;
{code}
Correct code.
{code:title=CacheNodeFilterExample.java|borderStyle=solid}
               ignite.compute().broadcast(new IgniteRunnable() {
                      @IgniteInstanceResource
                      Ignite ignite;

                      @Override public void run() {
                      IgniteTransactions txs = ignite.transactions();

                      try (Transaction tx = txs.txStart()) {

                        IgniteCache<Integer, Integer> cache = 
ignite.cache(RED_ONLY_CACHE);

                        cache.put(1, 2);

                        System.out.println("Red cache local size: " + 
cache.localSize());
                       }
                  }
              });;
{code}
           

> Unable to get a reference to a cache inside TX on a node that is filtered out 
> by a node filter
> ----------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-3133
>                 URL: https://issues.apache.org/jira/browse/IGNITE-3133
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 1.5.0.final
>            Reporter: Denis Magda
>            Assignee: Dmitriy Govorukhin
>             Fix For: 1.8
>
>         Attachments: CacheNodeFilter.java, CacheNodeFilterExample.java
>
>
> It's impossible to get a reference to a cache (Ignite.cache("name")) inside 
> of a transaction on a node that is filtered out with 
> CacheConfiguration.nodeFilter (doesn't hold cache data). The following 
> exception happens.
> {noformat}
> Caused by: java.lang.reflect.InvocationTargetException
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.apache.ignite.marshaller.optimized.OptimizedObjectInputStream.readExternalizable(OptimizedObjectInputStream.java:527)
>       ... 32 more
> Caused by: java.io.InvalidObjectException: Failed to find cache for name: 
> red_cache
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheContext.readResolve(GridCacheContext.java:2051)
>       ... 37 more
> Caused by: java.lang.IllegalStateException: Failed to find cache for name: 
> red_cache
>       at 
> org.apache.ignite.internal.processors.cache.GridCacheContext.readResolve(GridCacheContext.java:2046)
>       ... 37 more
> {noformat}
> To reproduce:
> - start ExampleNodeStartup
> - start attached CacheNodeFilterExample



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to