Jian Li
Committed by Gerrit Code Review

[ONOS-3648] Rename CPMan REST API prefix

Existing REST API prefix is "cpman" which does not convey the
right meaning of the API.
This commit changes the prefix name from "cpman" to "collector"
to better convey the right meaning. This commit also splits the
REST URL with "_" to improve the URL readability.

Change-Id: I3152f7b784f2ae6cbaa8855dea8d5eaabd152487
...@@ -37,7 +37,7 @@ import java.util.Optional; ...@@ -37,7 +37,7 @@ import java.util.Optional;
37 /** 37 /**
38 * Collect control plane metrics. 38 * Collect control plane metrics.
39 */ 39 */
40 -@Path("cpman") 40 +@Path("collector")
41 public class ControlMetricsCollectorWebResource extends AbstractWebResource { 41 public class ControlMetricsCollectorWebResource extends AbstractWebResource {
42 42
43 final ControlPlaneMonitorService service = get(ControlPlaneMonitorService.class); 43 final ControlPlaneMonitorService service = get(ControlPlaneMonitorService.class);
...@@ -52,7 +52,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource { ...@@ -52,7 +52,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
52 * @onos.rsModel CpuMetricsPost 52 * @onos.rsModel CpuMetricsPost
53 */ 53 */
54 @POST 54 @POST
55 - @Path("cpumetrics") 55 + @Path("cpu_metrics")
56 @Consumes(MediaType.APPLICATION_JSON) 56 @Consumes(MediaType.APPLICATION_JSON)
57 @Produces(MediaType.APPLICATION_JSON) 57 @Produces(MediaType.APPLICATION_JSON)
58 public Response cpuMetrics(InputStream stream) { 58 public Response cpuMetrics(InputStream stream) {
...@@ -110,7 +110,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource { ...@@ -110,7 +110,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
110 * @onos.rsModel MemoryMetricsPost 110 * @onos.rsModel MemoryMetricsPost
111 */ 111 */
112 @POST 112 @POST
113 - @Path("memorymetrics") 113 + @Path("memory_metrics")
114 @Consumes(MediaType.APPLICATION_JSON) 114 @Consumes(MediaType.APPLICATION_JSON)
115 @Produces(MediaType.APPLICATION_JSON) 115 @Produces(MediaType.APPLICATION_JSON)
116 public Response memoryMetrics(InputStream stream) { 116 public Response memoryMetrics(InputStream stream) {
...@@ -161,7 +161,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource { ...@@ -161,7 +161,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
161 * @onos.rsModel DiskMetricsPost 161 * @onos.rsModel DiskMetricsPost
162 */ 162 */
163 @POST 163 @POST
164 - @Path("diskmetrics") 164 + @Path("disk_metrics")
165 @Consumes(MediaType.APPLICATION_JSON) 165 @Consumes(MediaType.APPLICATION_JSON)
166 @Produces(MediaType.APPLICATION_JSON) 166 @Produces(MediaType.APPLICATION_JSON)
167 public Response diskMetrics(InputStream stream) { 167 public Response diskMetrics(InputStream stream) {
...@@ -198,7 +198,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource { ...@@ -198,7 +198,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
198 * @onos.rsModel NetworkMetricsPost 198 * @onos.rsModel NetworkMetricsPost
199 */ 199 */
200 @POST 200 @POST
201 - @Path("networkmetrics") 201 + @Path("network_metrics")
202 @Consumes(MediaType.APPLICATION_JSON) 202 @Consumes(MediaType.APPLICATION_JSON)
203 @Produces(MediaType.APPLICATION_JSON) 203 @Produces(MediaType.APPLICATION_JSON)
204 public Response networkMetrics(InputStream stream) { 204 public Response networkMetrics(InputStream stream) {
...@@ -252,7 +252,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource { ...@@ -252,7 +252,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
252 * @onos.rsModel SystemSpecsPost 252 * @onos.rsModel SystemSpecsPost
253 */ 253 */
254 @POST 254 @POST
255 - @Path("systemspecs") 255 + @Path("system_specs")
256 @Consumes(MediaType.APPLICATION_JSON) 256 @Consumes(MediaType.APPLICATION_JSON)
257 @Produces(MediaType.APPLICATION_JSON) 257 @Produces(MediaType.APPLICATION_JSON)
258 public Response systemSpecs(InputStream stream) { 258 public Response systemSpecs(InputStream stream) {
......
...@@ -52,6 +52,8 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest { ...@@ -52,6 +52,8 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
52 final ControlPlaneMonitorService mockControlPlaneMonitorService = 52 final ControlPlaneMonitorService mockControlPlaneMonitorService =
53 createMock(ControlPlaneMonitorService.class); 53 createMock(ControlPlaneMonitorService.class);
54 54
55 + private static final String PREFIX = "collector";
56 +
55 /** 57 /**
56 * Sets up the global values for all the tests. 58 * Sets up the global values for all the tests.
57 */ 59 */
...@@ -69,7 +71,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest { ...@@ -69,7 +71,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
69 (Optional<DeviceId>) anyObject()); 71 (Optional<DeviceId>) anyObject());
70 expectLastCall().times(5); 72 expectLastCall().times(5);
71 replay(mockControlPlaneMonitorService); 73 replay(mockControlPlaneMonitorService);
72 - basePostTest("cpu-metrics-post.json", "cpman/cpumetrics"); 74 + basePostTest("cpu-metrics-post.json", PREFIX + "/cpu_metrics");
73 } 75 }
74 76
75 @Test 77 @Test
...@@ -78,7 +80,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest { ...@@ -78,7 +80,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
78 (Optional<DeviceId>) anyObject()); 80 (Optional<DeviceId>) anyObject());
79 expectLastCall().times(4); 81 expectLastCall().times(4);
80 replay(mockControlPlaneMonitorService); 82 replay(mockControlPlaneMonitorService);
81 - basePostTest("memory-metrics-post.json", "cpman/memorymetrics"); 83 + basePostTest("memory-metrics-post.json", PREFIX + "/memory_metrics");
82 } 84 }
83 85
84 @Test 86 @Test
...@@ -87,7 +89,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest { ...@@ -87,7 +89,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
87 (Optional<DeviceId>) anyObject()); 89 (Optional<DeviceId>) anyObject());
88 expectLastCall().times(2); 90 expectLastCall().times(2);
89 replay(mockControlPlaneMonitorService); 91 replay(mockControlPlaneMonitorService);
90 - basePostTest("disk-metrics-post.json", "cpman/diskmetrics"); 92 + basePostTest("disk-metrics-post.json", PREFIX + "/disk_metrics");
91 } 93 }
92 94
93 @Test 95 @Test
...@@ -96,12 +98,12 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest { ...@@ -96,12 +98,12 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
96 (Optional<DeviceId>) anyObject()); 98 (Optional<DeviceId>) anyObject());
97 expectLastCall().times(4); 99 expectLastCall().times(4);
98 replay(mockControlPlaneMonitorService); 100 replay(mockControlPlaneMonitorService);
99 - basePostTest("network-metrics-post.json", "cpman/networkmetrics"); 101 + basePostTest("network-metrics-post.json", PREFIX + "/network_metrics");
100 } 102 }
101 103
102 @Test 104 @Test
103 public void testSystemSpecsPost() { 105 public void testSystemSpecsPost() {
104 - basePostTest("system-spec-post.json", "cpman/systemspecs"); 106 + basePostTest("system-spec-post.json", PREFIX + "/system_specs");
105 } 107 }
106 108
107 private void basePostTest(String jsonFile, String path) { 109 private void basePostTest(String jsonFile, String path) {
......