use of org.apache.ignite.IgniteCache in project ignite by apache.
the class IgniteVariousConnectionNumberTest method runOperations.
/**
* @param time Execution time.
* @throws Exception If failed.
*/
private void runOperations(final long time) throws Exception {
final AtomicInteger idx = new AtomicInteger();
GridTestUtils.runMultiThreaded(new Callable<Void>() {
@Override
public Void call() throws Exception {
Ignite node = ignite(idx.getAndIncrement() % NODES);
IgniteCache cache = node.cache(DEFAULT_CACHE_NAME);
long stopTime = U.currentTimeMillis() + time;
ThreadLocalRandom rnd = ThreadLocalRandom.current();
while (U.currentTimeMillis() < stopTime) {
cache.put(rnd.nextInt(10_000), 0);
node.compute().broadcast(new DummyJob());
}
return null;
}
}, NODES * 10, "test-thread");
}
use of org.apache.ignite.IgniteCache in project ignite by apache.
the class GridCacheGetAndTransformStoreAbstractTest method testGetAndTransform.
/**
* @throws Exception If failed.
*/
public void testGetAndTransform() throws Exception {
final AtomicBoolean finish = new AtomicBoolean();
try {
startGrid(0);
startGrid(1);
startGrid(2);
final Processor entryProcessor = new Processor();
IgniteInternalFuture<?> fut = multithreadedAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
IgniteCache<Integer, String> c = jcache(ThreadLocalRandom.current().nextInt(3));
while (!finish.get() && !Thread.currentThread().isInterrupted()) {
c.get(ThreadLocalRandom.current().nextInt(100));
c.put(ThreadLocalRandom.current().nextInt(100), "s");
c.invoke(ThreadLocalRandom.current().nextInt(100), entryProcessor);
}
return null;
}
}, 20);
Thread.sleep(15_000);
finish.set(true);
fut.get();
} finally {
stopGrid(0);
stopGrid(1);
stopGrid(2);
while (jcache().localSize() != 0) jcache().clear();
}
}
use of org.apache.ignite.IgniteCache in project ignite by apache.
the class CacheClientStoreSelfTest method testReplicatedLoadFromClient.
/**
* Load cache created on client as REPLICATED and see if it only loaded on servers
*/
public void testReplicatedLoadFromClient() throws Exception {
cacheMode = CacheMode.REPLICATED;
factory = new Factory3();
startGrids(2);
Ignite client = startGrid("client-1");
IgniteCache cache = client.cache(CACHE_NAME);
cache.loadCache(null);
assertEquals(0, cache.localSize(CachePeekMode.ALL));
assertEquals(10, grid(0).cache(CACHE_NAME).localSize(CachePeekMode.ALL));
assertEquals(10, grid(1).cache(CACHE_NAME).localSize(CachePeekMode.ALL));
assert !loadedFromClient : "Loaded data from client!";
}
use of org.apache.ignite.IgniteCache in project ignite by apache.
the class CacheClientStoreSelfTest method testPartitionedLoadFromClient.
/**
* Load cache created on client as REPLICATED and see if it only loaded on servers
*/
public void testPartitionedLoadFromClient() throws Exception {
cacheMode = CacheMode.PARTITIONED;
factory = new Factory3();
startGrids(2);
Ignite client = startGrid("client-1");
IgniteCache cache = client.cache(CACHE_NAME);
cache.loadCache(null);
assertEquals(0, cache.localSize(CachePeekMode.ALL));
assertEquals(10, grid(0).cache(CACHE_NAME).localSize(CachePeekMode.ALL));
assertEquals(10, grid(1).cache(CACHE_NAME).localSize(CachePeekMode.ALL));
assert !loadedFromClient : "Loaded data from client!";
}
use of org.apache.ignite.IgniteCache in project ignite by apache.
the class CacheConfigurationLeakTest method testCacheCreateLeak.
/**
* @throws Exception If failed.
*/
public void testCacheCreateLeak() throws Exception {
final Ignite ignite = grid();
GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() {
@Override
public void apply(Integer idx) {
for (int i = 0; i < 100; i++) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setName("cache-" + idx + "-" + i);
ccfg.setEvictionPolicy(new LruEvictionPolicy(1000));
ccfg.setOnheapCacheEnabled(true);
IgniteCache<Object, Object> cache = ignite.createCache(ccfg);
for (int k = 0; k < 5000; k++) cache.put(k, new byte[1024]);
ignite.destroyCache(cache.getName());
}
}
}, 5, "cache-thread");
}
Aggregations