Search in sources :

Example 1 with GatewayProtectedCacheProxy

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();
    }
}
Also used : GatewayProtectedCacheProxy(org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy) CompleteConfiguration(javax.cache.configuration.CompleteConfiguration) CacheException(javax.cache.CacheException) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 2 with GatewayProtectedCacheProxy

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));
    }
}
Also used : GatewayProtectedCacheProxy(org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy) IgniteCache(org.apache.ignite.IgniteCache) Ignite(org.apache.ignite.Ignite)

Example 3 with GatewayProtectedCacheProxy

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);
}
Also used : IndexName(org.apache.ignite.internal.cache.query.index.IndexName) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GatewayProtectedCacheProxy(org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy)

Aggregations

GatewayProtectedCacheProxy (org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy)3 CacheException (javax.cache.CacheException)1 CompleteConfiguration (javax.cache.configuration.CompleteConfiguration)1 Ignite (org.apache.ignite.Ignite)1 IgniteCache (org.apache.ignite.IgniteCache)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 IndexName (org.apache.ignite.internal.cache.query.index.IndexName)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1