本文整理汇总了Java中org.onosproject.net.meter.Meter.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Meter.Builder方法的具体用法?Java Meter.Builder怎么用?Java Meter.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.meter.Meter
的用法示例。
在下文中一共展示了Meter.Builder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submit
import org.onosproject.net.meter.Meter; //导入方法依赖的package包/类
@Override
public Meter submit(MeterRequest request) {
MeterId id = allocateMeterId(request.deviceId());
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(id)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_ADD);
store.storeMeter(m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
return m;
}
示例2: withdraw
import org.onosproject.net.meter.Meter; //导入方法依赖的package包/类
@Override
public void withdraw(MeterRequest request, MeterId meterId) {
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(meterId)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_REMOVE);
store.deleteMeter(m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
}
示例3: testPerformMeterOperationDeviceIdMeterRemove
import org.onosproject.net.meter.Meter; //导入方法依赖的package包/类
@Test
public void testPerformMeterOperationDeviceIdMeterRemove() {
DeviceId mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
Band cbsBand = DefaultBand.builder()
.ofType(Band.Type.REMARK) //Committed - CIR & CBS
.withRate(37500L)
.burstSize(2000)
.dropPrecedence((short) 0)
.build();
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(mockDeviceId)
.withId(MeterId.meterId(1))
.fromApp(new DefaultApplicationId(101, "unit.test"))
.burst()
.withBands(new HashSet<Band>() { { add(cbsBand); } });
MeterOperation meterOp = new MeterOperation(mBuilder.build(), Type.REMOVE);
meterProvider.performMeterOperation(mockDeviceId, meterOp);
//The NETCONF XML generated by this matches the pattern
// sampleXmlRegexEditConfigBwpGroup1
// in MockNetconfSession
}
示例4: submit
import org.onosproject.net.meter.Meter; //导入方法依赖的package包/类
@Override
public Meter submit(MeterRequest request) {
MeterId id = allocateMeterId(request.deviceId());
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(id)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_ADD);
store.storeMeter(networkId(), m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
return m;
}
示例5: withdraw
import org.onosproject.net.meter.Meter; //导入方法依赖的package包/类
@Override
public void withdraw(MeterRequest request, MeterId meterId) {
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(meterId)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_REMOVE);
store.deleteMeter(networkId(), m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
}
示例6: testPerformMeterOperationDeviceIdMeterAdd
import org.onosproject.net.meter.Meter; //导入方法依赖的package包/类
@Test
public void testPerformMeterOperationDeviceIdMeterAdd() {
DeviceId mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
Band cbsBand = DefaultBand.builder()
.ofType(Band.Type.REMARK) //Committed - CIR & CBS
.withRate(37500L)
.burstSize(2000)
.dropPrecedence((short) 0)
.build();
Band ebsBand = DefaultBand.builder()
.ofType(Band.Type.DROP) //Excess - EIR & EBS
.withRate(50000L) //The rate at which we drop - for EA 1000 subtract CIR to get EIR
.burstSize(3000) //The burst rate to drop at
.build();
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(mockDeviceId)
.withId(MeterId.meterId(1))
.fromApp(new DefaultApplicationId(101, "unit.test"))
.burst()
.withUnit(Unit.KB_PER_SEC)
.withBands(new HashSet<Band>() { { add(cbsBand); add(ebsBand); } });
MeterOperation meterOp = new MeterOperation(mBuilder.build(), Type.ADD);
meterProvider.performMeterOperation(mockDeviceId, meterOp);
//The NETCONF XML generated by this matches the pattern
// sampleXmlRegexEditConfigBwpGroup1
// in MockNetconfSession
}