本文整理汇总了Java中org.projectfloodlight.openflow.types.OFPort.ZERO属性的典型用法代码示例。如果您正苦于以下问题:Java OFPort.ZERO属性的具体用法?Java OFPort.ZERO怎么用?Java OFPort.ZERO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.projectfloodlight.openflow.types.OFPort
的用法示例。
在下文中一共展示了OFPort.ZERO属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLastSeen
@Test
public void testLastSeen() throws Exception {
Calendar c = Calendar.getInstance();
Date d1 = c.getTime();
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, d1);
c.add(Calendar.SECOND, 1);
Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.of(1), IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, c.getTime());
IDevice d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(c.getTime(), d.getLastSeen());
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(c.getTime(), d.getLastSeen());
deviceManager.startUp(null);
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(d1, d.getLastSeen());
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(c.getTime(), d.getLastSeen());
}
示例2: setUp
@Override
protected void setUp() throws Exception {
super.setUp();
e1a = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), IPv4Address.of(1), IPv6Address.of(1, 1), DatapathId.of(1L), OFPort.of(1), new Date());
e1b = new Entity(MacAddress.of(1L), VlanVid.ofVlan(2), IPv4Address.of(1), IPv6Address.of(1, 1), DatapathId.of(1L), OFPort.of(1), new Date());
List<Entity> d1Entities = new ArrayList<Entity>(2);
d1Entities.add(e1a);
d1Entities.add(e1b);
d1 = new Device(null, Long.valueOf(1), null, null, null,
d1Entities, null);
// e2 and e2 alt match in MAC and VLAN
e2 = new Entity(MacAddress.of(2L), VlanVid.ofVlan(2), IPv4Address.of(2), IPv6Address.of(2, 2), DatapathId.of(2L), OFPort.of(2), new Date());
e2alt = new Entity(MacAddress.of(2L), VlanVid.ofVlan(2), IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
// IP is null
e3 = new Entity(MacAddress.of(3L), VlanVid.ofVlan(3), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(3L), OFPort.of(3), new Date());
// IP and switch and port are null
e4 = new Entity(MacAddress.of(4L), VlanVid.ofVlan(4), IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, new Date());
}
示例3: findClassDevice
@Override
public IDevice findClassDevice(@Nonnull IEntityClass entityClass, @Nonnull MacAddress macAddress,
@Nonnull VlanVid vlan, @Nonnull IPv4Address ipv4Address, @Nonnull IPv6Address ipv6Address)
throws IllegalArgumentException {
if (entityClass == null) {
throw new IllegalArgumentException("Entity class cannot be null.");
}
if (macAddress == null) {
throw new IllegalArgumentException("MAC address cannot be null. Try MacAddress.NONE if intention is 'no MAC'");
}
if (ipv4Address == null) {
throw new IllegalArgumentException("IPv4 address cannot be null. Try IPv4Address.NONE if intention is 'no IPv4'");
}
if (ipv6Address == null) {
throw new IllegalArgumentException("IPv6 address cannot be null. Try IPv6Address.NONE if intention is 'no IPv6'");
}
if (vlan == null) {
throw new IllegalArgumentException("VLAN cannot be null. Try VlanVid.ZERO if intention is 'no VLAN / untagged'");
}
Entity e = new Entity(macAddress, vlan, ipv4Address, ipv6Address, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
if (!allKeyFieldsPresent(e, entityClass.getKeyFields())) {
throw new IllegalArgumentException("Not all key fields and/or "
+ " no source device specified. Required fields: " +
entityClassifier.getKeyFields());
}
return findDestByEntity(entityClass, e);
}
示例4: getDestEntityFromPacket
/**
* Get a (partial) entity for the destination from the packet.
* @param eth
* @return
*/
protected Entity getDestEntityFromPacket(Ethernet eth) {
MacAddress dlAddr = eth.getDestinationMACAddress();
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
IPv4Address ipv4Dst = IPv4Address.NONE;
IPv6Address ipv6Dst = IPv6Address.NONE;
// Ignore broadcast/multicast destination
if (dlAddr.isBroadcast() || dlAddr.isMulticast())
return null;
// Ignore zero dest mac
if (dlAddr.equals(MacAddress.of(0)))
return null;
if (eth.getPayload() instanceof IPv4) {
IPv4 ipv4 = (IPv4) eth.getPayload();
ipv4Dst = ipv4.getDestinationAddress();
} else if (eth.getPayload() instanceof IPv6) {
IPv6 ipv6 = (IPv6) eth.getPayload();
ipv6Dst = ipv6.getDestinationAddress();
}
return new Entity(dlAddr,
vlan,
ipv4Dst,
ipv6Dst,
DatapathId.NONE,
OFPort.ZERO,
Entity.NO_DATE);
}
示例5: doTestEntityOrdering
private void doTestEntityOrdering(boolean computeInsertionPoint) throws Exception {
Entity e = new Entity(MacAddress.of(10L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
IEntityClass ec = createNiceMock(IEntityClass.class);
Device d = new Device(deviceManager, 1L, e, ec);
int expectedLength = 1;
Long[] macs = new Long[] { 5L, // new first element
15L, // new last element
7L, // insert in middle
12L, // insert in middle
6L, // insert at idx 1
14L, // insert at idx length-2
1L,
20L
};
for (Long mac: macs) {
e = new Entity(MacAddress.of(mac), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
int insertionPoint;
if (computeInsertionPoint) {
insertionPoint = -(Arrays.binarySearch(d.entities, e)+1);
} else {
insertionPoint = -1;
}
d = deviceManager.allocateDevice(d, e, insertionPoint);
expectedLength++;
assertEquals(expectedLength, d.entities.length);
for (int i = 0; i < d.entities.length-1; i++)
assertEquals(-1, d.entities[i].compareTo(d.entities[i+1]));
}
}
示例6: testSyncEntity
@Test
public void testSyncEntity() {
Date d1 = new Date();
Date d2 = new Date(1);
Entity e1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(2), IPv4Address.of(3), IPv6Address.NONE, DatapathId.of(4L), OFPort.of(5), d1);
e1.setActiveSince(d2);
SyncEntity se1 = new SyncEntity(e1);
assertEntityEquals(e1, se1);
assertEquals(1L, se1.macAddress);
assertEquals(2, se1.vlan);
assertEquals(3, se1.ipv4Address);
assertEquals(4L, se1.switchDPID);
assertEquals(5, se1.switchPort);
assertEquals(d1, se1.lastSeenTimestamp);
assertEquals(d2, se1.activeSince);
assertNotSame(d1, se1.lastSeenTimestamp);
assertNotSame(d2, se1.activeSince);
Entity e2 = new Entity(MacAddress.of(42L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
SyncEntity se2 = new SyncEntity(e2);
assertEntityEquals(e2, se2);
SyncEntity se3 = new SyncEntity();
SyncEntity se4 = new SyncEntity();
se3.lastSeenTimestamp = new Date(1000);
se4.lastSeenTimestamp = new Date(2000);
assertTrue("", se3.compareTo(se4) < 0);
assertTrue("", se4.compareTo(se3) > 0);
se4.lastSeenTimestamp = new Date(1000);
assertTrue("", se3.compareTo(se4) == 0);
assertTrue("", se4.compareTo(se3) == 0);
se4.lastSeenTimestamp = new Date(500);
assertTrue("", se3.compareTo(se4) > 0);
assertTrue("", se4.compareTo(se3) < 0);
}
示例7: testConsolitateStore
@Test
public void testConsolitateStore() throws Exception {
int syncStoreInternalMs = 0;
ITopologyService mockTopology = makeMockTopologyAllPortsAp();
replay(mockTopology);
deviceManager.topology = mockTopology;
// We want an EntityClassifier that has switch/port as key fields
deviceManager.entityClassifier = new MockEntityClassifier();
deviceManager.setSyncStoreWriteInterval(syncStoreInternalMs);
// Add Device1 with two entities to store and let device manager
// learn
Entity e1a = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(4L), OFPort.of(5), new Date(1000));
Entity e1b = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.of(3), IPv6Address.NONE, DatapathId.of(4L), OFPort.of(5), new Date(2000));
Device d1 = deviceManager.learnDeviceByEntity(e1a);
deviceManager.learnDeviceByEntity(e1b);
String dev1Key = DeviceSyncRepresentation.computeKey(d1);
// Add a second device to the store but do NOT add to device manager
Entity e2 = new Entity(MacAddress.of(2L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(5L), OFPort.of(5), new Date());
Device d2 = deviceManager.allocateDevice(42L, e2,
DefaultEntityClassifier.entityClass);
DeviceSyncRepresentation dsr = new DeviceSyncRepresentation(d2);
storeClient.put(dsr.getKey(), dsr);
String dev2Key = DeviceSyncRepresentation.computeKey(d2);
// Make sure we have two devices in the store
List<DeviceSyncRepresentation> entries = getEntriesFromStore();
assertEquals(2, entries.size());
deviceManager.scheduleConsolidateStoreNow();
Thread.sleep(25); // give the scheduler time to run the task
// We should still have two entries, however one of them will be a
// tombstone
entries = getEntriesFromStore();
assertEquals(2, entries.size());
// Device 1 should still be in store
Versioned<DeviceSyncRepresentation> versioned =
storeClient.get(dev1Key);
dsr = versioned.getValue();
assertNotNull(dsr);
assertEquals(2, dsr.getEntities().size());
assertEntityEquals(e1a, dsr.getEntities().get(0));
assertEntityEquals(e1b, dsr.getEntities().get(1));
// Device2 should be gone
versioned = storeClient.get(dev2Key);
assertNull(versioned.getValue());
// Run consolitate again. This time we check that tombstones in
// the store are handled correctly
deviceManager.scheduleConsolidateStoreNow();
Thread.sleep(25); // give the scheduler time to run the task
// Now write a device to the store that doesn't have any switch-port
// it should be removed
Entity e3 = new Entity(MacAddress.of(3L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
dsr.setKey("Device3");
dsr.setEntities(Collections.singletonList(new SyncEntity(e3)));
storeClient.put(dsr.getKey(), dsr);
// Run consolitate again. This time we check that tombstones in
// the store are handled correctly
deviceManager.scheduleConsolidateStoreNow();
Thread.sleep(25); // give the scheduler time to run the task
versioned = storeClient.get("Device3");
assertNull(versioned.getValue());
}
示例8: learnEntity
/**
* Learn a device using the given characteristics.
* @param macAddress the MAC
* @param vlan the VLAN (can be null)
* @param ipv4Address the IP (can be null)
* @param switchDPID the attachment point switch DPID (can be null)
* @param switchPort the attachment point switch port (can be null)
* @param processUpdates if false, will not send updates. Note that this
* method is not thread safe if this is false
* @return the device, either new or not
*/
public IDevice learnEntity(long macAddress, Short vlan,
Integer ipv4Address, Long switchDPID,
Integer switchPort,
boolean processUpdates) {
List<IDeviceListener> listeners = deviceListeners.getOrderedListeners();
if (!processUpdates) {
deviceListeners.clearListeners();
}
VlanVid v;
IPv4Address i;
DatapathId d;
OFPort p;
if (vlan != null && vlan.shortValue() <= 0)
vlan = null;
if (ipv4Address != null && ipv4Address == 0)
ipv4Address = null;
if (vlan == null) {
v = VlanVid.ofVlan(-1);
} else {
v = VlanVid.ofVlan(vlan);
}
if (ipv4Address == null) {
i = IPv4Address.NONE;
} else {
i = IPv4Address.of(ipv4Address);
}
if (switchDPID == null) {
d = DatapathId.of(0);
} else {
d = DatapathId.of(switchDPID.longValue());
}
if (switchPort == null) {
p = OFPort.ZERO;
} else {
p = OFPort.of(switchPort);
}
IDevice res = learnDeviceByEntity(new Entity(MacAddress.of(macAddress),
v, i, d, p, new Date()));
// Restore listeners
if (listeners != null) {
for (IDeviceListener listener : listeners) {
deviceListeners.addListener("device", listener);
}
}
return res;
}