You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:36:13 UTC

[GitHub] [beam] robertwb commented on a change in pull request #11932: [BEAM-9577] Migrate PortablePipelineJarCreator to new artifact service.

robertwb commented on a change in pull request #11932:
URL: https://github.com/apache/beam/pull/11932#discussion_r437009347



##########
File path: runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/artifact/ArtifactRetrievalService.java
##########
@@ -89,34 +92,41 @@ public void resolveArtifacts(
   public void getArtifact(
       ArtifactApi.GetArtifactRequest request,
       StreamObserver<ArtifactApi.GetArtifactResponse> responseObserver) {
-    switch (request.getArtifact().getTypeUrn()) {
+    try {
+      InputStream inputStream = getArtifact(request.getArtifact());
+      byte[] buffer = new byte[bufferSize];
+      int bytesRead;
+      while ((bytesRead = inputStream.read(buffer)) > 0) {
+        responseObserver.onNext(
+            ArtifactApi.GetArtifactResponse.newBuilder()
+                .setData(ByteString.copyFrom(buffer, 0, bytesRead))
+                .build());
+      }
+      responseObserver.onCompleted();
+    } catch (IOException exn) {
+      exn.printStackTrace();
+      responseObserver.onError(exn);

Review comment:
       onError will do its own wrapping (and there's not really a significaintly appropriate status to return here). 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org