Skip to content

[BEAM-2885] Implement a Local Artifact Retrieval service#4422

Merged
tgroh merged 4 commits intoapache:masterfrom
tgroh:artifact_retrieval_service
Feb 3, 2018
Merged

[BEAM-2885] Implement a Local Artifact Retrieval service#4422
tgroh merged 4 commits intoapache:masterfrom
tgroh:artifact_retrieval_service

Conversation

@tgroh
Copy link
Copy Markdown
Member

@tgroh tgroh commented Jan 17, 2018

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@tgroh tgroh requested a review from lukecwik January 17, 2018 02:04
@tgroh tgroh force-pushed the artifact_retrieval_service branch from c69f828 to f135ab9 Compare January 17, 2018 21:48
artifactsDirectory.exists(), "Nonexistent artifact directory %s", artifactsDirectory);
checkArgument(
artifactsDirectory.isDirectory(),
"Artifact Location %s is not a directory",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Location -> location

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done.

* LocalFileSystemArtifactRetrievalService}.
*/
private ArtifactApi.Manifest getManifest() throws IOException {
return ArtifactApi.Manifest.parseFrom(new FileInputStream(location.getManifestFile()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets do this during construction instead of failing during a client call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

input.read(buf);
buf.flip();
chunks.add(buf);
} while (chunks.size() * DEFAULT_CHUNK_SIZE < input.size());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will load everything into memory. Consider using https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileChannel.html#map-java.nio.channels.FileChannel.MapMode-long-long- and moving the reading part into the getArtifact loop.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

File baseFolder = tmp.newFolder();
LocalArtifactStagingLocation newLocation = LocalArtifactStagingLocation.createAt(baseFolder);
File newManifest = newLocation.getManifestFile();
assertThat("Manifest creation failed", newManifest.createNewFile(), is(true));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would use checkState here instead of assertThat since this is really a precondition to running the test.
You could also use assumeTrue which will mark the test as skipped if the assumption is ever broken but using checkState will force that the test is maintained.

Ditto on other test precondition checks.

assumeTrue works best in cases where you only want to run the test if the system can handle it like only if it can load a JNI library.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

checkState is what we want

@lukecwik lukecwik assigned tgroh and unassigned lukecwik Jan 30, 2018
@tgroh tgroh force-pushed the artifact_retrieval_service branch from f135ab9 to a3c762f Compare January 31, 2018 01:14
@tgroh tgroh assigned lukecwik and unassigned tgroh Jan 31, 2018
Copy link
Copy Markdown
Member

@lukecwik lukecwik left a comment

Choose a reason for hiding this comment

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

minor change. Self merge.

return ArtifactApi.Manifest.parseFrom(new FileInputStream(location.getManifestFile()));
try {
this.manifest =
ArtifactApi.Manifest.parseFrom(new FileInputStream(location.getManifestFile()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to close the FileInputStream otherwise you'll leak file handles.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed.

@tgroh tgroh force-pushed the artifact_retrieval_service branch 3 times, most recently from 9d51ab3 to 0ef5ad2 Compare February 2, 2018 17:34
tgroh added 4 commits February 2, 2018 10:01
This encapsulates the logic required for the Stager and Retrieval
services to use the same directory structure and filenames.
This enables LocalArtifactStagingLocations to be created for a staging
location that already exists. This enables retrieval services to be
created for a corresponding stager service.
Add a Local Artifact Retrieval Service which implements this interface.

The runner is not expected to interact directly with an instance of the
ArtifactRetrievalService, and is only exepcted to make it available to
environments it creates. As such, the interface is merely a signifier
to use within GrpcFnServer.
This mirrors the LocalFileSystemArtifactStagerService, and can be used
by containers to retrieve artifacts staged by the pipeline.
@tgroh tgroh force-pushed the artifact_retrieval_service branch from 0ef5ad2 to 7a537b9 Compare February 2, 2018 18:01
@tgroh
Copy link
Copy Markdown
Member Author

tgroh commented Feb 2, 2018

run java gradle precommit

@tgroh tgroh merged commit af864b8 into apache:master Feb 3, 2018
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.

2 participants