Refine search
@Override public void test(Factory factory, Ignite ignite) throws Exception { ignite.getOrCreateCache("test0"); ignite.getOrCreateCache("test1"); final IgniteCompute comp = ignite.compute(); for (int i = 0; i < MAX_JOB_COUNT; ++i) { IgniteRunnable job = (IgniteRunnable)factory.create(); comp.affinityRun(Arrays.asList("test0", "test1"), 0, job); } } });
static void checkListener(CaffeineConfiguration<?, ?> config) { CacheEntryListenerConfiguration<?, ?> listener = Iterables.getOnlyElement( config.getCacheEntryListenerConfigurations()); assertThat(listener.getCacheEntryListenerFactory().create(), instanceOf(TestCacheEntryListener.class)); assertThat(listener.getCacheEntryEventFilterFactory().create(), instanceOf(TestCacheEntryEventFilter.class)); assertThat(listener.isSynchronous(), is(true)); assertThat(listener.isOldValueRequired(), is(true)); }
/** {@inheritDoc} */ @Override protected IgniteClosure<CacheEntryEvent<? extends K, ? extends V>, ?> getTransformer() { if (rmtTrans == null && rmtTransFactory != null) rmtTrans = rmtTransFactory.create(); return rmtTrans; }
/** * Registers a cache entry listener based on the supplied configuration. * * @param configuration the listener's configuration. */ public void register(CacheEntryListenerConfiguration<K, V> configuration) { if (configuration.getCacheEntryListenerFactory() == null) { return; } EventTypeAwareListener<K, V> listener = new EventTypeAwareListener<>( configuration.getCacheEntryListenerFactory().create()); CacheEntryEventFilter<K, V> filter = event -> true; if (configuration.getCacheEntryEventFilterFactory() != null) { filter = new EventTypeFilter<>(listener, configuration.getCacheEntryEventFilterFactory().create()); } Registration<K, V> registration = new Registration<>(configuration, filter, listener); dispatchQueues.putIfAbsent(registration, CompletableFuture.completedFuture(null)); }
final IgniteCache cache = client.createCache(cacheConfiguration(atomicityMode, heapCache, cfgExpiryPlc)); assertEquals(data, client.compute().affinityCall(cache.getName(), 1, new GetAllClosure(data.keySet(), cache.getName(), withExpiryPlc))); assertEquals(1, client.compute().affinityCall(cache.getName(), 1, new GetClosure(1, cache.getName(), withExpiryPlc))); srvCache = srvCache.withExpiryPolicy(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES).create());
cctx.config().addCacheEntryListenerConfiguration(cfg); CacheEntryListener locLsnrImpl = (CacheEntryListener)cfg.getCacheEntryListenerFactory().create();
/** {@inheritDoc} */ @Override public Object call() throws Exception { IgniteCache cache = ignite.cache(cacheName); if (withExpiryPlc) cache = cache.withExpiryPolicy(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES).create()); Map vals = cache.getAll(keys); Collection<CacheEntry> entries = cache.getEntries(keys); assertEquals(vals.size(), entries.size()); for (CacheEntry entry : entries) { Object val = vals.get(entry.getKey()); assertEquals(val, entry.getValue()); } return vals; } }
if (!forceSrvMode && (Boolean.TRUE.equals(ignite.configuration().isClientMode()))) { if (ackTimeout == 0) ackTimeout = DFLT_ACK_TIMEOUT_CLIENT; metricsUpdateFreq = ignite.configuration().getMetricsUpdateFrequency(); SSLContext sslCtx = ignite().configuration().getSslContextFactory().create();
private void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration, boolean addToConfig) { Factory<CacheEntryListener<? super K, ? super V>> factory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory(); final CacheEntryListener<? super K, ? super V> listener = factory.create(); Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = cacheEntryListenerConfiguration.getCacheEntryEventFilterFactory(); final CacheEntryEventFilter<? super K, ? super V> filter; if (filterFactory != null) { filter = filterFactory.create(); } else { filter = null; final boolean sync = cacheEntryListenerConfiguration.isSynchronous();
@Override public void test(Factory factory, Ignite ignite) throws Exception { IgniteRunnable job = (IgniteRunnable)factory.create(); ignite.compute().run(job); // All checks are inside the run() method of the job. Collection<IgniteRunnable> jobs = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) jobs.add((IgniteRunnable)factory.create()); ignite.compute().run(jobs); // All checks are inside the run() method of the job. } });
@SuppressWarnings("unchecked") static <K, V> ListenerResources<K, V> createListenerResources(CacheEntryListenerConfiguration<K, V> listenerConfig) { CacheEntryListener<? super K, ? super V> listener = listenerConfig.getCacheEntryListenerFactory().create(); // create the filter, closing the listener above upon exception CacheEntryEventFilter<? super K, ? super V> filter; try { Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = listenerConfig .getCacheEntryEventFilterFactory(); if (filterFactory != null) { filter = listenerConfig.getCacheEntryEventFilterFactory().create(); } else { filter = event -> true; } } catch (Throwable t) { throw closeAllAfter(new CacheException(t), listener); } try { return new ListenerResources<>(listener, filter); } catch (Throwable t) { throw closeAllAfter(new CacheException(t), filter, listener); } }
private CacheEntryListener<K, V> createCacheEntryListener( CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) { Factory<CacheEntryListener<? super K, ? super V>> cacheEntryListenerFactory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory(); injectDependencies(cacheEntryListenerFactory); return (CacheEntryListener<K, V>) cacheEntryListenerFactory.create(); }
/** {@inheritDoc} */ @Override public Object call() throws Exception { IgniteCache cache = ignite.cache(cacheName); if (withExpiryPlc) cache = cache.withExpiryPolicy(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES).create()); Object val = cache.get(key); CacheEntry e = cache.getEntry(key); assertEquals(val, e.getValue()); return val; } }
boolean clientMode = Boolean.TRUE.equals(ignite.configuration().isClientMode()); new GridNioSslFilter(ignite.configuration().getSslContextFactory().create(), true, ByteOrder.nativeOrder(), log);
@Override public void test(Factory factory, Ignite ignite) throws Exception { ignite.getOrCreateCache("test0"); ignite.getOrCreateCache("test1"); final IgniteCompute comp = ignite.compute(); for (int i = 0; i < MAX_JOB_COUNT; ++i) { IgniteRunnable job = (IgniteRunnable)factory.create(); IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), 0, job); fut.get(); } } });
private void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration, boolean addToConfig) { Factory<CacheEntryListener<? super K, ? super V>> factory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory(); final CacheEntryListener<? super K, ? super V> listener = factory.create(); Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = cacheEntryListenerConfiguration.getCacheEntryEventFilterFactory(); final CacheEntryEventFilter<? super K, ? super V> filter; if (filterFactory != null) { filter = filterFactory.create(); } else { filter = null; final boolean sync = cacheEntryListenerConfiguration.isSynchronous();
@Override public void test(Factory factory, Ignite ignite) throws Exception { final Collection<Object> resultsAllNull = ignite.compute() .broadcast((IgniteClosure<Object, Object>)factory.create(), null); assertEquals("Result's size mismatch: job must be run on all server nodes", gridCount() - clientsCount(), resultsAllNull.size()); for (Object o : resultsAllNull) assertNull("All results must be null", o); Collection<Object> resultsNotNull = ignite.compute() .broadcast((IgniteClosure<Object, Object>)factory.create(), value(0)); checkResultsClassCount(gridCount() - clientsCount(), resultsNotNull, value(0).getClass()); } });
/** {@inheritDoc} */ @Override public CacheEntryEventFilter getEventFilter() { if (filter == null) { assert rmtFilterFactory != null; Factory<? extends CacheEntryEventFilter> factory = rmtFilterFactory; filter = factory.create(); if (types != 0) filter = new JCacheQueryRemoteFilter(filter, types); } return filter; }