Viswanath KSP
Committed by Gerrit Code Review

Addressing review comments of patch-3

Addressing review comments of patch-2
Fixing javadoc warnings
Pushing changes for onos-5146 - Added 2 new APIs in DeviceService.java to get port specific PortStatistics by specifying Device ID & Port Number. Also implemented the APIs in SimpleDeviceStore etc. This will be a very useful API for app developers who are intersted to query port specific port statistics

Change-Id: I8f3e5a443eb5b50237a679999311b48609e54a44
...@@ -24,6 +24,7 @@ import java.util.Optional; ...@@ -24,6 +24,7 @@ import java.util.Optional;
24 import org.onosproject.net.device.DeviceEvent; 24 import org.onosproject.net.device.DeviceEvent;
25 import org.onosproject.net.device.DeviceListener; 25 import org.onosproject.net.device.DeviceListener;
26 import org.onosproject.net.device.DeviceService; 26 import org.onosproject.net.device.DeviceService;
27 +import org.onosproject.net.device.PortStatistics;
27 import org.onosproject.net.optical.OpticalDevice; 28 import org.onosproject.net.optical.OpticalDevice;
28 import org.onosproject.net.utils.ForwardingDeviceService; 29 import org.onosproject.net.utils.ForwardingDeviceService;
29 import org.slf4j.Logger; 30 import org.slf4j.Logger;
...@@ -148,6 +149,16 @@ public class OpticalDeviceServiceView ...@@ -148,6 +149,16 @@ public class OpticalDeviceServiceView
148 } 149 }
149 150
150 @Override 151 @Override
152 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
153 + return null;
154 + }
155 +
156 + @Override
157 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
158 + return null;
159 + }
160 +
161 + @Override
151 public Port getPort(DeviceId deviceId, PortNumber portNumber) { 162 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
152 return augment(super.getPort(deviceId, portNumber)); 163 return augment(super.getPort(deviceId, portNumber));
153 } 164 }
......
...@@ -113,6 +113,28 @@ public interface DeviceService ...@@ -113,6 +113,28 @@ public interface DeviceService
113 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); 113 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
114 114
115 /** 115 /**
116 + * Returns the port specific port statistics associated with the device and port.
117 + *
118 + * @param deviceId device identifier
119 + * @param portNumber port identifier
120 + * @return port statistics of specified port
121 + */
122 + default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
123 + return null;
124 + }
125 +
126 + /**
127 + * Returns the port specific port delta statistics associated with the device and port.
128 + *
129 + * @param deviceId device identifier
130 + * @param portNumber port identifier
131 + * @return port delta statistics of specified port
132 + */
133 + default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
134 + return null;
135 + }
136 +
137 + /**
116 * Returns the port with the specified number and hosted by the given device. 138 * Returns the port with the specified number and hosted by the given device.
117 * 139 *
118 * @param deviceId device identifier 140 * @param deviceId device identifier
......
...@@ -152,6 +152,17 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { ...@@ -152,6 +152,17 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
152 List<PortStatistics> getPortStatistics(DeviceId deviceId); 152 List<PortStatistics> getPortStatistics(DeviceId deviceId);
153 153
154 /** 154 /**
155 + * Returns the port statistics of the specified device and port.
156 + *
157 + * @param deviceId device identifier
158 + * @param portNumber port identifier
159 + * @return port statistics of specific port of the device
160 + */
161 + default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
162 + return null;
163 + }
164 +
165 + /**
155 * Returns the list of delta port statistics of the specified device. 166 * Returns the list of delta port statistics of the specified device.
156 * 167 *
157 * @param deviceId device identifier 168 * @param deviceId device identifier
...@@ -160,6 +171,17 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { ...@@ -160,6 +171,17 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
160 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); 171 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
161 172
162 /** 173 /**
174 + * Returns the port delta statistics of the specified device and port.
175 + *
176 + * @param deviceId device identifier
177 + * @param portNumber port identifier
178 + * @return port statistics of specific port of the device
179 + */
180 + default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
181 + return null;
182 + }
183 +
184 + /**
163 * Returns the specified device port. 185 * Returns the specified device port.
164 * 186 *
165 * @param deviceId device identifier 187 * @param deviceId device identifier
......
...@@ -92,6 +92,16 @@ public class DeviceServiceAdapter implements DeviceService { ...@@ -92,6 +92,16 @@ public class DeviceServiceAdapter implements DeviceService {
92 } 92 }
93 93
94 @Override 94 @Override
95 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
96 + return null;
97 + }
98 +
99 + @Override
100 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
101 + return null;
102 + }
103 +
104 + @Override
95 public Port getPort(DeviceId deviceId, PortNumber portNumber) { 105 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
96 return null; 106 return null;
97 } 107 }
......
...@@ -101,11 +101,21 @@ public class DeviceStoreAdapter implements DeviceStore { ...@@ -101,11 +101,21 @@ public class DeviceStoreAdapter implements DeviceStore {
101 } 101 }
102 102
103 @Override 103 @Override
104 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
105 + return null;
106 + }
107 +
108 + @Override
104 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) { 109 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
105 return null; 110 return null;
106 } 111 }
107 112
108 @Override 113 @Override
114 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
115 + return null;
116 + }
117 +
118 + @Override
109 public Port getPort(DeviceId deviceId, PortNumber portNumber) { 119 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
110 return null; 120 return null;
111 } 121 }
......
...@@ -514,6 +514,16 @@ public class SimpleDeviceStore ...@@ -514,6 +514,16 @@ public class SimpleDeviceStore
514 } 514 }
515 515
516 @Override 516 @Override
517 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
518 + Map<PortNumber, PortStatistics> portStatsMap = devicePortStats.get(deviceId);
519 + if (portStatsMap == null) {
520 + return null;
521 + }
522 + PortStatistics portStats = portStatsMap.get(portNumber);
523 + return portStats;
524 + }
525 +
526 + @Override
517 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) { 527 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
518 Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId); 528 Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId);
519 if (portStats == null) { 529 if (portStats == null) {
...@@ -523,6 +533,16 @@ public class SimpleDeviceStore ...@@ -523,6 +533,16 @@ public class SimpleDeviceStore
523 } 533 }
524 534
525 @Override 535 @Override
536 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
537 + Map<PortNumber, PortStatistics> portStatsMap = devicePortDeltaStats.get(deviceId);
538 + if (portStatsMap == null) {
539 + return null;
540 + }
541 + PortStatistics portStats = portStatsMap.get(portNumber);
542 + return portStats;
543 + }
544 +
545 + @Override
526 public boolean isAvailable(DeviceId deviceId) { 546 public boolean isAvailable(DeviceId deviceId) {
527 return availableDevices.contains(deviceId); 547 return availableDevices.contains(deviceId);
528 } 548 }
......
...@@ -228,6 +228,22 @@ public class DeviceManager ...@@ -228,6 +228,22 @@ public class DeviceManager
228 } 228 }
229 229
230 @Override 230 @Override
231 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
232 + checkPermission(DEVICE_READ);
233 + checkNotNull(deviceId, DEVICE_ID_NULL);
234 + checkNotNull(portNumber, PORT_NUMBER_NULL);
235 + return store.getStatisticsForPort(deviceId, portNumber);
236 + }
237 +
238 + @Override
239 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
240 + checkPermission(DEVICE_READ);
241 + checkNotNull(deviceId, DEVICE_ID_NULL);
242 + checkNotNull(portNumber, PORT_NUMBER_NULL);
243 + return store.getDeltaStatisticsForPort(deviceId, portNumber);
244 + }
245 +
246 + @Override
231 public Port getPort(DeviceId deviceId, PortNumber portNumber) { 247 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
232 checkPermission(DEVICE_READ); 248 checkPermission(DEVICE_READ);
233 checkNotNull(deviceId, DEVICE_ID_NULL); 249 checkNotNull(deviceId, DEVICE_ID_NULL);
......
...@@ -679,6 +679,16 @@ public class ECDeviceStore ...@@ -679,6 +679,16 @@ public class ECDeviceStore
679 } 679 }
680 680
681 @Override 681 @Override
682 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
683 + Map<PortNumber, PortStatistics> portStatsMap = devicePortStats.get(deviceId);
684 + if (portStatsMap == null) {
685 + return null;
686 + }
687 + PortStatistics portStats = portStatsMap.get(portNumber);
688 + return portStats;
689 + }
690 +
691 + @Override
682 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) { 692 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
683 Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId); 693 Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId);
684 if (portStats == null) { 694 if (portStats == null) {
...@@ -688,6 +698,16 @@ public class ECDeviceStore ...@@ -688,6 +698,16 @@ public class ECDeviceStore
688 } 698 }
689 699
690 @Override 700 @Override
701 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
702 + Map<PortNumber, PortStatistics> portStatsMap = devicePortDeltaStats.get(deviceId);
703 + if (portStatsMap == null) {
704 + return null;
705 + }
706 + PortStatistics portStats = portStatsMap.get(portNumber);
707 + return portStats;
708 + }
709 +
710 + @Override
691 public boolean isAvailable(DeviceId deviceId) { 711 public boolean isAvailable(DeviceId deviceId) {
692 return availableDevices.contains(deviceId); 712 return availableDevices.contains(deviceId);
693 } 713 }
......
...@@ -998,6 +998,16 @@ public class GossipDeviceStore ...@@ -998,6 +998,16 @@ public class GossipDeviceStore
998 } 998 }
999 999
1000 @Override 1000 @Override
1001 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
1002 + Map<PortNumber, PortStatistics> portStatsMap = devicePortStats.get(deviceId);
1003 + if (portStatsMap == null) {
1004 + return null;
1005 + }
1006 + PortStatistics portStats = portStatsMap.get(portNumber);
1007 + return portStats;
1008 + }
1009 +
1010 + @Override
1001 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) { 1011 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
1002 Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId); 1012 Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId);
1003 if (portStats == null) { 1013 if (portStats == null) {
...@@ -1007,6 +1017,16 @@ public class GossipDeviceStore ...@@ -1007,6 +1017,16 @@ public class GossipDeviceStore
1007 } 1017 }
1008 1018
1009 @Override 1019 @Override
1020 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
1021 + Map<PortNumber, PortStatistics> portStatsMap = devicePortDeltaStats.get(deviceId);
1022 + if (portStatsMap == null) {
1023 + return null;
1024 + }
1025 + PortStatistics portStats = portStatsMap.get(portNumber);
1026 + return portStats;
1027 + }
1028 +
1029 + @Override
1010 public Port getPort(DeviceId deviceId, PortNumber portNumber) { 1030 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
1011 Map<PortNumber, Port> ports = devicePorts.get(deviceId); 1031 Map<PortNumber, Port> ports = devicePorts.get(deviceId);
1012 return ports == null ? null : ports.get(portNumber); 1032 return ports == null ? null : ports.get(portNumber);
......
...@@ -47,6 +47,7 @@ public class VirtualNetworkDeviceService extends AbstractListenerManager<DeviceE ...@@ -47,6 +47,7 @@ public class VirtualNetworkDeviceService extends AbstractListenerManager<DeviceE
47 private static final String NETWORK_NULL = "Network ID cannot be null"; 47 private static final String NETWORK_NULL = "Network ID cannot be null";
48 private static final String TYPE_NULL = "Type cannot be null"; 48 private static final String TYPE_NULL = "Type cannot be null";
49 private static final String DEVICE_NULL = "Device cannot be null"; 49 private static final String DEVICE_NULL = "Device cannot be null";
50 + private static final String PORT_NUMBER_NULL = "PortNumber cannot be null";
50 51
51 private final VirtualNetwork network; 52 private final VirtualNetwork network;
52 private final VirtualNetworkService manager; 53 private final VirtualNetworkService manager;
...@@ -135,6 +136,22 @@ public class VirtualNetworkDeviceService extends AbstractListenerManager<DeviceE ...@@ -135,6 +136,22 @@ public class VirtualNetworkDeviceService extends AbstractListenerManager<DeviceE
135 } 136 }
136 137
137 @Override 138 @Override
139 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
140 + checkNotNull(deviceId, DEVICE_NULL);
141 + checkNotNull(deviceId, PORT_NUMBER_NULL);
142 + // TODO not supported at the moment.
143 + return null;
144 + }
145 +
146 + @Override
147 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
148 + checkNotNull(deviceId, DEVICE_NULL);
149 + checkNotNull(deviceId, PORT_NUMBER_NULL);
150 + // TODO not supported at the moment.
151 + return null;
152 + }
153 +
154 + @Override
138 public Port getPort(DeviceId deviceId, PortNumber portNumber) { 155 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
139 checkNotNull(deviceId, DEVICE_NULL); 156 checkNotNull(deviceId, DEVICE_NULL);
140 157
......
...@@ -83,6 +83,16 @@ class NetconfDeviceServiceMock implements DeviceService { ...@@ -83,6 +83,16 @@ class NetconfDeviceServiceMock implements DeviceService {
83 } 83 }
84 84
85 @Override 85 @Override
86 + public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
87 + return null;
88 + }
89 +
90 + @Override
91 + public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
92 + return null;
93 + }
94 +
95 + @Override
86 public Port getPort(DeviceId deviceId, PortNumber portNumber) { 96 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
87 return null; 97 return null;
88 } 98 }
......