private Object handleTxWriteCommand ( InvocationContext ctx , AbstractDataWriteCommand command , Object key ) throws Throwable { try { if ( ! ctx . isOriginLocal ( ) ) { LocalizedCacheTopology cacheTopology = checkTopologyId ( command ) ; // Ignore any remote command when we aren't the owner if ( ! cacheTopology . isSegmentWriteOwner ( command . getSegment ( ) ) ) { return null ; } } CacheEntry entry = ctx . lookupEntry ( command . getKey ( ) ) ; if ( entry == null ) { if ( isLocalModeForced ( command ) || command . hasAnyFlag ( FlagBitSets . SKIP_REMOTE_LOOKUP ) || ! needsPreviousValue ( ctx , command ) ) { // in transactional mode, we always need the entry wrapped entryFactory . wrapExternalEntry ( ctx , key , null , false , true ) ; } else { // we need to retrieve the value locally regardless of load type; in transactional mode all operations // execute on origin // Also, operations that need value on backup [delta write] need to do the remote lookup even on // non-origin Object result = asyncInvokeNext ( ctx , command , remoteGetSingleKey ( ctx , command , command . getKey ( ) , true ) ) ; return makeStage ( result ) . andFinally ( ctx , command , ( rCtx , rCommand , rv , t ) -> updateMatcherForRetry ( ( WriteCommand ) rCommand ) ) ; } } // already wrapped, we can continue return invokeNextAndFinally ( ctx , command , ( rCtx , rCommand , rv , t ) -> updateMatcherForRetry ( ( WriteCommand ) rCommand ) ) ; } catch ( Throwable t ) { updateMatcherForRetry ( command ) ; throw t ; } }
If we are within one transaction we won t do any replication as replication would only be performed at commit time . If the operation didn t originate locally we won t do any replication either .