Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Part 6]: Blob Store abstractions and a classloader factory that uses the blob store #155

Merged
merged 4 commits into from
Mar 29, 2022

Conversation

sundargates
Copy link
Collaborator

Two features are added through this change.
1). Firstly, I'm introducing a new blob store abstraction and a few implementations that can help download the blob from various stores such as s3, artifactory, etc.
2). A new class loader implementation has also been added to use the blob store to download the requested artifacts from s3 or artifactory or elsewhere and create a class loader object that can run the user's application code.

Context

In the new Titus world, one can use the cluster to run any user-submitted mantis job. Thus, we need capabilities to both download artifacts on demand and load them into the JVM to run the user's mantis job. This diff adds some of the abilities required for the above functionality.

Checklist

  • ./gradlew build compiles code correctly
  • Added new tests where applicable
  • ./gradlew test passes all tests
  • Extended README or added javadocs where applicable
  • Added copyright headers for new files from CONTRIBUTING.md

…use it

Two features are added through this change.
1). Firstly, I'm introducing a new blob store abstraction and a few implementations that can help download the blob from various stores such as s3, artifactory, etc...
2). A new class loader implementation has also been added that can use the blob store to download the requested artifacts from s3 or artifactory or elsewhere and create a class loader object that can run the user's application code.
@@ -0,0 +1,13 @@
# EditorConfig helps developers define and maintain consistent
Copy link
Contributor

Choose a reason for hiding this comment

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

Great call. I just installed the plugin for my editor.

build.gradle Outdated Show resolved Hide resolved
} else {
String destDirStr = getDestDir(zipFile);
File destDir = new File(destDirStr);
if (!destDir.exists()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like if the file path exists, we should delete it entirely and unzip zipFile there ofc logging a warning along with it.
Also, delete or close the localFile in this scenario.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm now throwing an exception in case of the destDir not being empty, which is the expectation for this method.


@Override
public void close() throws IOException {
blobStore.close();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we close it or let our caller close blobStore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case, the blob store object represents the delegate that we do not want to expose to the caller to. So, we need to perform this action.

blobStore.close();
}

private String getDestDir(ZipFile zipFile) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be called getUnzippedFile or something. Initially I got confused thinking this points to the destination directory containing the zipfile and we'll need to append something to determine the name of the unzipped file.

The name (with -unzipped suffix) would look weird it zipFile has extensions in the name but I guess that's okay for the time being.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@sundargates
Copy link
Collaborator Author

Please feel free to add any comments. I'll address them in later diffs. Closing for now.

@sundargates sundargates merged commit 8479c62 into Netflix:master Mar 29, 2022
for (Closeable closeable: closeables) {
try {
closeable.close();
} catch (IOException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering if we encouter runtime exception what should be the best behavior (e.g. closeable1 failed with runtime exception, shall closeable2 still get closed)?

@hmitnflx hmitnflx mentioned this pull request Mar 29, 2022
5 tasks
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.

5 participants