Search in sources :

Example 1 with IgniteCacheProxy

use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.

the class PlatformProcessorImpl method getOrCreateNearCache.

/** {@inheritDoc} */
@Override
public PlatformTargetProxy getOrCreateNearCache(@Nullable String cacheName, long memPtr) {
    NearCacheConfiguration cfg = getNearCacheConfiguration(memPtr);
    IgniteCacheProxy cache = (IgniteCacheProxy) ctx.grid().getOrCreateNearCache(cacheName, cfg);
    return createPlatformCache(cache);
}
Also used : IgniteCacheProxy(org.apache.ignite.internal.processors.cache.IgniteCacheProxy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 2 with IgniteCacheProxy

use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.

the class PlatformProcessorImpl method getOrCreateCacheFromConfig.

/** {@inheritDoc} */
@Override
public PlatformTargetProxy getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
    BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
    CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
    IgniteCacheProxy cache = reader.readBoolean() ? (IgniteCacheProxy) ctx.grid().getOrCreateCache(cfg, PlatformConfigurationUtils.readNearConfiguration(reader)) : (IgniteCacheProxy) ctx.grid().getOrCreateCache(cfg);
    return createPlatformCache(cache);
}
Also used : IgniteCacheProxy(org.apache.ignite.internal.processors.cache.IgniteCacheProxy) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 3 with IgniteCacheProxy

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);
}
Also used : IgniteCacheProxy(org.apache.ignite.internal.processors.cache.IgniteCacheProxy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 4 with IgniteCacheProxy

use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.

the class CacheContinuousQueryManager method onEntryUpdated.

/**
 * @param lsnrCol Listeners to notify.
 * @param key Key.
 * @param newVal New value.
 * @param oldVal Old value.
 * @param internal Internal entry (internal key or not user cache),
 * @param partId Partition.
 * @param primary {@code True} if called on primary node.
 * @param preload Whether update happened during preloading.
 * @param updateCntr Update counter.
 * @param topVer Topology version.
 * @param fut Dht atomic future.
 * @throws IgniteCheckedException In case of error.
 */
public void onEntryUpdated(Map<UUID, CacheContinuousQueryListener> lsnrCol, KeyCacheObject key, CacheObject newVal, CacheObject oldVal, boolean internal, int partId, boolean primary, boolean preload, long updateCntr, @Nullable GridDhtAtomicAbstractUpdateFuture fut, AffinityTopologyVersion topVer) throws IgniteCheckedException {
    assert key != null;
    assert lsnrCol != null;
    boolean hasNewVal = newVal != null;
    boolean hasOldVal = oldVal != null;
    if (!hasNewVal && !hasOldVal) {
        skipUpdateEvent(lsnrCol, key, partId, updateCntr, primary, topVer);
        return;
    }
    EventType evtType = !hasNewVal ? REMOVED : !hasOldVal ? CREATED : UPDATED;
    boolean initialized = false;
    boolean recordIgniteEvt = primary && !internal && cctx.events().isRecordable(EVT_CACHE_QUERY_OBJECT_READ);
    for (CacheContinuousQueryListener lsnr : lsnrCol.values()) {
        if (preload && !lsnr.notifyExisting() || lsnr.isPrimaryOnly() && !primary)
            continue;
        if (!initialized) {
            if (lsnr.oldValueRequired()) {
                oldVal = (CacheObject) cctx.unwrapTemporary(oldVal);
                if (oldVal != null)
                    oldVal.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader());
            }
            if (newVal != null)
                newVal.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader());
            initialized = true;
        }
        CacheContinuousQueryEntry e0 = new CacheContinuousQueryEntry(cctx.cacheId(), evtType, key, (!internal && evtType == REMOVED && lsnr.oldValueRequired()) ? oldVal : newVal, lsnr.oldValueRequired() ? oldVal : null, lsnr.keepBinary(), partId, updateCntr, topVer, (byte) 0);
        IgniteCacheProxy jcache = cctx.kernalContext().cache().jcacheProxy(cctx.name(), true);
        assert jcache != null : "Failed to get cache proxy [name=" + cctx.name() + ", locStart=" + cctx.startTopologyVersion() + ", locNode=" + cctx.localNode() + ", stopping=" + cctx.kernalContext().isStopping();
        CacheContinuousQueryEvent evt = new CacheContinuousQueryEvent<>(jcache, cctx, e0);
        lsnr.onEntryUpdated(evt, primary, recordIgniteEvt, fut);
    }
}
Also used : EventType(javax.cache.event.EventType) IgniteCacheProxy(org.apache.ignite.internal.processors.cache.IgniteCacheProxy)

Example 5 with IgniteCacheProxy

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();
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) ArrayList(java.util.ArrayList) IgniteCacheProxy(org.apache.ignite.internal.processors.cache.IgniteCacheProxy) Callable(java.util.concurrent.Callable) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) Ignite(org.apache.ignite.Ignite)

Aggregations

IgniteCacheProxy (org.apache.ignite.internal.processors.cache.IgniteCacheProxy)23 Ignite (org.apache.ignite.Ignite)8 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)7 Test (org.junit.Test)7 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)6 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 IgniteKernal (org.apache.ignite.internal.IgniteKernal)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 List (java.util.List)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 IgniteCache (org.apache.ignite.IgniteCache)3 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)3 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Map (java.util.Map)2 Callable (java.util.concurrent.Callable)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 Cache (javax.cache.Cache)2