Showing
1 changed file
with
18 additions
and
17 deletions
... | @@ -36,6 +36,7 @@ public class SimpleHostStore { | ... | @@ -36,6 +36,7 @@ public class SimpleHostStore { |
36 | 36 | ||
37 | // hosts sorted based on their location | 37 | // hosts sorted based on their location |
38 | private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); | 38 | private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); |
39 | + | ||
39 | /** | 40 | /** |
40 | * Creates a new host or updates the existing one based on the specified | 41 | * Creates a new host or updates the existing one based on the specified |
41 | * description. | 42 | * description. |
... | @@ -56,13 +57,13 @@ public class SimpleHostStore { | ... | @@ -56,13 +57,13 @@ public class SimpleHostStore { |
56 | 57 | ||
57 | // creates a new host and sends HOST_ADDED | 58 | // creates a new host and sends HOST_ADDED |
58 | private HostEvent createHost(ProviderId providerId, HostId hostId, | 59 | private HostEvent createHost(ProviderId providerId, HostId hostId, |
59 | - HostDescription descr) { | 60 | + HostDescription descr) { |
60 | DefaultHost newhost = new DefaultHost(providerId, hostId, | 61 | DefaultHost newhost = new DefaultHost(providerId, hostId, |
61 | - descr.hwAddress(), | 62 | + descr.hwAddress(), |
62 | - descr.vlan(), | 63 | + descr.vlan(), |
63 | - descr.location(), | 64 | + descr.location(), |
64 | - descr.ipAddresses()); | 65 | + descr.ipAddresses()); |
65 | - synchronized(this) { | 66 | + synchronized (this) { |
66 | hosts.put(hostId, newhost); | 67 | hosts.put(hostId, newhost); |
67 | locations.put(descr.location(), newhost); | 68 | locations.put(descr.location(), newhost); |
68 | } | 69 | } |
... | @@ -71,22 +72,22 @@ public class SimpleHostStore { | ... | @@ -71,22 +72,22 @@ public class SimpleHostStore { |
71 | 72 | ||
72 | // checks for type of update to host, sends appropriate event | 73 | // checks for type of update to host, sends appropriate event |
73 | private HostEvent updateHost(ProviderId providerId, Host host, | 74 | private HostEvent updateHost(ProviderId providerId, Host host, |
74 | - HostDescription descr) { | 75 | + HostDescription descr) { |
75 | DefaultHost updated; | 76 | DefaultHost updated; |
76 | HostEvent event; | 77 | HostEvent event; |
77 | if (host.location().equals(descr.location())) { | 78 | if (host.location().equals(descr.location())) { |
78 | updated = new DefaultHost(providerId, host.id(), | 79 | updated = new DefaultHost(providerId, host.id(), |
79 | - host.mac(), | 80 | + host.mac(), |
80 | - host.vlan(), | 81 | + host.vlan(), |
81 | - host.location(), | 82 | + host.location(), |
82 | - descr.ipAddresses()); | 83 | + descr.ipAddresses()); |
83 | event = new HostEvent(HOST_UPDATED, updated); | 84 | event = new HostEvent(HOST_UPDATED, updated); |
84 | } else { | 85 | } else { |
85 | updated = new DefaultHost(providerId, host.id(), | 86 | updated = new DefaultHost(providerId, host.id(), |
86 | - host.mac(), | 87 | + host.mac(), |
87 | - host.vlan(), | 88 | + host.vlan(), |
88 | - descr.location(), | 89 | + descr.location(), |
89 | - host.ipAddresses()); | 90 | + host.ipAddresses()); |
90 | event = new HostEvent(HOST_MOVED, updated); | 91 | event = new HostEvent(HOST_MOVED, updated); |
91 | } | 92 | } |
92 | synchronized (this) { | 93 | synchronized (this) { |
... | @@ -104,7 +105,7 @@ public class SimpleHostStore { | ... | @@ -104,7 +105,7 @@ public class SimpleHostStore { |
104 | * @return remove even or null if host was not found | 105 | * @return remove even or null if host was not found |
105 | */ | 106 | */ |
106 | HostEvent removeHost(HostId hostId) { | 107 | HostEvent removeHost(HostId hostId) { |
107 | - synchronized(this) { | 108 | + synchronized (this) { |
108 | Host host = hosts.remove(hostId); | 109 | Host host = hosts.remove(hostId); |
109 | if (host != null) { | 110 | if (host != null) { |
110 | locations.remove((host.location()), host); | 111 | locations.remove((host.location()), host); |
... | @@ -216,4 +217,4 @@ public class SimpleHostStore { | ... | @@ -216,4 +217,4 @@ public class SimpleHostStore { |
216 | return hostset; | 217 | return hostset; |
217 | } | 218 | } |
218 | 219 | ||
219 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
220 | +} | ... | ... |
-
Please register or login to post a comment