|
17 | 17 |
|
18 | 18 | package org.apache.ignite.internal.processors.cache.distributed.dht.preloader; |
19 | 19 |
|
20 | | -import java.nio.ByteBuffer; |
21 | 20 | import java.util.ArrayList; |
22 | 21 | import java.util.Collection; |
23 | 22 | import java.util.List; |
24 | 23 | import java.util.Map; |
25 | 24 | import org.apache.ignite.cluster.ClusterNode; |
26 | | -import org.apache.ignite.internal.GridDirectCollection; |
27 | | -import org.apache.ignite.internal.GridDirectMap; |
| 25 | +import org.apache.ignite.internal.Order; |
28 | 26 | import org.apache.ignite.internal.managers.discovery.DiscoCache; |
29 | 27 | import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; |
30 | 28 | import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache; |
|
35 | 33 | import org.apache.ignite.internal.util.typedef.internal.S; |
36 | 34 | import org.apache.ignite.internal.util.typedef.internal.U; |
37 | 35 | import org.apache.ignite.plugin.extensions.communication.Message; |
38 | | -import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; |
39 | | -import org.apache.ignite.plugin.extensions.communication.MessageReader; |
40 | | -import org.apache.ignite.plugin.extensions.communication.MessageWriter; |
41 | 36 | import org.jetbrains.annotations.Nullable; |
42 | 37 |
|
43 | 38 | /** |
44 | 39 | * Information about affinity assignment. |
45 | 40 | */ |
46 | 41 | public class CacheGroupAffinityMessage implements Message { |
47 | 42 | /** */ |
48 | | - @GridDirectCollection(GridLongList.class) |
| 43 | + @Order(value = 0, method = "assignments") |
49 | 44 | private List<GridLongList> assigns; |
50 | 45 |
|
51 | 46 | /** */ |
52 | | - @GridDirectCollection(GridLongList.class) |
| 47 | + @Order(value = 1, method = "idealAssignments") |
53 | 48 | private List<GridLongList> idealAssigns; |
54 | 49 |
|
55 | 50 | /** */ |
56 | | - @GridDirectMap(keyType = Integer.class, valueType = GridLongList.class) |
| 51 | + @Order(value = 2, method = "assignmentsDiff") |
57 | 52 | private Map<Integer, GridLongList> assignsDiff; |
58 | 53 |
|
59 | 54 | /** |
@@ -240,79 +235,45 @@ private List<List<ClusterNode>> createAssignments(List<GridLongList> assigns, |
240 | 235 | } |
241 | 236 |
|
242 | 237 | /** |
243 | | - * @return Difference with ideal affinity assignment. |
| 238 | + * @return Assignment. |
244 | 239 | */ |
245 | | - public Map<Integer, GridLongList> assignmentsDiff() { |
246 | | - return assignsDiff; |
| 240 | + public List<GridLongList> assignments() { |
| 241 | + return assigns; |
247 | 242 | } |
248 | 243 |
|
249 | | - /** {@inheritDoc} */ |
250 | | - @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { |
251 | | - writer.setBuffer(buf); |
252 | | - |
253 | | - if (!writer.isHeaderWritten()) { |
254 | | - if (!writer.writeHeader(directType())) |
255 | | - return false; |
256 | | - |
257 | | - writer.onHeaderWritten(); |
258 | | - } |
259 | | - |
260 | | - switch (writer.state()) { |
261 | | - case 0: |
262 | | - if (!writer.writeCollection(assigns, MessageCollectionItemType.MSG)) |
263 | | - return false; |
264 | | - |
265 | | - writer.incrementState(); |
266 | | - |
267 | | - case 1: |
268 | | - if (!writer.writeMap(assignsDiff, MessageCollectionItemType.INT, MessageCollectionItemType.MSG)) |
269 | | - return false; |
270 | | - |
271 | | - writer.incrementState(); |
272 | | - |
273 | | - case 2: |
274 | | - if (!writer.writeCollection(idealAssigns, MessageCollectionItemType.MSG)) |
275 | | - return false; |
276 | | - |
277 | | - writer.incrementState(); |
278 | | - |
279 | | - } |
280 | | - |
281 | | - return true; |
| 244 | + /** |
| 245 | + * @param assigns Assignment. |
| 246 | + */ |
| 247 | + public void assignments(List<GridLongList> assigns) { |
| 248 | + this.assigns = assigns; |
282 | 249 | } |
283 | 250 |
|
284 | | - /** {@inheritDoc} */ |
285 | | - @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { |
286 | | - reader.setBuffer(buf); |
287 | | - |
288 | | - switch (reader.state()) { |
289 | | - case 0: |
290 | | - assigns = reader.readCollection(MessageCollectionItemType.MSG); |
291 | | - |
292 | | - if (!reader.isLastRead()) |
293 | | - return false; |
294 | | - |
295 | | - reader.incrementState(); |
296 | | - |
297 | | - case 1: |
298 | | - assignsDiff = reader.readMap(MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false); |
299 | | - |
300 | | - if (!reader.isLastRead()) |
301 | | - return false; |
302 | | - |
303 | | - reader.incrementState(); |
304 | | - |
305 | | - case 2: |
306 | | - idealAssigns = reader.readCollection(MessageCollectionItemType.MSG); |
307 | | - |
308 | | - if (!reader.isLastRead()) |
309 | | - return false; |
| 251 | + /** |
| 252 | + * @return Ideal assignment. |
| 253 | + */ |
| 254 | + public List<GridLongList> idealAssignments() { |
| 255 | + return idealAssigns; |
| 256 | + } |
310 | 257 |
|
311 | | - reader.incrementState(); |
| 258 | + /** |
| 259 | + * @param idealAssigns Ideal assignment. |
| 260 | + */ |
| 261 | + public void idealAssignments(List<GridLongList> idealAssigns) { |
| 262 | + this.idealAssigns = idealAssigns; |
| 263 | + } |
312 | 264 |
|
313 | | - } |
| 265 | + /** |
| 266 | + * @return Difference with ideal affinity assignment. |
| 267 | + */ |
| 268 | + public Map<Integer, GridLongList> assignmentsDiff() { |
| 269 | + return assignsDiff; |
| 270 | + } |
314 | 271 |
|
315 | | - return true; |
| 272 | + /** |
| 273 | + * @param assignsDiff Difference with ideal affinity assignment. |
| 274 | + */ |
| 275 | + public void assignmentsDiff(Map<Integer, GridLongList> assignsDiff) { |
| 276 | + this.assignsDiff = assignsDiff; |
316 | 277 | } |
317 | 278 |
|
318 | 279 | /** {@inheritDoc} */ |
|
0 commit comments