use of org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy in project ignite by apache.
the class CacheManager method createCache.
/**
* {@inheritDoc}
*/
@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();
((GatewayProtectedCacheProxy<K, V>) res).setCacheManager(this);
if (igniteCacheCfg.isManagementEnabled())
enableManagement(cacheName, true);
if (igniteCacheCfg.isStatisticsEnabled())
enableStatistics(cacheName, true);
return res;
} finally {
kernalGateway.readUnlock();
}
}
use of org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy in project ignite by apache.
the class IgnitePdsDestroyCacheAbstractTest method checkDestroyCachesAbruptly.
/**
* @param ignite Ignite instance.
*/
protected void checkDestroyCachesAbruptly(Ignite ignite) throws Exception {
loadCaches(ignite, false);
log.warning("Destroying caches");
((GatewayProtectedCacheProxy) ignite.cache(cacheName(0))).destroyAsync();
((GatewayProtectedCacheProxy) ignite.cache(cacheName(1))).destroyAsync();
log.warning("Stopping grid");
stopAllGrids();
log.warning("Grid stopped");
log.warning("Starting grid");
ignite = startGrids(NODES);
ignite.cluster().active(true);
log.warning("Grid started");
for (Ignite ig : G.allGrids()) {
assertTrue(ig.cacheNames().contains(cacheName(2)));
IgniteCache cache = ig.cache(cacheName(2));
for (int j = 0; j < NUM_OF_KEYS; j++) assertNotNull("Check that survived cache cache2 contains key: " + j + " node: " + ig.name(), cache.get(j));
}
}
use of org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy in project ignite by apache.
the class IndexQueryFailoverTest method destroyIndex.
/**
*/
private void destroyIndex() {
IndexName idxName = new IndexName(CACHE, CACHE, Person.class.getSimpleName().toUpperCase(), IDX);
GridCacheContext cctx = ((GatewayProtectedCacheProxy) cache).context();
cctx.kernalContext().indexProcessor().removeIndex(cctx, idxName, false);
}
Aggregations