ArtifactRetrievalService extends ArtifactRetrievalServiceGrpc.ArtifactRetrievalServiceImplBase implements FnService { @Override public void getArtifact( ArtifactApi.GetArtifactRequest request, StreamObserver<ArtifactApi.GetArtifactResponse> responseObserver) { 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); } catch (UnsupportedOperationException exn) { responseObserver.onError( new StatusException(Status.INVALID_ARGUMENT.withDescription(exn.getMessage()))); } } ArtifactRetrievalService();  ArtifactRetrievalService(ArtifactResolver resolver);  ArtifactRetrievalService(int bufferSize);  ArtifactRetrievalService(ArtifactResolver resolver, int bufferSize); @Override void resolveArtifacts(
      ArtifactApi.ResolveArtifactsRequest request,
      StreamObserver<ArtifactApi.ResolveArtifactsResponse> responseObserver); @Override void getArtifact(
      ArtifactApi.GetArtifactRequest request,
      StreamObserver<ArtifactApi.GetArtifactResponse> responseObserver); static InputStream getArtifact(RunnerApi.ArtifactInformation artifact); @Override void close(); static final int DEFAULT_BUFFER_SIZE; static final String FILE_ARTIFACT_URN; static final String URL_ARTIFACT_URN; static final String EMBEDDED_ARTIFACT_URN; static final String STAGING_TO_ARTIFACT_URN; }
@Test public void testRetrieveArtifacts() throws IOException, InterruptedException { Map<String, String> artifacts = ImmutableMap.of( "a.txt", "a", "b.txt", "bbb", "c.txt", Strings.repeat("cxy", TEST_BUFFER_SIZE * 3 / 4)); stageFiles(stagingDir, artifacts); for (Map.Entry<String, String> artifact : artifacts.entrySet()) { assertEquals( artifact.getValue(), getArtifact(fileArtifact(Paths.get(stagingDir.toString(), artifact.getKey())))); } }