Search in sources :

Example 6 with GridDeploymentInfo

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

the class GridContinuousProcessor method processStartRequest.

/**
 * @param node Sender.
 * @param req Start request.
 */
private void processStartRequest(ClusterNode node, StartRoutineDiscoveryMessage req) {
    if (node.id().equals(ctx.localNodeId()))
        return;
    UUID routineId = req.routineId();
    if (req.deserializationException() != null && checkNodeFilter(req)) {
        IgniteCheckedException err = new IgniteCheckedException(req.deserializationException());
        req.addError(node.id(), err);
        U.error(log, "Failed to register handler [nodeId=" + node.id() + ", routineId=" + routineId + ']', err);
        return;
    }
    StartRequestData data = req.startRequestData();
    GridContinuousHandler hnd = data.handler();
    if (req.keepBinary()) {
        assert hnd instanceof CacheContinuousQueryHandler;
        ((CacheContinuousQueryHandler) hnd).keepBinary(true);
    }
    IgniteCheckedException err = null;
    try {
        if (ctx.config().isPeerClassLoadingEnabled()) {
            String clsName = data.className();
            if (clsName != null) {
                GridDeploymentInfo depInfo = data.deploymentInfo();
                GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, clsName, depInfo.userVersion(), node.id(), depInfo.classLoaderId(), depInfo.participants(), null);
                if (dep == null)
                    throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
                data.p2pUnmarshal(marsh, U.resolveClassLoader(dep.classLoader(), ctx.config()));
            }
        }
    } catch (IgniteCheckedException e) {
        err = e;
        U.error(log, "Failed to register handler [nodeId=" + node.id() + ", routineId=" + routineId + ']', e);
    }
    if (node.isClient()) {
        Map<UUID, LocalRoutineInfo> clientRoutineMap = clientInfos.get(node.id());
        if (clientRoutineMap == null) {
            clientRoutineMap = new HashMap<>();
            Map<UUID, LocalRoutineInfo> old = clientInfos.put(node.id(), clientRoutineMap);
            assert old == null;
        }
        clientRoutineMap.put(routineId, new LocalRoutineInfo(node.id(), data.projectionPredicate(), hnd, data.bufferSize(), data.interval(), data.autoUnsubscribe()));
    }
    if (err == null) {
        try {
            IgnitePredicate<ClusterNode> prjPred = data.projectionPredicate();
            if (prjPred != null)
                ctx.resource().injectGeneric(prjPred);
            if ((prjPred == null || prjPred.apply(ctx.discovery().node(ctx.localNodeId()))) && !locInfos.containsKey(routineId)) {
                if (ctx.config().isPeerClassLoadingEnabled())
                    hnd.p2pUnmarshal(node.id(), ctx);
                registerHandler(node.id(), routineId, hnd, data.bufferSize(), data.interval(), data.autoUnsubscribe(), false);
                // Load partition counters.
                if (err == null && hnd.isQuery()) {
                    GridCacheProcessor proc = ctx.cache();
                    if (proc != null) {
                        GridCacheAdapter cache = ctx.cache().internalCache(hnd.cacheName());
                        if (cache != null && !cache.isLocal() && cache.context().userCache())
                            req.addUpdateCounters(ctx.localNodeId(), hnd.updateCounters());
                    }
                }
            }
            if (!data.autoUnsubscribe())
                // Register routine locally.
                locInfos.putIfAbsent(routineId, new LocalRoutineInfo(node.id(), prjPred, hnd, data.bufferSize(), data.interval(), data.autoUnsubscribe()));
        } catch (IgniteCheckedException e) {
            err = e;
            U.error(log, "Failed to register handler [nodeId=" + node.id() + ", routineId=" + routineId + ']', e);
        }
    }
    if (err != null)
        req.addError(ctx.localNodeId(), err);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteDeploymentCheckedException(org.apache.ignite.internal.IgniteDeploymentCheckedException) 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) GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) UUID(java.util.UUID)

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