当前位置: 首页>>代码示例>>Java>>正文


Java IPv4Address.NONE属性代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.types.IPv4Address.NONE属性的典型用法代码示例。如果您正苦于以下问题:Java IPv4Address.NONE属性的具体用法?Java IPv4Address.NONE怎么用?Java IPv4Address.NONE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.projectfloodlight.openflow.types.IPv4Address的用法示例。


在下文中一共展示了IPv4Address.NONE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:DeviceManagerImplTest.java

示例2: testGetSwitchPortVlanId

@Test
public void testGetSwitchPortVlanId() {
	Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
	Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
	Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(3), IPv4Address.NONE, IPv6Address.NONE,  DatapathId.of(1L), OFPort.of(1), new Date());
	Entity entity4 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(42), IPv4Address.NONE, IPv6Address.NONE,  DatapathId.of(1L), OFPort.of(1), new Date());
	Entity[] entities = new Entity[] { entity1, entity2,
			entity3, entity4
	};
	Device d = new Device(null,1L, null, null, null,
			Arrays.asList(entities), null);
	SwitchPort swp1x1 = new SwitchPort(DatapathId.of(1L), OFPort.of(1));
	SwitchPort swp1x2 = new SwitchPort(DatapathId.of(1L), OFPort.of(2));
	SwitchPort swp2x1 = new SwitchPort(DatapathId.of(2L), OFPort.of(1));
	SwitchPort swp10x1 = new SwitchPort(DatapathId.of(10L), OFPort.of(1));
	assertArrayEquals(new VlanVid[] { VlanVid.ZERO, VlanVid.ofVlan(1)},
			d.getSwitchPortVlanIds(swp10x1));
	assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(3), VlanVid.ofVlan(42)},
			d.getSwitchPortVlanIds(swp1x1));
	assertArrayEquals(new VlanVid[0],
			d.getSwitchPortVlanIds(swp1x2));
	assertArrayEquals(new VlanVid[0],
			d.getSwitchPortVlanIds(swp2x1));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:DeviceManagerImplTest.java

示例3: 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());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:21,代码来源:DeviceUniqueIndexTest.java

示例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 nwDst = IPv4Address.NONE;

	// Ignore broadcast/multicast destination
	if (dlAddr.isBroadcast() || dlAddr.isMulticast())
		return null;
	// Ignore zero dest mac
	if (dlAddr.getLong() == 0)
		return null;

	if (eth.getPayload() instanceof IPv4) {
		IPv4 ipv4 = (IPv4) eth.getPayload();
		nwDst = ipv4.getDestinationAddress();
	}
	
	return new Entity(dlAddr,
			vlan,
			nwDst,
			null,
			null,
			null);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:29,代码来源:DeviceManagerImpl.java

示例5: getSrcIPv4AddrFromARP

/**
 * Get sender IPv4 address from packet if the packet is an ARP
 * packet and if the source MAC address matches the ARP packets
 * sender MAC address.
 * @param eth
 * @param dlAddr
 * @return
 */
private IPv4Address getSrcIPv4AddrFromARP(Ethernet eth, MacAddress dlAddr) {
	if (eth.getPayload() instanceof ARP) {
		ARP arp = (ARP) eth.getPayload();
		if ((arp.getProtocolType() == ARP.PROTO_TYPE_IP) && (arp.getSenderHardwareAddress().equals(dlAddr))) {
			return arp.getSenderProtocolAddress();
		}
	}
	return IPv4Address.NONE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:DeviceManagerImpl.java

示例6: 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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:34,代码来源:DeviceManagerImpl.java

示例7: IPv4

/**
 * Default constructor that sets the version to 4.
 */
public IPv4() {
    super();
    this.version = 4;
    isTruncated = false;
    isFragment = false;
    protocol = IpProtocol.NONE;
    sourceAddress = IPv4Address.NONE;
    destinationAddress = IPv4Address.NONE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:12,代码来源:IPv4.java

示例8: 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]));
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:31,代码来源:DeviceManagerImplTest.java

示例9: 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);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:35,代码来源:DeviceManagerImplTest.java

示例10: testDeviceSyncRepresentationBasics

@Test
public void testDeviceSyncRepresentationBasics() {
	DeviceSyncRepresentation dsr = new DeviceSyncRepresentation();
	assertNull(dsr.getKey());
	assertNull(dsr.getEntities());
	dsr.setKey("MyKey");
	assertEquals("MyKey", dsr.getKey());
	assertEquals("MyKey", dsr.toString());

	List<SyncEntity> entities = new ArrayList<SyncEntity>();
	Entity e1a = new Entity(MacAddress.of(1L), VlanVid.ofVlan(2), IPv4Address.of(3), IPv6Address.NONE, DatapathId.of(4L), OFPort.of(5), new Date(1000));
	Entity e1b = new Entity(MacAddress.of(1L), VlanVid.ofVlan(2), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(4L), OFPort.of(5), new Date(1));
	entities.add(new SyncEntity(e1a));
	entities.add(new SyncEntity(e1b));
	// e1b comes before e1 (lastSeen) but we add it after it to test
	// sorting
	dsr.setEntities(entities);

	assertEquals(2, dsr.getEntities().size());
	// e1b has earlier time
	assertEquals(e1b, dsr.getEntities().get(0).asEntity());
	assertEquals(e1a, dsr.getEntities().get(1).asEntity());

	dsr.setKey(null);
	dsr.setEntities(null);
	assertNull(dsr.getKey());
	assertNull(dsr.getEntities());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:28,代码来源:DeviceManagerImplTest.java

示例11: getSrcNwAddr

/**
 * Get sender IP address from packet if the packet is an ARP
 * packet and if the source MAC address matches the ARP packets
 * sender MAC address.
 * @param eth
 * @param dlAddr
 * @return
 */
private IPv4Address getSrcNwAddr(Ethernet eth, MacAddress dlAddr) {
	if (eth.getPayload() instanceof ARP) {
		ARP arp = (ARP) eth.getPayload();
		if ((arp.getProtocolType() == ARP.PROTO_TYPE_IP) && (MacAddress.of(arp.getSenderHardwareAddress()).equals(dlAddr))) {
			return IPv4Address.of(arp.getSenderProtocolAddress());
		}
	}
	return IPv4Address.NONE;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:17,代码来源:DeviceManagerImpl.java

示例12: IPClient

public IPClient() {
    ipAddress = IPv4Address.NONE;
    nw_proto = IpProtocol.NONE;
    srcPort = TransportPort.NONE;
    targetPort = TransportPort.NONE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:6,代码来源:LoadBalancer.java

示例13: testBDAttachmentPointLearning

@Test
public void testBDAttachmentPointLearning() throws Exception {
	ITopologyService mockTopology = createMock(ITopologyService.class);
	expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
	expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
	andReturn(true).anyTimes();
	expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
	andReturn(false).anyTimes();
	expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
	andReturn(true).anyTimes();
	expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
			DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
	expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
			DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
	expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();

	Date topologyUpdateTime = new Date();
	expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
	anyTimes();

	replay(mockTopology);

	deviceManager.topology = mockTopology;

	Calendar c = Calendar.getInstance();
	Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.of(1), IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), c.getTime());
	c.add(Calendar.MILLISECOND,
			(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
	Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(2), c.getTime());
	c.add(Calendar.MILLISECOND,
			(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT / 2 + 1);
	Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(2), c.getTime());

	IDevice d;
	SwitchPort[] aps;

	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(1, deviceManager.getAllDevices().size());
	aps = d.getAttachmentPoints();
	assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);

	// this timestamp is too soon; don't switch
	d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(1, deviceManager.getAllDevices().size());
	aps = d.getAttachmentPoints();
	assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);

	// it should switch when we learn with a timestamp after the
	// timeout
	d = deviceManager.learnDeviceByEntity(entity3);
	assertEquals(1, deviceManager.getAllDevices().size());
	aps = d.getAttachmentPoints();
	assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(2)) }, aps);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:54,代码来源:DeviceManagerImplTest.java

示例14: testLOCALAttachmentPointLearning

/**
 * This test verifies that the learning behavior on OFPP_LOCAL ports.
 * Once a host is learned on OFPP_LOCAL, it is allowed to move only from
 * one OFPP_LOCAL to another OFPP_LOCAL port.
 * @throws Exception
 */
@Test
public void testLOCALAttachmentPointLearning() throws Exception {
	ITopologyService mockTopology = createMock(ITopologyService.class);
	expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).
	andReturn(DatapathId.of(1L)).anyTimes();
	expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
	andReturn(true).anyTimes();
	expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
	andReturn(false).anyTimes();
	expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.LOCAL)).
	andReturn(false).anyTimes();
	expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
	andReturn(true).anyTimes();
	expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
			DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
	expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.LOCAL,
			DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
	expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
			DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
	expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();

	Date topologyUpdateTime = new Date();
	expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
	anyTimes();

	replay(mockTopology);

	deviceManager.topology = mockTopology;

	Calendar c = Calendar.getInstance();
	Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.of(1), IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), c.getTime());
	c.add(Calendar.MILLISECOND,
			(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
	Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.LOCAL, c.getTime());
	c.add(Calendar.MILLISECOND,
			(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT + 1);
	Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(2), c.getTime());

	IDevice d;
	SwitchPort[] aps;

	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(1, deviceManager.getAllDevices().size());
	aps = d.getAttachmentPoints();
	assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);

	// Ensure that the attachment point changes to OFPP_LOCAL
	d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(1, deviceManager.getAllDevices().size());
	aps = d.getAttachmentPoints();
	assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);

	// Even though the new attachment point is consistent with old
	// and the time has elapsed, OFPP_LOCAL attachment point should
	// be maintained.
	d = deviceManager.learnDeviceByEntity(entity3);
	assertEquals(1, deviceManager.getAllDevices().size());
	aps = d.getAttachmentPoints();
	assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:66,代码来源:DeviceManagerImplTest.java

示例15: 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());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:71,代码来源:DeviceManagerImplTest.java


注:本文中的org.projectfloodlight.openflow.types.IPv4Address.NONE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。