本文整理汇总了Java中net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity类的典型用法代码示例。如果您正苦于以下问题:Java SyncEntity类的具体用法?Java SyncEntity怎么用?Java SyncEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyncEntity类属于net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation包,在下文中一共展示了SyncEntity类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: goToMaster
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的package包/类
/**
* Synchronously transition from SLAVE to MASTER. By iterating through
* the store and learning all devices from the store
*/
private void goToMaster() {
if (logger.isDebugEnabled()) {
logger.debug("Transitioning to MASTER role");
}
cntTransitionToMaster.increment();
IClosableIterator<Map.Entry<String,Versioned<DeviceSyncRepresentation>>>
iter = null;
try {
iter = storeClient.entries();
} catch (SyncException e) {
cntSyncException.increment();
logger.error("Failed to read devices from sync store", e);
return;
}
try {
while(iter.hasNext()) {
Versioned<DeviceSyncRepresentation> versionedDevice =
iter.next().getValue();
DeviceSyncRepresentation storedDevice =
versionedDevice.getValue();
if (storedDevice == null)
continue;
cntDevicesFromStore.increment();
for(SyncEntity se: storedDevice.getEntities()) {
learnDeviceByEntity(se.asEntity());
}
}
} finally {
if (iter != null)
iter.close();
}
storeConsolidateTask.reschedule(initialSyncStoreConsolidateMs,
TimeUnit.MILLISECONDS);
}
示例2: testSyncEntity
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的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);
}
示例3: testDeviceSyncRepresentationBasics
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的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());
}
示例4: assertEntityEquals
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的package包/类
private static void assertEntityEquals(Entity expected, SyncEntity actual) {
assertNotNull(actual);
assertNotNull(expected);
Entity actualEntity = actual.asEntity();
assertEquals("entityFields", expected, actualEntity);
assertEquals("lastSeenTimestamp",
expected.getLastSeenTimestamp(),
actualEntity.getLastSeenTimestamp());
assertEquals("activeSince",
expected.getActiveSince(), actualEntity.getActiveSince());
}
示例5: testSyncEntity
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的package包/类
@Test
public void testSyncEntity() {
Date d1 = new Date();
Date d2 = new Date(0);
Entity e1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(2), IPv4Address.of(3), 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), null, null, null, null, null);
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);
}
示例6: testDeviceSyncRepresentationBasics
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的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), DatapathId.of(4L), OFPort.of(5), new Date(1000));
Entity e1b = new Entity(MacAddress.of(1L), VlanVid.ofVlan(2), null, DatapathId.of(4L), OFPort.of(5), new Date(0));
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());
}
示例7: goToMaster
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的package包/类
/**
* Synchronously transition from SLAVE to MASTER. By iterating through
* the store and learning all devices from the store
*/
private void goToMaster() {
if (logger.isDebugEnabled()) {
logger.debug("Transitioning to MASTER role");
}
cntTransitionToMaster.updateCounterWithFlush();
IClosableIterator<Map.Entry<String,Versioned<DeviceSyncRepresentation>>>
iter = null;
try {
iter = storeClient.entries();
} catch (SyncException e) {
cntSyncException.updateCounterWithFlush();
logger.error("Failed to read devices from sync store", e);
return;
}
try {
while(iter.hasNext()) {
Versioned<DeviceSyncRepresentation> versionedDevice =
iter.next().getValue();
DeviceSyncRepresentation storedDevice =
versionedDevice.getValue();
if (storedDevice == null)
continue;
cntDevicesFromStore.updateCounterWithFlush();
for(SyncEntity se: storedDevice.getEntities()) {
learnDeviceByEntity(se.asEntity());
}
}
} finally {
if (iter != null)
iter.close();
}
storeConsolidateTask.reschedule(initialSyncStoreConsolidateMs,
TimeUnit.MILLISECONDS);
}
示例8: testSyncEntity
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的package包/类
@Test
public void testSyncEntity() {
Date d1 = new Date();
Date d2 = new Date(0);
Entity e1 = new Entity(1L, (short)2, 3, 4L, 5, d1);
e1.setActiveSince(d2);
SyncEntity se1 = new SyncEntity(e1);
assertEntityEquals(e1, se1);
assertEquals(1L, se1.macAddress);
assertEquals(Short.valueOf((short)2), se1.vlan);
assertEquals(Integer.valueOf(3), se1.ipv4Address);
assertEquals(Long.valueOf(4L), se1.switchDPID);
assertEquals(Integer.valueOf(5), se1.switchPort);
assertEquals(d1, se1.lastSeenTimestamp);
assertEquals(d2, se1.activeSince);
assertNotSame(d1, se1.lastSeenTimestamp);
assertNotSame(d2, se1.activeSince);
Entity e2 = new Entity(42L, null, null, null, null, null);
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);
}
示例9: testDeviceSyncRepresentationBasics
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的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(1L, (short)2, 3, 4L, 5, new Date(1000));
Entity e1b = new Entity(1L, (short)2, null, 4L, 5, new Date(0));
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());
}
示例10: assertEntityEquals
import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation.SyncEntity; //导入依赖的package包/类
private static void assertEntityEquals(Entity expected, SyncEntity actual) {
assertNotNull(actual);
assertNotNull(expected);
Entity actualEntity = actual.asEntity();
assertEquals("entityFields", expected, actualEntity);
assertEquals("lastSeenTimestamp",
expected.getLastSeenTimestamp(),
actualEntity.getLastSeenTimestamp());
assertEquals("activeSince",
expected.getActiveSince(), actualEntity.getActiveSince());
}