Skip to content

Commit 77a465c

Browse files
committed
fix tests
1 parent c08065d commit 77a465c

10 files changed

Lines changed: 83 additions & 64 deletions

File tree

modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public enum GridTopic {
178178
* @param id Topic ID.
179179
* @return Grid message topic with specified ID.
180180
*/
181-
public T1 topic(IgniteUuid id) {
181+
public Object topic(IgniteUuid id) {
182182
return new T1(this, id);
183183
}
184184

@@ -231,7 +231,7 @@ public Object topic(String id1, UUID id2, long id3) {
231231
}
232232

233233
/** */
234-
public static class T1 implements Externalizable {
234+
private static class T1 implements Externalizable {
235235
/** */
236236
private static final long serialVersionUID = 0L;
237237

@@ -252,21 +252,11 @@ public T1() {
252252
* @param topic Topic.
253253
* @param id ID.
254254
*/
255-
public T1(GridTopic topic, IgniteUuid id) {
255+
private T1(GridTopic topic, IgniteUuid id) {
256256
this.topic = topic;
257257
this.id = id;
258258
}
259259

260-
/** */
261-
public GridTopic topic() {
262-
return topic;
263-
}
264-
265-
/** */
266-
public IgniteUuid id() {
267-
return id;
268-
}
269-
270260
/** {@inheritDoc} */
271261
@Override public int hashCode() {
272262
return topic.ordinal() + id.hashCode();

modules/core/src/main/java/org/apache/ignite/internal/GridTopicMessage.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,27 @@ public class GridTopicMessage implements MarshallableMessage {
3636
@Order(1)
3737
int ord = -1;
3838

39+
/** */
40+
@Order(2)
41+
boolean needCustomClsLdr;
42+
3943
/** Constructor for {@link CoreMessagesProvider}. */
4044
public GridTopicMessage() {
4145
// No-op.
4246
}
4347

44-
/** @param topic Topic. */
48+
/** Constructor. */
4549
public GridTopicMessage(Object topic) {
50+
this(topic, false);
51+
}
52+
53+
/**
54+
* @param topic Topic.
55+
* @param needCustomClsLdr Flag indicating whether to use a special class loader for unmarshalling.
56+
*/
57+
public GridTopicMessage(Object topic, boolean needCustomClsLdr) {
4658
this.topic = topic;
59+
this.needCustomClsLdr = needCustomClsLdr;
4760

4861
if (topic instanceof GridTopic)
4962
ord = ((Enum<GridTopic>)topic).ordinal();
@@ -60,7 +73,7 @@ public static int ordinal(GridTopicMessage msg) {
6073
}
6174

6275
/** @return Topic. */
63-
private Object topic() {
76+
public Object topic() {
6477
return topic;
6578
}
6679

@@ -77,6 +90,9 @@ private int ordinal() {
7790

7891
/** {@inheritDoc} */
7992
@Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException {
93+
if (needCustomClsLdr)
94+
return;
95+
8096
if (ord < 0 && topicBytes != null) {
8197
topic = U.unmarshal(marsh, topicBytes, clsLdr);
8298

@@ -86,6 +102,22 @@ else if (ord >= 0)
86102
topic = GridTopic.fromOrdinal(ord);
87103
}
88104

105+
/**
106+
* Unmarshals topic using given marshaller and user-defined class loader.
107+
*
108+
* @param marsh Marshaller.
109+
* @param customClsLdr Custom class loader.
110+
*/
111+
public void unmarshal(Marshaller marsh, ClassLoader customClsLdr) throws IgniteCheckedException {
112+
if (ord < 0 && topicBytes != null) {
113+
topic = U.unmarshal(marsh, topicBytes, customClsLdr);
114+
115+
topicBytes = null;
116+
}
117+
else if (ord >= 0)
118+
topic = GridTopic.fromOrdinal(ord);
119+
}
120+
89121
/** {@inheritDoc} */
90122
@Override public String toString() {
91123
return S.toString(GridTopicMessage.class, this);

modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import org.apache.ignite.events.Event;
8080
import org.apache.ignite.internal.GridKernalContext;
8181
import org.apache.ignite.internal.GridTopic;
82+
import org.apache.ignite.internal.GridTopicMessage;
8283
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
8384
import org.apache.ignite.internal.IgniteDeploymentCheckedException;
8485
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -3502,8 +3503,6 @@ private class GridUserMessageListener implements GridMessageListener {
35023503
assert msgBody != null || ioMsg.bodyBytes() != null;
35033504

35043505
try {
3505-
Object msgTopic = ioMsg.topic();
3506-
35073506
GridDeployment dep = ioMsg.deployment();
35083507

35093508
if (dep == null && ctx.config().isPeerClassLoadingEnabled() &&
@@ -3527,6 +3526,16 @@ private class GridUserMessageListener implements GridMessageListener {
35273526
ioMsg.deployment(dep); // Cache deployment.
35283527
}
35293528

3529+
GridTopicMessage topicMsg = ioMsg.topicMessage();
3530+
Object msgTopic = null;
3531+
3532+
// Unmarshall message topic if needed.
3533+
if (topicMsg != null) {
3534+
topicMsg.unmarshal(marsh, U.resolveClassLoader(dep != null ? dep.classLoader() : null, ctx.config()));
3535+
3536+
msgTopic = topicMsg.topic();
3537+
}
3538+
35303539
if (!Objects.equals(topic, msgTopic))
35313540
return;
35323541

modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
/**
3434
* User message wrapper.
3535
*/
36-
// TODO CHECK
3736
public class GridIoUserMessage implements Message {
3837
/** Message body. */
3938
private Object body;
@@ -94,7 +93,7 @@ public class GridIoUserMessage implements Message {
9493
this.depClsName = depClsName;
9594

9695
if (topic != null)
97-
topicMsg = new GridTopicMessage(topic);
96+
topicMsg = new GridTopicMessage(topic, true);
9897

9998
this.depMode = depMode;
10099
this.clsLdrId = clsLdrId;
@@ -152,10 +151,10 @@ public GridIoUserMessage() {
152151
}
153152

154153
/**
155-
* @return Message topic.
154+
* @return Topic message.
156155
*/
157-
@Nullable Object topic() {
158-
return GridTopicMessage.topic(topicMsg);
156+
@Nullable GridTopicMessage topicMessage() {
157+
return topicMsg;
159158
}
160159

161160
/**

modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.ignite.events.DiscoveryEvent;
3030
import org.apache.ignite.events.Event;
3131
import org.apache.ignite.internal.GridKernalContext;
32-
import org.apache.ignite.internal.GridTopic;
3332
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
3433
import org.apache.ignite.internal.managers.communication.GridIoPolicy;
3534
import org.apache.ignite.internal.managers.communication.GridMessageListener;
@@ -376,7 +375,7 @@ GridDeploymentResponse sendResourceRequest(final String rsrcName, IgniteUuid cls
376375
", requesters=" + nodeIds + ']');
377376
}
378377

379-
GridTopic.T1 resTopic = TOPIC_CLASSLOAD.topic(IgniteUuid.fromUuid(ctx.localNodeId()));
378+
Object resTopic = TOPIC_CLASSLOAD.topic(IgniteUuid.fromUuid(ctx.localNodeId()));
380379

381380
GridDeploymentRequest req = new GridDeploymentRequest(resTopic, clsLdrId, rsrcName);
382381

modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import java.util.Collection;
2121
import java.util.UUID;
22-
import org.apache.ignite.internal.GridTopic;
22+
import org.apache.ignite.internal.GridTopicMessage;
2323
import org.apache.ignite.internal.Order;
2424
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
2525
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -30,26 +30,21 @@
3030
/**
3131
* Deployment request.
3232
*/
33-
// TODO CHECK
3433
public class GridDeploymentRequest implements Message {
35-
/** Response topic. Response should be sent back to this topic. */
34+
/** Response topic message. Response should be sent back to this topic. */
3635
@Order(0)
37-
@Nullable GridTopic topic;
38-
39-
/** Topic ID. */
40-
@Order(1)
41-
@Nullable IgniteUuid topicId;
36+
@Nullable GridTopicMessage topicMsg;
4237

4338
/** Requested class name. */
44-
@Order(2)
39+
@Order(1)
4540
String rsrcName;
4641

4742
/** Class loader ID. */
48-
@Order(3)
43+
@Order(2)
4944
@Nullable IgniteUuid ldrId;
5045

5146
/** Nodes participating in request (chain). */
52-
@Order(4)
47+
@Order(3)
5348
@GridToStringInclude
5449
Collection<UUID> nodeIds;
5550

@@ -67,9 +62,8 @@ public GridDeploymentRequest() {
6762
* @param ldrId Class loader ID.
6863
* @param rsrcName Resource name that should be found and sent back.
6964
*/
70-
GridDeploymentRequest(GridTopic.T1 topic, IgniteUuid ldrId, String rsrcName) {
71-
this.topic = topic.topic();
72-
topicId = topic.id();
65+
GridDeploymentRequest(Object topic, IgniteUuid ldrId, String rsrcName) {
66+
topicMsg = new GridTopicMessage(topic);
7367
this.ldrId = ldrId;
7468
this.rsrcName = rsrcName;
7569
}
@@ -88,10 +82,8 @@ public GridDeploymentRequest() {
8882
*
8983
* @return Response topic name.
9084
*/
91-
@Nullable GridTopic.T1 responseTopic() {
92-
assert topic == null && topicId == null || topic != null && topicId != null;
93-
94-
return topic == null ? null : new GridTopic.T1(topic, topicId);
85+
@Nullable Object responseTopic() {
86+
return GridTopicMessage.topic(topicMsg);
9587
}
9688

9789
/**
@@ -118,9 +110,7 @@ String resourceName() {
118110
* @return Property undeploy.
119111
*/
120112
boolean undeploy() {
121-
assert topic == null && topicId == null || topic != null && topicId != null;
122-
123-
return topic == null;
113+
return topicMsg == null;
124114
}
125115

126116
/**

modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,105 +167,105 @@ public DataStreamerRequest(
167167
/**
168168
* @return Request ID.
169169
*/
170-
public long requestId() {
170+
long requestId() {
171171
return reqId;
172172
}
173173

174174
/**
175175
* @return Response topic.
176176
*/
177-
public Object responseTopic() {
177+
Object responseTopic() {
178178
return GridTopicMessage.topic(resTopicMsg);
179179
}
180180

181181
/**
182182
* @return Cache name.
183183
*/
184-
public String cacheName() {
184+
String cacheName() {
185185
return cacheName;
186186
}
187187

188188
/**
189189
* @return Updater.
190190
*/
191-
public byte[] updaterBytes() {
191+
byte[] updaterBytes() {
192192
return updaterBytes;
193193
}
194194

195195
/**
196196
* @return Entries to update.
197197
*/
198-
public Collection<DataStreamerEntry> entries() {
198+
Collection<DataStreamerEntry> entries() {
199199
return entries;
200200
}
201201

202202
/**
203203
* @return {@code True} to ignore ownership.
204204
*/
205-
public boolean ignoreDeploymentOwnership() {
205+
boolean ignoreDeploymentOwnership() {
206206
return ignoreDepOwnership;
207207
}
208208

209209
/**
210210
* @return Skip store flag.
211211
*/
212-
public boolean skipStore() {
212+
boolean skipStore() {
213213
return skipStore;
214214
}
215215

216216
/**
217217
* @return Keep binary flag.
218218
*/
219-
public boolean keepBinary() {
219+
boolean keepBinary() {
220220
return keepBinary;
221221
}
222222

223223
/**
224224
* @return Deployment mode.
225225
*/
226-
public DeploymentMode deploymentMode() {
226+
DeploymentMode deploymentMode() {
227227
return depMode;
228228
}
229229

230230
/**
231231
* @return Sample class name.
232232
*/
233-
public String sampleClassName() {
233+
String sampleClassName() {
234234
return sampleClsName;
235235
}
236236

237237
/**
238238
* @return User version.
239239
*/
240-
public String userVersion() {
240+
String userVersion() {
241241
return userVer;
242242
}
243243

244244
/**
245245
* @return Participants.
246246
*/
247-
public Map<UUID, IgniteUuid> participants() {
247+
Map<UUID, IgniteUuid> participants() {
248248
return ldrParticipants;
249249
}
250250

251251
/**
252252
* @return Class loader ID.
253253
*/
254-
public IgniteUuid classLoaderId() {
254+
IgniteUuid classLoaderId() {
255255
return clsLdrId;
256256
}
257257

258258
/**
259259
* @return {@code True} to force local deployment.
260260
*/
261-
public boolean forceLocalDeployment() {
261+
boolean forceLocalDeployment() {
262262
return forceLocDep;
263263
}
264264

265265
/**
266266
* @return Topology version.
267267
*/
268-
public AffinityTopologyVersion topologyVersion() {
268+
AffinityTopologyVersion topologyVersion() {
269269
return topVer;
270270
}
271271

0 commit comments

Comments
 (0)