private List < DelayedEntry > callHandler ( Collection < DelayedEntry > delayedEntries , StoreOperationType operationType ) { final int size = delayedEntries . size ( ) ; if ( size == 0 ) { return Collections . emptyList ( ) ; } // if we want to write all store operations on a key into the MapStore, not same as write-coalescing, we don't call // batch processing methods e.g., MapStore{#storeAll,#deleteAll}, instead we call methods which process single entries // e.g. MapStore{#store,#delete}. This is because MapStore#storeAll requires a Map type in its signature and Map type // can only contain one store operation type per key, so only last update on a key can be included when batching. // Due to that limitation it is not possible to provide a correct no-write-coalescing write-behind behavior. // Under that limitation of current MapStore interface, we are making a workaround and persisting all // entries one by one for no-write-coalescing write-behind map-stores and as a result not doing batching // when writeCoalescing is false. if ( size == 1 || ! writeCoalescing ) { return processEntriesOneByOne ( delayedEntries , operationType ) ; } final DelayedEntry [ ] delayedEntriesArray = delayedEntries . toArray ( new DelayedEntry [ 0 ] ) ; final Map < Object , DelayedEntry > batchMap = prepareBatchMap ( delayedEntriesArray ) ; // if all batch is on same key, call single store. if ( batchMap . size ( ) == 1 ) { final DelayedEntry delayedEntry = delayedEntriesArray [ delayedEntriesArray . length - 1 ] ; return callSingleStoreWithListeners ( delayedEntry , operationType ) ; } final List < DelayedEntry > failedEntryList = callBatchStoreWithListeners ( batchMap , operationType ) ; final List < DelayedEntry > failedTries = new ArrayList <> ( ) ; for ( DelayedEntry entry : failedEntryList ) { final Collection < DelayedEntry > tmpFails = callSingleStoreWithListeners ( entry , operationType ) ; failedTries . addAll ( tmpFails ) ; } return failedTries ; }
Decides how entries should be passed to handlers . It passes entries to handler s single or batch handling methods .