Search in sources :

Example 1 with DownloadInstructions

use of org.javaswift.joss.instructions.DownloadInstructions in project alluxio by Alluxio.

the class SwiftInputStream method createStream.

@Override
protected InputStream createStream(long startPos, long endPos) throws IOException {
    NotFoundException lastException = null;
    while (mRetryPolicy.attempt()) {
        try {
            StoredObject storedObject = mAccount.getContainer(mContainerName).getObject(mObjectPath);
            DownloadInstructions downloadInstructions = new DownloadInstructions();
            downloadInstructions.setRange(new MidPartLongRange(startPos, endPos - 1));
            return storedObject.downloadObjectAsInputStream(downloadInstructions);
        } catch (NotFoundException e) {
            LOG.warn("Attempt {} to get object {} from container {} failed with exception : {}", mRetryPolicy.getAttemptCount(), mObjectPath, mContainerName, e.toString());
            // Object does not exist
            lastException = e;
        }
    }
    // Failed after retrying object does not exist
    throw lastException;
}
Also used : DownloadInstructions(org.javaswift.joss.instructions.DownloadInstructions) StoredObject(org.javaswift.joss.model.StoredObject) NotFoundException(org.javaswift.joss.exception.NotFoundException)

Aggregations

NotFoundException (org.javaswift.joss.exception.NotFoundException)1 DownloadInstructions (org.javaswift.joss.instructions.DownloadInstructions)1 StoredObject (org.javaswift.joss.model.StoredObject)1