@Test public void testAttachmentPointFlapping() throws Exception { Calendar c = Calendar.getInstance(); ITopologyService mockTopology = createMock(ITopologyService.class); expect(mockTopology.isAttachmentPointPort(anyLong(), anyShort())).andReturn(true).anyTimes(); expect(mockTopology.isBroadcastDomainPort(anyLong(), anyShort())). andReturn(false).anyTimes(); expect(mockTopology.isInSameBroadcastDomain(anyLong(), anyShort(), anyLong(), anyShort())).andReturn(false).anyTimes(); expect(mockTopology.getL2DomainId(anyLong())). andReturn(1L).anyTimes(); expect(mockTopology.isConsistent(1L, (short)1, 1L, (short)1)). andReturn(true).anyTimes(); expect(mockTopology.isConsistent(1L, (short)1, 5L, (short)1)). andReturn(false).anyTimes(); expect(mockTopology.isConsistent(1L, (short)1, 10L, (short)1)). andReturn(false).anyTimes(); expect(mockTopology.isConsistent(5L, (short)1, 10L, (short)1)). andReturn(false).anyTimes(); expect(mockTopology.isConsistent(10L, (short)1, 1L, (short)1)). andReturn(false).anyTimes(); expect(mockTopology.isConsistent(5L, (short)1, 1L, (short)1)). andReturn(false).anyTimes(); expect(mockTopology.isConsistent(10L, (short)1, 5L, (short)1)). andReturn(false).anyTimes(); Date topologyUpdateTime = new Date(); expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime). anyTimes(); replay(mockTopology); deviceManager.topology = mockTopology; Entity entity1 = new Entity(1L, null, null, 1L, 1, c.getTime()); Entity entity1a = new Entity(1L, null, 1, 1L, 1, c.getTime()); Entity entity2 = new Entity(1L, null, null, 5L, 1, c.getTime()); Entity entity3 = new Entity(1L, null, null, 10L, 1, c.getTime()); entity1.setLastSeenTimestamp(c.getTime()); c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT/2); entity1a.setLastSeenTimestamp(c.getTime()); c.add(Calendar.MILLISECOND, 1); entity2.setLastSeenTimestamp(c.getTime()); c.add(Calendar.MILLISECOND, 1); entity3.setLastSeenTimestamp(c.getTime()); IDevice d; d = deviceManager.learnDeviceByEntity(entity1); d = deviceManager.learnDeviceByEntity(entity1a); d = deviceManager.learnDeviceByEntity(entity2); d = deviceManager.learnDeviceByEntity(entity3); assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1) }, d.getAttachmentPoints()); assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1),}, d.getAttachmentPoints(true)); c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT/4); entity1.setLastSeenTimestamp(c.getTime()); d = deviceManager.learnDeviceByEntity(entity1); assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) }, d.getAttachmentPoints()); assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1), new SwitchPort(5L, 1, ErrorStatus.DUPLICATE_DEVICE), new SwitchPort(10L, 1, ErrorStatus.DUPLICATE_DEVICE) }, d.getAttachmentPoints(true)); c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT+2000); entity1.setLastSeenTimestamp(c.getTime()); d = deviceManager.learnDeviceByEntity(entity1); assertEquals(entity1.getActiveSince(), entity1.getLastSeenTimestamp()); assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) }, d.getAttachmentPoints()); assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) }, d.getAttachmentPoints(true)); }
protected Device learnDeviceByEntity(Entity entity) { ArrayList<Long> deleteQueue = null; LinkedList<DeviceUpdate> deviceUpdates = null; Device device = null; while (true) { deviceUpdates = null; Long deviceKey = primaryIndex.findByEntity(entity); IEntityClass entityClass = null; if (deviceKey == null) { entityClass = entityClassifier.classifyEntity(entity); if (entityClass == null) { device = null; break; } ClassState classState = getClassState(entityClass); if (classState.classIndex != null) { deviceKey = classState.classIndex.findByEntity(entity); } } if (deviceKey != null) { device = deviceMap.get(deviceKey); if (device == null) { if (logger.isDebugEnabled()) { logger.debug("No device for deviceKey {} while " + "while processing entity {}", deviceKey, entity); } continue; } } else { if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntDeviceOnInternalPortNotLearned.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("Not learning new device on internal" + " link: {}", entity); } device = null; break; } if (!isEntityAllowed(entity, entityClass)) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("PacketIn is not allowed {} {}", entityClass.getName(), entity); } device = null; break; } deviceKey = deviceKeyCounter.getAndIncrement(); device = allocateDevice(deviceKey, entity, entityClass); deviceMap.put(deviceKey, device); if (!updateIndices(device, deviceKey)) { if (deleteQueue == null) deleteQueue = new ArrayList<Long>(); deleteQueue.add(deviceKey); continue; } updateSecondaryIndices(entity, entityClass, deviceKey); cntNewDevice.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("New device created: {} deviceKey={}, entity={}", new Object[]{device, deviceKey, entity}); } deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(device, ADD, null)); break; } if (!isEntityAllowed(entity, device.getEntityClass())) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.info("PacketIn is not allowed {} {}", device.getEntityClass().getName(), entity); } return null; } if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntPacketOnInternalPortForKnownDevice.updateCounterNoFlush(); break; } int entityindex = -1; if ((entityindex = device.entityIndex(entity)) >= 0) { Date lastSeen = entity.getLastSeenTimestamp(); if (lastSeen == null) { lastSeen = new Date(); entity.setLastSeenTimestamp(lastSeen); } device.entities[entityindex].setLastSeenTimestamp(lastSeen); } else { entityindex = -(entityindex + 1); Device newDevice = allocateDevice(device, entity, entityindex); EnumSet<DeviceField> changedFields = findChangedFields(device, entity); boolean res = deviceMap.replace(deviceKey, device, newDevice); if (!res) continue; device = newDevice; if (!updateIndices(device, deviceKey)) { continue; } updateSecondaryIndices(entity, device.getEntityClass(), deviceKey); cntNewEntity.updateCounterNoFlush(); if (changedFields.size() > 0) { cntDeviceChanged.updateCounterNoFlush(); deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(newDevice, CHANGE, changedFields)); } } if (entity.hasSwitchPort()) { boolean moved = device.updateAttachmentPoint(entity.getSwitchDPID(), entity.getSwitchPort().shortValue(), entity.getLastSeenTimestamp().getTime()); if (moved) { sendDeviceMovedNotification(device); if (logger.isTraceEnabled()) { logger.trace("Device moved: attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } else { if (logger.isTraceEnabled()) { logger.trace("Device attachment point updated: " + "attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } } break; } if (deleteQueue != null) { for (Long l : deleteQueue) { Device dev = deviceMap.get(l); this.deleteDevice(dev); } } processUpdates(deviceUpdates); deviceSyncManager.storeDeviceThrottled(device); return device; }
DeviceManagerImpl implements
IDeviceService, IOFMessageListener, ITopologyListener,
IFloodlightModule, IEntityClassListener,
IFlowReconcileListener, IInfoProvider { protected Device learnDeviceByEntity(Entity entity) { ArrayList<Long> deleteQueue = null; LinkedList<DeviceUpdate> deviceUpdates = null; Device device = null; while (true) { deviceUpdates = null; Long deviceKey = primaryIndex.findByEntity(entity); IEntityClass entityClass = null; if (deviceKey == null) { entityClass = entityClassifier.classifyEntity(entity); if (entityClass == null) { device = null; break; } ClassState classState = getClassState(entityClass); if (classState.classIndex != null) { deviceKey = classState.classIndex.findByEntity(entity); } } if (deviceKey != null) { device = deviceMap.get(deviceKey); if (device == null) { if (logger.isDebugEnabled()) { logger.debug("No device for deviceKey {} while " + "while processing entity {}", deviceKey, entity); } continue; } } else { if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntDeviceOnInternalPortNotLearned.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("Not learning new device on internal" + " link: {}", entity); } device = null; break; } if (!isEntityAllowed(entity, entityClass)) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("PacketIn is not allowed {} {}", entityClass.getName(), entity); } device = null; break; } deviceKey = deviceKeyCounter.getAndIncrement(); device = allocateDevice(deviceKey, entity, entityClass); deviceMap.put(deviceKey, device); if (!updateIndices(device, deviceKey)) { if (deleteQueue == null) deleteQueue = new ArrayList<Long>(); deleteQueue.add(deviceKey); continue; } updateSecondaryIndices(entity, entityClass, deviceKey); cntNewDevice.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("New device created: {} deviceKey={}, entity={}", new Object[]{device, deviceKey, entity}); } deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(device, ADD, null)); break; } if (!isEntityAllowed(entity, device.getEntityClass())) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.info("PacketIn is not allowed {} {}", device.getEntityClass().getName(), entity); } return null; } if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntPacketOnInternalPortForKnownDevice.updateCounterNoFlush(); break; } int entityindex = -1; if ((entityindex = device.entityIndex(entity)) >= 0) { Date lastSeen = entity.getLastSeenTimestamp(); if (lastSeen == null) { lastSeen = new Date(); entity.setLastSeenTimestamp(lastSeen); } device.entities[entityindex].setLastSeenTimestamp(lastSeen); } else { entityindex = -(entityindex + 1); Device newDevice = allocateDevice(device, entity, entityindex); EnumSet<DeviceField> changedFields = findChangedFields(device, entity); boolean res = deviceMap.replace(deviceKey, device, newDevice); if (!res) continue; device = newDevice; if (!updateIndices(device, deviceKey)) { continue; } updateSecondaryIndices(entity, device.getEntityClass(), deviceKey); cntNewEntity.updateCounterNoFlush(); if (changedFields.size() > 0) { cntDeviceChanged.updateCounterNoFlush(); deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(newDevice, CHANGE, changedFields)); } } if (entity.hasSwitchPort()) { boolean moved = device.updateAttachmentPoint(entity.getSwitchDPID(), entity.getSwitchPort().shortValue(), entity.getLastSeenTimestamp().getTime()); if (moved) { sendDeviceMovedNotification(device); if (logger.isTraceEnabled()) { logger.trace("Device moved: attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } else { if (logger.isTraceEnabled()) { logger.trace("Device attachment point updated: " + "attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } } break; } if (deleteQueue != null) { for (Long l : deleteQueue) { Device dev = deviceMap.get(l); this.deleteDevice(dev); } } processUpdates(deviceUpdates); deviceSyncManager.storeDeviceThrottled(device); return device; } }
DeviceManagerImpl implements
IDeviceService, IOFMessageListener, ITopologyListener,
IFloodlightModule, IEntityClassListener,
IFlowReconcileListener, IInfoProvider { protected Device learnDeviceByEntity(Entity entity) { ArrayList<Long> deleteQueue = null; LinkedList<DeviceUpdate> deviceUpdates = null; Device device = null; while (true) { deviceUpdates = null; Long deviceKey = primaryIndex.findByEntity(entity); IEntityClass entityClass = null; if (deviceKey == null) { entityClass = entityClassifier.classifyEntity(entity); if (entityClass == null) { device = null; break; } ClassState classState = getClassState(entityClass); if (classState.classIndex != null) { deviceKey = classState.classIndex.findByEntity(entity); } } if (deviceKey != null) { device = deviceMap.get(deviceKey); if (device == null) { if (logger.isDebugEnabled()) { logger.debug("No device for deviceKey {} while " + "while processing entity {}", deviceKey, entity); } continue; } } else { if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntDeviceOnInternalPortNotLearned.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("Not learning new device on internal" + " link: {}", entity); } device = null; break; } if (!isEntityAllowed(entity, entityClass)) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("PacketIn is not allowed {} {}", entityClass.getName(), entity); } device = null; break; } deviceKey = deviceKeyCounter.getAndIncrement(); device = allocateDevice(deviceKey, entity, entityClass); deviceMap.put(deviceKey, device); if (!updateIndices(device, deviceKey)) { if (deleteQueue == null) deleteQueue = new ArrayList<Long>(); deleteQueue.add(deviceKey); continue; } updateSecondaryIndices(entity, entityClass, deviceKey); cntNewDevice.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("New device created: {} deviceKey={}, entity={}", new Object[]{device, deviceKey, entity}); } deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(device, ADD, null)); break; } if (!isEntityAllowed(entity, device.getEntityClass())) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.info("PacketIn is not allowed {} {}", device.getEntityClass().getName(), entity); } return null; } if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntPacketOnInternalPortForKnownDevice.updateCounterNoFlush(); break; } int entityindex = -1; if ((entityindex = device.entityIndex(entity)) >= 0) { Date lastSeen = entity.getLastSeenTimestamp(); if (lastSeen == null) { lastSeen = new Date(); entity.setLastSeenTimestamp(lastSeen); } device.entities[entityindex].setLastSeenTimestamp(lastSeen); } else { entityindex = -(entityindex + 1); Device newDevice = allocateDevice(device, entity, entityindex); EnumSet<DeviceField> changedFields = findChangedFields(device, entity); boolean res = deviceMap.replace(deviceKey, device, newDevice); if (!res) continue; device = newDevice; if (!updateIndices(device, deviceKey)) { continue; } updateSecondaryIndices(entity, device.getEntityClass(), deviceKey); cntNewEntity.updateCounterNoFlush(); if (changedFields.size() > 0) { cntDeviceChanged.updateCounterNoFlush(); deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(newDevice, CHANGE, changedFields)); } } if (entity.hasSwitchPort()) { boolean moved = device.updateAttachmentPoint(entity.getSwitchDPID(), entity.getSwitchPort().shortValue(), entity.getLastSeenTimestamp().getTime()); if (moved) { sendDeviceMovedNotification(device); if (logger.isTraceEnabled()) { logger.trace("Device moved: attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } else { if (logger.isTraceEnabled()) { logger.trace("Device attachment point updated: " + "attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } } break; } if (deleteQueue != null) { for (Long l : deleteQueue) { Device dev = deviceMap.get(l); this.deleteDevice(dev); } } processUpdates(deviceUpdates); deviceSyncManager.storeDeviceThrottled(device); return device; }  }
DeviceManagerImpl implements
IDeviceService, IOFMessageListener, ITopologyListener,
IFloodlightModule, IEntityClassListener,
IFlowReconcileListener, IInfoProvider { protected Device learnDeviceByEntity(Entity entity) { ArrayList<Long> deleteQueue = null; LinkedList<DeviceUpdate> deviceUpdates = null; Device device = null; while (true) { deviceUpdates = null; Long deviceKey = primaryIndex.findByEntity(entity); IEntityClass entityClass = null; if (deviceKey == null) { entityClass = entityClassifier.classifyEntity(entity); if (entityClass == null) { device = null; break; } ClassState classState = getClassState(entityClass); if (classState.classIndex != null) { deviceKey = classState.classIndex.findByEntity(entity); } } if (deviceKey != null) { device = deviceMap.get(deviceKey); if (device == null) { if (logger.isDebugEnabled()) { logger.debug("No device for deviceKey {} while " + "while processing entity {}", deviceKey, entity); } continue; } } else { if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntDeviceOnInternalPortNotLearned.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("Not learning new device on internal" + " link: {}", entity); } device = null; break; } if (!isEntityAllowed(entity, entityClass)) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("PacketIn is not allowed {} {}", entityClass.getName(), entity); } device = null; break; } deviceKey = deviceKeyCounter.getAndIncrement(); device = allocateDevice(deviceKey, entity, entityClass); deviceMap.put(deviceKey, device); if (!updateIndices(device, deviceKey)) { if (deleteQueue == null) deleteQueue = new ArrayList<Long>(); deleteQueue.add(deviceKey); continue; } updateSecondaryIndices(entity, entityClass, deviceKey); cntNewDevice.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("New device created: {} deviceKey={}, entity={}", new Object[]{device, deviceKey, entity}); } deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(device, ADD, null)); break; } if (!isEntityAllowed(entity, device.getEntityClass())) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.info("PacketIn is not allowed {} {}", device.getEntityClass().getName(), entity); } return null; } if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntPacketOnInternalPortForKnownDevice.updateCounterNoFlush(); break; } int entityindex = -1; if ((entityindex = device.entityIndex(entity)) >= 0) { Date lastSeen = entity.getLastSeenTimestamp(); if (lastSeen == null) { lastSeen = new Date(); entity.setLastSeenTimestamp(lastSeen); } device.entities[entityindex].setLastSeenTimestamp(lastSeen); } else { entityindex = -(entityindex + 1); Device newDevice = allocateDevice(device, entity, entityindex); EnumSet<DeviceField> changedFields = findChangedFields(device, entity); boolean res = deviceMap.replace(deviceKey, device, newDevice); if (!res) continue; device = newDevice; if (!updateIndices(device, deviceKey)) { continue; } updateSecondaryIndices(entity, device.getEntityClass(), deviceKey); cntNewEntity.updateCounterNoFlush(); if (changedFields.size() > 0) { cntDeviceChanged.updateCounterNoFlush(); deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(newDevice, CHANGE, changedFields)); } } if (entity.hasSwitchPort()) { boolean moved = device.updateAttachmentPoint(entity.getSwitchDPID(), entity.getSwitchPort().shortValue(), entity.getLastSeenTimestamp().getTime()); if (moved) { sendDeviceMovedNotification(device); if (logger.isTraceEnabled()) { logger.trace("Device moved: attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } else { if (logger.isTraceEnabled()) { logger.trace("Device attachment point updated: " + "attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } } break; } if (deleteQueue != null) { for (Long l : deleteQueue) { Device dev = deviceMap.get(l); this.deleteDevice(dev); } } processUpdates(deviceUpdates); deviceSyncManager.storeDeviceThrottled(device); return device; }  @Override IDevice getDevice(Long deviceKey); @Override IDevice findDevice(long macAddress, Short vlan,
                              Integer ipv4Address, Long switchDPID,
                              Integer switchPort); @Override IDevice findClassDevice(IEntityClass entityClass, long macAddress,
                                  Short vlan, Integer ipv4Address); @Override Collection<? extends IDevice> getAllDevices(); @Override void addIndex(boolean perClass,
                         EnumSet<DeviceField> keyFields); @Override Iterator<? extends IDevice> queryDevices(Long macAddress,
                                                    Short vlan,
                                                    Integer ipv4Address,
                                                    Long switchDPID,
                                                    Integer switchPort); @Override Iterator<? extends IDevice> queryClassDevices(IEntityClass entityClass,
                                                         Long macAddress,
                                                         Short vlan,
                                                         Integer ipv4Address,
                                                         Long switchDPID,
                                                         Integer switchPort); @Override void addListener(IDeviceListener listener); @Override void addSuppressAPs(long swId, short port); @Override void removeSuppressAPs(long swId, short port); @Override Set<SwitchPort> getSuppressAPs(); @Override Map<String, Object> getInfo(String type); @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override Command receive(IOFSwitch sw, OFMessage msg,
                           FloodlightContext cntx); @Override Command reconcileFlows(ArrayList<OFMatchReconcile> ofmRcList); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext fmc); @Override void startUp(FloodlightModuleContext fmc); boolean isValidAttachmentPoint(long switchDPID,
                                             int switchPort); @Override void topologyChanged(List<LDUpdate> updateList); @Override void entityClassChanged(Set<String> entityClassNames); }
DeviceManagerImpl implements
IDeviceService, IOFMessageListener, ITopologyListener,
IFloodlightModule, IEntityClassListener,
IFlowReconcileListener, IInfoProvider { protected Device learnDeviceByEntity(Entity entity) { ArrayList<Long> deleteQueue = null; LinkedList<DeviceUpdate> deviceUpdates = null; Device device = null; while (true) { deviceUpdates = null; Long deviceKey = primaryIndex.findByEntity(entity); IEntityClass entityClass = null; if (deviceKey == null) { entityClass = entityClassifier.classifyEntity(entity); if (entityClass == null) { device = null; break; } ClassState classState = getClassState(entityClass); if (classState.classIndex != null) { deviceKey = classState.classIndex.findByEntity(entity); } } if (deviceKey != null) { device = deviceMap.get(deviceKey); if (device == null) { if (logger.isDebugEnabled()) { logger.debug("No device for deviceKey {} while " + "while processing entity {}", deviceKey, entity); } continue; } } else { if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntDeviceOnInternalPortNotLearned.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("Not learning new device on internal" + " link: {}", entity); } device = null; break; } if (!isEntityAllowed(entity, entityClass)) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("PacketIn is not allowed {} {}", entityClass.getName(), entity); } device = null; break; } deviceKey = deviceKeyCounter.getAndIncrement(); device = allocateDevice(deviceKey, entity, entityClass); deviceMap.put(deviceKey, device); if (!updateIndices(device, deviceKey)) { if (deleteQueue == null) deleteQueue = new ArrayList<Long>(); deleteQueue.add(deviceKey); continue; } updateSecondaryIndices(entity, entityClass, deviceKey); cntNewDevice.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.debug("New device created: {} deviceKey={}, entity={}", new Object[]{device, deviceKey, entity}); } deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(device, ADD, null)); break; } if (!isEntityAllowed(entity, device.getEntityClass())) { cntPacketNotAllowed.updateCounterNoFlush(); if (logger.isDebugEnabled()) { logger.info("PacketIn is not allowed {} {}", device.getEntityClass().getName(), entity); } return null; } if (entity.hasSwitchPort() && !topology.isAttachmentPointPort(entity.getSwitchDPID(), entity.getSwitchPort().shortValue())) { cntPacketOnInternalPortForKnownDevice.updateCounterNoFlush(); break; } int entityindex = -1; if ((entityindex = device.entityIndex(entity)) >= 0) { Date lastSeen = entity.getLastSeenTimestamp(); if (lastSeen == null) { lastSeen = new Date(); entity.setLastSeenTimestamp(lastSeen); } device.entities[entityindex].setLastSeenTimestamp(lastSeen); } else { entityindex = -(entityindex + 1); Device newDevice = allocateDevice(device, entity, entityindex); EnumSet<DeviceField> changedFields = findChangedFields(device, entity); boolean res = deviceMap.replace(deviceKey, device, newDevice); if (!res) continue; device = newDevice; if (!updateIndices(device, deviceKey)) { continue; } updateSecondaryIndices(entity, device.getEntityClass(), deviceKey); cntNewEntity.updateCounterNoFlush(); if (changedFields.size() > 0) { cntDeviceChanged.updateCounterNoFlush(); deviceUpdates = updateUpdates(deviceUpdates, new DeviceUpdate(newDevice, CHANGE, changedFields)); } } if (entity.hasSwitchPort()) { boolean moved = device.updateAttachmentPoint(entity.getSwitchDPID(), entity.getSwitchPort().shortValue(), entity.getLastSeenTimestamp().getTime()); if (moved) { sendDeviceMovedNotification(device); if (logger.isTraceEnabled()) { logger.trace("Device moved: attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } else { if (logger.isTraceEnabled()) { logger.trace("Device attachment point updated: " + "attachment points {}," + "entities {}", device.attachmentPoints, device.entities); } } } break; } if (deleteQueue != null) { for (Long l : deleteQueue) { Device dev = deviceMap.get(l); this.deleteDevice(dev); } } processUpdates(deviceUpdates); deviceSyncManager.storeDeviceThrottled(device); return device; }  @Override IDevice getDevice(Long deviceKey); @Override IDevice findDevice(long macAddress, Short vlan,
                              Integer ipv4Address, Long switchDPID,
                              Integer switchPort); @Override IDevice findClassDevice(IEntityClass entityClass, long macAddress,
                                  Short vlan, Integer ipv4Address); @Override Collection<? extends IDevice> getAllDevices(); @Override void addIndex(boolean perClass,
                         EnumSet<DeviceField> keyFields); @Override Iterator<? extends IDevice> queryDevices(Long macAddress,
                                                    Short vlan,
                                                    Integer ipv4Address,
                                                    Long switchDPID,
                                                    Integer switchPort); @Override Iterator<? extends IDevice> queryClassDevices(IEntityClass entityClass,
                                                         Long macAddress,
                                                         Short vlan,
                                                         Integer ipv4Address,
                                                         Long switchDPID,
                                                         Integer switchPort); @Override void addListener(IDeviceListener listener); @Override void addSuppressAPs(long swId, short port); @Override void removeSuppressAPs(long swId, short port); @Override Set<SwitchPort> getSuppressAPs(); @Override Map<String, Object> getInfo(String type); @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override Command receive(IOFSwitch sw, OFMessage msg,
                           FloodlightContext cntx); @Override Command reconcileFlows(ArrayList<OFMatchReconcile> ofmRcList); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext fmc); @Override void startUp(FloodlightModuleContext fmc); boolean isValidAttachmentPoint(long switchDPID,
                                             int switchPort); @Override void topologyChanged(List<LDUpdate> updateList); @Override void entityClassChanged(Set<String> entityClassNames); static final String MODULE_NAME; static final String PACKAGE; public IDebugCounter cntIncoming; public IDebugCounter cntReconcileRequest; public IDebugCounter cntReconcileNoSource; public IDebugCounter cntReconcileNoDest; public IDebugCounter cntInvalidSource; public IDebugCounter cntInvalidDest; public IDebugCounter cntNoSource; public IDebugCounter cntNoDest; public IDebugCounter cntDhcpClientNameSnooped; public IDebugCounter cntDeviceOnInternalPortNotLearned; public IDebugCounter cntPacketNotAllowed; public IDebugCounter cntNewDevice; public IDebugCounter cntPacketOnInternalPortForKnownDevice; public IDebugCounter cntNewEntity; public IDebugCounter cntDeviceChanged; public IDebugCounter cntDeviceMoved; public IDebugCounter cntCleanupEntitiesRuns; public IDebugCounter cntEntityRemovedTimeout; public IDebugCounter cntDeviceDeleted; public IDebugCounter cntDeviceReclassifyDelete; public IDebugCounter cntDeviceStrored; public IDebugCounter cntDeviceStoreThrottled; public IDebugCounter cntDeviceRemovedFromStore; public IDebugCounter cntSyncException; public IDebugCounter cntDevicesFromStore; public IDebugCounter cntConsolidateStoreRuns; public IDebugCounter cntConsolidateStoreDevicesRemoved; public IDebugCounter cntTransitionToMaster; public AttachmentPointComparator apComparator; public SingletonTask entityCleanupTask; }