當前位置: 首頁>>代碼示例>>Java>>正文


Java Band.Type方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:23,代碼來源:MeterProtoTranslator.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:41,代碼來源:MeterBandCodec.java

示例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;
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:41,代碼來源:MeterBandCodec.java

示例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();
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:69,代碼來源:MeterFeaturesBuilder.java


注:本文中的org.onosproject.net.meter.Band.Type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。