本文整理汇总了Java中org.projectfloodlight.openflow.types.OFPort.of方法的典型用法代码示例。如果您正苦于以下问题:Java OFPort.of方法的具体用法?Java OFPort.of怎么用?Java OFPort.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.projectfloodlight.openflow.types.OFPort
的用法示例。
在下文中一共展示了OFPort.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteLink
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@Test
public void testDeleteLink() throws Exception {
LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1));
LinkInfo info = new LinkInfo(new Date(),
new Date(), null);
linkDiscovery.addOrUpdateLink(lt, info);
linkDiscovery.deleteLinks(Collections.singletonList(lt), "Test");
// check invariants hold
assertNull(linkDiscovery.switchLinks.get(lt.getSrc()));
assertNull(linkDiscovery.switchLinks.get(lt.getDst()));
assertNull(linkDiscovery.portLinks.get(lt.getSrc()));
assertNull(linkDiscovery.portLinks.get(lt.getDst()));
assertTrue(linkDiscovery.links.isEmpty());
}
示例2: testGetSwitchPortVlanId
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@Test
public void testGetSwitchPortVlanId() {
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), null, DatapathId.of(10L), OFPort.of(1), new Date());
Entity entity2 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(10L), OFPort.of(1), new Date());
Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(3), null, DatapathId.of(1L), OFPort.of(1), new Date());
Entity entity4 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(42), null, 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.ofVlan(-1), 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));
}
示例3: verifyDevice
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
/**
* Verify that the given device exactly matches the given fields. E.g.,
* if ip is not null we expect the device to have exactly one IP address.
* swId and port are the attachment point port.
* Vlan and ip are optional all other fields must be specified.
* @return
*/
private static void verifyDevice(IDevice d, long mac, Short vlan, Integer ip,
long swId, int port) {
assertNotNull(d);
assertEquals(MacAddress.of(mac), d.getMACAddress());
if (vlan == null)
assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(-1) }, d.getVlanId());
else
assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(vlan) }, d.getVlanId());
if (ip == null)
assertArrayEquals(new IPv4Address[] { IPv4Address.of(0) }, d.getIPv4Addresses());
else
assertArrayEquals(new IPv4Address[] { IPv4Address.of(ip) }, d.getIPv4Addresses());
SwitchPort expectedAp = new SwitchPort(DatapathId.of(swId), OFPort.of(port));
assertArrayEquals(new SwitchPort[] { expectedAp },
d.getAttachmentPoints());
}
示例4: testDeleteLinkToSelf
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@Test
public void testDeleteLinkToSelf() throws Exception {
LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(1L), OFPort.of(3));
NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(3));
LinkInfo info = new LinkInfo(new Date(),
new Date(), null);
linkDiscovery.addOrUpdateLink(lt, info);
linkDiscovery.deleteLinks(Collections.singletonList(lt), "Test to self");
// check invariants hold
assertNull(linkDiscovery.switchLinks.get(lt.getSrc()));
assertNull(linkDiscovery.switchLinks.get(lt.getDst()));
assertNull(linkDiscovery.portLinks.get(srcNpt));
assertNull(linkDiscovery.portLinks.get(dstNpt));
assertTrue(linkDiscovery.links.isEmpty());
}
示例5: testGetSwitchPortVlanId
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@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));
}
示例6: setUp
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@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());
}
示例7: testAddOrUpdateLink
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@Test
public void testAddOrUpdateLink() throws Exception {
LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
U64 latency = U64.of(100);
Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1), latency);
LinkInfo info = new LinkInfo(new Date(),
new Date(), null);
linkDiscovery.addOrUpdateLink(lt, info);
NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1));
// check invariants hold
assertNotNull(linkDiscovery.switchLinks.get(lt.getSrc()));
assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).contains(lt));
assertNotNull(linkDiscovery.getPortLinks().get(srcNpt));
assertTrue(linkDiscovery.getPortLinks().get(srcNpt).contains(lt));
assertNotNull(linkDiscovery.portLinks.get(dstNpt));
assertTrue(linkDiscovery.portLinks.get(dstNpt).contains(lt));
assertTrue(linkDiscovery.links.containsKey(lt));
assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).iterator().next().getLatency().equals(latency));
}
示例8: decode_output
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
/**
* Parse string and numerical port representations.
* The key and delimiter for the action should be omitted, and only the
* data should be presented to this decoder. Data can be any signed integer
* as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
* or 'flood'.
* @param actionToDecode; The action as a string to decode
* @param version; The OF version to create the action for
* @param log
* @return
*/
@LogMessageDoc(level="ERROR",
message="Invalid subaction: '{subaction}'",
explanation="A static flow entry contained an invalid subaction",
recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
OFPort port = OFPort.ANY;
if (n.matches()) {
if (n.group(1) != null && n.group(1).equals("all"))
port = OFPort.ALL;
else if (n.group(1) != null && n.group(1).equals("controller"))
port = OFPort.CONTROLLER;
else if (n.group(1) != null && n.group(1).equals("local"))
port = OFPort.LOCAL;
else if (n.group(1) != null && n.group(1).equals("ingress-port"))
port = OFPort.IN_PORT;
else if (n.group(1) != null && n.group(1).equals("normal"))
port = OFPort.NORMAL;
else if (n.group(1) != null && n.group(1).equals("flood"))
port = OFPort.FLOOD;
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
log.debug("action {}", ab.build());
return ab.build();
}
else {
try {
port = OFPort.of(Integer.parseInt(actionToDecode));
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
return ab.build();
} catch (NumberFormatException e) {
log.error("Could not parse Integer port: '{}'", actionToDecode);
return null;
}
}
}
示例9: decode_output
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
/**
* Parse string and numerical port representations.
* The key and delimiter for the action should be omitted, and only the
* data should be presented to this decoder. Data can be any signed integer
* as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
* or 'flood'.
* @param actionToDecode; The action as a string to decode
* @param version; The OF version to create the action for
* @param log
* @return
*/
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
OFPort port = OFPort.ANY;
if (n.matches()) {
if (n.group(1) != null && n.group(1).equals("all"))
port = OFPort.ALL;
else if (n.group(1) != null && n.group(1).equals("controller"))
port = OFPort.CONTROLLER;
else if (n.group(1) != null && n.group(1).equals("local"))
port = OFPort.LOCAL;
else if (n.group(1) != null && n.group(1).equals("ingress-port"))
port = OFPort.IN_PORT;
else if (n.group(1) != null && n.group(1).equals("normal"))
port = OFPort.NORMAL;
else if (n.group(1) != null && n.group(1).equals("flood"))
port = OFPort.FLOOD;
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
log.debug("action {}", ab.build());
return ab.build();
}
else {
try {
port = OFPort.of(Integer.parseInt(actionToDecode));
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
return ab.build();
} catch (NumberFormatException e) {
log.error("Could not parse Integer port: '{}'", actionToDecode);
return null;
}
}
}
示例10: makeSwitchMock
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
private IOFSwitch makeSwitchMock(DatapathId id) {
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
OFPortDesc mockPortDesc = createMock(OFPortDesc.class);
OFPort port = OFPort.of(1);
expect(mockSwitch.getId()).andReturn(id).anyTimes();
expect(mockSwitch.getPort(OFPort.of(1))).andReturn(mockPortDesc).anyTimes();
expect(mockPortDesc.getPortNo()).andReturn(port).anyTimes();
return mockSwitch;
}
示例11: testSyncEntity
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@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);
}
示例12: testDeviceSyncRepresentationBasics
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@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());
}
示例13: asEntity
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
public Entity asEntity() {
Entity e = new Entity(macAddress == 0 ? null : MacAddress.of(macAddress),
vlan == -1 ? null : VlanVid.ofVlan(vlan),
ipv4Address == 0 ? null : IPv4Address.of(ipv4Address),
switchDPID == 0 ? null : DatapathId.of(switchDPID),
switchPort == 0 ? null : OFPort.of(switchPort),
lastSeenTimestamp);
e.setActiveSince(activeSince);
return e;
}
示例14: testBDAttachmentPointLearning
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@Test
public void testBDAttachmentPointLearning() throws Exception {
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.getL2DomainId(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), null, IPv4Address.of(1), 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), null, null, 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), null, null, 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);
}
示例15: testConsolitateStore
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
@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), null, null, DatapathId.of(4L), OFPort.of(5), new Date(1000));
Entity e1b = new Entity(MacAddress.of(1L), null, IPv4Address.of(3), 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), null, null, 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), null, null, null, null, null);
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());
}