2222import java .util .UUID ;
2323import org .apache .ignite .IgniteCheckedException ;
2424import org .apache .ignite .cluster .ClusterNode ;
25+ import org .apache .ignite .internal .Order ;
26+ import org .apache .ignite .internal .managers .communication .ErrorMessage ;
2527import org .apache .ignite .internal .managers .discovery .DiscoCache ;
2628import org .apache .ignite .internal .managers .discovery .DiscoveryCustomMessage ;
2729import org .apache .ignite .internal .managers .discovery .GridDiscoveryManager ;
3234import org .apache .ignite .internal .util .typedef .internal .S ;
3335import org .apache .ignite .internal .util .typedef .internal .U ;
3436import org .apache .ignite .lang .IgniteUuid ;
37+ import org .apache .ignite .plugin .extensions .communication .Message ;
38+ import org .apache .ignite .plugin .extensions .communication .MessageFactory ;
3539import org .jetbrains .annotations .Nullable ;
3640
3741/**
3842 * This class represents discovery message that is used to provide information about dynamic cache start failure.
3943 */
40- public class ExchangeFailureMessage implements DiscoveryCustomMessage {
44+ public class ExchangeFailureMessage implements DiscoveryCustomMessage , Message {
4145 /** */
4246 private static final long serialVersionUID = 0L ;
4347
4448 /** Cache names. */
4549 @ GridToStringInclude
46- private final Collection <String > cacheNames ;
50+ @ Order (0 )
51+ Collection <String > cacheNames ;
4752
4853 /** Custom message ID. */
49- private final IgniteUuid id ;
54+ @ Order (1 )
55+ IgniteUuid id ;
5056
5157 /** */
52- private final GridDhtPartitionExchangeId exchId ;
58+ @ Order (2 )
59+ GridDhtPartitionExchangeId exchId ;
5360
5461 /** */
5562 @ GridToStringInclude
56- private final Map <UUID , Throwable > exchangeErrors ;
63+ @ Order (3 )
64+ Map <UUID , ErrorMessage > exchangeErrors ;
5765
5866 /** Actions to be done to rollback changes done before the exchange failure. */
5967 private transient ExchangeActions exchangeRollbackActions ;
6068
69+ /** Default constructor for {@link MessageFactory}. */
70+ public ExchangeFailureMessage () {
71+ // No-op.
72+ }
73+
6174 /**
6275 * Creates new DynamicCacheChangeFailureMessage instance.
6376 *
@@ -78,7 +91,7 @@ public ExchangeFailureMessage(
7891 this .id = IgniteUuid .fromUuid (locNode .id ());
7992 this .exchId = exchId ;
8093 this .cacheNames = cacheNames ;
81- this .exchangeErrors = exchangeErrors ;
94+ this .exchangeErrors = F . viewReadOnly ( exchangeErrors , ErrorMessage :: new ) ;
8295 }
8396
8497 /** {@inheritDoc} */
@@ -95,7 +108,7 @@ public Collection<String> cacheNames() {
95108
96109 /** */
97110 public Map <UUID , Throwable > exchangeErrors () {
98- return exchangeErrors ;
111+ return F . viewReadOnly ( exchangeErrors , e -> ErrorMessage . error ( e )) ;
99112 }
100113
101114 /**
@@ -123,7 +136,7 @@ public void exchangeRollbackActions(ExchangeActions exchangeRollbackActions) {
123136 public IgniteCheckedException createFailureCompoundException () {
124137 IgniteCheckedException ex = new IgniteCheckedException ("Failed to complete exchange process." );
125138
126- for (Map .Entry <UUID , Throwable > entry : exchangeErrors .entrySet ())
139+ for (Map .Entry <UUID , Throwable > entry : exchangeErrors () .entrySet ())
127140 U .addSuppressed (ex , entry .getValue ());
128141
129142 return ex ;
0 commit comments