本文整理匯總了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
}