@Override public List<IMonitoringRecord> deserializeRecords(final ByteBuffer buffer, final int dataSize) { // Check the container identifier final int magic = buffer.getInt(); if (magic != CONTAINER_IDENTIFIER) { throw new InvalidFormatException(String.format("Invalid magic value %08x was found.", magic)); } // Check the actual format identifier final int formatIdentifier = buffer.getInt(); if (formatIdentifier != this.getFormatIdentifier()) { throw new InvalidFormatException(String.format("An invalid format identifier %08x was found.", formatIdentifier)); } return this.decodeRecords(buffer, (dataSize - HEADER_SIZE)); }
@Override public List<IMonitoringRecord> deserializeRecords(final ByteBuffer buffer, final int dataSize) { // Check the container identifier final int magic = buffer.getInt(); if (magic != CONTAINER_IDENTIFIER) { throw new InvalidFormatException(String.format("Invalid magic value %08x was found.", magic)); } // Check the actual format identifier final int formatIdentifier = buffer.getInt(); if (formatIdentifier != this.getFormatIdentifier()) { throw new InvalidFormatException( String.format("An invalid format identifier %08x was found.", formatIdentifier)); } return this.decodeRecords(buffer, (dataSize - HEADER_SIZE)); }
private List<IMonitoringRecord> decodeMonitoringRecords(final ByteBuffer buffer, final IRegistry<String> stringRegistry, final int endOffset) { final List<IMonitoringRecord> records = new ArrayList<IMonitoringRecord>(); int currentOffset = buffer.position(); final CachedRecordFactoryCatalog recordFactoryCatalog = this.cachedRecordFactoryCatalog; while (currentOffset < endOffset) { final int recordTypeId = buffer.getInt(); final String recordTypeName = stringRegistry.get(recordTypeId); final long loggingTimestamp = buffer.getLong(); final IRecordFactory<? extends IMonitoringRecord> recordFactory = recordFactoryCatalog.get(recordTypeName); final IMonitoringRecord record = recordFactory.create(DefaultValueDeserializer.create(buffer, stringRegistry)); record.setLoggingTimestamp(loggingTimestamp); records.add(record); currentOffset = buffer.position(); } // The record data must end exactly at the given end offset if (currentOffset != endOffset) { throw new InvalidFormatException("Invalid record data found, should have ended at offset " + endOffset + ", but ended at offset " + currentOffset + "."); } return records; }
private List<IMonitoringRecord> decodeMonitoringRecords(final ByteBuffer buffer, final ReaderRegistry<String> stringRegistry, final int endOffset) { final List<IMonitoringRecord> records = new ArrayList<>(); int currentOffset = buffer.position(); final CachedRecordFactoryCatalog recordFactoryCatalog = this.cachedRecordFactoryCatalog; while (currentOffset < endOffset) { final int recordTypeId = buffer.getInt(); final String recordTypeName = stringRegistry.get(recordTypeId); final long loggingTimestamp = buffer.getLong(); final IRecordFactory<? extends IMonitoringRecord> recordFactory = recordFactoryCatalog.get(recordTypeName); final IMonitoringRecord record = recordFactory .create(BinaryValueDeserializer.create(buffer, stringRegistry)); record.setLoggingTimestamp(loggingTimestamp); records.add(record); currentOffset = buffer.position(); } // The record data must end exactly at the given end offset if (currentOffset != endOffset) { throw new InvalidFormatException("Invalid record data found, should have ended at offset " + endOffset + ", but ended at offset " + currentOffset + "."); } return records; }