/** * @param ignite Node. * @param joinEvtCnt Expected events number. * @return Events latch. */ private CountDownLatch expectJoinEvents(Ignite ignite, int joinEvtCnt) { final CountDownLatch latch = new CountDownLatch(joinEvtCnt); ignite.events().remoteListen(new IgniteBiPredicate<UUID, Event>() { @Override public boolean apply(UUID uuid, Event evt) { latch.countDown(); return true; } }, null, EventType.EVT_NODE_JOINED); return latch; } }
@Override public Object call() throws Exception { boolean failed = false; try { client.events().remoteListen(null, new IgnitePredicate<Event>() { @Override public boolean apply(Event event) { return true; } }); } catch (IgniteClientDisconnectedException e) { failed = true; checkAndWait(e); } assertTrue(failed); return client.events().remoteListen(null, new IgnitePredicate<Event>() { @Override public boolean apply(Event event) { return true; } }); } },
/** * Starts Ignite source. * * @param filter User defined filter. * @param cacheEvts Converts comma-delimited cache events strings to Ignite internal representation. */ @SuppressWarnings("unchecked") public void start(IgnitePredicate<CacheEvent> filter, int... cacheEvts) { A.notNull(cacheName, "Cache name"); TaskRemoteFilter rmtLsnr = new TaskRemoteFilter(cacheName, filter); try { synchronized (this) { if (isRunning) return; isRunning = true; rmtLsnrId = ignite.events(ignite.cluster().forCacheNodes(cacheName)) .remoteListen(locLsnr, rmtLsnr, cacheEvts); } } catch (IgniteException e) { log.error("Failed to register event listener!", e); throw e; } }
client.events().remoteListen( new IgniteBiPredicate<UUID, Event>() { @Override public boolean apply(UUID uuid, Event event) { srv.events().remoteListen( new IgniteBiPredicate<UUID, Event>() { @Override public boolean apply(UUID uuid, Event event) {
/** * @throws Exception If test failed. */ private void testExternalClassesAtEvent0(boolean p2p) throws Exception { try { useExtClassLoader = true; cutromEvt = true; if (p2p) disableP2p = true; final Class cls = (Class)getExternalClassLoader(). loadClass("org.apache.ignite.tests.p2p.CacheDeploymentExternalizableTestValue"); final Class cls2 = (Class)getExternalClassLoader(). loadClass("org.apache.ignite.tests.p2p.GridEventConsumeFilter"); Ignite g1 = startGrid(1); startGrid(2); latch = new CountDownLatch(3); g1.events().localListen((IgnitePredicate)cls2.newInstance(), EVT_CACHE_OBJECT_PUT); g1.events().localListen(new EventListener(), EVT_CACHE_OBJECT_PUT); g1.events().remoteListen(null, (IgnitePredicate)cls2.newInstance(), EVT_CACHE_OBJECT_PUT); g1.events().remoteListen(null, new EventListener(), EVT_CACHE_OBJECT_PUT); g1.cache(DEFAULT_CACHE_NAME).put("1", cls.newInstance()); latch.await(); } finally { useExtClassLoader = false; cutromEvt = false; if (p2p) disableP2p = false; } }
final CountDownLatch latch = new CountDownLatch(GRID_CNT); UUID consumeId = grid(0).events().remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
final CountDownLatch latch = new CountDownLatch(1); UUID consumeId = grid(0).events().remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
final CountDownLatch latch = new CountDownLatch(GRID_CNT); UUID consumeId = grid(0).events().remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
final CountDownLatch latch = new CountDownLatch(GRID_CNT); UUID consumeId = grid(0).events().remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
final CountDownLatch latch = new CountDownLatch(GRID_CNT - 1); UUID consumeId = events(grid(0).cluster().forRemotes()).remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
/** * @param ignite Node. * @param cache Cache. * @param async Use async API. * @param oldAsync Use old async API. * @throws Exception If failed. */ private void doTransformResourceInjection(Ignite ignite, IgniteCache<String, Integer> cache, boolean async, boolean oldAsync) throws Exception { final Collection<ResourceType> required = Arrays.asList(ResourceType.IGNITE_INSTANCE, ResourceType.CACHE_NAME, ResourceType.LOGGER); final CacheEventListener lsnr = new CacheEventListener(); IgniteEvents evts = ignite.events(ignite.cluster()); UUID opId = evts.remoteListen(lsnr, null, EventType.EVT_CACHE_OBJECT_READ); try { checkResourceInjectionOnInvoke(cache, required, async, oldAsync); checkResourceInjectionOnInvokeAll(cache, required, async, oldAsync); checkResourceInjectionOnInvokeAllMap(cache, required, async, oldAsync); } finally { evts.stopRemoteListen(opId); } }
final CountDownLatch latch = new CountDownLatch(GRID_CNT - 1); UUID consumeId = events(grid(0).cluster().forAttribute("include", null)).remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); startGridsMultiThreaded(3); Ignition.setClientMode(true); try { Ignite ignite = startGrid("client"); ignite.events().remoteListen( new IgniteBiPredicate<UUID, Event>() { @Override public boolean apply(UUID uuid, Event evt) { return true; } }, new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { throw new NoClassDefFoundError("XXX"); } }, EventType.EVT_CACHE_OBJECT_PUT ); } finally { Ignition.setClientMode(false); } }
final CountDownLatch latch = new CountDownLatch(1); UUID consumeId = grid(0).events().remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
g.events().remoteListen( null, new P1<Event>() {
final CountDownLatch latch = new CountDownLatch(GRID_CNT); UUID consumeId = events(grid(0).cluster().forAttribute("include", null)).remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
final CountDownLatch latch = new CountDownLatch(1); UUID consumeId = events(grid(0).cluster().forLocal()).remoteListen( new P2<UUID, Event>() { @Override public boolean apply(UUID nodeId, Event evt) {
UUID opId = client.events().remoteListen(lsnr, null, EventType.EVT_JOB_STARTED);
/** * Checks that starting query not blocking by updating metadata. * * @throws Exception If failed. */ @Test public void testStartQueryOnMetadataUpdate() throws Exception { Ignite srv1 = startGrid(0); Ignite srv2 = startGrid(1); IgniteInternalFuture fut1 = GridTestUtils.runAsync(() -> { for (int i = 0; i < 5; i++) srv1.events().remoteListen(null, new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { return true; } }); }); IgniteInternalFuture fut2 = GridTestUtils.runAsync(() -> { for (int i = 0; i < 5; i++) srv2.compute().call(new IgniteCallable<Object>() { @Override public Object call() { return null; } }); }); fut1.get(); fut2.get(); }
/** * */ private void check(boolean loc) throws Exception { Ignite ignite = startGrids(5); final IgniteEvents evts = loc ? ignite.events() : grid(3).events(); if (loc) evts.localListen((IgnitePredicate<Event>)e -> { assert e instanceof TransactionStateChangedEvent; checkEvent((TransactionStateChangedEvent)e); return true; }, EVTS_TX); else evts.remoteListen(null, (IgnitePredicate<Event>)e -> { assert e instanceof TransactionStateChangedEvent; checkEvent((TransactionStateChangedEvent)e); return false; }, EVTS_TX); IgniteTransactions txs = ignite.transactions(); IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(getCacheConfig()); checkCommit(txs, cache); if (!MvccFeatureChecker.forcedMvcc()) checkSuspendResume(txs, cache); checkRollback(txs, cache); }