Package org.graylog2.plugin.journal

Examples of org.graylog2.plugin.journal.RawMessage


            }
            final ChannelBuffer buffer = (ChannelBuffer) msg;
            final byte[] payload = new byte[buffer.readableBytes()];
            buffer.toByteBuffer().get(payload, buffer.readerIndex(), buffer.readableBytes());

            final RawMessage raw = new RawMessage(input.getCodec().getName(), input.getId(),
                                                  (InetSocketAddress) e.getRemoteAddress(), payload);
            input.processRawMessage(raw);
        }
View Full Code Here


        generatorService = new AbstractExecutionThreadService() {
            @Override
            protected void run() throws Exception {
                while (isRunning()) {

                    final RawMessage rawMessage = GeneratorTransport.this.produceRawMessage(input);
                    if (rawMessage != null) {
                        input.processRawMessage(rawMessage);
                    }
                }
            }
View Full Code Here

                        final byte[] bytes = message.message();
                        totalBytesRead.addAndGet(bytes.length);
                        lastSecBytesReadTmp.addAndGet(bytes.length);

                        final RawMessage rawMessage = new RawMessage("radio-msgpack",
                                input.getId(),
                                null,
                                bytes);

                        // the loop below is like this because we cannot "unsee" the message we've just gotten by calling .next()
                        // the high level consumer of Kafka marks the message as "processed" immediately after being returned from next.
                        // thus we need to retry processing it.
                        boolean retry = false;
                        int retryCount = 0;
                        do {
                            try {
                                if (retry) {
                                    // don't try immediately if the buffer was full, try not spin too much
                                    LOG.debug("Waiting 10ms to retry inserting into buffer, retried {} times",
                                            retryCount);
                                    Uninterruptibles.sleepUninterruptibly(10,
                                            TimeUnit.MILLISECONDS); // TODO magic number
                                }
                                // try to process the message, if it succeeds, we immediately move on to the next message (retry will be false)
                                // if parsing the message failed, this will return 'true' (sorry for the stupid return value handling, amqp needs to know
                                // whether to ack or nack the message)
                                final boolean discardMalformedMessage = input.processRawMessageFailFast(rawMessage);
                                if (discardMalformedMessage) {
                                    LOG.debug("Message {} was malformed, skipping message.", rawMessage.getId());
                                }
                                retry = false;
                            } catch (BufferOutOfCapacityException e) {
                                LOG.debug("Input buffer full, retrying Kafka message processing");
                                retry = true;
View Full Code Here

                final Map<String, Object> data = Maps.newHashMap();
                data.put("short_message", shortMessage);
                data.put("host", source);
                data.putAll(fields);
                final byte[] payload = mapper.writeValueAsBytes(data);
                input.processRawMessage(new RawMessage("gelf", input.getId(), null, payload));
            } catch (JsonProcessingException e) {
                log.error("Unable to serialized metrics", e);
            }
        }
View Full Code Here

                    if (r.getStatusCode() != 200) {
                        throw new RuntimeException("Expected HTTP status code 200, got " + r.getStatusCode());
                    }

                    input.processRawMessage(new RawMessage(input.getCodec().getName(),
                                                           input.getId(),
                                                           remoteAddress,
                                                           r.getResponseBody().getBytes(StandardCharsets.UTF_8)));
                } catch (InterruptedException | ExecutionException | IOException e) {
                    LOG.error("Could not fetch HTTP resource at " + url, e);
View Full Code Here

        final byte[] payload;
        try {
            final FakeHttpRawMessageGenerator.GeneratorState state = generator.generateState();
            payload = objectMapper.writeValueAsBytes(state);

            final RawMessage raw = new RawMessage("randomhttp", input.getId(), null, payload);

            sleepUninterruptibly(rateDeviation(sleepMs, maxSleepDeviation, rand), MILLISECONDS);
            return raw;
        } catch (JsonProcessingException e) {
            log.error("Unable to serialize generator state", e);
View Full Code Here

                    long deliveryTag = envelope.getDeliveryTag();
                    try {
                        totalBytesRead.addAndGet(body.length);
                        lastSecBytesReadTmp.addAndGet(body.length);

                        final RawMessage rawMessage = new RawMessage("radio-msgpack", sourceInput.getId(), null, body);
                        sourceInput.processRawMessageFailFast(rawMessage);
                        channel.basicAck(deliveryTag, false);
                    } catch (BufferOutOfCapacityException e) {
                        LOG.debug("Input buffer full, requeuing message. Delaying 10 ms until trying next message.");
                        if (channel.isOpen()) {
View Full Code Here

        assertEquals(message.getField("facility"), "syslogd");
        assertEquals(message.getField("full_message"), UNSTRUCTURED);
    }

    private RawMessage buildRawMessage(String message) {
        return new RawMessage("syslog", "input-id", new InetSocketAddress(5140), message.getBytes());
    }
View Full Code Here

    public Response status() {
        /*
         * IMPORTANT!! When implementing permissions for radio: This must be
         *             accessible without authorization. LBs don't do that.
         */
        final LoadBalancerStatus lbStatus = serverStatus.getLifecycle().getLoadbalancerStatus();

        final Response.Status status = lbStatus == LoadBalancerStatus.ALIVE
                ? Response.Status.OK : Response.Status.SERVICE_UNAVAILABLE;

        return Response.status(status)
                .entity(lbStatus.toString().toUpperCase())
                .build();
    }
View Full Code Here

    @PUT @Timed
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/override/{status}")
    public Response override(@PathParam("status") String status) {
        final LoadBalancerStatus lbStatus;
        try {
            lbStatus = LoadBalancerStatus.valueOf(status.toUpperCase());
        } catch(IllegalArgumentException e) {
            throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
        }
View Full Code Here

TOP

Related Classes of org.graylog2.plugin.journal.RawMessage

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.