@Test public void testWindow() throws IOException, InterruptedException { final LumberjackFrame openFrame = new LumberjackFrame.Builder() .version((byte) 0x31) .frameType((byte) 0x57) .seqNumber(-1) .payload(Integer.toString(1).getBytes()) .build(); final String sender = "sender1"; final CapturingChannelResponder responder = new CapturingChannelResponder(); frameHandler.handle(openFrame, responder, sender); Assert.assertEquals(0, responder.responded); }
public void handle(final LumberjackFrame frame, final ChannelResponder<SocketChannel> responder, final String sender) throws IOException, InterruptedException { final Map<String, String> metadata = EventFactoryUtil.createMapWithSender(sender.toString()); metadata.put(LumberjackMetadata.SEQNUMBER_KEY, String.valueOf(frame.getSeqNumber())); String line = ""; if (frame.getFrameType() == 0x44) { ByteBuffer currentData = ByteBuffer.wrap(frame.getPayload()); long pairCount = currentData.getInt() & 0x00000000ffffffffL; Map<String,String> fields = new HashMap<>(); for (int i = 0; i < pairCount; i++) { long keyLength = currentData.getInt() & 0x00000000ffffffffL; byte[] bytes = new byte[(int) keyLength]; currentData.get(bytes); String key = new String(bytes); long valueLength = currentData.getInt() & 0x00000000ffffffffL; bytes = new byte[(int) valueLength]; currentData.get(bytes); String value = new String(bytes); if (key.equals("line")) { line = value; } else { fields.put(key, value); } } Gson serialFields = new Gson(); metadata.put("lumberjack.fields", serialFields.toJson(fields).toString()); final E event = eventFactory.create(line.getBytes(), metadata, responder); events.offer(event); } else if (frame.getFrameType() == 0x4A ) { logger.error("Data type was JSON. JSON payload aren't yet supported, pending the documentation of Lumberjack protocol v2"); } }
LumberjackFrameHandler { public void handle(final LumberjackFrame frame, final ChannelResponder<SocketChannel> responder, final String sender) throws IOException, InterruptedException { final Map<String, String> metadata = EventFactoryUtil.createMapWithSender(sender.toString()); metadata.put(LumberjackMetadata.SEQNUMBER_KEY, String.valueOf(frame.getSeqNumber())); String line = ""; if (frame.getFrameType() == 0x44) { ByteBuffer currentData = ByteBuffer.wrap(frame.getPayload()); long pairCount = currentData.getInt() & 0x00000000ffffffffL; Map<String,String> fields = new HashMap<>(); for (int i = 0; i < pairCount; i++) { long keyLength = currentData.getInt() & 0x00000000ffffffffL; byte[] bytes = new byte[(int) keyLength]; currentData.get(bytes); String key = new String(bytes); long valueLength = currentData.getInt() & 0x00000000ffffffffL; bytes = new byte[(int) valueLength]; currentData.get(bytes); String value = new String(bytes); if (key.equals("line")) { line = value; } else { fields.put(key, value); } } Gson serialFields = new Gson(); metadata.put("lumberjack.fields", serialFields.toJson(fields).toString()); final E event = eventFactory.create(line.getBytes(), metadata, responder); events.offer(event); } else if (frame.getFrameType() == 0x4A ) { logger.error("Data type was JSON. JSON payload aren't yet supported, pending the documentation of Lumberjack protocol v2"); } } }
LumberjackFrameHandler { public void handle(final LumberjackFrame frame, final ChannelResponder<SocketChannel> responder, final String sender) throws IOException, InterruptedException { final Map<String, String> metadata = EventFactoryUtil.createMapWithSender(sender.toString()); metadata.put(LumberjackMetadata.SEQNUMBER_KEY, String.valueOf(frame.getSeqNumber())); String line = ""; if (frame.getFrameType() == 0x44) { ByteBuffer currentData = ByteBuffer.wrap(frame.getPayload()); long pairCount = currentData.getInt() & 0x00000000ffffffffL; Map<String,String> fields = new HashMap<>(); for (int i = 0; i < pairCount; i++) { long keyLength = currentData.getInt() & 0x00000000ffffffffL; byte[] bytes = new byte[(int) keyLength]; currentData.get(bytes); String key = new String(bytes); long valueLength = currentData.getInt() & 0x00000000ffffffffL; bytes = new byte[(int) valueLength]; currentData.get(bytes); String value = new String(bytes); if (key.equals("line")) { line = value; } else { fields.put(key, value); } } Gson serialFields = new Gson(); metadata.put("lumberjack.fields", serialFields.toJson(fields).toString()); final E event = eventFactory.create(line.getBytes(), metadata, responder); events.offer(event); } else if (frame.getFrameType() == 0x4A ) { logger.error("Data type was JSON. JSON payload aren't yet supported, pending the documentation of Lumberjack protocol v2"); } } LumberjackFrameHandler(final SelectionKey selectionKey,
                                  final Charset charset,
                                  final EventFactory<E> eventFactory,
                                  final BlockingQueue<E> events,
                                  final AsyncChannelDispatcher dispatcher,
                                  final ComponentLog logger); }
LumberjackFrameHandler { public void handle(final LumberjackFrame frame, final ChannelResponder<SocketChannel> responder, final String sender) throws IOException, InterruptedException { final Map<String, String> metadata = EventFactoryUtil.createMapWithSender(sender.toString()); metadata.put(LumberjackMetadata.SEQNUMBER_KEY, String.valueOf(frame.getSeqNumber())); String line = ""; if (frame.getFrameType() == 0x44) { ByteBuffer currentData = ByteBuffer.wrap(frame.getPayload()); long pairCount = currentData.getInt() & 0x00000000ffffffffL; Map<String,String> fields = new HashMap<>(); for (int i = 0; i < pairCount; i++) { long keyLength = currentData.getInt() & 0x00000000ffffffffL; byte[] bytes = new byte[(int) keyLength]; currentData.get(bytes); String key = new String(bytes); long valueLength = currentData.getInt() & 0x00000000ffffffffL; bytes = new byte[(int) valueLength]; currentData.get(bytes); String value = new String(bytes); if (key.equals("line")) { line = value; } else { fields.put(key, value); } } Gson serialFields = new Gson(); metadata.put("lumberjack.fields", serialFields.toJson(fields).toString()); final E event = eventFactory.create(line.getBytes(), metadata, responder); events.offer(event); } else if (frame.getFrameType() == 0x4A ) { logger.error("Data type was JSON. JSON payload aren't yet supported, pending the documentation of Lumberjack protocol v2"); } } LumberjackFrameHandler(final SelectionKey selectionKey,
                                  final Charset charset,
                                  final EventFactory<E> eventFactory,
                                  final BlockingQueue<E> events,
                                  final AsyncChannelDispatcher dispatcher,
                                  final ComponentLog logger); void handle(final LumberjackFrame frame, final ChannelResponder<SocketChannel> responder, final String sender); }
LumberjackFrameHandler { public void handle(final LumberjackFrame frame, final ChannelResponder<SocketChannel> responder, final String sender) throws IOException, InterruptedException { final Map<String, String> metadata = EventFactoryUtil.createMapWithSender(sender.toString()); metadata.put(LumberjackMetadata.SEQNUMBER_KEY, String.valueOf(frame.getSeqNumber())); String line = ""; if (frame.getFrameType() == 0x44) { ByteBuffer currentData = ByteBuffer.wrap(frame.getPayload()); long pairCount = currentData.getInt() & 0x00000000ffffffffL; Map<String,String> fields = new HashMap<>(); for (int i = 0; i < pairCount; i++) { long keyLength = currentData.getInt() & 0x00000000ffffffffL; byte[] bytes = new byte[(int) keyLength]; currentData.get(bytes); String key = new String(bytes); long valueLength = currentData.getInt() & 0x00000000ffffffffL; bytes = new byte[(int) valueLength]; currentData.get(bytes); String value = new String(bytes); if (key.equals("line")) { line = value; } else { fields.put(key, value); } } Gson serialFields = new Gson(); metadata.put("lumberjack.fields", serialFields.toJson(fields).toString()); final E event = eventFactory.create(line.getBytes(), metadata, responder); events.offer(event); } else if (frame.getFrameType() == 0x4A ) { logger.error("Data type was JSON. JSON payload aren't yet supported, pending the documentation of Lumberjack protocol v2"); } } LumberjackFrameHandler(final SelectionKey selectionKey,
                                  final Charset charset,
                                  final EventFactory<E> eventFactory,
                                  final BlockingQueue<E> events,
                                  final AsyncChannelDispatcher dispatcher,
                                  final ComponentLog logger); void handle(final LumberjackFrame frame, final ChannelResponder<SocketChannel> responder, final String sender);  }