/** {@inheritDoc} */ @Override public IgniteEvents events() { checkIgnite(); return g.events(); }
/** {@inheritDoc} */ @Override public IgniteEvents events(ClusterGroup grp) { checkIgnite(); return g.events(grp); }
/** * @param ignite Grid to remove listeners from. */ private void removeListeners(Ignite ignite) { for (IgnitePredicate<Event> lsnr : lsnrs) ignite.events().stopLocalListen(lsnr); }
@Override public Boolean apply(Object o) { UUID remoteId = (UUID)o; assertNotNull(remoteId); client.events().stopRemoteListen(remoteId); return true; } }
/** * Stops the remote listener. */ protected void stopRemoteListen() { if (rmtLsnrId != null) IgniteGrid.getIgnite().events(IgniteGrid.getIgnite().cluster().forCacheNodes(cacheName)) .stopRemoteListen(rmtLsnrId); rmtLsnrId = null; }
/** * @param ignite Grid to remove listeners from. */ private void removeListeners(Ignite ignite) { if (ignite != null) for (CacheEventListener lsnr : lsnrs) { assert lsnr.latch.getCount() == 0; ignite.events().stopLocalListen(lsnr); } }
/** * * @param ignite Grid. * @param lsnr Listener. * @param type Event types. */ private void addListener(Ignite ignite, CacheEventListener lsnr, int... type) { if (!lsnrs.contains(lsnr)) lsnrs.add(lsnr); ignite.events().localListen(lsnr, type.length == 0 ? EVTS_CACHE : type); }
/** {@inheritDoc} */ @Override public void cancel() { synchronized (this) { if (!isRunning) return; isRunning = false; if (rmtLsnrId != null && ignite != null) { ignite.events(ignite.cluster().forCacheNodes(cacheName)) .stopRemoteListen(rmtLsnrId); rmtLsnrId = null; } } }
/** * @param prj Projection. * @return {@link org.apache.ignite.IgniteMessaging} for given projection. */ protected IgniteEvents events(ClusterGroup prj) { return prj.ignite().events(prj); }
/** * @param g Grid. * @return Enabled events. */ private int[] getEnabledEvents(Ignite g) { return g.events().enabledEvents(); }
/** * @param ignite Grid * @param lsnr Listener. */ void addListener(Ignite ignite, IgnitePredicate<Event> lsnr) { if (!lsnrs.contains(lsnr)) lsnrs.add(lsnr); ignite.events().localListen(lsnr, EVTS_CACHE); }
/** {@inheritDoc} */ @Override public void run() { ignite.events().localListen(lsnr, types); } }
/** * @param execId Execution ID. */ private void checkTimedOutEvents(final IgniteUuid execId) { Ignite ignite = G.ignite(getTestIgniteInstanceName()); Collection<Event> evts = ignite.events().localQuery(new PE() { @Override public boolean apply(Event evt) { return ((TaskEvent) evt).taskSessionId().equals(execId); } }, EVT_TASK_TIMEDOUT); assert evts.size() == 1 : "Invalid number of timed out tasks: " + evts.size(); }
/** * @throws Exception Thrown in case of any errors. */ @Test public void testRemoveDiscoveryListener() throws Exception { try { ignite.events().stopLocalListen(null); assert false : "Null listener can't be removed."; } catch (NullPointerException ignored) { // No-op. } }
/** * @throws Exception Thrown in case of any errors. */ @Test public void testAddEventLocalListener() throws Exception { try { ignite.events().localListen(null, EVTS_ALL); assert false : "Null listener can't be added."; } catch (NullPointerException ignored) { // No-op. } }
/** * @throws Exception Thrown in case of any errors. */ @Test public void testRemoveEventLocalListener() throws Exception { try { ignite.events().stopLocalListen(null); assert false : "Null listener can't be removed."; } catch (NullPointerException ignored) { // No-op. } }
/** * @throws Exception Thrown in case of any errors. */ @Test public void testAddDiscoveryListener() throws Exception { try { ignite.events().localListen(null, EVTS_ALL); assert false : "Null listener can't be added."; } catch (NullPointerException ignored) { // No-op. } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { for (int i = 0; i < PERM_NODES_CNT; i++) { Ignite g = startGrid(gridCntr++); g.events().localListen(lsnr, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED); alive.add(g); } for (int i = 0; i < PERM_NODES_CNT + TMP_NODES_CNT; i++) F.rand(alive).cache(DEFAULT_CACHE_NAME).put(i, String.valueOf(i)); }
/** * Starts temporary nodes. * * @throws Exception If failed. */ private void startTempNodes() throws Exception { for (int j = 0; j < TMP_NODES_CNT; j++) { Ignite newNode = startGrid(gridCntr++); info("New node started: " + newNode.name()); alive.add(newNode); newNode.events().localListen(lsnr, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED); } }
/** * */ public void register() { ignite().events().localListen(this.delegate, this.causes); sync(); }