Search in sources :

Example 1 with GridDeploymentInfoBean

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

the class GridMessageListenHandler method p2pMarshal.

/** {@inheritDoc} */
@Override
public void p2pMarshal(GridKernalContext ctx) throws IgniteCheckedException {
    assert ctx != null;
    assert ctx.config().isPeerClassLoadingEnabled();
    if (topic != null)
        topicBytes = U.marshal(ctx.config().getMarshaller(), topic);
    predBytes = U.marshal(ctx.config().getMarshaller(), pred);
    // Deploy only listener, as it is very likely to be of some user class.
    GridPeerDeployAware pda = U.peerDeployAware(pred);
    clsName = pda.deployClass().getName();
    GridDeployment dep = ctx.deploy().deploy(pda.deployClass(), pda.classLoader());
    if (dep == null)
        throw new IgniteDeploymentCheckedException("Failed to deploy message listener.");
    depInfo = new GridDeploymentInfoBean(dep);
    depEnabled = true;
}
Also used : GridPeerDeployAware(org.apache.ignite.internal.util.lang.GridPeerDeployAware) GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) GridDeploymentInfoBean(org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean)

Example 2 with GridDeploymentInfoBean

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

the class GridEventConsumeHandler method p2pMarshal.

/** {@inheritDoc} */
@Override
public void p2pMarshal(GridKernalContext ctx) throws IgniteCheckedException {
    assert ctx != null;
    assert ctx.config().isPeerClassLoadingEnabled();
    if (filter != null) {
        Class cls = U.detectClass(filter);
        clsName = cls.getName();
        GridDeployment dep = ctx.deploy().deploy(cls, U.detectClassLoader(cls));
        if (dep == null)
            throw new IgniteDeploymentCheckedException("Failed to deploy event filter: " + filter);
        depInfo = new GridDeploymentInfoBean(dep);
        filterBytes = U.marshal(ctx.config().getMarshaller(), filter);
    }
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) GridDeploymentInfoBean(org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean)

Example 3 with GridDeploymentInfoBean

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

the class GridCacheDeploymentManager method prepare.

/**
     * Prepares deployable object.
     *
     * @param deployable Deployable object.
     */
public void prepare(GridCacheDeployable deployable) {
    assert depEnabled;
    // Only set deployment info if it was not set automatically.
    if (deployable.deployInfo() == null) {
        GridDeploymentInfoBean dep = globalDeploymentInfo();
        if (dep == null) {
            GridDeployment locDep0 = locDep.get();
            if (locDep0 != null) {
                // Will copy sequence number to bean.
                dep = new GridDeploymentInfoBean(locDep0);
                dep.localDeploymentOwner(locDepOwner);
            }
        }
        if (dep != null)
            deployable.prepare(dep);
        if (log.isDebugEnabled())
            log.debug("Prepared grid cache deployable [dep=" + dep + ", deployable=" + deployable + ']');
    }
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) GridDeploymentInfoBean(org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean)

Example 4 with GridDeploymentInfoBean

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

the class GridContinuousProcessor method startRoutine.

/**
     * @param hnd Handler.
     * @param bufSize Buffer size.
     * @param interval Time interval.
     * @param autoUnsubscribe Automatic unsubscribe flag.
     * @param locOnly Local only flag.
     * @param prjPred Projection predicate.
     * @return Future.
     */
@SuppressWarnings("TooBroadScope")
public IgniteInternalFuture<UUID> startRoutine(GridContinuousHandler hnd, boolean locOnly, int bufSize, long interval, boolean autoUnsubscribe, @Nullable IgnitePredicate<ClusterNode> prjPred) {
    assert hnd != null;
    assert bufSize > 0;
    assert interval >= 0;
    // Generate ID.
    final UUID routineId = UUID.randomUUID();
    // Register routine locally.
    locInfos.put(routineId, new LocalRoutineInfo(prjPred, hnd, bufSize, interval, autoUnsubscribe));
    if (locOnly) {
        try {
            registerHandler(ctx.localNodeId(), routineId, hnd, bufSize, interval, autoUnsubscribe, true);
            return new GridFinishedFuture<>(routineId);
        } catch (IgniteCheckedException e) {
            unregisterHandler(routineId, hnd, true);
            return new GridFinishedFuture<>(e);
        }
    }
    // Whether local node is included in routine.
    boolean locIncluded = prjPred == null || prjPred.apply(ctx.discovery().localNode());
    StartRequestData reqData = new StartRequestData(prjPred, hnd.clone(), bufSize, interval, autoUnsubscribe);
    try {
        if (ctx.config().isPeerClassLoadingEnabled()) {
            // Handle peer deployment for projection predicate.
            if (prjPred != null && !U.isGrid(prjPred.getClass())) {
                Class cls = U.detectClass(prjPred);
                String clsName = cls.getName();
                GridDeployment dep = ctx.deploy().deploy(cls, U.detectClassLoader(cls));
                if (dep == null)
                    throw new IgniteDeploymentCheckedException("Failed to deploy projection predicate: " + prjPred);
                reqData.className(clsName);
                reqData.deploymentInfo(new GridDeploymentInfoBean(dep));
                reqData.p2pMarshal(marsh);
            }
            // Handle peer deployment for other handler-specific objects.
            reqData.handler().p2pMarshal(ctx);
        }
    } catch (IgniteCheckedException e) {
        return new GridFinishedFuture<>(e);
    }
    // Register per-routine notifications listener if ordered messaging is used.
    registerMessageListener(hnd);
    StartFuture fut = new StartFuture(ctx, routineId);
    startFuts.put(routineId, fut);
    try {
        if (locIncluded || hnd.isQuery())
            registerHandler(ctx.localNodeId(), routineId, hnd, bufSize, interval, autoUnsubscribe, true);
        ctx.discovery().sendCustomEvent(new StartRoutineDiscoveryMessage(routineId, reqData, reqData.handler().keepBinary()));
    } catch (IgniteCheckedException e) {
        startFuts.remove(routineId);
        locInfos.remove(routineId);
        unregisterHandler(routineId, hnd, true);
        fut.onDone(e);
        return fut;
    }
    // Handler is registered locally.
    fut.onLocalRegistered();
    return fut;
}
Also used : IgniteDeploymentCheckedException(org.apache.ignite.internal.IgniteDeploymentCheckedException) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridDeploymentInfoBean(org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean) UUID(java.util.UUID)

Aggregations

GridDeployment (org.apache.ignite.internal.managers.deployment.GridDeployment)4 GridDeploymentInfoBean (org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean)4 UUID (java.util.UUID)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteDeploymentCheckedException (org.apache.ignite.internal.IgniteDeploymentCheckedException)1 GridFinishedFuture (org.apache.ignite.internal.util.future.GridFinishedFuture)1 GridPeerDeployAware (org.apache.ignite.internal.util.lang.GridPeerDeployAware)1