本文整理汇总了Java中net.floodlightcontroller.devicemanager.SwitchPort类的典型用法代码示例。如果您正苦于以下问题:Java SwitchPort类的具体用法?Java SwitchPort怎么用?Java SwitchPort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SwitchPort类属于net.floodlightcontroller.devicemanager包,在下文中一共展示了SwitchPort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOldAP
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public SwitchPort[] getOldAP() {
List<SwitchPort> sp = new ArrayList<SwitchPort>();
SwitchPort[] returnSwitchPorts = new SwitchPort[] {};
if (oldAPs == null)
return returnSwitchPorts;
if (oldAPs.isEmpty())
return returnSwitchPorts;
// copy ap list.
List<AttachmentPoint> oldAPList;
oldAPList = new ArrayList<AttachmentPoint>();
if (oldAPs != null)
oldAPList.addAll(oldAPs);
removeExpiredAttachmentPoints(oldAPList);
if (oldAPList != null) {
for (AttachmentPoint ap : oldAPList) {
SwitchPort swport = new SwitchPort(ap.getSw(), ap.getPort());
sp.add(swport);
}
}
return sp.toArray(new SwitchPort[sp.size()]);
}
示例2: generateDeviceEvent
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
List<IPv4Address> ipv4Addresses =
new ArrayList<IPv4Address>(Arrays.asList(device.getIPv4Addresses()));
List<IPv6Address> ipv6Addresses =
new ArrayList<IPv6Address>(Arrays.asList(device.getIPv6Addresses()));
List<SwitchPort> oldAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getOldAP()));
List<SwitchPort> currentAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getAttachmentPoints()));
List<VlanVid> vlanIds =
new ArrayList<VlanVid>(Arrays.asList(device.getVlanId()));
debugEventCategory.newEventNoFlush(new DeviceEvent(device.getMACAddress(),
ipv4Addresses,
ipv6Addresses,
oldAps,
currentAps,
vlanIds, reason));
}
示例3: DeviceSyncRepresentation
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
public DeviceSyncRepresentation(Device device) {
this.key = computeKey(device);
this.entities = new ArrayList<SyncEntity>();
// FIXME: do we need the APs with errors as well??
// FIXME
SwitchPort[] aps = device.getAttachmentPoints();
for (Entity e : device.getEntities()) {
// Add the entities from the device only if they either don't
// have a switch/port or if they are an attachment point or
// if they have an IP address.
if (!e.hasSwitchPort()) {
this.entities.add(new SyncEntity(e));
} else if (isAttachmentPointEntity(aps, e)) {
this.entities.add(new SyncEntity(e));
} else if (!e.getIpv4Address().equals(IPv4Address.NONE)) {
this.entities.add(new SyncEntity(e));
}
}
Collections.sort(this.entities);
}
示例4: customFormat
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public EventResourceBuilder
customFormat(@Nullable Collection<SwitchPort> aps2, String name,
EventResourceBuilder edb) {
if (aps2 != null) {
StringBuilder apsStr2 = new StringBuilder();
if (aps2.size() == 0) {
apsStr2.append("--");
} else {
for (SwitchPort ap : aps2) {
apsStr2.append(ap.getSwitchDPID().toString());
apsStr2.append("/");
apsStr2.append(ap.getPort());
apsStr2.append(" ");
}
// remove trailing space
apsStr2.deleteCharAt(apsStr2.length());
}
edb.dataFields.add(new Metadata(name, apsStr2.toString()));
}
return edb;
}
示例5: deviceAdded
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public void deviceAdded(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
if (switchPort.length == 0) {
//Device manager does not yet know an attachment point for a device (Bug Fix)
return;
}
IPv4Address[] ips = device.getIPv4Addresses();
if (ips.length == 0) {
// A new no-ip device added
return;
}
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
.getLong());
String ip = IPv4.fromIPv4Address(ips[0].getInt());
logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);
AP ap = new AP(ip, dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例6: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
IPv4Address[] ips = device.getIPv4Addresses();
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
.getLong());
String ip = null;
// some device may first appear with no IP address(default set to
// 0.0.0.0), ignore it
for (IPv4Address i : ips) {
if (i.getInt() != 0) {
ip = IPv4.fromIPv4Address(i.getInt());
break;
}
}
logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);
AP ap = new AP(ip, dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例7: verifyDevice
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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, MacAddress mac, VlanVid vlan, IPv4Address ipv4,
IPv6Address ipv6, DatapathId swId, OFPort port) {
assertNotNull(d);
if (!mac.equals(MacAddress.NONE)) {
assertEquals(mac, d.getMACAddress());
}
if (vlan != null) {
assertArrayEquals(new VlanVid[] { vlan }, d.getVlanId());
}
if (!ipv4.equals(IPv4Address.NONE)) {
assertArrayEquals(new IPv4Address[] { ipv4 }, d.getIPv4Addresses());
}
if (!ipv6.equals(IPv6Address.NONE)) {
assertArrayEquals(new IPv6Address[] { ipv6 }, d.getIPv6Addresses());
}
if (!swId.equals(DatapathId.NONE) && !port.equals(OFPort.ZERO)) {
SwitchPort expectedAp = new SwitchPort(swId, port);
assertArrayEquals(new SwitchPort[] { expectedAp }, d.getAttachmentPoints());
}
}
示例8: testGetSwitchPortVlanId
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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));
}
示例9: getOldAP
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public SwitchPort[] getOldAP() {
List<SwitchPort> sp = new ArrayList<SwitchPort>();
SwitchPort [] returnSwitchPorts = new SwitchPort[] {};
if (oldAPs == null) return returnSwitchPorts;
if (oldAPs.isEmpty()) return returnSwitchPorts;
// copy ap list.
List<AttachmentPoint> oldAPList;
oldAPList = new ArrayList<AttachmentPoint>();
if (oldAPs != null) oldAPList.addAll(oldAPs);
removeExpiredAttachmentPoints(oldAPList);
if (oldAPList != null) {
for(AttachmentPoint ap: oldAPList) {
SwitchPort swport = new SwitchPort(ap.getSw(),
ap.getPort());
sp.add(swport);
}
}
return sp.toArray(new SwitchPort[sp.size()]);
}
示例10: generateDeviceEvent
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
List<IPv4Address> ipv4Addresses =
new ArrayList<IPv4Address>(Arrays.asList(device.getIPv4Addresses()));
List<SwitchPort> oldAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getOldAP()));
List<SwitchPort> currentAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getAttachmentPoints()));
List<VlanVid> vlanIds =
new ArrayList<VlanVid>(Arrays.asList(device.getVlanId()));
debugEventCategory.newEventNoFlush(new DeviceEvent(device.getMACAddress(),
ipv4Addresses,
oldAps,
currentAps,
vlanIds, reason));
}
示例11: DeviceSyncRepresentation
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
public DeviceSyncRepresentation(Device device) {
this.key = computeKey(device);
this.entities = new ArrayList<SyncEntity>();
// FIXME: do we need the APs with errors as well??
// FIXME
SwitchPort[] aps = device.getAttachmentPoints();
for(Entity e: device.getEntities()) {
// Add the entities from the device only if they either don't
// have a switch/port or if they are an attachment point or
// if they have an IP address.
if (!e.hasSwitchPort()) {
this.entities.add(new SyncEntity(e));
} else if (isAttachmentPointEntity(aps, e)) {
this.entities.add(new SyncEntity(e));
} else if (e.getIpv4Address() != null) {
this.entities.add(new SyncEntity(e));
}
}
Collections.sort(this.entities);
}
示例12: deviceAdded
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
/**
* listen for new device
*/
@Override
public void deviceAdded(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
IPv4Address[] ips = device.getIPv4Addresses();
if(ips.length == 0){
// A new no-ip device added
return;
}
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
String ip = IPv4.fromIPv4Address(ips[0].getInt());
logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]");
AP ap = new AP(ip,dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例13: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
IPv4Address[] ips = device.getIPv4Addresses();
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
String ip = null;
// some device may first appear with no IP address(default set to 0.0.0.0), ignore it
for(IPv4Address i : ips){
if(i.getInt() != 0){
ip = IPv4.fromIPv4Address(i.getInt());
break;
}
}
logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]");
AP ap = new AP(ip, dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
示例14: verifyDevice
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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());
}
示例15: testGetSwitchPortVlanId
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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));
}