use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteCacheClientNearCacheExpiryTest method testExpirationOnClient.
/**
* @throws Exception If failed.
*/
public void testExpirationOnClient() throws Exception {
Ignite ignite = grid(NODES - 1);
assertTrue(ignite.configuration().isClientMode());
IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME);
assertTrue(((IgniteCacheProxy) cache).context().isNear());
for (int i = 0; i < KEYS_COUNT; i++) cache.put(i, i);
CreatedExpiryPolicy plc = new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, 500));
IgniteCache<Object, Object> cacheWithExpiry = cache.withExpiryPolicy(plc);
for (int i = KEYS_COUNT; i < KEYS_COUNT * 2; i++) {
cacheWithExpiry.put(i, i);
assertEquals(i, cacheWithExpiry.localPeek(i));
}
U.sleep(1000);
// Check size of near entries via reflection because entries is filtered for size() API call.
IgniteEx igniteEx = (IgniteEx) ignite;
GridCacheConcurrentMap map = GridTestUtils.getFieldValue(((GridCacheProxyImpl) igniteEx.cachex(DEFAULT_CACHE_NAME)).delegate(), GridCacheAdapter.class, "map");
assertEquals(KEYS_COUNT, map.publicSize());
assertEquals(KEYS_COUNT, cache.size());
for (int i = 0; i < KEYS_COUNT; i++) assertEquals(i, cacheWithExpiry.localPeek(i));
for (int i = KEYS_COUNT; i < KEYS_COUNT * 2; i++) assertNull(cache.localPeek(i));
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgfsAbstractBaseSelfTest method getMetaCache.
/**
* Gets meta cache.
*
* @param igfs The IGFS instance.
* @return The data cache.
*/
protected static GridCacheAdapter<IgniteUuid, IgfsEntryInfo> getMetaCache(IgniteFileSystem igfs) {
String dataCacheName = igfs.configuration().getMetaCacheConfiguration().getName();
IgniteEx igniteEx = ((IgfsEx) igfs).context().kernalContext().grid();
return ((IgniteKernal) igniteEx).internalCache(dataCacheName);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgfsAbstractBaseSelfTest method getDataCache.
/**
* Gets the data cache instance for this IGFS instance.
*
* @param igfs The IGFS unstance.
* @return The data cache.
*/
protected static GridCacheAdapter<IgfsBlockKey, byte[]> getDataCache(IgniteFileSystem igfs) {
String dataCacheName = igfs.configuration().getDataCacheConfiguration().getName();
IgniteEx igniteEx = ((IgfsEx) igfs).context().kernalContext().grid();
return ((IgniteKernal) igniteEx).internalCache(dataCacheName);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class GridQueryParsingTest method connection.
/**
*
*/
private JdbcConnection connection() throws Exception {
GridKernalContext ctx = ((IgniteEx) ignite).context();
GridQueryProcessor qryProcessor = ctx.query();
IgniteH2Indexing idx = U.field(qryProcessor, "idx");
String schemaName = idx.schema(DEFAULT_CACHE_NAME);
return (JdbcConnection) idx.connectionForSchema(schemaName);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class CacheLoadingConcurrentGridStartSelfTest method loadCacheWithDataStreamerSequential.
/**
* @throws Exception if failed
*/
private void loadCacheWithDataStreamerSequential() throws Exception {
startGrid(1);
Ignite g0 = startGrid(0);
IgniteInternalFuture<Object> restartFut = runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
while (restarts) {
stopGrid(1);
startGrid(1);
U.sleep(100);
}
return null;
}
});
IgniteInternalFuture<Object> fut = runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
for (int i = 2; i < GRIDS_CNT; i++) startGrid(i);
return null;
}
});
final HashSet<IgniteFuture> set = new HashSet<>();
IgniteInClosure<Ignite> f = new IgniteInClosure<Ignite>() {
@Override
public void apply(Ignite grid) {
try (IgniteDataStreamer<Integer, String> dataStreamer = grid.dataStreamer(DEFAULT_CACHE_NAME)) {
dataStreamer.allowOverwrite(allowOverwrite);
for (int i = 0; i < KEYS_CNT; i++) {
set.add(dataStreamer.addData(i, "Data"));
if (i % 100000 == 0)
log.info("Streaming " + i + "'th entry.");
}
}
}
};
f.apply(g0);
log.info("Data loaded.");
restarts = false;
fut.get();
restartFut.get();
for (IgniteFuture res : set) assertNull(res.get());
IgniteCache<Integer, String> cache = grid(0).cache(DEFAULT_CACHE_NAME);
long size = cache.size(CachePeekMode.PRIMARY);
if (size != KEYS_CNT) {
Set<Integer> failedKeys = new LinkedHashSet<>();
for (int i = 0; i < KEYS_CNT; i++) if (!cache.containsKey(i)) {
log.info("Actual cache size: " + size);
for (Ignite ignite : G.allGrids()) {
IgniteEx igniteEx = (IgniteEx) ignite;
log.info("Missed key info:" + igniteEx.localNode().id() + " primary=" + ignite.affinity(DEFAULT_CACHE_NAME).isPrimary(igniteEx.localNode(), i) + " backup=" + ignite.affinity(DEFAULT_CACHE_NAME).isBackup(igniteEx.localNode(), i) + " local peek=" + ignite.cache(DEFAULT_CACHE_NAME).localPeek(i, CachePeekMode.ONHEAP));
}
for (int j = i; j < i + 10000; j++) {
if (!cache.containsKey(j))
failedKeys.add(j);
}
break;
}
assert failedKeys.isEmpty() : "Some failed keys: " + failedKeys.toString();
}
assertCacheSize();
}
Aggregations