Package com.rackspacecloud.blueflood.inputs.formats

Examples of com.rackspacecloud.blueflood.inputs.formats.JSONMetricsContainer


                mapper.readValue(
                        body,
                        typeFactory.constructCollectionType(List.class,
                                JSONMetricsContainer.JSONMetric.class)
                );
        return new JSONMetricsContainer(tenantId, jsonMetrics);
    }
View Full Code Here


    }

    @Override
    public void handle(ChannelHandlerContext ctx, HttpRequest request) {
        final String tenantId = request.getHeader("tenantId");
        JSONMetricsContainer jsonMetricsContainer = null;
        final Timer.Context jsonTimerContext = jsonTimer.time();

        final String body = request.getContent().toString(Constants.DEFAULT_CHARSET);
        try {
            jsonMetricsContainer = createContainer(body, tenantId);
            if (!jsonMetricsContainer.isValid()) {
                throw new IOException("Invalid JSONMetricsContainer");
            }
        } catch (JsonParseException e) {
            log.warn("Exception parsing content", e);
            sendResponse(ctx, request, "Cannot parse content", HttpResponseStatus.BAD_REQUEST);
            return;
        } catch (JsonMappingException e) {
            log.warn("Exception parsing content", e);
            sendResponse(ctx, request, "Cannot parse content", HttpResponseStatus.BAD_REQUEST);
            return;
        } catch (IOException e) {
            log.warn("IO Exception parsing content", e);
            sendResponse(ctx, request, "Cannot parse content", HttpResponseStatus.BAD_REQUEST);
            return;
        } catch (Exception e) {
            log.warn("Other exception while trying to parse content", e);
            sendResponse(ctx, request, "Failed parsing content", HttpResponseStatus.INTERNAL_SERVER_ERROR);
            return;
        }

        if (jsonMetricsContainer == null) {
            log.warn(ctx.getChannel().getRemoteAddress() + " No valid metrics");
            sendResponse(ctx, request, "No valid metrics", HttpResponseStatus.BAD_REQUEST);
            return;
        }

        List<Metric> containerMetrics;
        try {
            containerMetrics = jsonMetricsContainer.toMetrics();
            forceTTLsIfConfigured(containerMetrics);
        } catch (InvalidDataException ex) {
            // todo: we should measure these. if they spike, we track down the bad client.
            // this is strictly a client problem. Someting wasn't right (data out of range, etc.)
            log.warn(ctx.getChannel().getRemoteAddress() + " " + ex.getMessage());
View Full Code Here

                mapper.readValue(
                        body,
                        typeFactory.constructCollectionType(List.class,
                                JSONMetricsContainer.ScopedJSONMetric.class)
                );
        return new JSONMetricsContainer(tenantId, jsonMetrics);
    }
View Full Code Here

TOP

Related Classes of com.rackspacecloud.blueflood.inputs.formats.JSONMetricsContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.