本文整理汇总了Java中org.projectfloodlight.openflow.types.DatapathId类的典型用法代码示例。如果您正苦于以下问题:Java DatapathId类的具体用法?Java DatapathId怎么用?Java DatapathId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DatapathId类属于org.projectfloodlight.openflow.types包,在下文中一共展示了DatapathId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteLinkToSelf
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的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), U64.ZERO);
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());
}
示例2: removeSwitch
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
public void removeSwitch(DatapathId sid) {
// Delete all the links in the switch, switch and all
// associated data should be deleted.
if (switchPorts.containsKey(sid) == false) return;
// Check if any tunnel ports need to be removed.
for(NodePortTuple npt: tunnelPorts) {
if (npt.getNodeId() == sid) {
removeTunnelPort(npt.getNodeId(), npt.getPortId());
}
}
Set<Link> linksToRemove = new HashSet<Link>();
for(OFPort p: switchPorts.get(sid)) {
NodePortTuple n1 = new NodePortTuple(sid, p);
linksToRemove.addAll(switchPortLinks.get(n1));
}
if (linksToRemove.isEmpty()) return;
for(Link link: linksToRemove) {
removeLink(link);
}
}
示例3: SwitchUpdate
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
public SwitchUpdate(DatapathId swId,
SwitchUpdateType switchUpdateType,
OFPortDesc port,
PortChangeType changeType) {
if (switchUpdateType == SwitchUpdateType.PORTCHANGED) {
if (port == null) {
throw new NullPointerException("Port must not be null " +
"for PORTCHANGED updates");
}
if (changeType == null) {
throw new NullPointerException("ChangeType must not be " +
"null for PORTCHANGED updates");
}
} else {
if (port != null || changeType != null) {
throw new IllegalArgumentException("port and changeType " +
"must be null for " + switchUpdateType +
" updates");
}
}
this.swId = swId;
this.switchUpdateType = switchUpdateType;
this.port = port;
this.changeType = changeType;
}
示例4: init
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
linkDiscoveryService = context.getServiceImpl(ILinkDiscoveryService.class);
threadPoolService = context.getServiceImpl(IThreadPoolService.class);
floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
switchService = context.getServiceImpl(IOFSwitchService.class);
restApiService = context.getServiceImpl(IRestApiService.class);
debugCounterService = context.getServiceImpl(IDebugCounterService.class);
debugEventService = context.getServiceImpl(IDebugEventService.class);
switchPorts = new HashMap<DatapathId, Set<OFPort>>();
switchPortLinks = new HashMap<NodePortTuple, Set<Link>>();
directLinks = new HashMap<NodePortTuple, Set<Link>>();
portBroadcastDomainLinks = new HashMap<NodePortTuple, Set<Link>>();
tunnelPorts = new HashSet<NodePortTuple>();
topologyAware = new ArrayList<ITopologyListener>();
ldUpdates = new LinkedBlockingQueue<LDUpdate>();
haListener = new HAListenerDelegate();
registerTopologyDebugCounters();
registerTopologyDebugEvents();
}
示例5: testAddOrUpdateLink
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的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));
}
示例6: installVerificationRule
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
* Installs the verification rule
*
* @param dpid datapathId of switch
* @param isBroadcast if broadcast then set a generic match; else specific to switch Id
* @return true if the command is accepted to be sent to switch, false otherwise - switch is disconnected or in
* SLAVE mode
*/
private boolean installVerificationRule(final DatapathId dpid, final boolean isBroadcast) {
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
Match match = matchVerification(sw, isBroadcast);
ArrayList<OFAction> actionList = new ArrayList<>(2);
actionList.add(actionSendToController(sw));
actionList.add(actionSetDstMac(sw, dpidToMac(sw)));
OFInstructionApplyActions instructionApplyActions = sw.getOFFactory().instructions()
.applyActions(actionList).createBuilder().build();
final long cookie = isBroadcast ? 0x8000000000000002L : 0x8000000000000003L;
OFFlowMod flowMod = buildFlowMod(sw, match, null, instructionApplyActions,
cookie, FlowModUtils.PRIORITY_VERY_HIGH);
String flowname = (isBroadcast) ? "Broadcast" : "Unicast";
flowname += "--VerificationFlow--" + dpid.toString();
return pushFlow(flowname, dpid, flowMod);
}
示例7: switchActivated
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void switchActivated(final DatapathId switchId) {
final IOFSwitch sw = switchService.getSwitch(switchId);
Message message = buildSwitchMessage(sw, SwitchState.ACTIVATED);
kafkaProducer.postMessage(TOPO_EVENT_TOPIC, message);
ImmutablePair<Long, Boolean> metersDeleted;
metersDeleted = switchManager.deleteMeter(switchId, ALL_VAL);
if (!metersDeleted.getRight()) {
logger.error("Could not delete meters from switch={} xid={}", switchId, metersDeleted.getLeft());
}
boolean defaultRulesInstalled = switchManager.installDefaultRules(switchId);
if (!defaultRulesInstalled) {
logger.error("Could not install default rules on switch={}", switchId);
}
if (sw.getEnabledPortNumbers() != null) {
for (OFPort p : sw.getEnabledPortNumbers()) {
kafkaProducer.postMessage(TOPO_EVENT_TOPIC, buildPortMessage(sw.getId(), p, PortChangeType.UP));
}
}
}
示例8: isAttachmentPointPort
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public boolean isAttachmentPointPort(DatapathId switchid, OFPort port, boolean tunnelEnabled) {
// If the switch port is 'tun-bsn' port, it is not
// an attachment point port, irrespective of whether
// a link is found through it or not.
if (linkDiscoveryService.isTunnelPort(switchid, port))
return false;
TopologyInstance ti = getCurrentInstance(tunnelEnabled);
// if the port is not attachment point port according to
// topology instance, then return false
if (ti.isAttachmentPointPort(switchid, port) == false)
return false;
// Check whether the port is a physical port. We should not learn
// attachment points on "special" ports.
if ((port.getShortPortNumber() & 0xff00) == 0xff00 && port.getShortPortNumber() != (short)0xfffe) return false;
// Make sure that the port is enabled.
IOFSwitch sw = switchService.getActiveSwitch(switchid);
if (sw == null) return false;
return (sw.portEnabled(port));
}
示例9: getEntityKeys
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
private EnumSet<DeviceField> getEntityKeys(MacAddress macAddress,
VlanVid vlan,
IPv4Address ipv4Address,
DatapathId switchDPID,
OFPort switchPort) {
// FIXME: vlan==null is a valid search. Need to handle this
// case correctly. Note that the code will still work correctly.
// But we might do a full device search instead of using an index.
EnumSet<DeviceField> keys = EnumSet.noneOf(DeviceField.class);
if (macAddress != null) keys.add(DeviceField.MAC);
if (vlan != null) keys.add(DeviceField.VLAN);
if (ipv4Address != null) keys.add(DeviceField.IPV4);
if (switchDPID != null) keys.add(DeviceField.SWITCH);
if (switchPort != null) keys.add(DeviceField.PORT);
return keys;
}
示例10: calculateBroadcastPortMap
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
protected void calculateBroadcastPortMap(){
this.broadcastPortMap.clear();
for (DatapathId sw : this.switches) {
for (OFPort p : this.allPorts.get(sw)){
NodePortTuple npt = new NodePortTuple(sw, p);
if (isEdge(sw, p) || broadcastNodePorts.contains(npt)) {
if (broadcastPortMap.containsKey(sw)) {
broadcastPortMap.get(sw).add(p);
} else {
broadcastPortMap.put(sw, new HashSet<OFPort>(Arrays.asList(p)));
}
}
}
}
}
示例11: getSourceEntityFromPacket
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
* Parse an entity from an {@link Ethernet} packet.
* @param eth the packet to parse
* @param sw the switch on which the packet arrived
* @param pi the original packetin
* @return the entity from the packet
*/
protected Entity getSourceEntityFromPacket(Ethernet eth, DatapathId swdpid, OFPort port) {
MacAddress dlAddr = eth.getSourceMACAddress();
// Ignore broadcast/multicast source
if (dlAddr.isBroadcast() || dlAddr.isMulticast())
return null;
// Ignore 0 source mac
if (dlAddr.getLong() == 0)
return null;
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
IPv4Address ipv4Src = getSrcIPv4AddrFromARP(eth, dlAddr);
IPv6Address ipv6Src = ipv4Src.equals(IPv4Address.NONE) ? getSrcIPv6Addr(eth) : IPv6Address.NONE;
return new Entity(dlAddr,
vlan,
ipv4Src,
ipv6Src,
swdpid,
port,
new Date());
}
示例12: mockTopologyForPacketInTests
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
private static void
mockTopologyForPacketInTests(ITopologyService mockTopology) {
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()),
OFPort.of(anyShort()))).
andReturn(true).
anyTimes();
expect(mockTopology.isConsistent(DatapathId.of(EasyMock.anyLong()),
OFPort.of(EasyMock.anyShort()),
DatapathId.of(EasyMock.anyLong()),
OFPort.of(EasyMock.anyShort()))).andReturn(false).
anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(EasyMock.anyLong()),
OFPort.of(EasyMock.anyShort())))
.andReturn(false)
.anyTimes();
expect(mockTopology.getL2DomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()),
OFPort.of(anyShort()),
DatapathId.of(anyLong()),
OFPort.of(anyShort())))
.andReturn(false).anyTimes();
}
示例13: writeFlowModToSwitch
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
* Writes an OFFlowMod to a switch. It checks to make sure the switch
* exists before it sends
* @param dpid The data to write the flow mod to
* @param flowMod The OFFlowMod to write
*/
private void writeFlowModToSwitch(DatapathId dpid, OFFlowMod flowMod) {
IOFSwitch ofSwitch = switchService.getSwitch(dpid);
if (ofSwitch == null) {
if (log.isDebugEnabled()) {
log.debug("Not deleting key {} :: switch {} not connected", dpid.toString());
}
return;
}
writeFlowModToSwitch(ofSwitch, flowMod);
}
示例14: writeOFMessagesToSwitch
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
* Writes a list of OFMessages to a switch
* @param dpid The datapath ID of the switch to write to
* @param messages The list of OFMessages to write.
*/
private void writeOFMessagesToSwitch(DatapathId dpid, List<OFMessage> messages) {
IOFSwitch ofswitch = switchService.getSwitch(dpid);
if (ofswitch != null) { // is the switch connected
if (log.isDebugEnabled()) {
log.debug("Sending {} new entries to {}", messages.size(), dpid);
}
ofswitch.write(messages);
}
}
示例15: RemoveFromSuppressLLDPs
import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
* Remove a switch port from the suppressed LLDP list. Discover links on
* that switchport.
*/
@Override
public void RemoveFromSuppressLLDPs(DatapathId sw, OFPort port) {
NodePortTuple npt = new NodePortTuple(sw, port);
this.suppressLinkDiscovery.remove(npt);
discover(npt);
}