@Test public void testMissingDataRecordTemplate() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); out.writeShort(10); out.writeShort(16 + 8); out.writeInt(2); out.writeInt(1); out.writeInt(11); out.writeShort(256); out.writeShort(8); out.writeShort(111); out.writeShort(222); List<TSDRLogRecord> records1 = parseRecords(bos.toByteArray()); assertEquals(0, records1.size()); bos = new ByteArrayOutputStream(); out = new DataOutputStream(bos); out.writeShort(10); out.writeShort(16 + 6 + 12); out.writeInt(3); out.writeInt(2); out.writeInt(11); out.writeShort(256); out.writeShort(6); out.writeShort(333); out.writeShort(2); out.writeShort(12); out.writeShort(257); out.writeShort(1); out.writeShort(14); 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(10); out.writeShort(16 + 12); out.writeInt(4); out.writeInt(3); out.writeInt(11); out.writeShort(2); out.writeShort(12); out.writeShort(258); out.writeShort(1); out.writeShort(29); 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(10); out.writeShort(16 + 8); out.writeInt(5); out.writeInt(4); out.writeInt(11); 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(5 * 1000), records3.get(0).getTimeStamp()); assertEquals(NetflowIPFIXPacketParser.DATA_RECORD_TEXT, records3.get(0).getRecordFullText()); assertEquals("10", attrs.remove("version")); assertEquals("4", attrs.remove("Sequence_Number")); assertEquals("11", attrs.remove("Observation_Domain_ID")); assertEquals("999", attrs.remove("egressInterface")); bos = new ByteArrayOutputStream(); out = new DataOutputStream(bos); out.writeShort(10); out.writeShort(16 + 12); out.writeInt(1); out.writeInt(5); out.writeInt(11); out.writeShort(2); out.writeShort(12); out.writeShort(256); out.writeShort(1); out.writeShort(36); out.writeShort(2); assertEquals(0, parseRecords(bos.toByteArray()).size()); assertEquals(2, records1.size()); attrs = toMap(records1.get(0).getRecordAttributes()); assertEquals(Long.valueOf(2 * 1000), records1.get(0).getTimeStamp()); assertEquals(NetflowIPFIXPacketParser.DATA_RECORD_TEXT, records1.get(0).getRecordFullText()); assertEquals("10", attrs.remove("version")); assertEquals("1", attrs.remove("Sequence_Number")); assertEquals("11", attrs.remove("Observation_Domain_ID")); assertEquals("111", attrs.remove("flowActiveTimeout")); attrs = toMap(records1.get(1).getRecordAttributes()); assertEquals(Long.valueOf(2 * 1000), records1.get(1).getTimeStamp()); assertEquals(NetflowIPFIXPacketParser.DATA_RECORD_TEXT, records1.get(1).getRecordFullText()); assertEquals("10", attrs.remove("version")); assertEquals("1", attrs.remove("Sequence_Number")); assertEquals("11", attrs.remove("Observation_Domain_ID")); assertEquals("222", attrs.remove("flowActiveTimeout")); assertEquals(1, records2.size()); attrs = toMap(records2.get(0).getRecordAttributes()); assertEquals(Long.valueOf(3 * 1000), records2.get(0).getTimeStamp()); assertEquals(NetflowIPFIXPacketParser.DATA_RECORD_TEXT, records2.get(0).getRecordFullText()); assertEquals("10", attrs.remove("version")); assertEquals("2", attrs.remove("Sequence_Number")); assertEquals("11", attrs.remove("Observation_Domain_ID")); assertEquals("333", attrs.remove("flowActiveTimeout")); }
@Override public void parseRecords() { while (position() < totalPacketLength && !endOfData()) { if (!parseNextRecords()) { break; } } missingTemplateCache.checkTemplates(); }
NetflowIPFIXPacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (position() < totalPacketLength && !endOfData()) { if (!parseNextRecords()) { break; } } missingTemplateCache.checkTemplates(); } }
NetflowIPFIXPacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (position() < totalPacketLength && !endOfData()) { if (!parseNextRecords()) { break; } } missingTemplateCache.checkTemplates(); } NetflowIPFIXPacketParser(byte[] data, int initialPosition, String sourceIP,
            FlowTemplateCache flowTemplateCache, OptionsTemplateCache optionsTemplateCache,
            MissingTemplateCache missingTemplateCache, InformationElementMappings informationElementMappings,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowIPFIXPacketParser(NetflowIPFIXPacketParser other, int fromPosition, int bytesToCopy); }
NetflowIPFIXPacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (position() < totalPacketLength && !endOfData()) { if (!parseNextRecords()) { break; } } missingTemplateCache.checkTemplates(); } NetflowIPFIXPacketParser(byte[] data, int initialPosition, String sourceIP,
            FlowTemplateCache flowTemplateCache, OptionsTemplateCache optionsTemplateCache,
            MissingTemplateCache missingTemplateCache, InformationElementMappings informationElementMappings,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowIPFIXPacketParser(NetflowIPFIXPacketParser other, int fromPosition, int bytesToCopy); @Override void parseRecords(); }
NetflowIPFIXPacketParser extends AbstractNetflowPacketParser { @Override public void parseRecords() { while (position() < totalPacketLength && !endOfData()) { if (!parseNextRecords()) { break; } } missingTemplateCache.checkTemplates(); } NetflowIPFIXPacketParser(byte[] data, int initialPosition, String sourceIP,
            FlowTemplateCache flowTemplateCache, OptionsTemplateCache optionsTemplateCache,
            MissingTemplateCache missingTemplateCache, InformationElementMappings informationElementMappings,
            TSDRLogRecordBuilder recordBuilder, Consumer<TSDRLogRecordBuilder> callback); private  NetflowIPFIXPacketParser(NetflowIPFIXPacketParser other, int fromPosition, int bytesToCopy); @Override void parseRecords();  }