本文整理汇总了Java中org.onosproject.net.meter.DefaultBand类的典型用法代码示例。如果您正苦于以下问题:Java DefaultBand类的具体用法?Java DefaultBand怎么用?Java DefaultBand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultBand类属于org.onosproject.net.meter包,在下文中一共展示了DefaultBand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
@Activate
public void activate() {
local = clusterService.getLocalNode().id();
meters = storageService.<MeterKey, MeterData>consistentMapBuilder()
.withName(METERSTORE)
.withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
MeterKey.class,
MeterData.class,
DefaultMeter.class,
DefaultBand.class,
Band.Type.class,
MeterState.class,
Meter.Unit.class,
MeterFailReason.class)).build();
meters.addListener(mapListener);
log.info("Started");
}
示例2: execute
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
@Override
protected void execute() {
MeterService service = get(MeterService.class);
CoreService coreService = get(CoreService.class);
DeviceId deviceId = DeviceId.deviceId(uri);
Band band = DefaultBand.builder()
.ofType(Band.Type.DROP)
.withRate(500)
.build();
MeterRequest request = DefaultMeterRequest.builder()
.forDevice(deviceId)
.fromApp(coreService.registerApplication(appId))
.withUnit(Meter.Unit.KB_PER_SEC)
.withBands(Collections.singleton(band))
.add();
service.submit(request);
}
示例3: testMeterEncode
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
/**
* Tests encoding of a Meter object.
*/
@Test
public void testMeterEncode() {
Band band1 = DefaultBand.builder()
.ofType(Band.Type.DROP)
.burstSize(10)
.withRate(10).build();
Band band2 = DefaultBand.builder()
.ofType(Band.Type.REMARK)
.burstSize(10)
.withRate(10)
.dropPrecedence((short) 10).build();
Meter meter = DefaultMeter.builder()
.fromApp(APP_ID)
.withId(MeterId.meterId(1L))
.forDevice(NetTestTools.did("d1"))
.withBands(ImmutableList.of(band1, band2))
.withUnit(Meter.Unit.KB_PER_SEC).build();
ObjectNode meterJson = meterCodec.encode(meter, context);
assertThat(meterJson, matchesMeter(meter));
}
示例4: testPerformMeterOperationDeviceIdMeterRemove
import org.onosproject.net.meter.DefaultBand; //导入依赖的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
}
示例5: execute
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
@Override
protected void execute() {
MeterService service = get(MeterService.class);
CoreService coreService = get(CoreService.class);
DeviceId deviceId = DeviceId.deviceId(uri);
MeterId meterId = MeterId.meterId(Long.parseLong(meterIdstr, 16));
Band b = new DefaultBand(Band.Type.DROP, 0L, 0L, (short) 0);
MeterRequest.Builder builder = DefaultMeterRequest.builder()
.forDevice(deviceId)
.withBands(Collections.singleton(b))
.withUnit(Meter.Unit.PKTS_PER_SEC)
.fromApp(coreService.registerApplication(appId));
MeterRequest meterRequest = builder.remove();
service.withdraw(meterRequest, meterId);
log.info("Requested meter removal: {}", meterRequest.toString());
print("Requested meter removal: %s", meterRequest.toString());
}
示例6: band
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
private Band band(OFMeterBand ofMeterBand) {
DefaultBand.Builder builder = DefaultBand.builder();
if (ofMeterBand instanceof OFMeterBandDrop) {
OFMeterBandDrop ofMeterBandDrop = (OFMeterBandDrop) ofMeterBand;
builder.ofType(Band.Type.DROP)
.burstSize(ofMeterBandDrop.getBurstSize())
.withRate(ofMeterBandDrop.getRate());
} else if (ofMeterBand instanceof OFMeterBandDscpRemark) {
OFMeterBandDscpRemark ofMeterBandDscpRemark = (OFMeterBandDscpRemark) ofMeterBand;
builder.ofType(Band.Type.REMARK)
.burstSize(ofMeterBandDscpRemark.getBurstSize())
.withRate(ofMeterBandDscpRemark.getRate())
.dropPrecedence(ofMeterBandDscpRemark.getPrecLevel());
} else if (ofMeterBand instanceof OFMeterBandExperimenter) {
OFMeterBandExperimenter ofMeterBandExperimenter = (OFMeterBandExperimenter) ofMeterBand;
builder.ofType(Band.Type.EXPERIMENTAL)
.burstSize(ofMeterBandExperimenter.getBurstSize())
.withRate(ofMeterBandExperimenter.getRate());
}
return builder.build();
}
示例7: MockMeter
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
public MockMeter(DeviceId deviceId, int appId, long meterId, int id) {
this.deviceId = deviceId;
this.appId = new DefaultApplicationId(appId, String.valueOf(appId));
this.baseValue = id * 200;
this.meterId = MeterId.meterId(meterId);
Band band = DefaultBand.builder()
.ofType(Band.Type.REMARK)
.withRate(10)
.dropPrecedence((short) 20)
.burstSize(30).build();
this.bandList = new ArrayList<>();
this.bandList.add(band);
}
示例8: processMeterTable
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
protected void processMeterTable(boolean install) {
//Green meter : Pass all traffic
Band dropBand = DefaultBand.builder()
.ofType(Band.Type.DROP)
.withRate(0xFFFFFFFF) /* Max Rate */
.build();
MeterRequest.Builder ops = DefaultMeterRequest.builder()
.forDevice(deviceId)
.withBands(Collections.singletonList(dropBand))
.fromApp(appId);
Meter meter = meterService.submit(install ? ops.add() : ops.remove());
defaultMeterId = meter.id();
}
示例9: buildBands
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
private Collection<Band> buildBands(List<OFMeterBandStats> bandStats) {
return bandStats.stream().map(stat -> {
DefaultBand band = DefaultBand.builder().build();
band.setBytes(stat.getByteBandCount().getValue());
band.setPackets(stat.getPacketBandCount().getValue());
return band;
}).collect(Collectors.toSet());
}
示例10: decode
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
@Override
public Band decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
// parse rate
long rate = nullIsIllegal(json.get(RATE), RATE + MISSING_MEMBER_MESSAGE).asLong();
// parse burst size
long burstSize = nullIsIllegal(json.get(BURST_SIZE), BURST_SIZE + MISSING_MEMBER_MESSAGE).asLong();
// parse precedence
Short precedence = null;
// parse band type
String typeStr = nullIsIllegal(json.get(TYPE), TYPE + MISSING_MEMBER_MESSAGE).asText();
Band.Type type;
switch (typeStr) {
case "DROP":
type = Band.Type.DROP;
break;
case "REMARK":
type = Band.Type.REMARK;
precedence = (short) nullIsIllegal(json.get(PREC), PREC + MISSING_MEMBER_MESSAGE).asInt();
break;
default:
log.warn("The requested type {} is not defined for band.", typeStr);
return null;
}
Band band = DefaultBand.builder()
.ofType(type)
.burstSize(burstSize)
.withRate(rate)
.dropPrecedence(precedence)
.build();
return band;
}
示例11: MockMeter
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
public MockMeter(DeviceId deviceId, int appId, long meterId, int id) {
this.deviceId = deviceId;
this.appId = new DefaultApplicationId(appId, String.valueOf(appId));
this.baseValue = id * 200L;
this.meterId = MeterId.meterId(meterId);
Band band = DefaultBand.builder()
.ofType(Band.Type.REMARK)
.withRate(10)
.dropPrecedence((short) 20)
.burstSize(30).build();
this.bandList = new ArrayList<>();
this.bandList.add(band);
}
示例12: testPerformMeterOperationDeviceIdMeterAdd
import org.onosproject.net.meter.DefaultBand; //导入依赖的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
}
示例13: buildBands
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
private Collection<Band> buildBands(List<OFMeterBandStats> bandStats) {
return bandStats.stream().map(stat -> {
DefaultBand band = ((DefaultBand.Builder) DefaultBand.builder().ofType(DefaultBand.Type.DROP)).build();
band.setBytes(stat.getByteBandCount().getValue());
band.setPackets(stat.getPacketBandCount().getValue());
return band;
}).collect(Collectors.toList());
}
示例14: translate
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
/**
* Translates gRPC Band to {@link Band}.
*
* @param gBand gRPC message
* @return {@link Band}
*/
public static Band translate(BandProto gBand) {
Band.Type type = translate(gBand.getType());
long rate = gBand.getRate();
long burstSize = gBand.getBurst();
short prec = (short) gBand.getDropPrecedence();
Band band = new DefaultBand(type, rate, burstSize, prec);
return band;
}
示例15: decode
import org.onosproject.net.meter.DefaultBand; //导入依赖的package包/类
@Override
public Band decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
Builder builder = DefaultBand.builder();
// parse rate
long rate = nullIsIllegal(json.get(RATE), RATE + MISSING_MEMBER_MESSAGE).asLong();
builder.withRate(rate);
// parse burst size
long burstSize = nullIsIllegal(json.get(BURST_SIZE), BURST_SIZE + MISSING_MEMBER_MESSAGE).asLong();
builder.burstSize(burstSize);
// parse precedence
Short precedence = null;
// parse band type
String typeStr = nullIsIllegal(json.get(TYPE), TYPE + MISSING_MEMBER_MESSAGE).asText();
Band.Type type = null;
switch (typeStr) {
case "DROP":
type = Band.Type.DROP;
builder.ofType(type);
break;
case "REMARK":
type = Band.Type.REMARK;
precedence = (short) nullIsIllegal(json.get(PREC), PREC + MISSING_MEMBER_MESSAGE).asInt();
builder.ofType(type);
builder.dropPrecedence(precedence);
break;
default:
nullIsIllegal(type, "The requested type " + typeStr + " is not defined for band.");
}
Band band = builder.build();
return band;
}