use of org.apache.ignite.lang.IgniteOutClosure in project ignite by apache.
the class IgniteIndexReaderFilePageStoreFactoryImpl method headerBuffer.
/**
* {@inheritDoc}
*/
@Override
public ByteBuffer headerBuffer(byte type) throws IgniteCheckedException {
int ver = storeFactory.latestVersion();
FilePageStore store = (FilePageStore) storeFactory.createPageStore(type, (IgniteOutClosure<Path>) null, allocationTracker::add);
return store.header(type, storeFactory.headerSize(ver));
}
use of org.apache.ignite.lang.IgniteOutClosure in project ignite by apache.
the class IgniteCacheContinuousQueryClientTest method testServerNodeLeft.
/**
* @throws Exception If failed.
*/
@Test
public void testServerNodeLeft() throws Exception {
startGrids(3);
final int CLIENT_ID = 3;
Ignite clnNode = startClientGrid(CLIENT_ID);
IgniteOutClosure<IgniteCache<Integer, Integer>> rndCache = new IgniteOutClosure<IgniteCache<Integer, Integer>>() {
int cnt = 0;
@Override
public IgniteCache<Integer, Integer> apply() {
++cnt;
return grid(CLIENT_ID).cache(DEFAULT_CACHE_NAME);
}
};
final CacheEventListener lsnr = new CacheEventListener();
ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();
qry.setLocalListener(lsnr);
QueryCursor<?> cur = clnNode.cache(DEFAULT_CACHE_NAME).query(qry);
boolean first = true;
int keyCnt = 1;
for (int i = 0; i < 10; i++) {
log.info("Start iteration: " + i);
if (first)
first = false;
else {
for (int srv = 0; srv < CLIENT_ID - 1; srv++) startGrid(srv);
}
lsnr.latch = new CountDownLatch(keyCnt);
for (int key = 0; key < keyCnt; key++) rndCache.apply().put(key, key);
assertTrue("Failed to wait for event. Left events: " + lsnr.latch.getCount(), lsnr.latch.await(10, SECONDS));
for (int srv = 0; srv < CLIENT_ID - 1; srv++) stopGrid(srv);
}
tryClose(cur);
}
use of org.apache.ignite.lang.IgniteOutClosure in project ignite by apache.
the class BPlusTreePageMemoryImplTest method createPageMemory.
/**
* {@inheritDoc}
*/
@Override
protected PageMemory createPageMemory() throws Exception {
long[] sizes = new long[CPUS + 1];
for (int i = 0; i < sizes.length; i++) sizes[i] = 1024 * MB / CPUS;
sizes[CPUS] = 10 * MB;
DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setEncryptionSpi(new NoopEncryptionSpi());
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
cfg.setDataStorageConfiguration(new DataStorageConfiguration());
GridTestKernalContext cctx = new GridTestKernalContext(log, cfg);
cctx.add(new IgnitePluginProcessor(cctx, cfg, Collections.emptyList()));
cctx.add(new GridInternalSubscriptionProcessor(cctx));
cctx.add(new PerformanceStatisticsProcessor(cctx));
cctx.add(new GridEncryptionManager(cctx));
cctx.add(new GridMetricManager(cctx));
cctx.add(new GridSystemViewManager(cctx));
GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(cctx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, new CacheDiagnosticManager());
IgniteOutClosure<CheckpointProgress> clo = new IgniteOutClosure<CheckpointProgress>() {
@Override
public CheckpointProgress apply() {
return Mockito.mock(CheckpointProgressImpl.class);
}
};
PageMemory mem = new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement should happen during the test";
}, new CIX3<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long aLong, FullPageId fullPageId, PageMemoryEx ex) {
}
}, () -> true, new DataRegionMetricsImpl(new DataRegionConfiguration(), cctx), PageMemoryImpl.ThrottlingPolicy.DISABLED, clo);
mem.start();
return mem;
}
use of org.apache.ignite.lang.IgniteOutClosure in project ignite by apache.
the class BPlusTreeReuseListPageMemoryImplTest method createPageMemory.
/**
* {@inheritDoc}
*/
@Override
protected PageMemory createPageMemory() throws Exception {
long[] sizes = new long[CPUS + 1];
for (int i = 0; i < sizes.length; i++) sizes[i] = 1024 * MB / CPUS;
sizes[CPUS] = 10 * MB;
DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setEncryptionSpi(new NoopEncryptionSpi());
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
cfg.setDataStorageConfiguration(new DataStorageConfiguration());
GridTestKernalContext cctx = new GridTestKernalContext(log, cfg);
cctx.add(new IgnitePluginProcessor(cctx, cfg, Collections.emptyList()));
cctx.add(new GridInternalSubscriptionProcessor(cctx));
cctx.add(new PerformanceStatisticsProcessor(cctx));
cctx.add(new GridEncryptionManager(cctx));
cctx.add(new GridMetricManager(cctx));
cctx.add(new GridSystemViewManager(cctx));
GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(cctx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, null);
IgniteOutClosure<CheckpointProgress> clo = new IgniteOutClosure<CheckpointProgress>() {
@Override
public CheckpointProgress apply() {
return Mockito.mock(CheckpointProgressImpl.class);
}
};
PageMemory mem = new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement (rotation with disk) should happen during the test";
}, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long page, FullPageId fullPageId, PageMemoryEx pageMem) {
}
}, () -> true, new DataRegionMetricsImpl(new DataRegionConfiguration(), cctx), PageMemoryImpl.ThrottlingPolicy.DISABLED, clo);
mem.start();
return mem;
}
use of org.apache.ignite.lang.IgniteOutClosure in project ignite by apache.
the class CacheContinuousQueryFailoverAbstractSelfTest method testStartStopQuery.
/**
* @throws Exception If failed.
*/
@Test
public void testStartStopQuery() throws Exception {
this.backups = 1;
final int SRV_NODES = 3;
startGridsMultiThreaded(SRV_NODES);
final Ignite qryClient = startClientGrid(SRV_NODES);
IgniteCache<Object, Object> clnCache = qryClient.cache(DEFAULT_CACHE_NAME);
IgniteOutClosure<IgniteCache<Integer, Integer>> rndCache = new IgniteOutClosure<IgniteCache<Integer, Integer>>() {
int cnt = 0;
@Override
public IgniteCache<Integer, Integer> apply() {
++cnt;
return grid(cnt % SRV_NODES + 1).cache(DEFAULT_CACHE_NAME);
}
};
Ignite igniteSrv = ignite(0);
IgniteCache<Object, Object> srvCache = igniteSrv.cache(DEFAULT_CACHE_NAME);
List<Integer> keys = testKeys(srvCache, 3);
int keyCnt = keys.size();
for (int j = 0; j < 50; ++j) {
ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();
final CacheEventListener3 lsnr = asyncCallback() ? new CacheEventAsyncListener3() : new CacheEventListener3();
qry.setLocalListener(lsnr);
qry.setRemoteFilter(lsnr);
int keyIter = 0;
for (; keyIter < keyCnt / 2; keyIter++) {
int key = keys.get(keyIter);
rndCache.apply().put(key, key);
}
assert lsnr.evts.isEmpty();
QueryCursor<Cache.Entry<Object, Object>> qryCur = clnCache.query(qry);
Map<Object, T2<Object, Object>> updates = new HashMap<>();
final List<T3<Object, Object, Object>> expEvts = new ArrayList<>();
Affinity<Object> aff = affinity(srvCache);
boolean filtered = false;
for (; keyIter < keys.size(); keyIter++) {
int key = keys.get(keyIter);
int val = filtered ? 1 : 2;
log.info("Put [key=" + key + ", val=" + val + ", part=" + aff.partition(key) + ']');
T2<Object, Object> t = updates.get(key);
if (t == null) {
// Check filtered.
if (!filtered) {
updates.put(key, new T2<>((Object) val, null));
expEvts.add(new T3<>((Object) key, (Object) val, null));
}
} else {
// Check filtered.
if (!filtered) {
updates.put(key, new T2<>((Object) val, (Object) t.get1()));
expEvts.add(new T3<>((Object) key, (Object) val, (Object) t.get1()));
}
}
rndCache.apply().put(key, val);
filtered = !filtered;
}
checkEvents(expEvts, lsnr, false);
qryCur.close();
}
}
Aggregations