use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.
the class CompositeRecordFileReader method read.
@Override
public RecordFile read(@NonNull StreamFileData streamFileData) {
long count = 0;
Stopwatch stopwatch = Stopwatch.createStarted();
String filename = streamFileData.getFilename();
int version = 0;
try (DataInputStream dis = new DataInputStream(streamFileData.getInputStream())) {
RecordFileReader reader;
version = dis.readInt();
switch(version) {
case 1:
reader = version1Reader;
break;
case 2:
reader = version2Reader;
break;
case 5:
reader = version5Reader;
break;
default:
throw new InvalidStreamFileException(String.format("Unsupported record file version %d in file %s", version, filename));
}
RecordFile recordFile = reader.read(streamFileData);
count = recordFile.getCount();
return recordFile;
} catch (IOException e) {
throw new StreamFileReaderException("Error reading record file " + filename, e);
} finally {
log.info("Read {} items {}successfully from v{} record file {} in {}", count, count != 0 ? "" : "un", version, filename, stopwatch);
}
}
use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.
the class RecordFileParserTest method getStreamFile.
@Override
protected StreamFile getStreamFile() {
long id = ++count;
Instant instant = Instant.ofEpochSecond(0L, id);
String filename = StreamFilename.getFilename(parserProperties.getStreamType(), DATA, instant);
recordItem = recordItem(id);
RecordFile recordFile = new RecordFile();
recordFile.setBytes(new byte[] { 0, 1, 2 });
recordFile.setConsensusEnd(id);
recordFile.setConsensusStart(id);
recordFile.setConsensusEnd(id);
recordFile.setCount(id);
recordFile.setDigestAlgorithm(DigestAlgorithm.SHA384);
recordFile.setFileHash("fileHash" + id);
recordFile.setHapiVersionMajor(0);
recordFile.setHapiVersionMinor(23);
recordFile.setHapiVersionPatch(0);
recordFile.setHash("hash" + id);
recordFile.setLoadEnd(id);
recordFile.setLoadStart(id);
recordFile.setName(filename);
recordFile.setNodeAccountId(EntityId.of("0.0.3", EntityType.ACCOUNT));
recordFile.setPreviousHash("previousHash" + (id - 1));
recordFile.setVersion(1);
recordFile.setItems(Flux.just(recordItem));
return recordFile;
}
use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.
the class RecordFileParserIntegrationTest method recordFile.
RecordFile recordFile(File file, long index) {
RecordFile recordFile = recordFileReader.read(StreamFileData.from(file));
recordFile.setIndex(index);
recordFile.setNodeAccountId(NODE_ACCOUNT_ID);
return recordFile;
}
use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.
the class RecordFileParserIntegrationTest method rollback.
@Test
void rollback() {
// when
RecordFile recordFile = recordFileDescriptor1.getRecordFile();
recordFileParser.parse(recordFile);
// then
verifyFinalDatabaseState(recordFileDescriptor1);
// when
Assertions.assertThrows(ParserException.class, () -> recordFileParser.parse(recordFile));
// then
verifyFinalDatabaseState(recordFileDescriptor1);
}
use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.
the class RecordFileParserPerformanceTest method setup.
@BeforeAll
void setup() throws Exception {
EntityId nodeAccountId = EntityId.of(0L, 0L, 3L, EntityType.ACCOUNT);
for (int index = 0; index < testFiles.length; index++) {
RecordFile recordFile = recordFileReader.read(StreamFileData.from(testFiles[index].getFile()));
recordFile.setIndex((long) index);
recordFile.setNodeAccountId(nodeAccountId);
recordFiles.add(recordFile);
}
}
Aggregations