Skip to content

Commit 0db683b

Browse files
author
Marc De Leenheer
committed
Use builders when available. Harmonized CE packet node service API.
Change-Id: Ibf5e7de179eed122397ede63789d749520112926
1 parent 7c0600e commit 0db683b

File tree

11 files changed

+130
-105
lines changed

11 files changed

+130
-105
lines changed

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/api/CarrierEthernetPacketNodeService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ void setNodeForwarding(CarrierEthernetForwardingConstruct fc, CarrierEthernetNet
5757
/**
5858
* Removes the meters associated with a specific UNI of an FC.
5959
*
60-
* @param fcId the forwarding construct id
60+
* @param fc the forwarding construct
6161
* @param uni the user to network interface
6262
*/
63-
void removeBandwidthProfileResources(String fcId, CarrierEthernetUni uni);
63+
void removeBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni);
6464

6565
/**
6666
* Removes all installed flow objectives associated with a specific FC.

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetBandwidthProfile.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Bandwidth profile for a CE UNI.
2525
*/
2626
// TODO: Methods to associate a CE BWP to a generic BWP and a Meter
27-
public class CarrierEthernetBandwidthProfile {
27+
public final class CarrierEthernetBandwidthProfile {
2828

2929
public enum Type {
3030
INTERFACE, EVC, COS
@@ -39,9 +39,7 @@ public enum Type {
3939
protected long ebs;
4040

4141
// TODO: Remove id from constructor - should be generated by some manager
42-
// TODO: Make constructor private when SCA/NRP API apps are migrated
43-
@Deprecated
44-
public CarrierEthernetBandwidthProfile(String id, String cfgId, Type type,
42+
private CarrierEthernetBandwidthProfile(String id, String cfgId, Type type,
4543
Bandwidth cir, Bandwidth eir,
4644
long cbs, long ebs) {
4745
checkNotNull(cir, "BW Profile must have an associated CIR");
@@ -255,14 +253,12 @@ public Builder ebs(long ebs) {
255253
}
256254

257255
/**
258-
* Builds a new CarrierEthernetBandwidthProfile instance.
259-
* based on this builder's parameters
256+
* Builds a new CarrierEthernetBandwidthProfile instance based on this builder's parameters.
260257
*
261258
* @return a new CarrierEthernetBandwidthProfile instance
262259
*/
263260
public CarrierEthernetBandwidthProfile build() {
264-
return new CarrierEthernetBandwidthProfile(id, cfgId, type,
265-
cir, eir, cbs, ebs);
261+
return new CarrierEthernetBandwidthProfile(id, cfgId, type, cir, eir, cbs, ebs);
266262
}
267263
}
268264
}

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetEnni.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@
2121
import org.onosproject.net.ConnectPoint;
2222
import org.slf4j.Logger;
2323

24+
import java.util.Set;
2425

2526
import static com.google.common.base.MoreObjects.toStringHelper;
2627
import static org.slf4j.LoggerFactory.getLogger;
2728

28-
import java.util.Set;
29-
3029
/**
3130
* Representation of a Carrier Ethernet ENNI.
3231
* Class can be used in different two ways:
3332
* 1. As a global ENNI descriptor containing one or more S-VLAN tags
3433
* 2. As a service-specific ENNI descriptor containing a single S-VLAN tag and including a role (e.g. hub, spoke)
3534
*/
36-
public class CarrierEthernetEnni extends CarrierEthernetNetworkInterface<CarrierEthernetEnni> {
35+
public final class CarrierEthernetEnni extends CarrierEthernetNetworkInterface<CarrierEthernetEnni> {
3736

3837
private final Logger log = getLogger(getClass());
3938

@@ -61,9 +60,7 @@ public String toString() {
6160
protected Set<VlanId> sVlanIdSet;
6261
String tpid;
6362

64-
// TODO: Make constructor private when SCA/NRP API apps are migrated
65-
@Deprecated
66-
public CarrierEthernetEnni(ConnectPoint cp, String uniCfgId,
63+
private CarrierEthernetEnni(ConnectPoint cp, String uniCfgId,
6764
Role role, VlanId sVlanId, String tpid,
6865
Bandwidth usedCapacity) {
6966
super(cp, Type.ENNI, uniCfgId);
@@ -307,8 +304,7 @@ public Builder usedCapacity(Bandwidth usedCapacity) {
307304
* @return a new CarrierEthernetEnni instance
308305
*/
309306
public CarrierEthernetEnni build() {
310-
return new CarrierEthernetEnni(cp, cfgId, role,
311-
sVlanId, tpid, usedCapacity);
307+
return new CarrierEthernetEnni(cp, cfgId, role, sVlanId, tpid, usedCapacity);
312308
}
313309
}
314310
}

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetForwardingConstruct.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/**
3333
* Representation of a CE Forwarding Construct.
3434
*/
35-
public class CarrierEthernetForwardingConstruct extends CarrierEthernetConnection {
35+
public final class CarrierEthernetForwardingConstruct extends CarrierEthernetConnection {
3636

3737
private Set<CarrierEthernetLogicalTerminationPoint> ltpSet;
3838
private VlanId vlanId;
@@ -42,9 +42,7 @@ public class CarrierEthernetForwardingConstruct extends CarrierEthernetConnectio
4242

4343
// TODO: Remove id from constructor - currently used only when updating FC
4444
// TODO: Add congruentPaths flag to constructor and Builder
45-
// TODO: Make constructor private when SCA/NRP API apps are migrated
46-
@Deprecated
47-
public CarrierEthernetForwardingConstruct(String id, String cfgId, Type type,
45+
private CarrierEthernetForwardingConstruct(String id, String cfgId, Type type,
4846
Set<CarrierEthernetLogicalTerminationPoint> ltpSet,
4947
Duration maxLatency) {
5048
super(id, cfgId, type, maxLatency);
@@ -179,7 +177,6 @@ public static final class Builder {
179177
private Type type;
180178
private Duration maxLatency;
181179
private Set<CarrierEthernetLogicalTerminationPoint> ltpSet;
182-
private boolean congruentPaths;
183180

184181
/**
185182
* Sets the id of this builder.
@@ -246,8 +243,8 @@ public CarrierEthernetForwardingConstruct build() {
246243
checkNotNull(type, "FC must have a type");
247244
checkArgument(ltpSet != null && ltpSet.size() > 1,
248245
"FC must include at least two LTPs");
249-
return new CarrierEthernetForwardingConstruct(id, cfgId, type,
250-
ltpSet, maxLatency);
246+
247+
return new CarrierEthernetForwardingConstruct(id, cfgId, type, ltpSet, maxLatency);
251248
}
252249
}
253250
}

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetInni.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,18 @@
2222
import org.onosproject.net.ConnectPoint;
2323
import org.slf4j.Logger;
2424

25+
import java.util.Set;
2526

2627
import static com.google.common.base.MoreObjects.toStringHelper;
2728
import static org.slf4j.LoggerFactory.getLogger;
2829

29-
import java.util.Set;
30-
3130
/**
3231
* Representation of a Carrier Ethernet INNI.
3332
* Class can be used in different two ways:
3433
* 1. As a global INNI descriptor containing one or more S-VLAN tags
3534
* 2. As a service-specific INNI descriptor containing a single S-VLAN tag and including a role (e.g. hub, spoke)
3635
*/
37-
public class CarrierEthernetInni extends CarrierEthernetNetworkInterface<CarrierEthernetInni> {
36+
public final class CarrierEthernetInni extends CarrierEthernetNetworkInterface<CarrierEthernetInni> {
3837

3938
private final Logger log = getLogger(getClass());
4039

@@ -66,9 +65,7 @@ public String toString() {
6665
protected String tpid;
6766

6867
// TODO: Change sVlanId to Collection<VlanId>
69-
// TODO: Make constructor private when SCA/NRP API apps are migrated
70-
@Deprecated
71-
public CarrierEthernetInni(ConnectPoint connectPoint, String uniCfgId,
68+
private CarrierEthernetInni(ConnectPoint connectPoint, String uniCfgId,
7269
Role role, VlanId sVlanId, String tpid,
7370
Bandwidth usedCapacity) {
7471

@@ -313,8 +310,7 @@ public Builder usedCapacity(Bandwidth usedCapacity) {
313310
* @return a new CarrierEthernetInni instance
314311
*/
315312
public CarrierEthernetInni build() {
316-
return new CarrierEthernetInni(cp, cfgId, role,
317-
sVlanId, tpid, usedCapacity);
313+
return new CarrierEthernetInni(cp, cfgId, role, sVlanId, tpid, usedCapacity);
318314
}
319315
}
320316
}

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,10 @@ public CarrierEthernetUni generateUni(ConnectPoint cp) {
992992
return null;
993993
}
994994

995-
return new CarrierEthernetUni(cp, uniId);
995+
return CarrierEthernetUni.builder()
996+
.cp(cp)
997+
.cfgId(uniId)
998+
.build();
996999
}
9971000

9981001
@Override

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetPacketNodeManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,19 +413,19 @@ private FlowRule addMetersToFlowRule(FlowRule flowRule, Set<DeviceMeterId> devic
413413
}
414414

415415
@Override
416-
public void removeBandwidthProfileResources(String fcId, CarrierEthernetUni uni) {
417-
removeMeters(fcId, uni);
416+
public void removeBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
417+
removeMeters(fc, uni);
418418
}
419419

420420
/**
421421
* Removes the meters associated with a specific UNI of an FC.
422422
*
423-
* @param fcId the EVC ID
423+
* @param fc the forwarding construct
424424
* @param uni the UNI descriptor
425425
* */
426-
private void removeMeters(String fcId, CarrierEthernetUni uni) {
426+
private void removeMeters(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
427427

428-
Set<DeviceMeterId> newDeviceMeterIdSet = deviceMeterIdMap.get(fcId);
428+
Set<DeviceMeterId> newDeviceMeterIdSet = deviceMeterIdMap.get(fc.id());
429429
DeviceMeterId tmpDeviceMeterId;
430430

431431
Collection<Meter> meters = meterService.getMeters(uni.cp().deviceId());
@@ -435,7 +435,7 @@ private void removeMeters(String fcId, CarrierEthernetUni uni) {
435435
Meter meter = it.next();
436436
tmpDeviceMeterId = new DeviceMeterId(uni.cp().deviceId(), meter.id());
437437
if (meter.appId().equals(appId) &&
438-
deviceMeterIdMap.get(fcId).contains(tmpDeviceMeterId)) {
438+
deviceMeterIdMap.get(fc.id()).contains(tmpDeviceMeterId)) {
439439
MeterRequest.Builder mBuilder;
440440
mBuilder = DefaultMeterRequest.builder()
441441
.fromApp(meter.appId())
@@ -450,7 +450,7 @@ private void removeMeters(String fcId, CarrierEthernetUni uni) {
450450
}
451451
}
452452

453-
deviceMeterIdMap.put(fcId, newDeviceMeterIdSet);
453+
deviceMeterIdMap.put(fc.id(), newDeviceMeterIdSet);
454454
}
455455

456456
@Override

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetProvisioner.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@
5353

5454
import static org.slf4j.LoggerFactory.getLogger;
5555

56+
/**
57+
* Carrier Ethernet provisioner of connectivity for forwarding constructs and bandwidth profiles.
58+
*/
5659
@Component(immediate = true)
57-
@Service ()
60+
@Service
5861
public class CarrierEthernetProvisioner implements CarrierEthernetProvisionerService {
5962

6063
private final Logger log = getLogger(getClass());
@@ -350,7 +353,7 @@ public void removeBandwidthProfiles(CarrierEthernetForwardingConstruct fc) {
350353
// TODO: Select node manager depending on device protocol
351354
fc.ltpSet().forEach((ltp -> {
352355
if (ltp.ni().type().equals(CarrierEthernetNetworkInterface.Type.UNI)) {
353-
cePktNodeService.removeBandwidthProfileResources(fc.id(), (CarrierEthernetUni) ltp.ni());
356+
cePktNodeService.removeBandwidthProfileResources(fc, (CarrierEthernetUni) ltp.ni());
354357
}
355358
}));
356359
}

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetUni.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,22 @@
2222
import org.onosproject.net.ConnectPoint;
2323
import org.slf4j.Logger;
2424

25-
26-
import static com.google.common.base.MoreObjects.toStringHelper;
27-
import static org.slf4j.LoggerFactory.getLogger;
28-
2925
import java.util.Collection;
3026
import java.util.Collections;
3127
import java.util.HashMap;
3228
import java.util.Map;
3329
import java.util.Set;
3430

31+
import static com.google.common.base.MoreObjects.toStringHelper;
32+
import static org.slf4j.LoggerFactory.getLogger;
33+
3534
/**
3635
* Representation of a Carrier Ethernet UNI.
3736
* Class can be used in different two ways:
3837
* 1. As a global UNI descriptor containing one or more BW profiles
3938
* 2. As a service-specific UNI descriptor containing a single BW profile and including a type (root, leaf)
4039
*/
41-
public class CarrierEthernetUni extends CarrierEthernetNetworkInterface<CarrierEthernetUni> {
40+
public final class CarrierEthernetUni extends CarrierEthernetNetworkInterface<CarrierEthernetUni> {
4241

4342
private final Logger log = getLogger(getClass());
4443

@@ -68,9 +67,7 @@ public String toString() {
6867

6968
// TODO: May be needed to add refCount for CoS BWPs - only applicable to global UNIs
7069
// TODO: Change ceVlanId to Collection<VlanId>
71-
// TODO: Make constructor private when SCA/NRP API apps are migrated
72-
@Deprecated
73-
public CarrierEthernetUni(ConnectPoint cp, String uniCfgId, Role role,
70+
private CarrierEthernetUni(ConnectPoint cp, String uniCfgId, Role role,
7471
VlanId ceVlanId,
7572
CarrierEthernetBandwidthProfile bwp) {
7673
super(cp, Type.UNI, uniCfgId);
@@ -104,14 +101,6 @@ public CarrierEthernetUni(ConnectPoint cp, String uniCfgId, Role role,
104101
}
105102
}
106103

107-
public CarrierEthernetUni(ConnectPoint cp, String uniCfgId) {
108-
super(cp, Type.UNI, uniCfgId);
109-
this.scope = Scope.GLOBAL;
110-
for (CarrierEthernetBandwidthProfile.Type bwpType : CarrierEthernetBandwidthProfile.Type.values()) {
111-
this.bwpMap.put(bwpType, new HashMap<>());
112-
}
113-
}
114-
115104
/**
116105
* Adds a BW profile to a UNI.
117106
*

carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetVirtualConnection.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/**
2929
* Representation of a Carrier Ethernet EVC.
3030
*/
31-
public class CarrierEthernetVirtualConnection extends CarrierEthernetConnection {
31+
public final class CarrierEthernetVirtualConnection extends CarrierEthernetConnection {
3232

3333
private Short shortId;
3434
private Set<CarrierEthernetUni> uniSet;
@@ -40,9 +40,7 @@ public class CarrierEthernetVirtualConnection extends CarrierEthernetConnection
4040
public static final Integer MAX_NUM_UNI = 1000;
4141

4242
// TODO: Remove id from constructor - currently used only when updating EVC
43-
// TODO: Make constructor private when SCA/NRP API apps are migrated
44-
@Deprecated
45-
public CarrierEthernetVirtualConnection(String id, String cfgId, Type type,
43+
private CarrierEthernetVirtualConnection(String id, String cfgId, Type type,
4644
Integer maxNumUni,
4745
Set<CarrierEthernetUni> uniSet,
4846
Duration maxLatency) {
@@ -245,9 +243,7 @@ public CarrierEthernetVirtualConnection build() {
245243
checkNotNull(type, "EVC must have a type");
246244
checkArgument(uniSet != null && uniSet.size() > 1,
247245
"EVC must include at least two UNIs");
248-
return new CarrierEthernetVirtualConnection(id, cfgId, type,
249-
maxNumUni, uniSet,
250-
maxLatency);
246+
return new CarrierEthernetVirtualConnection(id, cfgId, type, maxNumUni, uniSet, maxLatency);
251247
}
252248
}
253249
}

0 commit comments

Comments
 (0)