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);
}
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);
}
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 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);
}
}
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();
}
}
Aggregations