Skip to content

Check if file exists in object store before reusing#1801

Open
IvanBorislavovDimitrov wants to merge 2 commits intomasterfrom
check-file-upload
Open

Check if file exists in object store before reusing#1801
IvanBorislavovDimitrov wants to merge 2 commits intomasterfrom
check-file-upload

Conversation

@IvanBorislavovDimitrov
Copy link
Contributor

LMCROSSITXSADEPLOY-3411

@@ -0,0 +1,2 @@
com.google.api.client.googleapis.services.AbstractGoogleClient.level=SEVERE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we set this to SEVERE in test logging? Is it to reduce noise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because now the GCP object store tests spam a lot and the build is getting too big without necessary information
this logging is only for tests

Comment on lines +84 to +85
public List<FileEntry> getExistingFileEntries(List<FileEntry> fileEntries) {
List<CompletableFuture<FileEntry>> existenceChecks = fileEntries.stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Azure implemenation there is validation if the fileEntries is empty. Do we need the same validation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added it

Comment on lines +80 to +84
List<CompletableFuture<FileEntry>> existenceChecks = fileEntries.stream()
.map(fileEntry -> CompletableFuture.supplyAsync(
() -> existsInBlobStore(fileEntry),
virtualThreadExecutor))
.toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part if duplicated. Can it be extracted somewhere and reused here so there is less duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

List<BlobId> blobIds = fileEntries.stream()
.map(fileEntry -> BlobId.of(bucketName, fileEntry.getId()))
.toList();
List<Blob> blobs = storage.get(blobIds);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this get request not executed in a thread like the other sdk-s?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it support multi fetch by multiple ids, others do not

Comment on lines +101 to +102
Storage mockedStorage = mock(Storage.class);
GcpObjectStoreFileStorage gcpFileStorage = gcpFileStorageWithMockedStorage(mockedStorage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s some duplicated mock setup - should we pull it into a helper method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored the class

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
78.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants