public Collection < Map . Entry < Address , List < Integer > > > getPartitions ( PartitionTableView partitionTableView ) { Map < Address , List < Integer > > partitionsMap = new HashMap < Address , List < Integer > > ( ) ; int partitionCount = partitionTableView . getLength ( ) ; for ( int partitionId = 0 ; partitionId < partitionCount ; partitionId ++ ) { PartitionReplica owner = partitionTableView . getReplica ( partitionId , 0 ) ; if ( owner == null ) { partitionsMap . clear ( ) ; return partitionsMap . entrySet ( ) ; } Address clientOwnerAddress = clientAddressOf ( owner . address ( ) ) ; if ( clientOwnerAddress == null ) { partitionsMap . clear ( ) ; return partitionsMap . entrySet ( ) ; } List < Integer > indexes = partitionsMap . get ( clientOwnerAddress ) ; if ( indexes == null ) { indexes = new LinkedList < Integer > ( ) ; partitionsMap . put ( clientOwnerAddress , indexes ) ; } indexes . add ( partitionId ) ; } return partitionsMap . entrySet ( ) ; }
If any partition does not have an owner this method returns empty collection