protected void downloadFileImpl()

in priam/src/main/java/com/netflix/priam/google/GoogleEncryptedFileSystem.java [179:216]


    protected void downloadFileImpl(AbstractBackupPath path, String suffix)
            throws BackupRestoreException {
        String remotePath = path.getRemotePath();
        File localFile = new File(path.newRestoreFile().getAbsolutePath() + suffix);
        String objectName = parseObjectname(getPrefix().toString());
        com.google.api.services.storage.Storage.Objects.Get get;

        try {
            get = constructObjectResourceHandle().get(this.srcBucketName, remotePath);
        } catch (IOException e) {
            throw new BackupRestoreException(
                    "IO error retrieving metadata for: "
                            + objectName
                            + " from bucket: "
                            + this.srcBucketName,
                    e);
        }

        // If you're not using GCS' AppEngine, download the whole thing (instead of chunks) in one
        // request, if possible.
        get.getMediaHttpDownloader().setDirectDownloadEnabled(true);
        try (OutputStream os = new FileOutputStream(localFile);
                InputStream is = get.executeMediaAsInputStream()) {
            IOUtils.copyLarge(is, os);
        } catch (IOException e) {
            throw new BackupRestoreException(
                    "IO error during streaming of object: "
                            + objectName
                            + " from bucket: "
                            + this.srcBucketName,
                    e);
        } catch (Exception ex) {
            throw new BackupRestoreException(
                    "Exception encountered when copying bytes from input to output", ex);
        }

        backupMetrics.recordDownloadRate(get.getLastResponseHeaders().getContentLength());
    }