I think you could use the DataContainer's keySet() directly here, without checking that the local node is the primary owner. 

But you are going to call the mapper twice for some entries, because an entry can be evicted from memory after you called the mapper for it but before you call keySet(). So I think you might need to keep track of mapped keys as you are iterating over them.