Given List of datacenters which are dc1, dc2, dc3 and list of machines, h1, h2, h3, h4 as mentioned below -
Datacenters = dc1, dc2, dc3
Machines = h1, h2, h3, h
Not really sure what you've asked here, but i think i can see where the problem is, each time get call get mapping you only generate 1 row. so i've rewritten the code so it generates all of them and gives you back a list of the maps. so you can do what you need with them.
public class DataCenterMapping {
public static void main(String[] args) {
DatacenterMachineMapping dcm = new DatacenterMachineMapping(
Arrays.asList("dc1", "dc2", "dc3"), Arrays.asList("h1", "h2",
"h3", "h4"));
List
example output:
[{h4=dc1, h1=dc1, h3=dc3, h2=dc2}, {h4=dc2, h1=dc2, h3=dc1, h2=dc3}, {h4=dc3, h1=dc3, h3=dc2, h2=dc1}]