4444import org .apache .ignite .internal .IgniteInternalFuture ;
4545import org .apache .ignite .internal .IgniteInterruptedCheckedException ;
4646import org .apache .ignite .internal .NodeStoppingException ;
47- import org .apache .ignite .internal .managers .discovery .DiscoveryCustomMessage ;
4847import org .apache .ignite .internal .managers .discovery .DiscoveryLocalJoinData ;
4948import org .apache .ignite .internal .managers .discovery .GridDiscoveryManager ;
5049import org .apache .ignite .internal .processors .GridProcessorAdapter ;
8483import static org .apache .ignite .internal .processors .metastorage .persistence .DistributedMetaStorageHistoryItem .EMPTY_ARRAY ;
8584import static org .apache .ignite .internal .processors .metastorage .persistence .DistributedMetaStorageUtil .historyItemPrefix ;
8685import static org .apache .ignite .internal .processors .metastorage .persistence .DistributedMetaStorageUtil .historyItemVer ;
87- import static org .apache .ignite .internal .processors .metastorage .persistence .DistributedMetaStorageUtil .marshal ;
8886import static org .apache .ignite .internal .processors .metastorage .persistence .DistributedMetaStorageUtil .unmarshal ;
8987import static org .apache .ignite .internal .processors .metastorage .persistence .DistributedMetaStorageVersion .INITIAL_VERSION ;
9088import static org .apache .ignite .internal .processors .metric .impl .MetricUtils .metricName ;
@@ -479,7 +477,7 @@ private void onMetaStorageReadyForWrite(ReadWriteMetastorage metastorage) {
479477 @ Override public void write (@ NotNull String key , @ NotNull Serializable val ) throws IgniteCheckedException {
480478 assert val != null : key ;
481479
482- startWrite (key , marshal ( marshaller , val ) ).get ();
480+ startWrite (key , val ).get ();
483481 }
484482
485483 /** {@inheritDoc} */
@@ -489,7 +487,7 @@ private void onMetaStorageReadyForWrite(ReadWriteMetastorage metastorage) {
489487 ) throws IgniteCheckedException {
490488 assert val != null : key ;
491489
492- return startWrite (key , marshal ( marshaller , val ) );
490+ return startWrite (key , val );
493491 }
494492
495493 /** {@inheritDoc} */
@@ -521,7 +519,7 @@ private void onMetaStorageReadyForWrite(ReadWriteMetastorage metastorage) {
521519 ) throws IgniteCheckedException {
522520 assert newVal != null : key ;
523521
524- return startCas (key , marshal ( marshaller , expVal ), marshal ( marshaller , newVal ) );
522+ return startCas (key , expVal , newVal );
525523 }
526524
527525 /** {@inheritDoc} */
@@ -531,7 +529,7 @@ private void onMetaStorageReadyForWrite(ReadWriteMetastorage metastorage) {
531529 ) throws IgniteCheckedException {
532530 assert expVal != null : key ;
533531
534- return startCas (key , marshal ( marshaller , expVal ) , null ).get ();
532+ return startCas (key , expVal , null ).get ();
535533 }
536534
537535 /** {@inheritDoc} */
@@ -1046,28 +1044,30 @@ else if (!isClient && ver.id() > 0) {
10461044 * for operation to be completed.
10471045 *
10481046 * @param key The key.
1049- * @param valBytes Value bytes to write. Null if value needs to be removed.
1047+ * @param val Value to write. Null if value needs to be removed.
10501048 * @throws IgniteCheckedException If there was an error while sending discovery message.
10511049 */
1052- private GridFutureAdapter <?> startWrite (String key , byte [] valBytes ) throws IgniteCheckedException {
1050+ private GridFutureAdapter <?> startWrite (String key , @ Nullable Serializable val ) throws IgniteCheckedException {
10531051 UUID reqId = UUID .randomUUID ();
10541052
10551053 GridFutureAdapter <?> fut = prepareWriteFuture (reqId );
10561054
10571055 if (fut .isDone ())
10581056 return fut ;
10591057
1060- DiscoveryCustomMessage msg = new DistributedMetaStorageUpdateMessage (reqId , key , valBytes );
1058+ DistributedMetaStorageUpdateMessage msg = new DistributedMetaStorageUpdateMessage (reqId , key , val );
1059+
1060+ msg .prepareMarshal (marshaller );
10611061
10621062 ctx .discovery ().sendCustomEvent (msg );
10631063
10641064 return fut ;
10651065 }
10661066
10671067 /**
1068- * Basically the same as {@link #startWrite(String, byte[] )} but for CAS operations.
1068+ * Basically the same as {@link #startWrite(String, Serializable )} but for CAS operations.
10691069 */
1070- private GridFutureAdapter <Boolean > startCas (String key , byte [] expValBytes , byte [] newValBytes )
1070+ private GridFutureAdapter <Boolean > startCas (String key , @ Nullable Serializable expVal , @ Nullable Serializable newVal )
10711071 throws IgniteCheckedException {
10721072 UUID reqId = UUID .randomUUID ();
10731073
@@ -1076,7 +1076,9 @@ private GridFutureAdapter<Boolean> startCas(String key, byte[] expValBytes, byte
10761076 if (fut .isDone ())
10771077 return fut ;
10781078
1079- DiscoveryCustomMessage msg = new DistributedMetaStorageCasMessage (reqId , key , expValBytes , newValBytes );
1079+ DistributedMetaStorageCasMessage msg = new DistributedMetaStorageCasMessage (reqId , key , expVal , newVal );
1080+
1081+ msg .prepareMarshal (marshaller );
10801082
10811083 ctx .discovery ().sendCustomEvent (msg );
10821084
@@ -1134,7 +1136,7 @@ private void onUpdateMessage(
11341136 if (msg instanceof DistributedMetaStorageCasMessage )
11351137 completeCas ((DistributedMetaStorageCasMessage )msg );
11361138 else
1137- completeWrite (new DistributedMetaStorageHistoryItem (msg .key (), msg .value ()));
1139+ completeWrite (new DistributedMetaStorageHistoryItem (msg .key (), msg .valueBytes ()));
11381140 }
11391141 catch (IgniteInterruptedCheckedException e ) {
11401142 throw U .convertException (e );
@@ -1318,16 +1320,16 @@ private void completeCas(
13181320
13191321 Serializable oldVal = bridge .read (msg .key ());
13201322
1321- Serializable expVal = unmarshal ( marshaller , msg .expectedValue () );
1323+ msg .finishUnmarshal ( marshaller );
13221324
1323- if (!Objects .deepEquals (oldVal , expVal )) {
1325+ if (!Objects .deepEquals (oldVal , msg . expectedValue () )) {
13241326 msg .setMatches (false );
13251327
13261328 // Do nothing if expected value doesn't match with the actual one.
13271329 return ;
13281330 }
13291331
1330- completeWrite (new DistributedMetaStorageHistoryItem (msg .key (), msg .value ()));
1332+ completeWrite (new DistributedMetaStorageHistoryItem (msg .key (), msg .valueBytes ()));
13311333 }
13321334
13331335 /**
0 commit comments