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;
/**
* Collect control plane metrics.
*/
@Path("cpman")
@Path("collector")
public class ControlMetricsCollectorWebResource extends AbstractWebResource {
final ControlPlaneMonitorService service = get(ControlPlaneMonitorService.class);
......@@ -52,7 +52,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
* @onos.rsModel CpuMetricsPost
*/
@POST
@Path("cpumetrics")
@Path("cpu_metrics")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response cpuMetrics(InputStream stream) {
......@@ -110,7 +110,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
* @onos.rsModel MemoryMetricsPost
*/
@POST
@Path("memorymetrics")
@Path("memory_metrics")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response memoryMetrics(InputStream stream) {
......@@ -161,7 +161,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
* @onos.rsModel DiskMetricsPost
*/
@POST
@Path("diskmetrics")
@Path("disk_metrics")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response diskMetrics(InputStream stream) {
......@@ -198,7 +198,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
* @onos.rsModel NetworkMetricsPost
*/
@POST
@Path("networkmetrics")
@Path("network_metrics")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response networkMetrics(InputStream stream) {
......@@ -252,7 +252,7 @@ public class ControlMetricsCollectorWebResource extends AbstractWebResource {
* @onos.rsModel SystemSpecsPost
*/
@POST
@Path("systemspecs")
@Path("system_specs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response systemSpecs(InputStream stream) {
......
......@@ -52,6 +52,8 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
final ControlPlaneMonitorService mockControlPlaneMonitorService =
createMock(ControlPlaneMonitorService.class);
private static final String PREFIX = "collector";
/**
* Sets up the global values for all the tests.
*/
......@@ -69,7 +71,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
(Optional<DeviceId>) anyObject());
expectLastCall().times(5);
replay(mockControlPlaneMonitorService);
basePostTest("cpu-metrics-post.json", "cpman/cpumetrics");
basePostTest("cpu-metrics-post.json", PREFIX + "/cpu_metrics");
}
@Test
......@@ -78,7 +80,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
(Optional<DeviceId>) anyObject());
expectLastCall().times(4);
replay(mockControlPlaneMonitorService);
basePostTest("memory-metrics-post.json", "cpman/memorymetrics");
basePostTest("memory-metrics-post.json", PREFIX + "/memory_metrics");
}
@Test
......@@ -87,7 +89,7 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
(Optional<DeviceId>) anyObject());
expectLastCall().times(2);
replay(mockControlPlaneMonitorService);
basePostTest("disk-metrics-post.json", "cpman/diskmetrics");
basePostTest("disk-metrics-post.json", PREFIX + "/disk_metrics");
}
@Test
......@@ -96,12 +98,12 @@ public class ControlMetricsCollectorResourceTest extends JerseyTest {
(Optional<DeviceId>) anyObject());
expectLastCall().times(4);
replay(mockControlPlaneMonitorService);
basePostTest("network-metrics-post.json", "cpman/networkmetrics");
basePostTest("network-metrics-post.json", PREFIX + "/network_metrics");
}
@Test
public void testSystemSpecsPost() {
basePostTest("system-spec-post.json", "cpman/systemspecs");
basePostTest("system-spec-post.json", PREFIX + "/system_specs");
}
private void basePostTest(String jsonFile, String path) {
......