@Test public void testMissingFlowsetTemplate() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); out.writeShort(9); out.writeShort(2); out.writeInt(10); out.writeInt(20); out.writeInt(1); out.writeInt(20); out.writeShort(256); out.writeShort(12); out.writeInt(111); out.writeInt(222); List<TSDRLogRecord> records1 = parseRecords(bos.toByteArray()); assertEquals(0, records1.size()); bos = new ByteArrayOutputStream(); out = new DataOutputStream(bos); out.writeShort(9); out.writeShort(2); out.writeInt(20); out.writeInt(30); out.writeInt(2); out.writeInt(20); out.writeShort(256); out.writeShort(8); out.writeInt(333); out.writeShort(0); out.writeShort(12); out.writeShort(257); out.writeShort(1); out.writeShort(1); out.writeShort(4); List<TSDRLogRecord> records2 = parseRecords(bos.toByteArray()); assertEquals(0, records2.size()); assertEquals(0, records1.size()); bos = new ByteArrayOutputStream(); out = new DataOutputStream(bos); out.writeShort(9); out.writeShort(1); out.writeInt(35); out.writeInt(45); out.writeInt(3); out.writeInt(20); out.writeShort(0); out.writeShort(12); out.writeShort(258); out.writeShort(1); out.writeShort(1); out.writeShort(1); assertEquals(0, parseRecords(bos.toByteArray()).size()); assertEquals(0, records1.size()); assertEquals(0, records2.size()); bos = new ByteArrayOutputStream(); out = new DataOutputStream(bos); out.writeShort(9); out.writeShort(1); out.writeInt(40); out.writeInt(50); out.writeInt(4); out.writeInt(20); out.writeShort(257); out.writeShort(8); out.writeInt(999); List<TSDRLogRecord> records3 = parseRecords(bos.toByteArray()); assertEquals(1, records3.size()); Map<String, String> attrs = toMap(records3.get(0).getRecordAttributes()); assertEquals(Long.valueOf(50L * 1000), records3.get(0).getTimeStamp()); assertEquals("40", attrs.remove("sys_uptime")); assertEquals("4", attrs.remove("package_sequence")); assertEquals("20", attrs.remove("source_id")); assertEquals("999", attrs.remove("IN_BYTES")); bos = new ByteArrayOutputStream(); out = new DataOutputStream(bos); out.writeShort(9); out.writeShort(1); out.writeInt(5); out.writeInt(5); out.writeInt(5); out.writeInt(20); out.writeShort(0); out.writeShort(12); out.writeShort(256); out.writeShort(1); out.writeShort(2); out.writeShort(4); assertEquals(0, parseRecords(bos.toByteArray()).size()); assertEquals(2, records1.size()); attrs = toMap(records1.get(0).getRecordAttributes()); assertEquals(Long.valueOf(20L * 1000), records1.get(0).getTimeStamp()); assertEquals("10", attrs.remove("sys_uptime")); assertEquals("1", attrs.remove("package_sequence")); assertEquals("20", attrs.remove("source_id")); assertEquals("111", attrs.remove("IN_PKTS")); attrs = toMap(records1.get(1).getRecordAttributes()); assertEquals(Long.valueOf(20L * 1000), records1.get(1).getTimeStamp()); assertEquals("10", attrs.remove("sys_uptime")); assertEquals("1", attrs.remove("package_sequence")); assertEquals("20", attrs.remove("source_id")); assertEquals("222", attrs.remove("IN_PKTS")); assertEquals(1, records2.size()); attrs = toMap(records2.get(0).getRecordAttributes()); assertEquals(Long.valueOf(30L * 1000), records2.get(0).getTimeStamp()); assertEquals("20", attrs.remove("sys_uptime")); assertEquals("2", attrs.remove("package_sequence")); assertEquals("20", attrs.remove("source_id")); assertEquals("333", attrs.remove("IN_PKTS")); }
@Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } NetflowV9PacketParser(byte[] data, int initialPosition, String sourceIP, FlowsetTemplateCache flowsetTemplateCache,
            OptionsTemplateCache optionsTemplateCache, MissingTemplateCache missingTemplateCache,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowV9PacketParser(NetflowV9PacketParser other, int fromPosition, int bytesToCopy); }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } NetflowV9PacketParser(byte[] data, int initialPosition, String sourceIP, FlowsetTemplateCache flowsetTemplateCache,
            OptionsTemplateCache optionsTemplateCache, MissingTemplateCache missingTemplateCache,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowV9PacketParser(NetflowV9PacketParser other, int fromPosition, int bytesToCopy); @Override void parseRecords(); }
NetflowV9PacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (recordCounter < totalRecordCount && !endOfData()) { final OptionalInt possibleCount = parseNextRecords(); if (!possibleCount.isPresent()) { return; } recordCounter += possibleCount.getAsInt(); } missingTemplateCache.checkTemplates(); } NetflowV9PacketParser(byte[] data, int initialPosition, String sourceIP, FlowsetTemplateCache flowsetTemplateCache,
            OptionsTemplateCache optionsTemplateCache, MissingTemplateCache missingTemplateCache,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowV9PacketParser(NetflowV9PacketParser other, int fromPosition, int bytesToCopy); @Override void parseRecords();  }