Java 类org.projectfloodlight.openflow.protocol.OFMeterFlags 实例源码

项目:athena    文件:MeterModBuilder.java   
private OFMeterMod.Builder builderMeterMod() {
    OFMeterMod.Builder builder = factory.buildMeterMod();
    int flags = 0;
    if (burst) {
        // covering loxi short comings.
        flags |= 1 << OFMeterFlags.BURST.ordinal();
    }
    switch (unit) {
        case PKTS_PER_SEC:
            flags |= 1 << OFMeterFlags.PKTPS.ordinal();
            break;
        case KB_PER_SEC:
            flags |= 1 << OFMeterFlags.KBPS.ordinal();
            break;
        default:
            log.warn("Unknown unit type {}", unit);
    }
    //FIXME: THIS WILL CHANGE IN OF1.4 to setBands.
    builder.setMeters(buildBands());
    builder.setFlags(flags)
            .setMeterId(id)
            .setXid(xid);
    return builder;
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer13.java   
public static short toWireValue(Set<OFMeterFlags> set) {
    short wireValue = 0;

    for(OFMeterFlags e: set) {
        switch(e) {
            case KBPS:
                wireValue |= KBPS_VAL;
                break;
            case PKTPS:
                wireValue |= PKTPS_VAL;
                break;
            case BURST:
                wireValue |= BURST_VAL;
                break;
            case STATS:
                wireValue |= STATS_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFMeterFlags in version 1.3: " + e);
        }
    }
    return wireValue;
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer14.java   
public static short toWireValue(Set<OFMeterFlags> set) {
    short wireValue = 0;

    for(OFMeterFlags e: set) {
        switch(e) {
            case KBPS:
                wireValue |= KBPS_VAL;
                break;
            case PKTPS:
                wireValue |= PKTPS_VAL;
                break;
            case BURST:
                wireValue |= BURST_VAL;
                break;
            case STATS:
                wireValue |= STATS_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFMeterFlags in version 1.4: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer13.java   
public static short toWireValue(Set<OFMeterFlags> set) {
    short wireValue = 0;

    for(OFMeterFlags e: set) {
        switch(e) {
            case KBPS:
                wireValue |= KBPS_VAL;
                break;
            case PKTPS:
                wireValue |= PKTPS_VAL;
                break;
            case BURST:
                wireValue |= BURST_VAL;
                break;
            case STATS:
                wireValue |= STATS_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFMeterFlags in version 1.3: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer15.java   
public static short toWireValue(Set<OFMeterFlags> set) {
    short wireValue = 0;

    for(OFMeterFlags e: set) {
        switch(e) {
            case KBPS:
                wireValue |= KBPS_VAL;
                break;
            case PKTPS:
                wireValue |= PKTPS_VAL;
                break;
            case BURST:
                wireValue |= BURST_VAL;
                break;
            case STATS:
                wireValue |= STATS_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFMeterFlags in version 1.5: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer14.java   
public static short toWireValue(Set<OFMeterFlags> set) {
    short wireValue = 0;

    for(OFMeterFlags e: set) {
        switch(e) {
            case KBPS:
                wireValue |= KBPS_VAL;
                break;
            case PKTPS:
                wireValue |= PKTPS_VAL;
                break;
            case BURST:
                wireValue |= BURST_VAL;
                break;
            case STATS:
                wireValue |= STATS_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFMeterFlags in version 1.4: " + e);
        }
    }
    return wireValue;
}
项目:open-kilda    文件:SwitchManager.java   
private ImmutablePair<Long, Boolean> installMeter(final IOFSwitch sw, final DatapathId dpid, final long bandwidth,
                                                 final long burstSize, final long meterId) {
    logger.debug("installing meter {} on switch {} width bandwidth {}", meterId, dpid, bandwidth);

    Set<OFMeterFlags> flags = new HashSet<>(Arrays.asList(OFMeterFlags.KBPS, OFMeterFlags.BURST));
    OFFactory ofFactory = sw.getOFFactory();

    OFMeterBandDrop.Builder bandBuilder = ofFactory.meterBands()
            .buildDrop()
            .setRate(bandwidth)
            .setBurstSize(burstSize);

    OFMeterMod.Builder meterModBuilder = ofFactory.buildMeterMod()
            .setMeterId(meterId)
            .setCommand(OFMeterModCommand.ADD)
            .setFlags(flags);

    if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
        meterModBuilder.setBands(singletonList(bandBuilder.build()));
    } else {
        meterModBuilder.setMeters(singletonList(bandBuilder.build()));
    }

    OFMeterMod meterMod = meterModBuilder.build();

    boolean response = sw.write(meterMod);
    return new ImmutablePair<>(meterMod.getXid(), response);
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer13.java   
public static Set<OFMeterFlags> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer13.java   
public static Set<OFMeterFlags> ofWireValue(short val) {
    EnumSet<OFMeterFlags> set = EnumSet.noneOf(OFMeterFlags.class);

    if((val & KBPS_VAL) != 0)
        set.add(OFMeterFlags.KBPS);
    if((val & PKTPS_VAL) != 0)
        set.add(OFMeterFlags.PKTPS);
    if((val & BURST_VAL) != 0)
        set.add(OFMeterFlags.BURST);
    if((val & STATS_VAL) != 0)
        set.add(OFMeterFlags.STATS);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer14.java   
public static Set<OFMeterFlags> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer14.java   
public static Set<OFMeterFlags> ofWireValue(short val) {
    EnumSet<OFMeterFlags> set = EnumSet.noneOf(OFMeterFlags.class);

    if((val & KBPS_VAL) != 0)
        set.add(OFMeterFlags.KBPS);
    if((val & PKTPS_VAL) != 0)
        set.add(OFMeterFlags.PKTPS);
    if((val & BURST_VAL) != 0)
        set.add(OFMeterFlags.BURST);
    if((val & STATS_VAL) != 0)
        set.add(OFMeterFlags.STATS);
    return Collections.unmodifiableSet(set);
}
项目:onos    文件:MeterModBuilder.java   
private OFMeterMod.Builder builderMeterMod() {
    OFMeterMod.Builder builder = factory.buildMeterMod();
    Set<OFMeterFlags> flags = EnumSet.noneOf(OFMeterFlags.class);
    if (burst) {
        flags.add(OFMeterFlags.BURST);
    }
    switch (unit) {
        case PKTS_PER_SEC:
            flags.add(OFMeterFlags.PKTPS);
            break;
        case KB_PER_SEC:
            flags.add(OFMeterFlags.KBPS);
            break;
        default:
            log.warn("Unknown unit type {}", unit);
    }

    if (factory.getVersion().getWireVersion() >= OFVersion.OF_14.getWireVersion()) {
        builder.setBands(buildBands());
    } else {
        builder.setMeters(buildBands());
    }

    builder.setFlags(flags)
            .setMeterId(id)
            .setXid(xid);
    return builder;
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer13.java   
public static Set<OFMeterFlags> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer13.java   
public static Set<OFMeterFlags> ofWireValue(short val) {
    EnumSet<OFMeterFlags> set = EnumSet.noneOf(OFMeterFlags.class);

    if((val & KBPS_VAL) != 0)
        set.add(OFMeterFlags.KBPS);
    if((val & PKTPS_VAL) != 0)
        set.add(OFMeterFlags.PKTPS);
    if((val & BURST_VAL) != 0)
        set.add(OFMeterFlags.BURST);
    if((val & STATS_VAL) != 0)
        set.add(OFMeterFlags.STATS);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer15.java   
public static Set<OFMeterFlags> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer15.java   
public static Set<OFMeterFlags> ofWireValue(short val) {
    EnumSet<OFMeterFlags> set = EnumSet.noneOf(OFMeterFlags.class);

    if((val & KBPS_VAL) != 0)
        set.add(OFMeterFlags.KBPS);
    if((val & PKTPS_VAL) != 0)
        set.add(OFMeterFlags.PKTPS);
    if((val & BURST_VAL) != 0)
        set.add(OFMeterFlags.BURST);
    if((val & STATS_VAL) != 0)
        set.add(OFMeterFlags.STATS);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer14.java   
public static Set<OFMeterFlags> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer14.java   
public static Set<OFMeterFlags> ofWireValue(short val) {
    EnumSet<OFMeterFlags> set = EnumSet.noneOf(OFMeterFlags.class);

    if((val & KBPS_VAL) != 0)
        set.add(OFMeterFlags.KBPS);
    if((val & PKTPS_VAL) != 0)
        set.add(OFMeterFlags.PKTPS);
    if((val & BURST_VAL) != 0)
        set.add(OFMeterFlags.BURST);
    if((val & STATS_VAL) != 0)
        set.add(OFMeterFlags.STATS);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer13.java   
public static void writeTo(ChannelBuffer bb, Set<OFMeterFlags> set) {
    bb.writeShort(toWireValue(set));
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer13.java   
public static void putTo(Set<OFMeterFlags> set, PrimitiveSink sink) {
    sink.putShort(toWireValue(set));
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer14.java   
public static void writeTo(ChannelBuffer bb, Set<OFMeterFlags> set) {
    bb.writeShort(toWireValue(set));
}
项目:openflowj-otn    文件:OFMeterFlagsSerializerVer14.java   
public static void putTo(Set<OFMeterFlags> set, PrimitiveSink sink) {
    sink.putShort(toWireValue(set));
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer13.java   
public static void writeTo(ByteBuf bb, Set<OFMeterFlags> set) {
    bb.writeShort(toWireValue(set));
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer13.java   
public static void putTo(Set<OFMeterFlags> set, PrimitiveSink sink) {
    sink.putShort(toWireValue(set));
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer15.java   
public static void writeTo(ByteBuf bb, Set<OFMeterFlags> set) {
    bb.writeShort(toWireValue(set));
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer15.java   
public static void putTo(Set<OFMeterFlags> set, PrimitiveSink sink) {
    sink.putShort(toWireValue(set));
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer14.java   
public static void writeTo(ByteBuf bb, Set<OFMeterFlags> set) {
    bb.writeShort(toWireValue(set));
}
项目:loxigen-artifacts    文件:OFMeterFlagsSerializerVer14.java   
public static void putTo(Set<OFMeterFlags> set, PrimitiveSink sink) {
    sink.putShort(toWireValue(set));
}