net.floodlightcontroller.devicemanager.internal
Class DeviceIndex

java.lang.Object
  extended by net.floodlightcontroller.devicemanager.internal.DeviceIndex
Direct Known Subclasses:
DeviceMultiIndex, DeviceUniqueIndex

public abstract class DeviceIndex
extends java.lang.Object

An index that maps key fields of an entity to device keys


Field Summary
protected  java.util.EnumSet<IDeviceService.DeviceField> keyFields
          The key fields for this index
 
Constructor Summary
DeviceIndex(java.util.EnumSet<IDeviceService.DeviceField> keyFields)
          Construct a new device index using the provided key fields
 
Method Summary
abstract  java.util.Iterator<java.lang.Long> getAll()
          Get all device keys in the index.
abstract  java.util.Iterator<java.lang.Long> queryByEntity(Entity entity)
          Find all device keys in the index that match the given entity on all the key fields for this index
abstract  void removeEntity(Entity entity)
          Remove the entry for the given entity
abstract  void removeEntity(Entity entity, java.lang.Long deviceKey)
          Remove the given device key from the index for the given entity
 void removeEntityIfNeeded(Entity entity, java.lang.Long deviceKey, java.util.Collection<Entity> others)
          Remove the give device from the index only if this the collection of others does not contain an entity that is identical on all the key fields for this index.
abstract  boolean updateIndex(Device device, java.lang.Long deviceKey)
          Attempt to update an index with the entities in the provided Device.
abstract  void updateIndex(Entity entity, java.lang.Long deviceKey)
          Add a mapping from the given entity to the given device key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyFields

protected java.util.EnumSet<IDeviceService.DeviceField> keyFields
The key fields for this index

Constructor Detail

DeviceIndex

public DeviceIndex(java.util.EnumSet<IDeviceService.DeviceField> keyFields)
Construct a new device index using the provided key fields

Parameters:
keyFields - the key fields to use
Method Detail

queryByEntity

public abstract java.util.Iterator<java.lang.Long> queryByEntity(Entity entity)
Find all device keys in the index that match the given entity on all the key fields for this index

Parameters:
e - the entity to search for
Returns:
an iterator over device keys

getAll

public abstract java.util.Iterator<java.lang.Long> getAll()
Get all device keys in the index. If certain devices exist multiple times, then these devices may be returned multiple times

Returns:
an iterator over device keys

updateIndex

public abstract boolean updateIndex(Device device,
                                    java.lang.Long deviceKey)
Attempt to update an index with the entities in the provided Device. If the update fails because of a concurrent update, will return false.

Parameters:
device - the device to update
deviceKey - the device key for the device
Returns:
true if the update succeeded, false otherwise.

updateIndex

public abstract void updateIndex(Entity entity,
                                 java.lang.Long deviceKey)
Add a mapping from the given entity to the given device key. This update will not fail because of a concurrent update

Parameters:
device - the device to update
deviceKey - the device key for the device

removeEntity

public abstract void removeEntity(Entity entity)
Remove the entry for the given entity

Parameters:
entity - the entity to remove

removeEntity

public abstract void removeEntity(Entity entity,
                                  java.lang.Long deviceKey)
Remove the given device key from the index for the given entity

Parameters:
entity - the entity to search for
deviceKey - the key to remove

removeEntityIfNeeded

public void removeEntityIfNeeded(Entity entity,
                                 java.lang.Long deviceKey,
                                 java.util.Collection<Entity> others)
Remove the give device from the index only if this the collection of others does not contain an entity that is identical on all the key fields for this index.

Parameters:
entity - the entity to search for
deviceKey - the key to remove
others - the others against which to check