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()));
}
}
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()));
}
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);
}
}
}
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;
}
}
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;
}
Aggregations