use of com.hedera.mirror.grpc.exception.EntityNotFoundException in project hedera-mirror-node by hashgraph.
the class ProtoUtilTest method toStatusRuntimeException.
@Test
void toStatusRuntimeException() {
var entityId = EntityId.of(1L, EntityType.ACCOUNT);
var message = "boom";
assertException(Exceptions.failWithOverflow(message), Status.DEADLINE_EXCEEDED, OVERFLOW_ERROR);
assertException(new ConstraintViolationException(message, null), Status.INVALID_ARGUMENT, message);
assertException(new IllegalArgumentException(message), Status.INVALID_ARGUMENT, message);
assertException(new InvalidEntityException(message), Status.INVALID_ARGUMENT, message);
assertException(new EntityNotFoundException(entityId), Status.NOT_FOUND, "Account 0.0.1 does not exist");
assertException(new NonTransientDataAccessResourceException(message), Status.UNAVAILABLE, DB_ERROR);
assertException(new QueryTimeoutException(message), Status.RESOURCE_EXHAUSTED, DB_ERROR);
assertException(new TimeoutException(message), Status.RESOURCE_EXHAUSTED, DB_ERROR);
assertException(new RuntimeException(message), Status.UNKNOWN, UNKNOWN_ERROR);
}
use of com.hedera.mirror.grpc.exception.EntityNotFoundException in project hedera-mirror-node by hashgraph.
the class NetworkServiceImpl method getNodes.
@Override
public Flux<AddressBookEntry> getNodes(AddressBookFilter filter) {
var fileId = filter.getFileId();
if (!VALID_FILE_IDS.contains(fileId)) {
throw new IllegalArgumentException(INVALID_FILE_ID);
}
long timestamp = addressBookRepository.findLatestTimestamp(fileId.getId()).orElseThrow(() -> new EntityNotFoundException(fileId));
var context = new AddressBookContext(timestamp);
return Flux.defer(() -> page(context)).repeatWhen(Repeat.onlyIf(c -> !context.isComplete()).randomBackoff(addressBookProperties.getMinPageDelay(), addressBookProperties.getMaxPageDelay()).jitter(Jitter.random()).withBackoffScheduler(Schedulers.parallel())).take(filter.getLimit() > 0 ? filter.getLimit() : Long.MAX_VALUE).name("addressBook").metrics().doOnNext(context::onNext).doOnSubscribe(s -> log.info("Querying for address book: {}", filter)).doOnComplete(() -> log.info("Retrieved {} nodes from the address book", context.getCount()));
}
Aggregations