Yuta HIGUCHI

GossipHostStore: prep for making initial size configurable

Change-Id: I256f46ff9772015dac2f02678c5396ee2b566741
...@@ -98,10 +98,13 @@ public class GossipHostStore ...@@ -98,10 +98,13 @@ public class GossipHostStore
98 98
99 private final Logger log = getLogger(getClass()); 99 private final Logger log = getLogger(getClass());
100 100
101 + // TODO: make this configurable
102 + private int hostsExpected = 2000000;
103 +
101 // Host inventory 104 // Host inventory
102 - private final Map<HostId, StoredHost> hosts = new ConcurrentHashMap<>(2000000, 0.75f, 16); 105 + private final Map<HostId, StoredHost> hosts = new ConcurrentHashMap<>(hostsExpected, 0.75f, 16);
103 106
104 - private final Map<HostId, Timestamped<Host>> removedHosts = new ConcurrentHashMap<>(2000000, 0.75f, 16); 107 + private final Map<HostId, Timestamped<Host>> removedHosts = new ConcurrentHashMap<>(hostsExpected, 0.75f, 16);
105 108
106 // Hosts tracked by their location 109 // Hosts tracked by their location
107 private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); 110 private final Multimap<ConnectPoint, Host> locations = HashMultimap.create();
...@@ -539,17 +542,14 @@ public class GossipHostStore ...@@ -539,17 +542,14 @@ public class GossipHostStore
539 Map<HostFragmentId, Timestamp> timestamps = new HashMap<>(hosts.size()); 542 Map<HostFragmentId, Timestamp> timestamps = new HashMap<>(hosts.size());
540 Map<HostId, Timestamp> tombstones = new HashMap<>(removedHosts.size()); 543 Map<HostId, Timestamp> tombstones = new HashMap<>(removedHosts.size());
541 544
542 - for (Entry<HostId, StoredHost> e : hosts.entrySet()) { 545 + hosts.forEach((hostId, hostInfo) -> {
543 -
544 - final HostId hostId = e.getKey();
545 - final StoredHost hostInfo = e.getValue();
546 final ProviderId providerId = hostInfo.providerId(); 546 final ProviderId providerId = hostInfo.providerId();
547 timestamps.put(new HostFragmentId(hostId, providerId), hostInfo.timestamp()); 547 timestamps.put(new HostFragmentId(hostId, providerId), hostInfo.timestamp());
548 - } 548 + });
549 549
550 - for (Entry<HostId, Timestamped<Host>> e : removedHosts.entrySet()) { 550 + removedHosts.forEach((hostId, timestamped) -> {
551 - tombstones.put(e.getKey(), e.getValue().timestamp()); 551 + tombstones.put(hostId, timestamped.timestamp());
552 - } 552 + });
553 553
554 return new HostAntiEntropyAdvertisement(self, timestamps, tombstones); 554 return new HostAntiEntropyAdvertisement(self, timestamps, tombstones);
555 } 555 }
......