[
https://issues.apache.org/jira/browse/BEAM-4290?focusedWorklogId=110827&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-110827
]
ASF GitHub Bot logged work on BEAM-4290:
----------------------------------------
Author: ASF GitHub Bot
Created on: 11/Jun/18 21:02
Start Date: 11/Jun/18 21:02
Worklog Time Spent: 10m
Work Description: robertwb commented on a change in pull request #5591:
[BEAM-4290] Beam File System based ArtifactStagingService
URL: https://github.com/apache/beam/pull/5591#discussion_r194544535
##########
File path:
runners/java-fn-execution/src/test/java/org/apache/beam/runners/fnexecution/artifact/BeamFileSystemArtifactStagingServiceTest.java
##########
@@ -251,17 +258,129 @@ public void putArtifactsMultipleFilesTest() throws
Exception {
assertFiles(files.keySet(), stagingToken);
}
+ @Test
+ public void putArtifactsMultipleFilesConcurrentlyTest() throws Exception {
+ String stagingSession = "123";
+ Map<String, Integer> files = new HashMap<>();
+ files.put("file5cb", (DATA_1KB / 2) /*500b*/);
+ files.put("file1kb", DATA_1KB /*1 kb*/);
+ files.put("file15cb", (DATA_1KB * 3) / 2 /*1.5 kb*/);
+ files.put("nested/file1kb", DATA_1KB /*1 kb*/);
+ files.put("file10kb", 10 * DATA_1KB /*10 kb*/);
+ files.put("file100kb", 100 * DATA_1KB /*100 kb*/);
+
+ final String text = "abcdefghinklmop\n";
+ files.forEach((fileName, size) -> {
+ Path filePath = Paths.get(srcDir.toString(), fileName).toAbsolutePath();
+ try {
+ Files.createDirectories(filePath.getParent());
+ Files.write(filePath,
+ Strings.repeat(text, Double.valueOf(Math.ceil(size * 1.0 /
text.length())).intValue())
+ .getBytes(CHARSET));
+ } catch (IOException ignored) {
+ }
+ });
+ String stagingSessionToken = BeamFileSystemArtifactStagingService
+ .generateStagingSessionToken(stagingSession,
destDir.toUri().getPath());
+
+ List<ArtifactMetadata> metadata = new ArrayList<>();
+ ExecutorService executorService = Executors.newFixedThreadPool(8);
+ try {
+ for (String fileName : files.keySet()) {
+ executorService.execute(() -> {
+ try {
+ putArtifact(stagingSessionToken,
+ Paths.get(srcDir.toString(),
fileName).toAbsolutePath().toString(), fileName);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+
metadata.add(ArtifactMetadata.newBuilder().setName(fileName).build());
+ });
+ }
+ } finally {
+ executorService.shutdown();
+ executorService.awaitTermination(2, TimeUnit.SECONDS);
+ }
+
+ String stagingToken = commitManifest(stagingSessionToken, metadata);
+ Assert.assertEquals(
+ Paths.get(destDir.toAbsolutePath().toString(), stagingSession,
"MANIFEST").toString(),
+ stagingToken);
+ assertFiles(files.keySet(), stagingToken);
+ }
+
+ @Test
+ public void putArtifactsMultipleFilesConcurrentSessionsTest() throws
Exception {
+ String stagingSession1 = "123";
+ String stagingSession2 = "abc";
+ Map<String, Integer> files = new HashMap<>();
Review comment:
Nit (here and above): I prefer using ImmutableMaps for constants like this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 110827)
Time Spent: 12h 50m (was: 12h 40m)
> ArtifactStagingService that stages to a distributed filesystem
> --------------------------------------------------------------
>
> Key: BEAM-4290
> URL: https://issues.apache.org/jira/browse/BEAM-4290
> Project: Beam
> Issue Type: Sub-task
> Components: runner-core
> Reporter: Eugene Kirpichov
> Assignee: Ankur Goenka
> Priority: Major
> Time Spent: 12h 50m
> Remaining Estimate: 0h
>
> Using the job's staging directory from PipelineOptions.
> Physical layout on the distributed filesystem is TBD but it should allow for
> arbitrary filenames and ideally for eventually avoiding uploading artifacts
> that are already there.
> Handling credentials is TBD.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)