use of org.projectnessie.error.NessieNotFoundException in project nessie by projectnessie.
the class ContentApiImpl method getMultipleContents.
@Override
public GetMultipleContentsResponse getMultipleContents(String namedRef, String hashOnRef, GetMultipleContentsRequest request) throws NessieNotFoundException {
try {
WithHash<NamedRef> ref = namedRefWithHashOrThrow(namedRef, hashOnRef);
List<ContentKey> externalKeys = request.getRequestedKeys();
List<Key> internalKeys = externalKeys.stream().map(ContentApiImpl::toKey).collect(Collectors.toList());
Map<Key, Content> values = getStore().getValues(ref.getHash(), internalKeys);
List<ContentWithKey> output = values.entrySet().stream().map(e -> ContentWithKey.of(toContentKey(e.getKey()), e.getValue())).collect(Collectors.toList());
return ImmutableGetMultipleContentsResponse.builder().contents(output).build();
} catch (ReferenceNotFoundException ex) {
throw new NessieReferenceNotFoundException(ex.getMessage(), ex);
}
}
use of org.projectnessie.error.NessieNotFoundException in project nessie by projectnessie.
the class TestNessieError method nessieNotFoundException.
@Test
void nessieNotFoundException() {
NessieNotFoundException ex = assertThrows(NessieNotFoundException.class, () -> unwrap(() -> client.newRequest().path("nessieNotFound").get()));
assertAll(() -> assertEquals("not-there-message", ex.getMessage()), () -> assertNull(ex.getServerStackTrace()), () -> assertEquals(Response.Status.NOT_FOUND.getStatusCode(), ex.getStatus()));
}
use of org.projectnessie.error.NessieNotFoundException in project iceberg by apache.
the class NessieCatalog method table.
private IcebergTable table(TableIdentifier tableIdentifier) {
try {
ContentKey key = NessieUtil.toKey(tableIdentifier);
Content table = api.getContent().key(key).reference(reference.getReference()).get().get(key);
return table != null ? table.unwrap(IcebergTable.class).orElse(null) : null;
} catch (NessieNotFoundException e) {
return null;
}
}
use of org.projectnessie.error.NessieNotFoundException in project iceberg by apache.
the class NessieTableOperations method doRefresh.
@Override
protected void doRefresh() {
try {
reference.refresh(api);
} catch (NessieNotFoundException e) {
throw new RuntimeException("Failed to refresh as ref is no longer valid.", e);
}
String metadataLocation = null;
try {
Content content = api.getContent().key(key).reference(reference.getReference()).get().get(key);
LOG.debug("Content '{}' at '{}': {}", key, reference.getReference(), content);
if (content == null) {
if (currentMetadataLocation() != null) {
throw new NoSuchTableException("No such table %s in %s", key, reference.getReference());
}
} else {
this.table = content.unwrap(IcebergTable.class).orElseThrow(() -> new IllegalStateException("Cannot refresh iceberg table: " + String.format("Nessie points to a non-Iceberg object for path: %s.", key)));
metadataLocation = table.getMetadataLocation();
}
} catch (NessieNotFoundException ex) {
if (currentMetadataLocation() != null) {
throw new NoSuchTableException(ex, "No such table %s", key);
}
}
refreshFromMetadataLocation(metadataLocation, 2);
}
use of org.projectnessie.error.NessieNotFoundException in project nessie by projectnessie.
the class IdentifyContentsPerExecutor method walkLiveCommitsInReference.
private Map<String, ContentBloomFilter> walkLiveCommitsInReference(GCStateParamsPerTask gcStateParamsPerTask) {
Map<String, ContentBloomFilter> bloomFilterMap = new HashMap<>();
Set<ContentKey> liveContentKeys = new HashSet<>();
try (Stream<LogResponse.LogEntry> commits = StreamingUtil.getCommitLogStream(gcStateParamsPerTask.getApi(), builder -> builder.hashOnRef(gcStateParamsPerTask.getReference().getHash()).refName(Detached.REF_NAME).fetch(FetchOption.ALL), OptionalInt.empty())) {
MutableBoolean foundAllLiveCommitHeadsBeforeCutoffTime = new MutableBoolean(false);
// commit handler for the spliterator
Consumer<LogResponse.LogEntry> commitHandler = logEntry -> handleLiveCommit(gcStateParamsPerTask, logEntry, bloomFilterMap, foundAllLiveCommitHeadsBeforeCutoffTime, liveContentKeys);
// traverse commits using the spliterator
GCUtil.traverseLiveCommits(foundAllLiveCommitHeadsBeforeCutoffTime, commits, commitHandler);
} catch (NessieNotFoundException e) {
throw new RuntimeException(e);
}
return bloomFilterMap;
}
Aggregations