Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public enum GridTopic {
* @param id Topic ID.
* @return Grid message topic with specified ID.
*/
public Object topic(IgniteUuid id) {
public T1 topic(IgniteUuid id) {
return new T1(this, id);
}

Expand Down Expand Up @@ -250,35 +250,33 @@ public Object topic(String id1, UUID id2, int id3, long id4) {
return new T7(this, UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2, id3, id4);
}

/**
*
*/
private static class T1 implements Externalizable {
/** */
private static final long serialVersionUID = 0L;

/** */
public static class T1 {
/** */
private GridTopic topic;

/** */
private IgniteUuid id;

/**
* No-arg constructor needed for {@link Serializable}.
*/
public T1() {
// No-op.
}

/**
* @param topic Topic.
* @param id ID.
*/
private T1(GridTopic topic, IgniteUuid id) {
public T1(GridTopic topic, IgniteUuid id) {
this.topic = topic;
this.id = id;
}

/** */
public GridTopic topic() {
return topic;
}

/** */
public IgniteUuid id() {
return id;
}

/** {@inheritDoc} */
@Override public int hashCode() {
return topic.ordinal() + id.hashCode();
Expand All @@ -295,18 +293,6 @@ private T1(GridTopic topic, IgniteUuid id) {
return false;
}

/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeByte(topic.ordinal());
U.writeIgniteUuid(out, id);
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
topic = fromOrdinal(in.readByte());
id = U.readIgniteUuid(in);
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(T1.class, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.GridTopic;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.managers.communication.GridIoPolicy;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
Expand Down Expand Up @@ -137,7 +138,7 @@ private void processDeploymentRequest(UUID nodeId, Object msg) {
try {
GridDeploymentRequest req = (GridDeploymentRequest)msg;

if (req.isUndeploy())
if (req.undeploy())
processUndeployRequest(nodeId, req);
else {
assert activeReqNodeIds.get() == null;
Expand Down Expand Up @@ -186,18 +187,6 @@ private void processResourceRequest(UUID nodeId, GridDeploymentRequest req) {
if (log.isDebugEnabled())
log.debug("Received peer class/resource loading request [originatingNodeId=" + nodeId + ", req=" + req + ']');

if (req.responseTopic() == null) {
try {
req.finishUnmarshal(marsh, U.resolveClassLoader(ctx.config()));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to process deployment request (will ignore) [" +
"originatingNodeId=" + nodeId + ", req=" + req + ']', e);

return;
}
}

GridDeploymentResponse res = new GridDeploymentResponse();

GridDeployment dep = ctx.deploy().getDeployment(req.classLoaderId());
Expand Down Expand Up @@ -361,7 +350,7 @@ void sendUndeployRequest(String rsrcName, Collection<ClusterNode> rmtNodes) thro
ctx.io().sendToGridTopic(
rmtNodes,
TOPIC_CLASSLOAD,
new GridDeploymentRequest(null, null, rsrcName, true),
new GridDeploymentRequest(rsrcName),
GridIoPolicy.P2P_POOL);
}
}
Expand Down Expand Up @@ -393,9 +382,9 @@ GridDeploymentResponse sendResourceRequest(final String rsrcName, IgniteUuid cls
", requesters=" + nodeIds + ']');
}

Object resTopic = TOPIC_CLASSLOAD.topic(IgniteUuid.fromUuid(ctx.localNodeId()));
GridTopic.T1 resTopic = TOPIC_CLASSLOAD.topic(IgniteUuid.fromUuid(ctx.localNodeId()));

GridDeploymentRequest req = new GridDeploymentRequest(resTopic, clsLdrId, rsrcName, false);
GridDeploymentRequest req = new GridDeploymentRequest(resTopic, clsLdrId, rsrcName);

// Send node IDs chain with request.
req.nodeIds(nodeIds);
Expand All @@ -417,9 +406,6 @@ GridDeploymentResponse sendResourceRequest(final String rsrcName, IgniteUuid cls

long start = U.currentTimeMillis();

if (req.responseTopic() != null && !ctx.localNodeId().equals(dstNode.id()))
req.prepareMarshal(marsh);

ctx.io().sendToGridTopic(dstNode, TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL);

if (log.isDebugEnabled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,34 @@

import java.util.Collection;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridTopic;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.jetbrains.annotations.Nullable;

/**
* Deployment request.
*/
public class GridDeploymentRequest implements Message {
/** Response topic. Response should be sent back to this topic. */
private Object resTopic;

/** Serialized topic. */
/** */
@Order(0)
byte[] resTopicBytes;
@Nullable GridTopic topic;

/** Requested class name. */
/** */
@Order(1)
String rsrcName;
@Nullable IgniteUuid topicId;

/** Class loader ID. */
/** Requested class name. */
@Order(2)
IgniteUuid ldrId;
String rsrcName;

/** Undeploy flag. */
/** Class loader ID. */
@Order(3)
boolean isUndeploy;
@Nullable IgniteUuid ldrId;

/** Nodes participating in request (chain). */
@Order(4)
Expand All @@ -64,31 +61,37 @@ public GridDeploymentRequest() {
}

/**
* Creates new request.
* Creates deploy request.
*
* @param resTopic Response topic.
* @param topic Response topic.
* @param ldrId Class loader ID.
* @param rsrcName Resource name that should be found and sent back.
* @param isUndeploy Undeploy property.
*/
GridDeploymentRequest(Object resTopic, IgniteUuid ldrId, String rsrcName, boolean isUndeploy) {
assert isUndeploy || resTopic != null;
assert isUndeploy || ldrId != null;
assert rsrcName != null;

this.resTopic = resTopic;
GridDeploymentRequest(GridTopic.T1 topic, IgniteUuid ldrId, String rsrcName) {
this.topic = topic.topic();
topicId = topic.id();
this.ldrId = ldrId;
this.rsrcName = rsrcName;
this.isUndeploy = isUndeploy;
}

/**
* Creates undeploy request.
*
* @param rsrcName Resource name that should be found and sent back.
*/
GridDeploymentRequest(String rsrcName) {
this.rsrcName = rsrcName;
}

/**
* Get topic response should be sent to.
*
* @return Response topic name.
*/
Object responseTopic() {
return resTopic;
@Nullable GridTopic.T1 responseTopic() {
assert topic == null && topicId == null || topic != null && topicId != null;

return topic == null ? null : new GridTopic.T1(topic, topicId);
}

/**
Expand All @@ -105,7 +108,7 @@ public String resourceName() {
*
* @return Property class loader ID.
*/
public IgniteUuid classLoaderId() {
public @Nullable IgniteUuid classLoaderId() {
return ldrId;
}

Expand All @@ -114,8 +117,10 @@ public IgniteUuid classLoaderId() {
*
* @return Property undeploy.
*/
public boolean isUndeploy() {
return isUndeploy;
public boolean undeploy() {
assert topic == null && topicId == null || topic != null && topicId != null;

return topic == null;
}

/**
Expand All @@ -134,26 +139,6 @@ public void nodeIds(Collection<UUID> nodeIds) {
this.nodeIds = nodeIds;
}

/**
* @param marsh Marshaller.
*/
public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
if (resTopic != null && resTopicBytes == null)
resTopicBytes = U.marshal(marsh, resTopic);
}

/**
* @param marsh Marshaller.
* @param ldr Class loader.
*/
public void finishUnmarshal(Marshaller marsh, ClassLoader ldr) throws IgniteCheckedException {
if (resTopicBytes != null && resTopic == null) {
resTopic = U.unmarshal(marsh, resTopicBytes, ldr);

resTopicBytes = null;
}
}

/** {@inheritDoc} */
@Override public short directType() {
return 11;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ org.apache.ignite.internal.GridTaskCancelRequest
org.apache.ignite.internal.GridTaskNameHashKey
org.apache.ignite.internal.GridTaskSessionRequest
org.apache.ignite.internal.GridTopic
org.apache.ignite.internal.GridTopic$T1
org.apache.ignite.internal.GridTopic$T2
org.apache.ignite.internal.GridTopic$T3
org.apache.ignite.internal.GridTopic$T4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ public void testSerializationTopicCreatedByIgniteUuid() throws Exception {
info("Test GridTopic externalization [marshaller=" + marsh + ']');

for (GridTopic topic : GridTopic.values()) {
Externalizable msgOut = (Externalizable)topic.topic(A_IGNITE_UUID);
if (topic.topic(A_IGNITE_UUID) instanceof Externalizable) {
Externalizable msgOut = (Externalizable)topic.topic(A_IGNITE_UUID);

assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.GridTopic;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.managers.communication.GridIoPolicy;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.testframework.GridTestExternalClassLoader;
import org.apache.ignite.testframework.ListeningTestLogger;
import org.apache.ignite.testframework.LogListener;
Expand All @@ -38,9 +40,6 @@
* Tests the processing of deployment request with an attempt to load a class with an unknown class name.
*/
public class DeploymentRequestOfUnknownClassProcessingTest extends GridCommonAbstractTest {
/** */
private static final String TEST_TOPIC_NAME = "TEST_TOPIC_NAME";

/** */
private static final String UNKNOWN_CLASS_NAME = "unknown.UnknownClassName";

Expand Down Expand Up @@ -100,7 +99,9 @@ public void testResponseReceivingOnDeploymentRequestOfUnknownClass() throws Exce

remNodeLog.registerListener(remNodeLogLsnr);

locNode.context().io().addMessageListener(TEST_TOPIC_NAME, new GridMessageListener() {
GridTopic.T1 topic = TOPIC_CLASSLOAD.topic(IgniteUuid.fromUuid(locNode.localNode().id()));

locNode.context().io().addMessageListener(topic, new GridMessageListener() {
@Override public void onMessage(UUID nodeId, Object msg, byte plc) {
try {
assertTrue(msg instanceof GridDeploymentResponse);
Expand All @@ -124,10 +125,7 @@ public void testResponseReceivingOnDeploymentRequestOfUnknownClass() throws Exce
}
});

GridDeploymentRequest req = new GridDeploymentRequest(TEST_TOPIC_NAME, locDep.classLoaderId(),
UNKNOWN_CLASS_NAME, false);

req.prepareMarshal(locNode.context().marshaller());
GridDeploymentRequest req = new GridDeploymentRequest(topic, locDep.classLoaderId(), UNKNOWN_CLASS_NAME);

locNode.context().io().sendToGridTopic(remNode.localNode(), TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL);

Expand Down