Showing
4 changed files
with
24 additions
and
9 deletions
... | @@ -105,7 +105,7 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> { | ... | @@ -105,7 +105,7 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> { |
105 | * | 105 | * |
106 | * @return port subject or null if the event is not port specific. | 106 | * @return port subject or null if the event is not port specific. |
107 | */ | 107 | */ |
108 | - Port port() { | 108 | + public Port port() { |
109 | return port; | 109 | return port; |
110 | } | 110 | } |
111 | 111 | ... | ... |
... | @@ -51,7 +51,7 @@ public class SimpleDeviceManager | ... | @@ -51,7 +51,7 @@ public class SimpleDeviceManager |
51 | private final AbstractListenerRegistry<DeviceEvent, DeviceListener> | 51 | private final AbstractListenerRegistry<DeviceEvent, DeviceListener> |
52 | listenerRegistry = new AbstractListenerRegistry<>(); | 52 | listenerRegistry = new AbstractListenerRegistry<>(); |
53 | 53 | ||
54 | - private final SimpleDeviceStore store = new SimpleDeviceStore(); | 54 | + private final SimpleDeviceStore store = new SimpleDeviceStore(); |
55 | 55 | ||
56 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 56 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
57 | protected EventDeliveryService eventDispatcher; | 57 | protected EventDeliveryService eventDispatcher; |
... | @@ -143,7 +143,10 @@ public class SimpleDeviceManager | ... | @@ -143,7 +143,10 @@ public class SimpleDeviceManager |
143 | public void removeDevice(DeviceId deviceId) { | 143 | public void removeDevice(DeviceId deviceId) { |
144 | checkNotNull(deviceId, DEVICE_ID_NULL); | 144 | checkNotNull(deviceId, DEVICE_ID_NULL); |
145 | DeviceEvent event = store.removeDevice(deviceId); | 145 | DeviceEvent event = store.removeDevice(deviceId); |
146 | - post(event); | 146 | + if (event != null) { |
147 | + log.info("Device {} administratively removed", deviceId); | ||
148 | + post(event); | ||
149 | + } | ||
147 | } | 150 | } |
148 | 151 | ||
149 | // Personalized device provider service issued to the supplied provider. | 152 | // Personalized device provider service issued to the supplied provider. |
... | @@ -159,12 +162,12 @@ public class SimpleDeviceManager | ... | @@ -159,12 +162,12 @@ public class SimpleDeviceManager |
159 | checkNotNull(deviceId, DEVICE_ID_NULL); | 162 | checkNotNull(deviceId, DEVICE_ID_NULL); |
160 | checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL); | 163 | checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL); |
161 | checkValidity(); | 164 | checkValidity(); |
162 | - log.info("Device {} connected", deviceId); | ||
163 | DeviceEvent event = store.createOrUpdateDevice(provider().id(), | 165 | DeviceEvent event = store.createOrUpdateDevice(provider().id(), |
164 | deviceId, deviceDescription); | 166 | deviceId, deviceDescription); |
165 | 167 | ||
166 | // If there was a change of any kind, trigger role selection process. | 168 | // If there was a change of any kind, trigger role selection process. |
167 | if (event != null) { | 169 | if (event != null) { |
170 | + log.info("Device {} connected", deviceId); | ||
168 | Device device = event.subject(); | 171 | Device device = event.subject(); |
169 | provider().roleChanged(device, store.getRole(device.id())); | 172 | provider().roleChanged(device, store.getRole(device.id())); |
170 | post(event); | 173 | post(event); |
... | @@ -175,9 +178,11 @@ public class SimpleDeviceManager | ... | @@ -175,9 +178,11 @@ public class SimpleDeviceManager |
175 | public void deviceDisconnected(DeviceId deviceId) { | 178 | public void deviceDisconnected(DeviceId deviceId) { |
176 | checkNotNull(deviceId, DEVICE_ID_NULL); | 179 | checkNotNull(deviceId, DEVICE_ID_NULL); |
177 | checkValidity(); | 180 | checkValidity(); |
178 | - log.info("Device {} disconnected", deviceId); | ||
179 | DeviceEvent event = store.markOffline(deviceId); | 181 | DeviceEvent event = store.markOffline(deviceId); |
180 | - post(event); | 182 | + if (event != null) { |
183 | + log.info("Device {} disconnected", deviceId); | ||
184 | + post(event); | ||
185 | + } | ||
181 | } | 186 | } |
182 | 187 | ||
183 | @Override | 188 | @Override |
... | @@ -185,7 +190,6 @@ public class SimpleDeviceManager | ... | @@ -185,7 +190,6 @@ public class SimpleDeviceManager |
185 | checkNotNull(deviceId, DEVICE_ID_NULL); | 190 | checkNotNull(deviceId, DEVICE_ID_NULL); |
186 | checkNotNull(portDescriptions, "Port descriptions list cannot be null"); | 191 | checkNotNull(portDescriptions, "Port descriptions list cannot be null"); |
187 | checkValidity(); | 192 | checkValidity(); |
188 | - log.info("Device {} ports updated", deviceId); | ||
189 | List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions); | 193 | List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions); |
190 | for (DeviceEvent event : events) { | 194 | for (DeviceEvent event : events) { |
191 | post(event); | 195 | post(event); |
... | @@ -199,9 +203,10 @@ public class SimpleDeviceManager | ... | @@ -199,9 +203,10 @@ public class SimpleDeviceManager |
199 | checkValidity(); | 203 | checkValidity(); |
200 | DeviceEvent event = store.updatePortStatus(deviceId, portDescription); | 204 | DeviceEvent event = store.updatePortStatus(deviceId, portDescription); |
201 | if (event != null) { | 205 | if (event != null) { |
202 | - log.info("Device {} port status changed", deviceId); | 206 | + log.info("Device {} port {} status changed", deviceId, |
207 | + event.port().number()); | ||
208 | + post(event); | ||
203 | } | 209 | } |
204 | - post(event); | ||
205 | } | 210 | } |
206 | } | 211 | } |
207 | 212 | ... | ... |
... | @@ -53,6 +53,8 @@ public class SimpleTopologyManager | ... | @@ -53,6 +53,8 @@ public class SimpleTopologyManager |
53 | private final AbstractListenerRegistry<TopologyEvent, TopologyListener> | 53 | private final AbstractListenerRegistry<TopologyEvent, TopologyListener> |
54 | listenerRegistry = new AbstractListenerRegistry<>(); | 54 | listenerRegistry = new AbstractListenerRegistry<>(); |
55 | 55 | ||
56 | + private final SimpleTopologyStore store = new SimpleTopologyStore(); | ||
57 | + | ||
56 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 58 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
57 | private EventDeliveryService eventDispatcher; | 59 | private EventDeliveryService eventDispatcher; |
58 | 60 | ... | ... |
-
Please register or login to post a comment