本文整理汇总了Java中org.onosproject.net.meter.Band类的典型用法代码示例。如果您正苦于以下问题:Java Band类的具体用法?Java Band怎么用?Java Band使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Band类属于org.onosproject.net.meter包,在下文中一共展示了Band类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import org.onosproject.net.meter.Band; //导入依赖的package包/类
@Override
public String format(Object value) {
StringBuilder sb = new StringBuilder();
Collection<Band> bands = (Collection<Band>) value;
if (bands.isEmpty()) {
return "(No bands for this meter)";
}
// TODO: re-arrange band properties based on band type
for (Band b : bands) {
sb.append("Bytes: ")
.append(b.bytes())
.append(" Packets: ")
.append(b.packets())
.append(" Type: ")
.append(b.type())
.append(BREAK);
}
return sb.toString();
}
示例2: buildMeters
import org.onosproject.net.meter.Band; //导入依赖的package包/类
private Collection<Meter> buildMeters(DeviceId deviceId,
List<OFMeterStats> entries) {
return entries.stream().map(stat -> {
DefaultMeter.Builder builder = DefaultMeter.builder();
Collection<Band> bands = buildBands(stat.getBandStats());
builder.forDevice(deviceId)
.withId(MeterId.meterId(stat.getMeterId()))
//FIXME: need to encode appId in meter id, but that makes
// things a little annoying for debugging
.fromApp(coreService.getAppId("org.onosproject.core"))
.withBands(bands);
DefaultMeter meter = builder.build();
meter.setState(MeterState.ADDED);
meter.setLife(stat.getDurationSec());
meter.setProcessedBytes(stat.getByteInCount().getValue());
meter.setProcessedPackets(stat.getPacketInCount().getValue());
meter.setReferenceCount(stat.getFlowCount());
// marks the meter as seen on the dataplane
pendingOperations.invalidate(stat.getMeterId());
return meter;
}).collect(Collectors.toSet());
}
示例3: activate
import org.onosproject.net.meter.Band; //导入依赖的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");
}
示例4: execute
import org.onosproject.net.meter.Band; //导入依赖的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);
}
示例5: encode
import org.onosproject.net.meter.Band; //导入依赖的package包/类
@Override
public ObjectNode encode(Band band, CodecContext context) {
checkNotNull(band, "Band cannot be null");
ObjectNode result = context.mapper().createObjectNode()
.put(TYPE, band.type().toString())
.put(RATE, band.rate())
.put(PACKETS, band.packets())
.put(BYTES, band.bytes())
.put(BURST_SIZE, band.burst());
if (band.dropPrecedence() != null) {
result.put(PREC, band.dropPrecedence());
}
return result;
}
示例6: testMeterEncode
import org.onosproject.net.meter.Band; //导入依赖的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));
}
示例7: testPerformMeterOperationDeviceIdMeterRemove
import org.onosproject.net.meter.Band; //导入依赖的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
}
示例8: buildMeters
import org.onosproject.net.meter.Band; //导入依赖的package包/类
private Collection<Meter> buildMeters(DeviceId deviceId,
List<OFMeterStats> entries) {
return entries.stream().map(stat -> {
DefaultMeter.Builder builder = DefaultMeter.builder();
Collection<Band> bands = buildBands(stat.getBandStats());
builder.forDevice(deviceId)
.withId(MeterId.meterId(stat.getMeterId()))
//FIXME: need to encode appId in meter id, but that makes
// things a little annoying for debugging
.fromApp(coreService.getAppId("org.onosproject.core"))
.withBands(bands);
DefaultMeter meter = builder.build();
meter.setState(MeterState.ADDED);
meter.setLife(stat.getDurationSec());
meter.setProcessedBytes(stat.getByteInCount().getValue());
meter.setProcessedPackets(stat.getPacketInCount().getValue());
if (stat.getVersion().getWireVersion() < OFVersion.OF_15.getWireVersion()) {
meter.setReferenceCount(stat.getFlowCount());
}
// marks the meter as seen on the dataplane
pendingOperations.invalidate(stat.getMeterId());
return meter;
}).collect(Collectors.toSet());
}
示例9: translate
import org.onosproject.net.meter.Band; //导入依赖的package包/类
/**
* Translates gRPC MeterRequest to {@link MeterRequest}.
*
* @param meterRequest gRPC message
* @return {@link MeterRequest}
*/
public static MeterRequest translate(MeterRequestProto meterRequest) {
DeviceId deviceid = DeviceId.deviceId(meterRequest.getDeviceId());
ApplicationId appId = translate(meterRequest.getApplicationId());
Meter.Unit unit = translate(meterRequest.getUnit());
boolean burst = meterRequest.getIsBurst();
Collection<Band> bands = translate(meterRequest.getBandsList());
MeterRequest.Type type = translate(meterRequest.getType());
if (type == MeterRequest.Type.ADD) {
return DefaultMeterRequest.builder()
.forDevice(deviceid)
.fromApp(appId)
.withUnit(unit)
.withBands(bands)
.add();
} else {
return DefaultMeterRequest.builder()
.forDevice(deviceid)
.fromApp(appId)
.withUnit(unit)
.withBands(bands)
.remove();
}
}
示例10: execute
import org.onosproject.net.meter.Band; //导入依赖的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());
}
示例11: band
import org.onosproject.net.meter.Band; //导入依赖的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();
}
示例12: getBwProfileActionFromBand
import org.onosproject.net.meter.Band; //导入依赖的package包/类
private static BandwidthProfileAction getBwProfileActionFromBand(Band band) {
checkNotNull(band.type(),
"Could not obtain BW profile: Meter band type is null");
Action action = null;
if (band.type().equals(Band.Type.DROP)) {
action = Action.DISCARD;
} else if (band.type().equals(Band.Type.REMARK)) {
action = Action.REMARK;
}
checkNotNull(action,
"Could not obtain BW profile: Invalid meter band type");
BandwidthProfileAction.Builder actionBuilder = getBuilder(action);
if (band.type().equals(Band.Type.REMARK)) {
checkNotNull(band.dropPrecedence(),
"Could not obtain DSCP class from meter band");
actionBuilder.dscpClass(DscpClass.fromShort(band.dropPrecedence()));
}
return actionBuilder.build();
}
示例13: MockMeter
import org.onosproject.net.meter.Band; //导入依赖的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);
}
示例14: processMeterTable
import org.onosproject.net.meter.Band; //导入依赖的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();
}
示例15: buildBands
import org.onosproject.net.meter.Band; //导入依赖的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());
}