Search in sources :

Example 1 with GridCacheDeploymentManager

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

the class CacheContinuousQueryHandler method notifyCallback0.

/**
 * @param nodeId Node id.
 * @param ctx Kernal context.
 * @param entries Entries.
 */
private void notifyCallback0(UUID nodeId, final GridKernalContext ctx, Collection<CacheContinuousQueryEntry> entries) {
    final GridCacheContext cctx = cacheContext(ctx);
    if (cctx == null) {
        IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
        if (log.isDebugEnabled())
            log.debug("Failed to notify callback, cache is not found: " + cacheId);
        return;
    }
    final Collection<CacheEntryEvent<? extends K, ? extends V>> entries0 = new ArrayList<>(entries.size());
    for (CacheContinuousQueryEntry e : entries) {
        GridCacheDeploymentManager depMgr = cctx.deploy();
        ClassLoader ldr = depMgr.globalLoader();
        try {
            if (ctx.config().isPeerClassLoadingEnabled()) {
                GridDeploymentInfo depInfo = e.deployInfo();
                if (depInfo != null) {
                    depMgr.p2pContext(nodeId, depInfo.classLoaderId(), depInfo.userVersion(), depInfo.deployMode(), depInfo.participants());
                }
            }
            e.unmarshal(cctx, ldr);
            Collection<CacheEntryEvent<? extends K, ? extends V>> evts = handleEvent(ctx, e);
            if (evts != null && !evts.isEmpty())
                entries0.addAll(evts);
        } catch (IgniteCheckedException ex) {
            if (ignoreClsNotFound)
                assert internal;
            else
                U.error(ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY), "Failed to unmarshal entry.", ex);
        }
    }
    notifyLocalListener(entries0, returnValTrans);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheDeploymentManager(org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager) ArrayList(java.util.ArrayList) GridDeploymentInfo(org.apache.ignite.internal.managers.deployment.GridDeploymentInfo) IgniteLogger(org.apache.ignite.IgniteLogger) CacheEntryEvent(javax.cache.event.CacheEntryEvent)

Example 2 with GridCacheDeploymentManager

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

the class GridEventConsumeHandler method notifyCallback.

/**
 * @param nodeId Node ID.
 * @param objs Notification objects.
 */
@Override
public void notifyCallback(UUID nodeId, UUID routineId, Collection<?> objs, GridKernalContext ctx) {
    assert nodeId != null;
    assert routineId != null;
    assert objs != null;
    assert ctx != null;
    for (Object obj : objs) {
        assert obj instanceof EventWrapper;
        EventWrapper wrapper = (EventWrapper) obj;
        if (wrapper.bytes != null) {
            assert ctx.config().isPeerClassLoadingEnabled();
            GridCacheAdapter cache = ctx.cache().internalCache(wrapper.cacheName);
            ClassLoader ldr = null;
            try {
                if (cache != null) {
                    GridCacheDeploymentManager depMgr = cache.context().deploy();
                    GridDeploymentInfo depInfo = wrapper.depInfo;
                    if (depInfo != null) {
                        depMgr.p2pContext(nodeId, depInfo.classLoaderId(), depInfo.userVersion(), depInfo.deployMode(), depInfo.participants());
                    }
                    ldr = depMgr.globalLoader();
                } else {
                    U.warn(ctx.log(getClass()), "Received cache event for cache that is not configured locally " + "when peer class loading is enabled: " + wrapper.cacheName + ". Will try to unmarshal " + "with default class loader.");
                }
                wrapper.p2pUnmarshal(ctx.config().getMarshaller(), U.resolveClassLoader(ldr, ctx.config()));
            } catch (IgniteCheckedException e) {
                U.error(ctx.log(getClass()), "Failed to unmarshal event.", e);
            }
        }
        if (!cb.apply(nodeId, wrapper.evt)) {
            ctx.continuous().stopRoutine(routineId);
            break;
        }
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheDeploymentManager(org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) GridDeploymentInfo(org.apache.ignite.internal.managers.deployment.GridDeploymentInfo)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 GridDeploymentInfo (org.apache.ignite.internal.managers.deployment.GridDeploymentInfo)2 GridCacheDeploymentManager (org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager)2 ArrayList (java.util.ArrayList)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 GridCacheAdapter (org.apache.ignite.internal.processors.cache.GridCacheAdapter)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1