ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Mashenkov <andrey.mashen...@gmail.com>
Subject Re: Cannot create cache in EVT_CLIENT_NODE_RECONNECTED event
Date Mon, 15 May 2017 15:28:25 GMT
Hi David,

Seems, this predicate called from sensitive code and cache creation end up
with deadlock.
Try to move cache creation to separate thread.

On Mon, May 15, 2017 at 11:44 AM, David Li <david.li.sg@gmail.com> wrote:

> Hi guys,
>
> In the code snippet below, I am trying to re-create a cache after the
> client node has disconnected and reconnected to the server node, somehow
> the line of creating the cache cannot be executed, the program just hangs
> there.
>
> public static class Predicate implements IgnitePredicate<DiscoveryEvent> {
>
>     private Ignite ignite;
>     private IgniteCache<Integer, String> cache;
>
>     public Predicate(Ignite ignite, IgniteCache<Integer, String> cache) {
>         this.ignite = ignite;
>         this.cache = cache;
>     }
>
>     @Override
>     public boolean apply(DiscoveryEvent evt) {
>         // see this line in output
>         System.out.println("Received event [evt=" + evt.name() + ", type=" + evt.type());
>         if (evt.type() == EventType.EVT_CLIENT_NODE_RECONNECTED) {
>             // reinitialize all the caches
>             cache = ignite.getOrCreateCache(CACHE_NAME);  // if debug, program hangs
here
>             System.out.println("Initialised cache: " + CACHE_NAME);  // never see this
in output
>         }
>         return true;
>     }
> }
>
> Appreciate any ideas. Thanks.
>
> BRs,
>
> David
>
>
>


-- 
Best regards,
Andrey V. Mashenkov

Mime
View raw message