Alex Abashev created IGNITE-28619:
-------------------------------------

             Summary: Extend prepareMarshalCacheObjects auto-invoke beyond 
GridCacheIdMessage
                 Key: IGNITE-28619
                 URL: https://issues.apache.org/jira/browse/IGNITE-28619
             Project: Ignite
          Issue Type: Sub-task
            Reporter: Alex Abashev


h2. Summary

The Phase 1 auto-invoke 
({{GridCacheIoManager.prepareMarshalGeneratedCacheObjects}}) only fires when 
{{msg instanceof GridCacheIdMessage}}, and uses 
{{((GridCacheIdMessage)msg).cacheId()}} to resolve the {{CacheObjectContext}}. 
Two tx-response classes fall outside this gating and have to keep a 
hand-written bridge into the generated serializer:

* {{GridDhtTxFinishResponse}} — {{extends GridCacheMessage}}, *not* 
{{GridCacheIdMessage}}; the helper short-circuits before the auto-invoke can 
run.
* {{GridNearTxPrepareResponse}} — *is* a {{GridCacheIdMessage}}, but its 
hand-written {{prepareMarshal}} resolves the {{CacheObjectContext}} from 
{{retVal.cacheId()}} (the inner {{GridCacheReturn}}'s own cacheId), not from 
the outer message's cacheId. Auto-invoking with the outer's id would marshal 
under the wrong cache context if the two ever differ.

Both keep {{retVal.prepareMarshal(cctx)}} → 
{{GridCacheReturnSerializer.prepareMarshalCacheObjects}}, which is why 
{{GridCacheReturn}} still carries a {{static final GridCacheReturnSerializer 
SER}} field and a {{prepareMarshal(GridCacheContext)}} bridge method.

This ticket extends the auto-invoke so those bridges can be deleted.

h2. Proposed approach

Two independent extensions; either or both unblock the cleanup:

# *Cover non-{{GridCacheIdMessage}} {{GridCacheMessage}} subclasses.* For 
messages without their own {{cacheId}} (tx finish responses), use the cacheId 
from the inner element that owns the cache context — typically resolvable via a 
small interface like {{HasCacheId}} or by exposing {{cacheObjectContext()}} on 
{{GridCacheMessage}} itself for the relevant subclasses to override.
# *Allow nested-message dispatch with a different {{cacheId}}.* Generator 
already recurses into {{GridCacheReturn}} via 
{{GRID_CACHE_RETURN_SER.prepareMarshalCacheObjects(msg.retVal, ctx)}} (after 
IGNITE-28520 narrowed {{isRecursableMessage}}). Today the recursion uses 
outer's {{ctx}}. Add a per-recursion override that, when the nested message has 
an {{@Order int cacheId}}, re-resolves the {{CacheObjectContext}} from 
{{retVal.cacheId()}} before calling its serializer.

After either extension lands:

* Drop {{GridCacheReturn.prepareMarshal(GridCacheContext)}} and the {{static 
final SER}} field.
* Drop {{retVal.prepareMarshal(cctx)}} calls in 
{{GridDhtTxFinishResponse.prepareMarshal}} and 
{{GridNearTxPrepareResponse.prepareMarshal}}.
* If both call sites become trivial after the drop, remove the override 
entirely (delegate to {{super}} / parent dispatch).

h2. Out of scope

* Anything in the receive direction — covered by IGNITE-YYYYY 
({{finishUnmarshal}} mirror) and a follow-up of this ticket once both 
directions are wired.
* Renaming {{GridCacheReturn.cacheId}} or relocating it — wire-protocol change, 
separate concern.

h2. Acceptance criteria

* {{GridDhtTxFinishResponseSerializer.prepareMarshalCacheObjects}} is 
auto-invoked end-to-end for tx finish flows (verifiable via a test that closes 
a tx with a non-empty {{retVal}} and asserts {{cacheObj.valBytes != null}} on 
the receiving node before {{processMessage}}).
* {{GridCacheReturn.prepareMarshal}}, {{GridCacheReturn.SER}}, 
{{retVal.prepareMarshal(cctx)}} call sites — gone.
* {{GridCacheReturnValueTransferSelfTest}}, 
{{IgniteCacheEntryProcessorCallTest}}, 
{{GridCachePartitionedTxMultiThreadedSelfTest}} green.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to