CasFileDownloader

public class CasFileDownloader
extends Object implements IFileDownloader

java.lang.Object
   ↳ com.google.android.tradefed.util.CasFileDownloader


File downloader to download files from RBE CAS.

Summary

Public constructors

CasFileDownloader(IFileDownloader fallbackDownloader, File manifestPath, boolean casAutoDiscovery, boolean casChunk, boolean casChunkDir)

Constructor for CasFileDownloader.

CasFileDownloader(IFileDownloader fallbackDownloader, File cacheDir, File manifestPath, boolean casAutoDiscovery, boolean casChunk, boolean casChunkDir, File casServiceAccountJson, File tempFileRoot, IRunUtil runUtil)

Public methods

void downloadFile(String remoteFilePath, File destFile, long startOffset, long size)

Alternate form of downloadFile(String,File), that allows caller to download a section of the file and save to a specific destination file.

void downloadFile(String relativeRemotePath, File destFile)

Alternate form of downloadFile(String), that allows caller to specify the destination file the remote contents should be placed in.

File downloadFile(String remoteFilePath)

Downloads a remote file to a temporary file on local disk.

void downloadZippedFiles(File destDir, String remoteFilePath, List<String> includeFilters, List<String> excludeFilters)

Download the files matching given filters in a remote zip file.

static CasOptions getCasOptions()
void setCasChunksOptions(boolean casKeepChunks, boolean casChunksOnly)
void setCasConcurrency(long casConcurrency)
void setCasMemoryLimit(long casMemoryLimit)
void setCasRpcTimeout(long casRpcTimeout, long casGetCapabilitiesTimeout, long casBatchUpdateBlobsTimeout, long casBatchReadBlobsTimeout, long casGetTreeTimeout)

Protected methods

File extractCasClient(String clientName)

Public constructors

CasFileDownloader

public CasFileDownloader (IFileDownloader fallbackDownloader, 
                File manifestPath, 
                boolean casAutoDiscovery, 
                boolean casChunk, 
                boolean casChunkDir)

Constructor for CasFileDownloader.

Parameters
fallbackDownloader IFileDownloader: the file downloader to use if the CAS file downloader fails to be initialized or the file fails to be downloaded from CAS.

manifestPath File

casAutoDiscovery boolean

casChunk boolean: whether to download the chunked version if both versions are available.

casChunkDir boolean: whether to download the chunked version uncompressed as a directory.

CasFileDownloader

public CasFileDownloader (IFileDownloader fallbackDownloader, 
                File cacheDir, 
                File manifestPath, 
                boolean casAutoDiscovery, 
                boolean casChunk, 
                boolean casChunkDir, 
                File casServiceAccountJson, 
                File tempFileRoot, 
                IRunUtil runUtil)

Parameters
fallbackDownloader IFileDownloader

cacheDir File

manifestPath File

casAutoDiscovery boolean

casChunk boolean

casChunkDir boolean

casServiceAccountJson File

tempFileRoot File

runUtil IRunUtil

Public methods

downloadFile

public void downloadFile (String remoteFilePath, 
                File destFile, 
                long startOffset, 
                long size)

Alternate form of downloadFile(String,File), that allows caller to download a section of the file and save to a specific destination file.

Parameters
remoteFilePath String: the remote path to the file to download, relative to an implementation-specific root.

destFile File: the file to place the downloaded contents into. Should not exist.

startOffset long: the start offset in the remote file.

size long: the number of bytes to download from the remote file. Set it to a negative value to download the whole file.

Throws
BuildRetrievalError

downloadFile

public void downloadFile (String relativeRemotePath, 
                File destFile)

Alternate form of downloadFile(String), that allows caller to specify the destination file the remote contents should be placed in.

Parameters
relativeRemotePath String: the remote path to the file to download, relative to an implementation-specific root.

destFile File: the file to place the downloaded contents into. Should not exist.

Throws
BuildRetrievalError

downloadFile

public File downloadFile (String remoteFilePath)

Downloads a remote file to a temporary file on local disk.

Parameters
remoteFilePath String: the remote path to the file to download, relative to a implementation specific root.

Returns
File the temporary local downloaded File.

Throws
BuildRetrievalError

downloadZippedFiles

public void downloadZippedFiles (File destDir, 
                String remoteFilePath, 
                List<String> includeFilters, 
                List<String> excludeFilters)

Download the files matching given filters in a remote zip file.

A file inside the remote zip file is only downloaded to its path matches any of the include filters but not the exclude filters.

Parameters
destDir File: the file to place the downloaded contents into.

remoteFilePath String: the remote path to the file to download, relative to an implementation specific root.

includeFilters List: a list of filters to download matching files.

excludeFilters List: a list of filters to skip downloading matching files.

Throws
BuildRetrievalError
IOException

getCasOptions

public static CasOptions getCasOptions ()

Returns
CasOptions

setCasChunksOptions

public void setCasChunksOptions (boolean casKeepChunks, 
                boolean casChunksOnly)

Parameters
casKeepChunks boolean

casChunksOnly boolean

setCasConcurrency

public void setCasConcurrency (long casConcurrency)

Parameters
casConcurrency long

setCasMemoryLimit

public void setCasMemoryLimit (long casMemoryLimit)

Parameters
casMemoryLimit long

setCasRpcTimeout

public void setCasRpcTimeout (long casRpcTimeout, 
                long casGetCapabilitiesTimeout, 
                long casBatchUpdateBlobsTimeout, 
                long casBatchReadBlobsTimeout, 
                long casGetTreeTimeout)

Parameters
casRpcTimeout long

casGetCapabilitiesTimeout long

casBatchUpdateBlobsTimeout long

casBatchReadBlobsTimeout long

casGetTreeTimeout long

Protected methods

extractCasClient

protected File extractCasClient (String clientName)

Parameters
clientName String

Returns
File

Throws
IOException