本文整理汇总了Java中net.floodlightcontroller.devicemanager.IDeviceService.DeviceField类的典型用法代码示例。如果您正苦于以下问题:Java DeviceField类的具体用法?Java DeviceField怎么用?Java DeviceField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeviceField类属于net.floodlightcontroller.devicemanager.IDeviceService包,在下文中一共展示了DeviceField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasNonZeroOrNonNullKeys
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
/**
* Check whether this entity has non-'zero' values in any of its key fields
* @return true if any key fields have a non-null value
*/
public boolean hasNonZeroOrNonNullKeys() {
for (DeviceField f : keyFields) {
switch (f) {
case MAC: /* We assume operation over Ethernet, thus all devices must have a MAC */
return true;
case IPv4:
if (!entity.ipv4Address.equals(IPv4Address.NONE)) return true;
break;
case IPv6:
if (!entity.ipv6Address.equals(IPv6Address.NONE)) return true;
break;
case SWITCH:
if (!entity.switchDPID.equals(DatapathId.NONE)) return true;
break;
case PORT:
if (!entity.switchPort.equals(OFPort.ZERO)) return true;
break;
case VLAN: /* VLAN can still be null, meaning 'don't care'. VlanVid.ZERO means 'untagged' */
if (entity.vlan != null) return true;
break;
}
}
return false;
}
示例2: testDeviceIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Test
public void testDeviceIndex() throws Exception {
EnumSet<IDeviceService.DeviceField> indexFields =
EnumSet.noneOf(IDeviceService.DeviceField.class);
indexFields.add(IDeviceService.DeviceField.IPv4);
indexFields.add(IDeviceService.DeviceField.VLAN);
deviceManager.addIndex(false, indexFields);
indexFields = EnumSet.noneOf(IDeviceService.DeviceField.class);
deviceManager.addIndex(false, indexFields);
ITopologyService mockTopology = createMock(ITopologyService.class);
deviceManager.topology = mockTopology;
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()),
OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
replay(mockTopology);
doTestDeviceQuery();
}
示例3: testDeviceClassIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Test
public void testDeviceClassIndex() throws Exception {
EnumSet<IDeviceService.DeviceField> indexFields =
EnumSet.noneOf(IDeviceService.DeviceField.class);
indexFields.add(IDeviceService.DeviceField.IPv4);
indexFields.add(IDeviceService.DeviceField.VLAN);
deviceManager.addIndex(true, indexFields);
ITopologyService mockTopology = createMock(ITopologyService.class);
deviceManager.topology = mockTopology;
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()),
OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.getOpenflowDomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
replay(mockTopology);
doTestDeviceClassQuery();
}
示例4: hasNonNullKeys
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
/**
* Check whether this entity has non-null values in any of its key fields
* @return true if any key fields have a non-null value
*/
public boolean hasNonNullKeys() {
for (DeviceField f : keyFields) {
switch (f) {
case MAC:
return true;
case IPV4:
if (entity.ipv4Address != null) return true;
break;
case SWITCH:
if (entity.switchDPID != null) return true;
break;
case PORT:
if (entity.switchPort != null) return true;
break;
case VLAN:
if (entity.vlan != null) return true;
break;
}
}
return false;
}
示例5: computeKey
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
static String computeKey(Device d) {
StringBuilder bld = new StringBuilder(d.getEntityClass().getName());
bld.append("::");
EnumSet<DeviceField> keyFields = d.getEntityClass().getKeyFields();
if (keyFields.contains(DeviceField.MAC)) {
bld.append(d.getMACAddressString());
bld.append("::");
}
if (keyFields.contains(DeviceField.VLAN)) {
if (d.getVlanId() != null)
bld.append(Arrays.toString(d.getVlanId()));
bld.append("::");
}
if (keyFields.contains(DeviceField.SWITCH) ||
keyFields.contains(DeviceField.PORT) ) {
if (d.getAttachmentPoints(true) != null)
bld.append(Arrays.toString(d.getAttachmentPoints(true)));
bld.append("::");
}
if (keyFields.contains(DeviceField.IPV4)) {
if (d.getIPv4Addresses() != null)
bld.append(Arrays.toString(d.getIPv4Addresses()));
bld.append("::");
}
return bld.toString();
}
示例6: testDeviceIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Test
public void testDeviceIndex() throws Exception {
EnumSet<IDeviceService.DeviceField> indexFields =
EnumSet.noneOf(IDeviceService.DeviceField.class);
indexFields.add(IDeviceService.DeviceField.IPV4);
indexFields.add(IDeviceService.DeviceField.VLAN);
deviceManager.addIndex(false, indexFields);
indexFields = EnumSet.noneOf(IDeviceService.DeviceField.class);
deviceManager.addIndex(false, indexFields);
ITopologyService mockTopology = createMock(ITopologyService.class);
deviceManager.topology = mockTopology;
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()),
OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.getL2DomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
replay(mockTopology);
doTestDeviceQuery();
}
示例7: testDeviceClassIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Test
public void testDeviceClassIndex() throws Exception {
EnumSet<IDeviceService.DeviceField> indexFields =
EnumSet.noneOf(IDeviceService.DeviceField.class);
indexFields.add(IDeviceService.DeviceField.IPV4);
indexFields.add(IDeviceService.DeviceField.VLAN);
deviceManager.addIndex(true, indexFields);
ITopologyService mockTopology = createMock(ITopologyService.class);
deviceManager.topology = mockTopology;
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()),
OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.getL2DomainId(DatapathId.of(EasyMock.anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
replay(mockTopology);
doTestDeviceClassQuery();
}
示例8: testDeviceIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Test
public void testDeviceIndex() throws Exception {
EnumSet<IDeviceService.DeviceField> indexFields =
EnumSet.noneOf(IDeviceService.DeviceField.class);
indexFields.add(IDeviceService.DeviceField.IPV4);
indexFields.add(IDeviceService.DeviceField.VLAN);
deviceManager.addIndex(false, indexFields);
indexFields = EnumSet.noneOf(IDeviceService.DeviceField.class);
deviceManager.addIndex(false, indexFields);
ITopologyService mockTopology = createMock(ITopologyService.class);
deviceManager.topology = mockTopology;
expect(mockTopology.isAttachmentPointPort(anyLong(),
anyShort())).
andReturn(true).anyTimes();
expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
replay(mockTopology);
doTestDeviceQuery();
}
示例9: testDeviceClassIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Test
public void testDeviceClassIndex() throws Exception {
EnumSet<IDeviceService.DeviceField> indexFields =
EnumSet.noneOf(IDeviceService.DeviceField.class);
indexFields.add(IDeviceService.DeviceField.IPV4);
indexFields.add(IDeviceService.DeviceField.VLAN);
deviceManager.addIndex(true, indexFields);
ITopologyService mockTopology = createMock(ITopologyService.class);
deviceManager.topology = mockTopology;
expect(mockTopology.isAttachmentPointPort(anyLong(),
anyShort())).
andReturn(true).anyTimes();
expect(mockTopology.getL2DomainId(EasyMock.anyLong())).andReturn(1L).anyTimes();
replay(mockTopology);
doTestDeviceClassQuery();
}
示例10: computeKey
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
static String computeKey(Device d) {
StringBuilder bld = new StringBuilder(d.getEntityClass().getName());
bld.append("::");
EnumSet<DeviceField> keyFields = d.getEntityClass().getKeyFields();
if (keyFields.contains(DeviceField.MAC)) {
bld.append(d.getMACAddressString());
bld.append("::");
}
if (keyFields.contains(DeviceField.VLAN)) {
if (d.getVlanId() != null)
bld.append(Arrays.toString(d.getVlanId()));
bld.append("::");
}
if (keyFields.contains(DeviceField.SWITCH) ||
keyFields.contains(DeviceField.PORT) ) {
if (d.getAttachmentPoints(true) != null)
bld.append(Arrays.toString(d.getAttachmentPoints(true)));
bld.append("::");
}
if (keyFields.contains(DeviceField.IPv4)) {
if (d.getIPv4Addresses() != null)
bld.append(Arrays.toString(d.getIPv4Addresses()));
bld.append("::");
}
if (keyFields.contains(DeviceField.IPv6)) {
if (d.getIPv6Addresses() != null)
bld.append(Arrays.toString(d.getIPv6Addresses()));
bld.append("::");
}
return bld.toString();
}
示例11: hashCode
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Override
public int hashCode() {
if (hashCode != 0) {
return hashCode;
}
final int prime = 31;
hashCode = 1;
for (DeviceField f : keyFields) {
switch (f) {
case MAC:
hashCode = prime * hashCode
+ (int) (entity.macAddress.getLong() ^
(entity.macAddress.getLong() >>> 32));
break;
case IPv4:
hashCode = prime * hashCode
+ ((entity.ipv4Address == null)
? 0
: entity.ipv4Address.hashCode());
break;
case IPv6:
hashCode = prime * hashCode
+ ((entity.ipv6Address == null)
? 0
: entity.ipv6Address.hashCode());
break;
case SWITCH:
hashCode = prime * hashCode
+ ((entity.switchDPID == null)
? 0
: entity.switchDPID.hashCode());
break;
case PORT:
hashCode = prime * hashCode
+ ((entity.switchPort == null)
? 0
: entity.switchPort.hashCode());
break;
case VLAN:
hashCode = prime * hashCode
+ ((entity.vlan == null)
? 0
: entity.vlan.hashCode());
break;
}
}
return hashCode;
}
示例12: equals
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
IndexedEntity other = (IndexedEntity) obj;
if (!keyFields.equals(other.keyFields))
return false;
for (IDeviceService.DeviceField f : keyFields) {
switch (f) {
case MAC:
if (!entity.macAddress.equals(other.entity.macAddress))
return false;
break;
case IPv4:
if (entity.ipv4Address == null) {
if (other.entity.ipv4Address != null) return false;
} else if (!entity.ipv4Address.equals(other.entity.ipv4Address)) return false;
break;
case IPv6:
if (entity.ipv6Address == null) {
if (other.entity.ipv6Address != null) return false;
} else if (!entity.ipv6Address.equals(other.entity.ipv6Address)) return false;
break;
case SWITCH:
if (entity.switchDPID == null) {
if (other.entity.switchDPID != null) return false;
} else if (!entity.switchDPID.equals(other.entity.switchDPID)) return false;
break;
case PORT:
if (entity.switchPort == null) {
if (other.entity.switchPort != null) return false;
} else if (!entity.switchPort.equals(other.entity.switchPort)) return false;
break;
case VLAN:
if (entity.vlan == null) {
if (other.entity.vlan != null) return false;
} else if (!entity.vlan.equals(other.entity.vlan)) return false;
break;
}
}
return true;
}
示例13: getKeyFields
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
@Override
public EnumSet<IDeviceService.DeviceField> getKeyFields() {
return keyFields;
}
示例14: DeviceMultiIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
/**
* @param keyFields
*/
public DeviceMultiIndex(EnumSet<DeviceField> keyFields) {
super(keyFields);
index = new ConcurrentHashMap<IndexedEntity, Collection<Long>>();
}
示例15: DeviceIndex
import net.floodlightcontroller.devicemanager.IDeviceService.DeviceField; //导入依赖的package包/类
/**
* Construct a new device index using the provided key fields
* @param keyFields the key fields to use
*/
public DeviceIndex(EnumSet<DeviceField> keyFields) {
super();
this.keyFields = keyFields;
}