@Test public void testGetMetrics() throws Exception { List<Map<String, Object>> response = (List<Map<String, Object>>) monitorResource.getEntityMetricMapList(applicationData.getSeaCloudsApplicationId()).getEntity(); for (Map<String, Object> entityMetricsPair : response) { List sensors = (List) entityMetricsPair.get("metrics"); assertEquals(sensors.size(), 2); } }
@GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/metrics") @Deprecated @ApiOperation(value = "Get Metrics from a SeaClouds Application") public Response getEntityMetricMapList(@PathParam("seacloudsId") String seacloudsId) throws IOException { if (seacloudsId == null) { LOG.error("Missing input parameters"); return Response.status(Response.Status.BAD_REQUEST).build(); } else { SeaCloudsApplicationData seaCloudsApplicationData = dataStore.getSeaCloudsApplicationDataById(seacloudsId); if (seaCloudsApplicationData == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } List<Map<String, Object>> entityList = new ArrayList<>(); List<EntitySummary> appEntities = getFlatEntityTree(seaCloudsApplicationData.getDeployerApplicationId()); for (EntitySummary entity : appEntities) { List<SensorSummary> entitySensors = deployer.getEntitySensors(seaCloudsApplicationData.getDeployerApplicationId(), entity.getId()); List<SensorSummary> numberSensors = new ArrayList<>(); for (SensorSummary entitySensor : entitySensors) { if (isNumberType(entitySensor.getType())) { numberSensors.add(entitySensor); } } HashMap<String, Object> entityMap = new HashMap<>(); entityMap.put("id", entity.getId()); entityMap.put("name", entity.getName()); entityMap.put("type", entity.getType()); entityMap.put("metrics", numberSensors); entityList.add(entityMap); } return Response.ok(entityList).build(); } }
MonitorResource implements Resource { @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/metrics") @Deprecated @ApiOperation(value = "Get Metrics from a SeaClouds Application") public Response getEntityMetricMapList(@PathParam("seacloudsId") String seacloudsId) throws IOException { if (seacloudsId == null) { LOG.error("Missing input parameters"); return Response.status(Response.Status.BAD_REQUEST).build(); } else { SeaCloudsApplicationData seaCloudsApplicationData = dataStore.getSeaCloudsApplicationDataById(seacloudsId); if (seaCloudsApplicationData == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } List<Map<String, Object>> entityList = new ArrayList<>(); List<EntitySummary> appEntities = getFlatEntityTree(seaCloudsApplicationData.getDeployerApplicationId()); for (EntitySummary entity : appEntities) { List<SensorSummary> entitySensors = deployer.getEntitySensors(seaCloudsApplicationData.getDeployerApplicationId(), entity.getId()); List<SensorSummary> numberSensors = new ArrayList<>(); for (SensorSummary entitySensor : entitySensors) { if (isNumberType(entitySensor.getType())) { numberSensors.add(entitySensor); } } HashMap<String, Object> entityMap = new HashMap<>(); entityMap.put("id", entity.getId()); entityMap.put("name", entity.getName()); entityMap.put("type", entity.getType()); entityMap.put("metrics", numberSensors); entityList.add(entityMap); } return Response.ok(entityList).build(); } } }
MonitorResource implements Resource { @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/metrics") @Deprecated @ApiOperation(value = "Get Metrics from a SeaClouds Application") public Response getEntityMetricMapList(@PathParam("seacloudsId") String seacloudsId) throws IOException { if (seacloudsId == null) { LOG.error("Missing input parameters"); return Response.status(Response.Status.BAD_REQUEST).build(); } else { SeaCloudsApplicationData seaCloudsApplicationData = dataStore.getSeaCloudsApplicationDataById(seacloudsId); if (seaCloudsApplicationData == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } List<Map<String, Object>> entityList = new ArrayList<>(); List<EntitySummary> appEntities = getFlatEntityTree(seaCloudsApplicationData.getDeployerApplicationId()); for (EntitySummary entity : appEntities) { List<SensorSummary> entitySensors = deployer.getEntitySensors(seaCloudsApplicationData.getDeployerApplicationId(), entity.getId()); List<SensorSummary> numberSensors = new ArrayList<>(); for (SensorSummary entitySensor : entitySensors) { if (isNumberType(entitySensor.getType())) { numberSensors.add(entitySensor); } } HashMap<String, Object> entityMap = new HashMap<>(); entityMap.put("id", entity.getId()); entityMap.put("name", entity.getName()); entityMap.put("type", entity.getType()); entityMap.put("metrics", numberSensors); entityList.add(entityMap); } return Response.ok(entityList).build(); } } MonitorResource(DeployerProxy deployer); }
MonitorResource implements Resource { @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/metrics") @Deprecated @ApiOperation(value = "Get Metrics from a SeaClouds Application") public Response getEntityMetricMapList(@PathParam("seacloudsId") String seacloudsId) throws IOException { if (seacloudsId == null) { LOG.error("Missing input parameters"); return Response.status(Response.Status.BAD_REQUEST).build(); } else { SeaCloudsApplicationData seaCloudsApplicationData = dataStore.getSeaCloudsApplicationDataById(seacloudsId); if (seaCloudsApplicationData == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } List<Map<String, Object>> entityList = new ArrayList<>(); List<EntitySummary> appEntities = getFlatEntityTree(seaCloudsApplicationData.getDeployerApplicationId()); for (EntitySummary entity : appEntities) { List<SensorSummary> entitySensors = deployer.getEntitySensors(seaCloudsApplicationData.getDeployerApplicationId(), entity.getId()); List<SensorSummary> numberSensors = new ArrayList<>(); for (SensorSummary entitySensor : entitySensors) { if (isNumberType(entitySensor.getType())) { numberSensors.add(entitySensor); } } HashMap<String, Object> entityMap = new HashMap<>(); entityMap.put("id", entity.getId()); entityMap.put("name", entity.getName()); entityMap.put("type", entity.getType()); entityMap.put("metrics", numberSensors); entityList.add(entityMap); } return Response.ok(entityList).build(); } } MonitorResource(DeployerProxy deployer); @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/sensors") @Deprecated @ApiOperation(value = "Get Sensors from a SeaClouds Application") Response getEntitySensorMapList(@PathParam("seacloudsId") String seacloudsId); @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/metrics") @Deprecated @ApiOperation(value = "Get Metrics from a SeaClouds Application") Response getEntityMetricMapList(@PathParam("seacloudsId") String seacloudsId); @GET @Timed @Produces(MediaType.TEXT_PLAIN) @Path("applications/{seacloudsId}/entities/{entityId}/metrics/{metricId}") @Deprecated @ApiOperation(value = "Get Metric Value from a particular <SeaCloudsApplication, EntityId, MetricId> combination") Response getMetricValue(@PathParam("seacloudsId") String seacloudsId,
                                   @PathParam("entityId") String brooklynEntityId,
                                   @PathParam("metricId") String brooklynMetricId); }
MonitorResource implements Resource { @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/metrics") @Deprecated @ApiOperation(value = "Get Metrics from a SeaClouds Application") public Response getEntityMetricMapList(@PathParam("seacloudsId") String seacloudsId) throws IOException { if (seacloudsId == null) { LOG.error("Missing input parameters"); return Response.status(Response.Status.BAD_REQUEST).build(); } else { SeaCloudsApplicationData seaCloudsApplicationData = dataStore.getSeaCloudsApplicationDataById(seacloudsId); if (seaCloudsApplicationData == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } List<Map<String, Object>> entityList = new ArrayList<>(); List<EntitySummary> appEntities = getFlatEntityTree(seaCloudsApplicationData.getDeployerApplicationId()); for (EntitySummary entity : appEntities) { List<SensorSummary> entitySensors = deployer.getEntitySensors(seaCloudsApplicationData.getDeployerApplicationId(), entity.getId()); List<SensorSummary> numberSensors = new ArrayList<>(); for (SensorSummary entitySensor : entitySensors) { if (isNumberType(entitySensor.getType())) { numberSensors.add(entitySensor); } } HashMap<String, Object> entityMap = new HashMap<>(); entityMap.put("id", entity.getId()); entityMap.put("name", entity.getName()); entityMap.put("type", entity.getType()); entityMap.put("metrics", numberSensors); entityList.add(entityMap); } return Response.ok(entityList).build(); } } MonitorResource(DeployerProxy deployer); @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/sensors") @Deprecated @ApiOperation(value = "Get Sensors from a SeaClouds Application") Response getEntitySensorMapList(@PathParam("seacloudsId") String seacloudsId); @GET @Timed @Produces(MediaType.APPLICATION_JSON) @Path("applications/{seacloudsId}/metrics") @Deprecated @ApiOperation(value = "Get Metrics from a SeaClouds Application") Response getEntityMetricMapList(@PathParam("seacloudsId") String seacloudsId); @GET @Timed @Produces(MediaType.TEXT_PLAIN) @Path("applications/{seacloudsId}/entities/{entityId}/metrics/{metricId}") @Deprecated @ApiOperation(value = "Get Metric Value from a particular <SeaCloudsApplication, EntityId, MetricId> combination") Response getMetricValue(@PathParam("seacloudsId") String seacloudsId,
                                   @PathParam("entityId") String brooklynEntityId,
                                   @PathParam("metricId") String brooklynMetricId);  }