本文整理汇总了Java中net.floodlightcontroller.core.IOFSwitch.getOFFactory方法的典型用法代码示例。如果您正苦于以下问题:Java IOFSwitch.getOFFactory方法的具体用法?Java IOFSwitch.getOFFactory怎么用?Java IOFSwitch.getOFFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.core.IOFSwitch
的用法示例。
在下文中一共展示了IOFSwitch.getOFFactory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dumpMeters
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public OFMeterConfigStatsReply dumpMeters(final DatapathId dpid) {
OFMeterConfigStatsReply values = null;
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
if (sw == null) {
throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
}
OFFactory ofFactory = sw.getOFFactory();
OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest()
.setMeterId(0xffffffff)
.build();
try {
ListenableFuture<OFMeterConfigStatsReply> future = sw.writeRequest(meterRequest);
values = future.get(5, TimeUnit.SECONDS);
} catch (ExecutionException | InterruptedException | TimeoutException e) {
logger.error("Could not get meter config stats: {}", e.getMessage());
}
return values;
}
示例2: installLegacyMeter
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
private ImmutablePair<Long, Boolean> installLegacyMeter(final IOFSwitch sw, final DatapathId dpid,
final long bandwidth, final long burstSize,
final long meterId) {
logger.debug("installing legacy meter {} on OVS switch {} width bandwidth {}", meterId, dpid, bandwidth);
Set<OFLegacyMeterFlags> flags = new HashSet<>(Arrays.asList(OFLegacyMeterFlags.KBPS, OFLegacyMeterFlags.BURST));
OFFactory ofFactory = sw.getOFFactory();
OFLegacyMeterBandDrop.Builder bandBuilder = ofFactory.legacyMeterBandDrop(bandwidth, burstSize).createBuilder();
OFLegacyMeterMod meterMod = ofFactory.buildLegacyMeterMod()
.setMeterId(meterId)
.setCommand(OFLegacyMeterModCommand.ADD)
.setMeters(singletonList(bandBuilder.build()))
.setFlags(flags)
.build();
boolean response = sw.write(meterMod);
return new ImmutablePair<>(meterMod.getXid(), response);
}
示例3: deleteMeter
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
public ImmutablePair<Long, Boolean> deleteMeter(IOFSwitch sw, final DatapathId dpid, final long meterId) {
logger.debug("deleting meter {} from switch {}", meterId, dpid);
OFFactory ofFactory = sw.getOFFactory();
OFMeterMod.Builder meterDeleteBuilder = ofFactory.buildMeterMod()
.setMeterId(meterId)
.setCommand(OFMeterModCommand.DELETE);
if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
meterDeleteBuilder.setBands(emptyList());
} else {
meterDeleteBuilder.setMeters(emptyList());
}
OFMeterMod meterDelete = meterDeleteBuilder.build();
boolean response = sw.write(meterDelete);
return new ImmutablePair<>(meterDelete.getXid(), response);
}
示例4: actionReplaceVlan
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
* Create an OFAction to change the outer most vlan.
*
* @param sw switch object
* @param newVlan final VLAN to be set on the packet
* @return {@link OFAction}
*/
private OFAction actionReplaceVlan(final IOFSwitch sw, final int newVlan) {
OFFactory factory = sw.getOFFactory();
OFOxms oxms = factory.oxms();
OFActions actions = factory.actions();
if (OF_12.compareTo(factory.getVersion()) == 0) {
return actions.buildSetField().setField(oxms.buildVlanVid()
.setValue(OFVlanVidMatch.ofRawVid((short) newVlan))
.build()).build();
} else {
return actions.buildSetField().setField(oxms.buildVlanVid()
.setValue(OFVlanVidMatch.ofVlan(newVlan))
.build()).build();
}
}
示例5: DhcpDiscoveryRequestOFPacketIn
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
* Generates a DHCP request OFPacketIn.
* @param hostMac The host MAC address of for the request.
* @return An OFPacketIn that contains a DHCP request packet.
*/
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
MacAddress hostMac) {
byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
OFFactory factory = sw.getOFFactory();
OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
if (factory.getVersion() == OFVersion.OF_10) {
packetInBuilder
.setInPort(OFPort.of(1))
.setData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH);
} else {
packetInBuilder
.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
.setData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH);
}
return packetInBuilder.build();
}
示例6: dumpFlowTable
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public OFFlowStatsReply dumpFlowTable(final DatapathId dpid) {
OFFlowStatsReply values = null;
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
if (sw == null) {
throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
}
OFFactory ofFactory = sw.getOFFactory();
OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest()
.setMatch(sw.getOFFactory().matchWildcardAll())
.setTableId(TableId.ALL)
.setOutPort(OFPort.ANY)
.setOutGroup(OFGroup.ANY)
.setCookieMask(U64.ZERO)
.build();
try {
ListenableFuture<OFFlowStatsReply> future = sw.writeRequest(flowRequest);
values = future.get(10, TimeUnit.SECONDS);
} catch (ExecutionException | InterruptedException | TimeoutException e) {
logger.error("Could not get flow stats: {}", e.getMessage());
}
return values;
}
示例7: installMeter
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
private ImmutablePair<Long, Boolean> installMeter(final IOFSwitch sw, final DatapathId dpid, final long bandwidth,
final long burstSize, final long meterId) {
logger.debug("installing meter {} on switch {} width bandwidth {}", meterId, dpid, bandwidth);
Set<OFMeterFlags> flags = new HashSet<>(Arrays.asList(OFMeterFlags.KBPS, OFMeterFlags.BURST));
OFFactory ofFactory = sw.getOFFactory();
OFMeterBandDrop.Builder bandBuilder = ofFactory.meterBands()
.buildDrop()
.setRate(bandwidth)
.setBurstSize(burstSize);
OFMeterMod.Builder meterModBuilder = ofFactory.buildMeterMod()
.setMeterId(meterId)
.setCommand(OFMeterModCommand.ADD)
.setFlags(flags);
if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
meterModBuilder.setBands(singletonList(bandBuilder.build()));
} else {
meterModBuilder.setMeters(singletonList(bandBuilder.build()));
}
OFMeterMod meterMod = meterModBuilder.build();
boolean response = sw.write(meterMod);
return new ImmutablePair<>(meterMod.getXid(), response);
}
示例8: deleteFlow
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ImmutablePair<Long, Boolean> deleteFlow(final DatapathId dpid, final String flowId, final Long cookie) {
logger.info("deleting flows {} from switch {}", flowId, dpid.toString());
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
OFFactory ofFactory = sw.getOFFactory();
OFFlowDelete flowDelete = ofFactory.buildFlowDelete()
.setCookie(U64.of(cookie))
.setCookieMask(NON_SYSTEM_MASK)
.build();
boolean response = sw.write(flowDelete);
return new ImmutablePair<>(flowDelete.getXid(), response);
}
示例9: deleteLegacyMeter
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
public ImmutablePair<Long, Boolean> deleteLegacyMeter(final IOFSwitch sw, final DatapathId dpid, final long meterId) {
logger.debug("deleting legacy meter {} from switch {}", meterId, dpid);
OFFactory ofFactory = sw.getOFFactory();
OFLegacyMeterMod meterDelete = ofFactory.buildLegacyMeterMod()
.setMeterId(meterId)
.setMeters(emptyList())
.setCommand(OFLegacyMeterModCommand.DELETE)
.build();
boolean response = sw.write(meterDelete);
return new ImmutablePair<>(meterDelete.getXid(), response);
}