Search in sources :

Example 1 with GridDeployment

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

the class GridEventConsumeHandler method p2pUnmarshal.

/** {@inheritDoc} */
@Override
public void p2pUnmarshal(UUID nodeId, GridKernalContext ctx) throws IgniteCheckedException {
    assert nodeId != null;
    assert ctx != null;
    assert ctx.config().isPeerClassLoadingEnabled();
    if (filterBytes != null) {
        GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, clsName, depInfo.userVersion(), nodeId, depInfo.classLoaderId(), depInfo.participants(), null);
        if (dep == null)
            throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
        filter = U.unmarshal(ctx, filterBytes, U.resolveClassLoader(dep.classLoader(), ctx.config()));
    }
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment)

Example 2 with GridDeployment

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

the class GridMessageListenHandler method p2pUnmarshal.

/** {@inheritDoc} */
@Override
public void p2pUnmarshal(UUID nodeId, GridKernalContext ctx) throws IgniteCheckedException {
    assert nodeId != null;
    assert ctx != null;
    assert ctx.config().isPeerClassLoadingEnabled();
    GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, clsName, depInfo.userVersion(), nodeId, depInfo.classLoaderId(), depInfo.participants(), null);
    if (dep == null)
        throw new IgniteDeploymentCheckedException("Failed to obtain deployment for class: " + clsName);
    ClassLoader ldr = dep.classLoader();
    if (topicBytes != null)
        topic = U.unmarshal(ctx, topicBytes, U.resolveClassLoader(ldr, ctx.config()));
    pred = U.unmarshal(ctx, predBytes, U.resolveClassLoader(ldr, ctx.config()));
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment)

Example 3 with GridDeployment

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

the class GridIoManager method sendUserMessage.

/**
     * Sends a peer deployable user message.
     *
     * @param nodes Destination nodes.
     * @param msg Message to send.
     * @param topic Message topic to use.
     * @param ordered Is message ordered?
     * @param timeout Message timeout in milliseconds for ordered messages.
     * @param async Async flag.
     * @throws IgniteCheckedException Thrown in case of any errors.
     */
@SuppressWarnings("ConstantConditions")
public void sendUserMessage(Collection<? extends ClusterNode> nodes, Object msg, @Nullable Object topic, boolean ordered, long timeout, boolean async) throws IgniteCheckedException {
    boolean loc = nodes.size() == 1 && F.first(nodes).id().equals(locNodeId);
    byte[] serMsg = null;
    byte[] serTopic = null;
    if (!loc) {
        serMsg = U.marshal(marsh, msg);
        if (topic != null)
            serTopic = U.marshal(marsh, topic);
    }
    GridDeployment dep = null;
    String depClsName = null;
    if (ctx.config().isPeerClassLoadingEnabled()) {
        Class<?> cls0 = U.detectClass(msg);
        if (U.isJdk(cls0) && topic != null)
            cls0 = U.detectClass(topic);
        dep = ctx.deploy().deploy(cls0, U.detectClassLoader(cls0));
        if (dep == null)
            throw new IgniteDeploymentCheckedException("Failed to deploy user message: " + msg);
        depClsName = cls0.getName();
    }
    Message ioMsg = new GridIoUserMessage(msg, serMsg, depClsName, topic, serTopic, dep != null ? dep.classLoaderId() : null, dep != null ? dep.deployMode() : null, dep != null ? dep.userVersion() : null, dep != null ? dep.participants() : null);
    if (ordered)
        sendOrderedMessageToGridTopic(nodes, TOPIC_COMM_USER, ioMsg, PUBLIC_POOL, timeout, true);
    else if (loc) {
        send(F.first(nodes), TOPIC_COMM_USER, TOPIC_COMM_USER.ordinal(), ioMsg, PUBLIC_POOL, false, 0, false, null, async);
    } else {
        ClusterNode locNode = F.find(nodes, null, F.localNode(locNodeId));
        Collection<? extends ClusterNode> rmtNodes = F.view(nodes, F.remoteNodes(locNodeId));
        if (!rmtNodes.isEmpty())
            sendToGridTopic(rmtNodes, TOPIC_COMM_USER, ioMsg, PUBLIC_POOL);
        // to allow remote nodes execute the requested operation in parallel.
        if (locNode != null) {
            send(locNode, TOPIC_COMM_USER, TOPIC_COMM_USER.ordinal(), ioMsg, PUBLIC_POOL, false, 0, false, null, async);
        }
    }
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) ClusterNode(org.apache.ignite.cluster.ClusterNode) Message(org.apache.ignite.plugin.extensions.communication.Message) GridNioBackPressureControl.threadProcessingMessage(org.apache.ignite.internal.util.nio.GridNioBackPressureControl.threadProcessingMessage) IgniteDeploymentCheckedException(org.apache.ignite.internal.IgniteDeploymentCheckedException) Collection(java.util.Collection)

Example 4 with GridDeployment

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

the class GridUrlConnection method connect.

/** {@inheritDoc} */
@Override
public void connect() throws IOException {
    URL url = getURL();
    // Gets class loader UUID.
    IgniteUuid ldrId = IgniteUuid.fromString(url.getHost());
    // Gets resource name.
    String name = url.getPath();
    GridDeployment dep = mgr.getDeployment(ldrId);
    if (dep != null) {
        in = dep.classLoader().getParent().getResourceAsStream(name);
        // If resource exists
        connected = true;
    }
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) IgniteUuid(org.apache.ignite.lang.IgniteUuid) URL(java.net.URL)

Example 5 with GridDeployment

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

the class GridAffinityUtils method unmarshall.

/**
     * Unmarshalls transfer object from remote node within a given context.
     *
     * @param ctx Grid kernal context that provides deployment and marshalling services.
     * @param sndNodeId {@link UUID} of the sender node.
     * @param msg Transfer object that contains original serialized object and deployment information.
     * @return Unmarshalled object.
     * @throws IgniteCheckedException If node cannot obtain deployment.
     */
static Object unmarshall(GridKernalContext ctx, UUID sndNodeId, GridAffinityMessage msg) throws IgniteCheckedException {
    GridDeployment dep = ctx.deploy().getGlobalDeployment(msg.deploymentMode(), msg.sourceClassName(), msg.sourceClassName(), msg.userVersion(), sndNodeId, msg.classLoaderId(), msg.loaderParticipants(), null);
    if (dep == null)
        throw new IgniteDeploymentCheckedException("Failed to obtain affinity object (is peer class loading turned on?): " + msg);
    Object src = U.unmarshal(ctx, msg.source(), U.resolveClassLoader(dep.classLoader(), ctx.config()));
    // Resource injection.
    ctx.resource().inject(dep, dep.deployedClass(msg.sourceClassName()), src);
    return src;
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) IgniteDeploymentCheckedException(org.apache.ignite.internal.IgniteDeploymentCheckedException)

Aggregations

GridDeployment (org.apache.ignite.internal.managers.deployment.GridDeployment)18 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 IgniteDeploymentCheckedException (org.apache.ignite.internal.IgniteDeploymentCheckedException)7 UUID (java.util.UUID)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 GridDeploymentInfoBean (org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean)4 Collection (java.util.Collection)3 GridTaskSessionImpl (org.apache.ignite.internal.GridTaskSessionImpl)3 IgniteDeploymentException (org.apache.ignite.IgniteDeploymentException)2 GridPeerDeployAware (org.apache.ignite.internal.util.lang.GridPeerDeployAware)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 IgniteException (org.apache.ignite.IgniteException)1