use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.
the class PlatformProcessorImpl method createNearCache.
/** {@inheritDoc} */
@Override
public PlatformTargetProxy createNearCache(@Nullable String cacheName, long memPtr) {
NearCacheConfiguration cfg = getNearCacheConfiguration(memPtr);
IgniteCacheProxy cache = (IgniteCacheProxy) ctx.grid().createNearCache(cacheName, cfg);
return createPlatformCache(cache);
}
use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.
the class VisorCacheConfigurationCollectorJob method run.
/** {@inheritDoc} */
@Override
protected Map<IgniteUuid, VisorCacheConfiguration> run(VisorCacheConfigurationCollectorTaskArg arg) {
Collection<IgniteCacheProxy<?, ?>> caches = ignite.context().cache().jcaches();
Collection<IgniteUuid> depIds = arg.getDeploymentIds();
boolean all = depIds == null || depIds.isEmpty();
Map<IgniteUuid, VisorCacheConfiguration> res = U.newHashMap(caches.size());
for (IgniteCacheProxy<?, ?> cache : caches) {
IgniteUuid deploymentId = cache.context().dynamicDeploymentId();
if (all || depIds.contains(deploymentId))
res.put(deploymentId, config(cache.getConfiguration(CacheConfiguration.class)));
}
return res;
}
use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.
the class BasicWarmupClosure method doWarmup.
/**
* @param grids Grids to warmup.
*/
private void doWarmup(Iterable<Ignite> grids) throws Exception {
Ignite first = F.first(grids);
ExecutorService svc = Executors.newFixedThreadPool(threadCnt);
try {
for (IgniteCacheProxy cache : ((IgniteKernal) first).caches()) {
if (!cache.context().userCache())
continue;
IgniteInternalCache<Object, Object> cache0 = cache.context().cache();
for (String warmupMethod : warmupMethods) {
Collection<Future> futs = new ArrayList<>(threadCnt);
for (int i = 0; i < threadCnt; i++) {
Callable call;
switch(warmupMethod) {
case "get":
{
call = new GetCallable(cache0);
break;
}
case "put":
{
call = new PutCallable(cache0);
break;
}
case "putx":
{
call = new PutxCallable(cache0);
break;
}
case "remove":
{
call = new RemoveCallable(cache0);
break;
}
case "removex":
{
call = new RemovexCallable(cache0);
break;
}
case "putIfAbsent":
{
call = new PutIfAbsentCallable(cache0);
break;
}
case "replace":
{
call = new ReplaceCallable(cache0);
break;
}
default:
throw new IgniteCheckedException("Unsupported warmup method: " + warmupMethod);
}
futs.add(svc.submit(call));
}
out("Running warmup [cacheName=" + U.maskName(cache.getName()) + ", method=" + warmupMethod + ']');
for (Future fut : futs) fut.get();
for (int key = 0; key < keyRange; key++) cache0.getAndRemove(key);
}
}
} finally {
svc.shutdownNow();
}
}
use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy 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.processors.cache.IgniteCacheProxy in project ignite by apache.
the class CacheManager method createCache.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public <K, V, C extends Configuration<K, V>> Cache<K, V> createCache(String cacheName, C cacheCfg) throws IllegalArgumentException {
kernalGateway.readLock();
try {
if (cacheCfg == null)
throw new NullPointerException();
if (cacheName == null)
throw new NullPointerException();
CacheConfiguration<K, V> igniteCacheCfg;
if (cacheCfg instanceof CompleteConfiguration)
igniteCacheCfg = new CacheConfiguration<>((CompleteConfiguration<K, V>) cacheCfg);
else {
igniteCacheCfg = new CacheConfiguration<>();
igniteCacheCfg.setTypes(cacheCfg.getKeyType(), cacheCfg.getValueType());
}
igniteCacheCfg.setName(cacheName);
IgniteCache<K, V> res = ignite.createCache(igniteCacheCfg);
if (res == null)
throw new CacheException();
((IgniteCacheProxy<K, V>) res).setCacheManager(this);
if (igniteCacheCfg.isManagementEnabled())
enableManagement(cacheName, true);
if (igniteCacheCfg.isStatisticsEnabled())
enableStatistics(cacheName, true);
return res;
} finally {
kernalGateway.readUnlock();
}
}
Aggregations