Sho SHIMIZU
Committed by Gerrit Code Review

Make TrafficTreatment.Builder.setLambda() deprecated

It is recommended to avoid to use a raw integer value to specify a lambda.

Replace uses of the deprecated method with the alternative

Change-Id: I108f0d15f4503df2a6a75c4f7c77aa0c678ff541
......@@ -41,6 +41,7 @@ import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.instructions.Instructions;
import org.slf4j.Logger;
/**
......@@ -110,7 +111,8 @@ public class LambdaForwarding {
inport = 10;
outport = 20;
sbuilder.matchInPort(PortNumber.portNumber(inport));
tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda);
tbuilder.setOutput(PortNumber.portNumber(outport))
.add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
break;
case 2:
inport = 21;
......@@ -124,7 +126,8 @@ public class LambdaForwarding {
outport = 31;
sbuilder.add(Criteria.matchLambda(new IndexedLambda(lambda))).
matchInPort(PortNumber.portNumber(inport));
tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda);
tbuilder.setOutput(PortNumber.portNumber(outport))
.add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
break;
default:
}
......
......@@ -330,6 +330,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
return add(Instructions.decMplsTtl());
}
@Deprecated
@Override
public Builder setLambda(short lambda) {
return add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
......
......@@ -230,7 +230,9 @@ public interface TrafficTreatment {
*
* @param lambda optical channel ID
* @return a treatment builder
* @deprecated in Drake Release
*/
@Deprecated
Builder setLambda(short lambda);
/**
......
......@@ -69,7 +69,7 @@ public class DefaultTrafficTreatmentTest {
.setEthSrc(MacAddress.BROADCAST)
.setIpDst(IpAddress.valueOf("1.1.1.1"))
.setIpSrc(IpAddress.valueOf("2.2.2.2"))
.setLambda((short) 4)
.add(Instructions.modL0Lambda(new IndexedLambda(4)))
.setOutput(PortNumber.portNumber(2))
.setVlanId(VlanId.vlanId((short) 4))
.setVlanPcp((byte) 3);
......
......@@ -32,6 +32,7 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.GridType;
import org.onosproject.net.HostId;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Lambda;
import org.onosproject.net.NetTestTools;
import org.onosproject.net.OchSignalType;
......@@ -41,6 +42,7 @@ import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.HostToHostIntent;
......@@ -151,7 +153,7 @@ public class IntentCodecTest extends AbstractIntentTest {
.matchIPDst(IpPrefix.valueOf("1.2.3.4/24"))
.build();
final TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setLambda((short) 33)
.add(Instructions.modL0Lambda(new IndexedLambda(33)))
.setMpls(MplsLabel.mplsLabel(44))
.setOutput(PortNumber.CONTROLLER)
.setEthDst(MacAddress.BROADCAST)
......
......@@ -37,6 +37,7 @@ import org.onosproject.net.flow.FlowEntry.FlowEntryState;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.openflow.controller.Dpid;
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
......@@ -301,7 +302,8 @@ public class FlowEntryBuilder {
if (exp.getExperimenter() == 0x80005A06 ||
exp.getExperimenter() == 0x748771) {
OFActionCircuit ct = (OFActionCircuit) exp;
builder.setLambda(((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber());
short lambda = ((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber();
builder.add(Instructions.modL0Lambda(Lambda.indexedLambda(lambda)));
} else {
log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
}
......
......@@ -23,9 +23,11 @@ import org.onlab.packet.MplsLabel;
import org.onlab.packet.VlanId;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.GroupId;
import org.onosproject.net.Lambda;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.group.DefaultGroupBucket;
import org.onosproject.net.group.GroupBucket;
import org.onosproject.net.group.GroupBuckets;
......@@ -177,7 +179,8 @@ public class GroupBucketEntryBuilder {
if (exp.getExperimenter() == 0x80005A06 ||
exp.getExperimenter() == 0x748771) {
OFActionCircuit ct = (OFActionCircuit) exp;
builder.setLambda(((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber());
short lambda = ((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber();
builder.add(Instructions.modL0Lambda(Lambda.indexedLambda(lambda)));
} else {
log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
}
......