Search in sources :

Example 1 with GridDeploymentInfo

use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo 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 GridDeploymentInfo

use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo 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)

Example 3 with GridDeploymentInfo

use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo in project ignite by apache.

the class GridContinuousProcessor method processStartRequestV2.

/**
 * @param topVer Current topology version.
 * @param snd Sender.
 * @param msg Start request.
 */
private void processStartRequestV2(final AffinityTopologyVersion topVer, final ClusterNode snd, final StartRoutineDiscoveryMessageV2 msg) {
    StartRequestDataV2 reqData = msg.startRequestData();
    ContinuousRoutineInfo routineInfo = new ContinuousRoutineInfo(snd.id(), msg.routineId(), reqData.handlerBytes(), reqData.nodeFilterBytes(), reqData.bufferSize(), reqData.interval(), reqData.autoUnsubscribe());
    routinesInfo.addRoutineInfo(routineInfo);
    final DiscoCache discoCache = ctx.discovery().discoCache(topVer);
    // Should not use marshaller and send messages from discovery thread.
    ctx.pools().getSystemExecutorService().execute(new Runnable() {

        @Override
        public void run() {
            if (snd.id().equals(ctx.localNodeId())) {
                StartFuture fut = startFuts.get(msg.routineId());
                if (fut != null)
                    fut.initRemoteNodes(discoCache);
                return;
            }
            StartRequestDataV2 reqData = msg.startRequestData();
            Exception err = null;
            IgnitePredicate<ClusterNode> nodeFilter = null;
            byte[] cntrs = null;
            if (reqData.nodeFilterBytes() != null) {
                try {
                    if (ctx.config().isPeerClassLoadingEnabled() && reqData.className() != null) {
                        String clsName = reqData.className();
                        GridDeploymentInfo depInfo = reqData.deploymentInfo();
                        GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, clsName, depInfo.userVersion(), snd.id(), depInfo.classLoaderId(), depInfo.participants(), null);
                        if (dep == null) {
                            throw new IgniteDeploymentCheckedException("Failed to obtain deployment " + "for class: " + clsName);
                        }
                        nodeFilter = U.unmarshal(marsh, reqData.nodeFilterBytes(), U.resolveClassLoader(dep.classLoader(), ctx.config()));
                    } else {
                        nodeFilter = U.unmarshal(marsh, reqData.nodeFilterBytes(), U.resolveClassLoader(ctx.config()));
                    }
                    if (nodeFilter != null)
                        ctx.resource().injectGeneric(nodeFilter);
                } catch (Exception e) {
                    err = e;
                    U.error(log, "Failed to unmarshal continuous routine filter [" + "routineId=" + msg.routineId + ", srcNodeId=" + snd.id() + ']', e);
                }
            }
            boolean register = err == null && (nodeFilter == null || nodeFilter.apply(ctx.discovery().localNode()));
            if (register) {
                try {
                    GridContinuousHandler hnd = U.unmarshal(marsh, reqData.handlerBytes(), U.resolveClassLoader(ctx.config()));
                    if (ctx.config().isPeerClassLoadingEnabled())
                        hnd.p2pUnmarshal(snd.id(), ctx);
                    if (msg.keepBinary()) {
                        assert hnd instanceof CacheContinuousQueryHandler : hnd;
                        ((CacheContinuousQueryHandler) hnd).keepBinary(true);
                    }
                    registerHandler(snd.id(), msg.routineId, hnd, reqData.bufferSize(), reqData.interval(), reqData.autoUnsubscribe(), false);
                    if (hnd.isQuery()) {
                        GridCacheProcessor proc = ctx.cache();
                        if (proc != null) {
                            GridCacheAdapter cache = ctx.cache().internalCache(hnd.cacheName());
                            if (cache != null && !cache.isLocal() && cache.context().userCache()) {
                                CachePartitionPartialCountersMap cntrsMap = cache.context().topology().localUpdateCounters(false);
                                cntrs = U.marshal(marsh, cntrsMap);
                            }
                        }
                    }
                } catch (Exception e) {
                    err = e;
                    U.error(log, "Failed to register continuous routine handler [" + "routineId=" + msg.routineId + ", srcNodeId=" + snd.id() + ']', e);
                }
            }
            sendMessageStartResult(snd, msg.routineId(), cntrs, err);
        }
    });
}
Also used : DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) IgniteDeploymentCheckedException(org.apache.ignite.internal.IgniteDeploymentCheckedException) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) CacheContinuousQueryHandler(org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler) GridDeploymentInfo(org.apache.ignite.internal.managers.deployment.GridDeploymentInfo) GridCacheProcessor(org.apache.ignite.internal.processors.cache.GridCacheProcessor) IgniteDeploymentCheckedException(org.apache.ignite.internal.IgniteDeploymentCheckedException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) IOException(java.io.IOException) CachePartitionPartialCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap) GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable)

Example 4 with GridDeploymentInfo

use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo in project ignite by apache.

the class GridCacheMessage method prepareObject.

/**
     * @param o Object to prepare for marshalling.
     * @param ctx Context.
     * @throws IgniteCheckedException If failed.
     */
protected final void prepareObject(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException {
    assert addDepInfo || forceAddDepInfo;
    if (!skipPrepare && o != null) {
        GridDeploymentInfo d = ctx.deploy().globalDeploymentInfo();
        if (d != null) {
            prepare(d);
            // Global deployment has been injected.
            skipPrepare = true;
        } else {
            Class<?> cls = U.detectClass(o);
            ctx.deploy().registerClass(cls);
            ClassLoader ldr = U.detectClassLoader(cls);
            if (ldr instanceof GridDeploymentInfo)
                prepare((GridDeploymentInfo) ldr);
        }
    }
}
Also used : GridDeploymentInfo(org.apache.ignite.internal.managers.deployment.GridDeploymentInfo)

Example 5 with GridDeploymentInfo

use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo in project ignite by apache.

the class GridCacheMessage method prepareObject.

/**
 * @param o Object to prepare for marshalling.
 * @param ctx Context.
 * @throws IgniteCheckedException If failed.
 */
protected final void prepareObject(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException {
    assert addDepInfo || forceAddDepInfo;
    if (!skipPrepare && o != null) {
        GridDeploymentInfo d = ctx.deploy().globalDeploymentInfo();
        if (d != null) {
            prepare(d);
            // Global deployment has been injected.
            skipPrepare = true;
        } else {
            Class<?> cls = U.detectClass(o);
            ctx.deploy().registerClass(cls);
            ClassLoader ldr = U.detectClassLoader(cls);
            if (ldr instanceof GridDeploymentInfo)
                prepare((GridDeploymentInfo) ldr);
        }
    }
}
Also used : GridDeploymentInfo(org.apache.ignite.internal.managers.deployment.GridDeploymentInfo)

Aggregations

GridDeploymentInfo (org.apache.ignite.internal.managers.deployment.GridDeploymentInfo)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridCacheAdapter (org.apache.ignite.internal.processors.cache.GridCacheAdapter)3 IgniteDeploymentCheckedException (org.apache.ignite.internal.IgniteDeploymentCheckedException)2 GridDeployment (org.apache.ignite.internal.managers.deployment.GridDeployment)2 GridCacheDeploymentManager (org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager)2 GridCacheProcessor (org.apache.ignite.internal.processors.cache.GridCacheProcessor)2 CacheContinuousQueryHandler (org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)1 IgniteFutureTimeoutCheckedException (org.apache.ignite.internal.IgniteFutureTimeoutCheckedException)1 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)1 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)1 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)1