Java Code Examples for org.onosproject.net.flow.TrafficTreatment#metered()

The following examples show how to use org.onosproject.net.flow.TrafficTreatment#metered() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowsListCommand.java    From onos with Apache License 2.0 6 votes vote down vote up
private String printTreatment(TrafficTreatment treatment) {
    final String delimiter = ", ";
    StringBuilder builder = new StringBuilder("[");
    if (!treatment.immediate().isEmpty()) {
        builder.append("immediate=" + treatment.immediate() + delimiter);
    }
    if (!treatment.deferred().isEmpty()) {
        builder.append("deferred=" + treatment.deferred() + delimiter);
    }
    if (treatment.clearedDeferred()) {
        builder.append("clearDeferred" + delimiter);
    }
    if (treatment.tableTransition() != null) {
        builder.append("transition=" + treatment.tableTransition() + delimiter);
    }
    if (treatment.metered() != null) {
        builder.append("meter=" + treatment.metered() + delimiter);
    }
    if (treatment.writeMetadata() != null) {
        builder.append("metadata=" + treatment.writeMetadata() + delimiter);
    }
    // Chop off last delimiter
    builder.replace(builder.length() - delimiter.length(), builder.length(), "");
    builder.append("]");
    return builder.toString();
}
 
Example 2
Source File: VirtualFlowsListCommand.java    From onos with Apache License 2.0 6 votes vote down vote up
private String printTreatment(TrafficTreatment treatment) {
    final String delimiter = ", ";
    StringBuilder builder = new StringBuilder("[");
    if (!treatment.immediate().isEmpty()) {
        builder.append("immediate=" + treatment.immediate() + delimiter);
    }
    if (!treatment.deferred().isEmpty()) {
        builder.append("deferred=" + treatment.deferred() + delimiter);
    }
    if (treatment.clearedDeferred()) {
        builder.append("clearDeferred" + delimiter);
    }
    if (treatment.tableTransition() != null) {
        builder.append("transition=" + treatment.tableTransition() + delimiter);
    }
    if (treatment.metered() != null) {
        builder.append("meter=" + treatment.metered() + delimiter);
    }
    if (treatment.writeMetadata() != null) {
        builder.append("metadata=" + treatment.writeMetadata() + delimiter);
    }
    // Chop off last delimiter
    builder.replace(builder.length() - delimiter.length(), builder.length(), "");
    builder.append("]");
    return builder.toString();
}
 
Example 3
Source File: T3CliUtils.java    From onos with Apache License 2.0 6 votes vote down vote up
private static String printTreatment(TrafficTreatment treatment) {
    final String delimiter = ", ";
    StringBuilder builder = new StringBuilder("[");
    if (!treatment.immediate().isEmpty()) {
        builder.append("immediate=" + treatment.immediate() + delimiter);
    }
    if (!treatment.deferred().isEmpty()) {
        builder.append("deferred=" + treatment.deferred() + delimiter);
    }
    if (treatment.clearedDeferred()) {
        builder.append("clearDeferred" + delimiter);
    }
    if (treatment.tableTransition() != null) {
        builder.append("transition=" + treatment.tableTransition() + delimiter);
    }
    if (treatment.metered() != null) {
        builder.append("meter=" + treatment.metered() + delimiter);
    }
    if (treatment.writeMetadata() != null) {
        builder.append("metadata=" + treatment.writeMetadata() + delimiter);
    }
    // Chop off last delimiter
    builder.replace(builder.length() - delimiter.length(), builder.length(), "");
    builder.append("]");
    return builder.toString();
}
 
Example 4
Source File: FlowViewMessageHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public String format(Object value) {
    FlowEntry flow = (FlowEntry) value;
    TrafficTreatment treatment = flow.treatment();
    List<Instruction> imm = treatment.immediate();
    List<Instruction> def = treatment.deferred();
    if (imm.isEmpty() &&
            def.isEmpty() &&
            treatment.metered() == null &&
            treatment.tableTransition() == null &&
            treatment.writeMetadata() == null) {
        return MSG_NO_TREATMENT;
    }

    StringBuilder sb = new StringBuilder();

    if (!shortFormat) {
        sb.append(TREATMENT_INSTRUCTIONS).append(COLON).append(SPACE);
    }

    formatInstructs(sb, imm, IMM);
    formatInstructs(sb, def, DEF);

    treatment.meters().forEach(meterInstruction ->
            addLabVal(sb, METERED, meterInstruction)
    );
    addLabVal(sb, TRANSITION, treatment.tableTransition());
    addLabVal(sb, METADATA, treatment.writeMetadata());

    sb.append(CLEARED).append(COLON)
            .append(treatment.clearedDeferred());

    return sb.toString();
}