use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.
the class ProtoBalanceFileReader method read.
@Override
public AccountBalanceFile read(StreamFileData streamFileData) {
Instant loadStart = Instant.now();
Flux<AccountBalance> items = toFlux(streamFileData);
long consensusTimestamp = items.map(AccountBalance::getId).map(AccountBalance.Id::getConsensusTimestamp).blockFirst();
try (InputStream inputStream = streamFileData.getInputStream()) {
AccountBalanceFile accountBalanceFile = new AccountBalanceFile();
accountBalanceFile.setBytes(streamFileData.getBytes());
accountBalanceFile.setConsensusTimestamp(consensusTimestamp);
accountBalanceFile.setFileHash(DigestUtils.sha384Hex(inputStream));
accountBalanceFile.setItems(items);
accountBalanceFile.setLoadStart(loadStart.getEpochSecond());
accountBalanceFile.setName(streamFileData.getFilename());
return accountBalanceFile;
} catch (IOException e) {
throw new StreamFileReaderException(e);
}
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.
the class AccountBalanceFileParserPerformanceTest method setup.
@BeforeAll
void setup() throws Exception {
balanceParserProperties.setEnabled(true);
EntityId nodeAccountId = EntityId.of(0L, 0L, 3L, EntityType.ACCOUNT);
for (Resource resource : testFiles) {
AccountBalanceFile accountBalanceFile = balanceFileReader.read(StreamFileData.from(resource.getFile()));
accountBalanceFile.setNodeAccountId(nodeAccountId);
accountBalanceFiles.add(accountBalanceFile);
}
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.
the class AccountBalanceFileParserTest method multipleBatches.
@Test
void multipleBatches() {
// given
int batchSize = parserProperties.getBatchSize();
parserProperties.setBatchSize(2);
AccountBalanceFile accountBalanceFile = accountBalanceFile(1);
List<AccountBalance> items = accountBalanceFile.getItems().collectList().block();
// when
accountBalanceFileParser.parse(accountBalanceFile);
// then
assertAccountBalanceFile(accountBalanceFile, items);
parserProperties.setBatchSize(batchSize);
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.
the class AccountBalanceFileParserTest method disabled.
@Test
void disabled() {
// given
parserProperties.setEnabled(false);
AccountBalanceFile accountBalanceFile = accountBalanceFile(1);
// when
accountBalanceFileParser.parse(accountBalanceFile);
// then
assertAccountBalanceFile(accountBalanceFile, List.of());
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.
the class AccountBalanceFileParserTest method success.
@Test
void success() {
// given
AccountBalanceFile accountBalanceFile = accountBalanceFile(1);
List<AccountBalance> items = accountBalanceFile.getItems().collectList().block();
// when
accountBalanceFileParser.parse(accountBalanceFile);
// then
assertAccountBalanceFile(accountBalanceFile, items);
assertThat(accountBalanceFile.getTimeOffset()).isZero();
}
Aggregations