本文整理汇总了Java中org.onosproject.net.meter.Band.Type方法的典型用法代码示例。如果您正苦于以下问题:Java Band.Type方法的具体用法?Java Band.Type怎么用?Java Band.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.meter.Band
的用法示例。
在下文中一共展示了Band.Type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import org.onosproject.net.meter.Band; //导入方法依赖的package包/类
/**
* Translates gRPC enum Band Type to ONOS enum.
*
* @param bandType BandType in gRPC enum
* @return equivalent in ONOS enum
*/
public static Band.Type translate(BandTypeProto bandType) {
switch (bandType) {
case DROP:
return Band.Type.DROP;
case REMARK:
return Band.Type.REMARK;
case EXPERIMENTAL:
return Band.Type.EXPERIMENTAL;
case UNRECOGNIZED:
log.warn("Unrecognized BandType gRPC message: {}", bandType);
return null;
default:
log.warn("Unrecognized BandType gRPC message: {}", bandType);
return null;
}
}
示例2: decode
import org.onosproject.net.meter.Band; //导入方法依赖的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;
}
示例3: decode
import org.onosproject.net.meter.Band; //导入方法依赖的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;
}
示例4: build
import org.onosproject.net.meter.Band; //导入方法依赖的package包/类
/**
* To build a MeterFeatures using the openflow object
* provided by the southbound.
*
* @return the meter features object
*/
public MeterFeatures build() {
/*
* We set the basic values before to extract the other information.
*/
MeterFeatures.Builder builder = DefaultMeterFeatures.builder()
.forDevice(deviceId)
.withMaxBands(ofMeterFeatures.getMaxBands())
.withMaxColors(ofMeterFeatures.getMaxColor())
.withMaxMeters(ofMeterFeatures.getMaxMeter());
/*
* We extract the supported band types.
*/
Set<Band.Type> bands = Sets.newHashSet();
if ((DROP_VAL & ofMeterFeatures.getCapabilities()) != 0) {
bands.add(DROP);
}
if ((DSCP_REMARK_VAL & ofMeterFeatures.getCapabilities()) != 0) {
bands.add(REMARK);
}
builder.withBandTypes(bands);
/*
* We extract the supported units;
*/
Set<Meter.Unit> units = Sets.newHashSet();
if ((PKTPS_VAL & ofMeterFeatures.getCapabilities()) != 0) {
units.add(PKTS_PER_SEC);
}
if ((KBPS_VAL & ofMeterFeatures.getCapabilities()) != 0) {
units.add(KB_PER_SEC);
}
if (units.isEmpty()) {
units.add(PKTS_PER_SEC);
}
builder.withUnits(units);
/*
* Burst is supported ?
*/
builder.hasBurst((BURST_VAL & ofMeterFeatures.getCapabilities()) != 0);
/*
* Stats are supported ?
*/
builder.hasStats((STATS_VAL & ofMeterFeatures.getCapabilities()) != 0);
/*
* Along with the OF1.5, we extract meter features flags
*/
if (ofMeterFeatures.getVersion().wireVersion >= OFVersion.OF_15.wireVersion) {
Set<MeterFeaturesFlag> meterFeaturesFlags = Sets.newHashSet();
if ((ACTION_SET_VAL & ofMeterFeatures.getFeatures()) != 0) {
meterFeaturesFlags.add(ACTION_SET);
}
if ((ANY_POSITION_VAL & ofMeterFeatures.getFeatures()) != 0) {
meterFeaturesFlags.add(ANY_POSITION);
}
if ((MULTI_LIST_VAL & ofMeterFeatures.getFeatures()) != 0) {
meterFeaturesFlags.add(MULTI_LIST);
}
builder.withFeatures(meterFeaturesFlags);
}
return builder.build();
}