本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFMeterMod类的典型用法代码示例。如果您正苦于以下问题:Java OFMeterMod类的具体用法?Java OFMeterMod怎么用?Java OFMeterMod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFMeterMod类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFMeterMod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareForMeterTest
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
private Capture<OFMeterMod> prepareForMeterTest() {
Capture<OFMeterMod> capture = EasyMock.newCapture();
expect(ofSwitchService.getSwitch(dpid)).andStubReturn(iofSwitch);
expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription);
expect(switchDescription.getManufacturerDescription()).andStubReturn("");
expect(iofSwitch.write(capture(capture))).andReturn(true);
EasyMock.expectLastCall();
replay(ofSwitchService);
replay(iofSwitch);
replay(switchDescription);
return capture;
}
示例2: deleteMeter
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的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);
}
示例3: builderMeterMod
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
private OFMeterMod.Builder builderMeterMod() {
OFMeterMod.Builder builder = factory.buildMeterMod();
int flags = 0;
if (burst) {
// covering loxi short comings.
flags |= 1 << OFMeterFlags.BURST.ordinal();
}
switch (unit) {
case PKTS_PER_SEC:
flags |= 1 << OFMeterFlags.PKTPS.ordinal();
break;
case KB_PER_SEC:
flags |= 1 << OFMeterFlags.KBPS.ordinal();
break;
default:
log.warn("Unknown unit type {}", unit);
}
//FIXME: THIS WILL CHANGE IN OF1.4 to setBands.
builder.setMeters(buildBands());
builder.setFlags(flags)
.setMeterId(id)
.setXid(xid);
return builder;
}
示例4: installMeter
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的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);
}
示例5: installMeter
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
default OFMeterMod installMeter(long bandwidth, long burstSize, long meterId) {
return ofFactory.buildMeterMod()
.setMeterId(meterId)
.setCommand(ADD)
.setMeters(singletonList(ofFactory.meterBands()
.buildDrop()
.setRate(bandwidth)
.setBurstSize(burstSize).build()))
.setFlags(new HashSet<>(Arrays.asList(KBPS, BURST)))
.setXid(0L)
.build();
}
示例6: deleteMeter
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void deleteMeter() {
final Capture<OFMeterMod> capture = prepareForMeterTest();
switchManager.deleteMeter(dpid, meterId);
final OFMeterMod meterMod = capture.getValue();
assertEquals(meterMod.getCommand(), OFMeterModCommand.DELETE);
assertEquals(meterMod.getMeterId(), meterId);
}
示例7: installOneSwitchNoneFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installOneSwitchNoneFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_one_switch_none_flow.json"), Charsets.UTF_8);
InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.oneSwitchNoneFlowMod(data.getInputPort(), data.getOutputPort(),
data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例8: installOneSwitchReplaceFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installOneSwitchReplaceFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_one_switch_replace_flow.json"), Charsets.UTF_8);
InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.oneSwitchReplaceFlowMod(data.getInputPort(), data.getOutputPort(),
data.getInputVlanId(), data.getOutputVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例9: installOneSwitchPushFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installOneSwitchPushFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_one_switch_push_flow.json"), Charsets.UTF_8);
InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.oneSwitchPushFlowMod(data.getInputPort(), data.getOutputPort(),
data.getOutputVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例10: installOneSwitchPopFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installOneSwitchPopFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_one_switch_pop_flow.json"), Charsets.UTF_8);
InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.oneSwitchPopFlowMod(data.getInputPort(), data.getOutputPort(),
data.getInputVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例11: installIngressNoneFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installIngressNoneFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_none_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressNoneFlowMod(data.getInputPort(), data.getOutputPort(),
data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例12: installIngressReplaceFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installIngressReplaceFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_replace_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressReplaceFlowMod(data.getInputPort(), data.getOutputPort(),
data.getInputVlanId(), data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例13: installIngressPushFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installIngressPushFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_push_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressPushFlowMod(data.getInputPort(), data.getOutputPort(),
data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例14: installIngressPopFlow
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
@Test
public void installIngressPopFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_pop_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressPopFlowMod(data.getInputPort(), data.getOutputPort(),
data.getInputVlanId(), data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
示例15: runTest
import org.projectfloodlight.openflow.protocol.OFMeterMod; //导入依赖的package包/类
/**
* Runs test case.
*
* @param value data string from json resource file
* @param flowCommand OFFlowAdd instance to compare result with
* @throws InterruptedException if test was interrupted during run
*/
private void runTest(final String value, final OFFlowAdd flowCommand, final OFMeterMod meterCommand,
final OFFlowAdd reverseFlowCommand, final OFMeterMod reverseMeterCommand)
throws InterruptedException {
// construct kafka message
ConsumerRecord<String, String> record = new ConsumerRecord<>("", 0, 0, "", value);
// create parser instance
KafkaMessageCollector.ParseRecord parseRecord = collector.new ParseRecord(record);
// init test mocks
Capture<OFFlowAdd> flowAddCapture = flowCommand == null ? null : newCapture(CaptureType.ALL);
Capture<OFMeterMod> meterAddCapture = meterCommand == null ? null : newCapture(CaptureType.ALL);
prepareMocks(flowAddCapture, meterAddCapture, reverseFlowCommand != null, reverseMeterCommand != null);
// run parser and wait for termination or timeout
parseRecordExecutor.execute(parseRecord);
parseRecordExecutor.shutdown();
parseRecordExecutor.awaitTermination(10, TimeUnit.SECONDS);
// verify results
if (meterCommand != null) {
assertEquals(meterCommand, meterAddCapture.getValues().get(0));
if (reverseMeterCommand != null) {
assertEquals(reverseMeterCommand, meterAddCapture.getValues().get(1));
}
}
if (flowCommand != null) {
assertEquals(flowCommand, flowAddCapture.getValues().get(0));
if (reverseFlowCommand != null) {
assertEquals(reverseFlowCommand, flowAddCapture.getValues().get(1));
}
}
}