private void collectTransactionsToTransfer(List<TransactionInfo> transactionsToTransfer,
Collection<? extends CacheTransaction> transactions,
Set<Integer> segments, CacheTopology cacheTopology) {
int topologyId = cacheTopology.getTopologyId();
List<Address> members = cacheTopology.getMembers();
ConsistentHash readCh = cacheTopology.getReadConsistentHash();
// no need to filter out state transfer generated transactions because there should not be any such transactions running for any of the requested segments
for (CacheTransaction tx : transactions) {
// Skip transactions whose originators left. The topology id check is needed for joiners.
if (tx.getTopologyId() < topologyId && !members.contains(tx.getGlobalTransaction().getAddress()))
continue;
// transfer only locked keys that belong to requested segments
Set<Object> filteredLockedKeys = new HashSet<Object>();
Set<Object> lockedKeys = tx.getLockedKeys();
synchronized (lockedKeys) {
for (Object key : lockedKeys) {
if (segments.contains(readCh.getSegment(key))) {
filteredLockedKeys.add(key);
}
}
}
Set<Object> backupLockedKeys = tx.getBackupLockedKeys();
synchronized (backupLockedKeys) {
for (Object key : backupLockedKeys) {
if (segments.contains(readCh.getSegment(key))) {
filteredLockedKeys.add(key);
}
}
}
if (!filteredLockedKeys.isEmpty()) {