Skip to content

Commit 8d1cf53

Browse files
authored
IGNITE-26735 GridDhtPartitionSupplyMessage minor refactoring (#12479)
1 parent 669372f commit 8d1cf53

File tree

2 files changed

+16
-31
lines changed

2 files changed

+16
-31
lines changed

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ else if (supplyMsg.error() != null)
599599

600600
assert part != null;
601601

602-
boolean last = supplyMsg.last() != null && supplyMsg.last().containsKey(p);
602+
boolean last = F.mapContainsKey(supplyMsg.last(), p);
603603

604604
if (part.state() == MOVING) {
605605
boolean reserved = part.reserve();
@@ -665,7 +665,7 @@ else if (supplyMsg.error() != null)
665665
}
666666
}
667667

668-
Collection<Integer> missed = supplyMsg.missed() == null ? Collections.emptyList() : supplyMsg.missed();
668+
Collection<Integer> missed = F.emptyIfNull(supplyMsg.missed());
669669

670670
// Only request partitions based on latest topology version.
671671
for (Integer miss : missed) {

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Map;
2525
import org.apache.ignite.IgniteCheckedException;
2626
import org.apache.ignite.internal.Order;
27+
import org.apache.ignite.internal.managers.communication.ErrorMessage;
2728
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
2829
import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection;
2930
import org.apache.ignite.internal.processors.cache.CacheGroupContext;
@@ -34,7 +35,6 @@
3435
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
3536
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
3637
import org.apache.ignite.internal.util.typedef.internal.S;
37-
import org.apache.ignite.internal.util.typedef.internal.U;
3838
import org.jetbrains.annotations.Nullable;
3939

4040
/**
@@ -67,13 +67,9 @@ public class GridDhtPartitionSupplyMessage extends GridCacheGroupIdMessage imple
6767
@Order(value = 9, method = "messageSize")
6868
private int msgSize;
6969

70-
/** Supplying process error. */
71-
private Throwable err;
72-
73-
// TODO: Should be removed in https://issues.apache.org/jira/browse/IGNITE-26523
74-
/** Serialized form of supplying process error. */
75-
@Order(10)
76-
private byte[] errBytes;
70+
/** Supplying process error message. */
71+
@Order(value = 10, method = "errorMessage")
72+
private @Nullable ErrorMessage errMsg;
7773

7874
/**
7975
* @param rebalanceId Rebalance id.
@@ -110,7 +106,9 @@ public class GridDhtPartitionSupplyMessage extends GridCacheGroupIdMessage imple
110106
this.rebalanceId = rebalanceId;
111107
this.topVer = topVer;
112108
this.addDepInfo = addDepInfo;
113-
this.err = err;
109+
110+
if (err != null)
111+
errMsg = new ErrorMessage(err);
114112
}
115113

116114
/**
@@ -234,21 +232,21 @@ public void infos(Map<Integer, CacheEntryInfoCollection> infos) {
234232

235233
/** Supplying process error. */
236234
@Nullable @Override public Throwable error() {
237-
return err;
235+
return ErrorMessage.error(errMsg);
238236
}
239237

240238
/**
241-
* @return Serialized form of supplying process error.
239+
* @return Supplying process error message.
242240
*/
243-
public byte[] errBytes() {
244-
return errBytes;
241+
@Nullable public ErrorMessage errorMessage() {
242+
return errMsg;
245243
}
246244

247245
/**
248-
* @param errBytes New serialized form of supplying process error.
246+
* @param errMsg New supplying process error message.
249247
*/
250-
public void errBytes(byte[] errBytes) {
251-
this.errBytes = errBytes;
248+
public void errorMessage(@Nullable ErrorMessage errMsg) {
249+
this.errMsg = errMsg;
252250
}
253251

254252
/**
@@ -295,15 +293,6 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar
295293
infoCol.add(info);
296294
}
297295

298-
/** {@inheritDoc} */
299-
@Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws IgniteCheckedException {
300-
super.prepareMarshal(ctx);
301-
302-
// TODO: Should be removed in https://issues.apache.org/jira/browse/IGNITE-26523
303-
if (err != null && errBytes == null)
304-
errBytes = U.marshal(ctx, err);
305-
}
306-
307296
/** {@inheritDoc} */
308297
@Override public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader ldr) throws IgniteCheckedException {
309298
super.finishUnmarshal(ctx, ldr);
@@ -319,10 +308,6 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar
319308
for (int i = 0; i < entries.size(); i++)
320309
entries.get(i).unmarshal(grp.cacheObjectContext(), ldr);
321310
}
322-
323-
// TODO: Should be removed in https://issues.apache.org/jira/browse/IGNITE-26523
324-
if (errBytes != null && err == null)
325-
err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
326311
}
327312

328313
/** {@inheritDoc} */

0 commit comments

Comments
 (0)