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

项目:open-kilda    文件:SwitchManager.java   
public ImmutablePair<Long, Boolean> deleteMeter(IOFSwitch sw, final DatapathId dpid, final long meterId) {
    logger.debug("deleting meter {} from switch {}", meterId, dpid);

    OFFactory ofFactory = sw.getOFFactory();

    OFMeterMod.Builder meterDeleteBuilder = ofFactory.buildMeterMod()
            .setMeterId(meterId)
            .setCommand(OFMeterModCommand.DELETE);

    if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
        meterDeleteBuilder.setBands(emptyList());
    } else {
        meterDeleteBuilder.setMeters(emptyList());
    }

    OFMeterMod meterDelete = meterDeleteBuilder.build();

    boolean response = sw.write(meterDelete);
    return new ImmutablePair<>(meterDelete.getXid(), response);
}
项目: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);
}
项目:open-kilda    文件:SwitchManagerTest.java   
@Test
public void deleteMeter() {
    final Capture<OFMeterMod> capture = prepareForMeterTest();
    switchManager.deleteMeter(dpid, meterId);
    final OFMeterMod meterMod = capture.getValue();
    assertEquals(meterMod.getCommand(), OFMeterModCommand.DELETE);
    assertEquals(meterMod.getMeterId(), meterId);
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer13.java   
public static OFMeterModCommand readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer13.java   
public static OFMeterModCommand ofWireValue(short val) {
    switch(val) {
        case ADD_VAL:
            return OFMeterModCommand.ADD;
        case MODIFY_VAL:
            return OFMeterModCommand.MODIFY;
        case DELETE_VAL:
            return OFMeterModCommand.DELETE;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFMeterModCommand in version 1.3: " + val);
    }
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer13.java   
public static short toWireValue(OFMeterModCommand e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case MODIFY:
            return MODIFY_VAL;
        case DELETE:
            return DELETE_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFMeterModCommand in version 1.3: " + e);
    }
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer14.java   
public static OFMeterModCommand readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer14.java   
public static OFMeterModCommand ofWireValue(short val) {
    switch(val) {
        case ADD_VAL:
            return OFMeterModCommand.ADD;
        case MODIFY_VAL:
            return OFMeterModCommand.MODIFY;
        case DELETE_VAL:
            return OFMeterModCommand.DELETE;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFMeterModCommand in version 1.4: " + val);
    }
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer14.java   
public static short toWireValue(OFMeterModCommand e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case MODIFY:
            return MODIFY_VAL;
        case DELETE:
            return DELETE_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFMeterModCommand in version 1.4: " + e);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer13.java   
public static OFMeterModCommand readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer13.java   
public static OFMeterModCommand ofWireValue(short val) {
    switch(val) {
        case ADD_VAL:
            return OFMeterModCommand.ADD;
        case MODIFY_VAL:
            return OFMeterModCommand.MODIFY;
        case DELETE_VAL:
            return OFMeterModCommand.DELETE;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFMeterModCommand in version 1.3: " + val);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer13.java   
public static short toWireValue(OFMeterModCommand e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case MODIFY:
            return MODIFY_VAL;
        case DELETE:
            return DELETE_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFMeterModCommand in version 1.3: " + e);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer15.java   
public static OFMeterModCommand readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer15.java   
public static OFMeterModCommand ofWireValue(short val) {
    switch(val) {
        case ADD_VAL:
            return OFMeterModCommand.ADD;
        case MODIFY_VAL:
            return OFMeterModCommand.MODIFY;
        case DELETE_VAL:
            return OFMeterModCommand.DELETE;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFMeterModCommand in version 1.5: " + val);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer15.java   
public static short toWireValue(OFMeterModCommand e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case MODIFY:
            return MODIFY_VAL;
        case DELETE:
            return DELETE_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFMeterModCommand in version 1.5: " + e);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer14.java   
public static OFMeterModCommand readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readShort());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer14.java   
public static OFMeterModCommand ofWireValue(short val) {
    switch(val) {
        case ADD_VAL:
            return OFMeterModCommand.ADD;
        case MODIFY_VAL:
            return OFMeterModCommand.MODIFY;
        case DELETE_VAL:
            return OFMeterModCommand.DELETE;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFMeterModCommand in version 1.4: " + val);
    }
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer14.java   
public static short toWireValue(OFMeterModCommand e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case MODIFY:
            return MODIFY_VAL;
        case DELETE:
            return DELETE_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFMeterModCommand in version 1.4: " + e);
    }
}
项目:athena    文件:MeterModBuilder.java   
public OFMeterMod add() {
    validate();
    OFMeterMod.Builder builder = builderMeterMod();
    builder.setCommand(OFMeterModCommand.ADD.ordinal());
    return builder.build();
}
项目:athena    文件:MeterModBuilder.java   
public OFMeterMod remove() {
    validate();
    OFMeterMod.Builder builder = builderMeterMod();
    builder.setCommand(OFMeterModCommand.DELETE.ordinal());
    return builder.build();
}
项目:athena    文件:MeterModBuilder.java   
public OFMeterMod modify() {
    validate();
    OFMeterMod.Builder builder = builderMeterMod();
    builder.setCommand(OFMeterModCommand.MODIFY.ordinal());
    return builder.build();
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer13.java   
public static void writeTo(ChannelBuffer bb, OFMeterModCommand e) {
    bb.writeShort(toWireValue(e));
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer13.java   
public static void putTo(OFMeterModCommand e, PrimitiveSink sink) {
    sink.putShort(toWireValue(e));
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer14.java   
public static void writeTo(ChannelBuffer bb, OFMeterModCommand e) {
    bb.writeShort(toWireValue(e));
}
项目:openflowj-otn    文件:OFMeterModCommandSerializerVer14.java   
public static void putTo(OFMeterModCommand e, PrimitiveSink sink) {
    sink.putShort(toWireValue(e));
}
项目:onos    文件:MeterModBuilder.java   
public OFMeterMod add() {
    validate();
    OFMeterMod.Builder builder = builderMeterMod();
    builder.setCommand(OFMeterModCommand.ADD);
    return builder.build();
}
项目:onos    文件:MeterModBuilder.java   
public OFMeterMod remove() {
    validate();
    OFMeterMod.Builder builder = builderMeterMod();
    builder.setCommand(OFMeterModCommand.DELETE);
    return builder.build();
}
项目:onos    文件:MeterModBuilder.java   
public OFMeterMod modify() {
    validate();
    OFMeterMod.Builder builder = builderMeterMod();
    builder.setCommand(OFMeterModCommand.MODIFY);
    return builder.build();
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer13.java   
public static void writeTo(ByteBuf bb, OFMeterModCommand e) {
    bb.writeShort(toWireValue(e));
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer13.java   
public static void putTo(OFMeterModCommand e, PrimitiveSink sink) {
    sink.putShort(toWireValue(e));
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer15.java   
public static void writeTo(ByteBuf bb, OFMeterModCommand e) {
    bb.writeShort(toWireValue(e));
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer15.java   
public static void putTo(OFMeterModCommand e, PrimitiveSink sink) {
    sink.putShort(toWireValue(e));
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer14.java   
public static void writeTo(ByteBuf bb, OFMeterModCommand e) {
    bb.writeShort(toWireValue(e));
}
项目:loxigen-artifacts    文件:OFMeterModCommandSerializerVer14.java   
public static void putTo(OFMeterModCommand e, PrimitiveSink sink) {
    sink.putShort(toWireValue(e));
}