예제 #1
0
 /**
  * Lists the blobs in the container. An inventory will be retrieved to obtain the list. Note that
  * this will take hours and the result may be inaccurate (Inventories are updated every 24 hours).
  *
  * @param container container name
  * @param listContainerOptions list options
  * @return the blob list
  * @see <a href="http://aws.amazon.com/glacier/faqs/#data-inventories" />
  */
 @Override
 public PageSet<? extends StorageMetadata> list(
     String container, ListContainerOptions listContainerOptions) {
   String jobId =
       sync.initiateJob(
           container, containerOptionsToInventoryRetrieval.apply(listContainerOptions));
   try {
     if (pollingStrategy.get().waitForSuccess(container, jobId)) {
       return archivesToBlobs.apply(sync.getInventoryRetrievalOutput(container, jobId));
     }
   } catch (InterruptedException e) {
     Throwables.propagate(e);
   }
   return null;
 }
예제 #2
0
  /**
   * Retrieves the blob This operation will take several hours.
   *
   * @param container container name
   * @param key blob name
   * @return The blob to retrieve, or null if the blob doesn't exist or the archive retrieval fails
   */
  @Override
  public Blob getBlob(String container, String key, GetOptions getOptions) {
    String jobId = sync.initiateJob(container, buildArchiveRetrievalRequest(key, getOptions));
    try {
      if (pollingStrategy.get().waitForSuccess(container, jobId)) {
        MutableBlobMetadata blobMetadata = new MutableBlobMetadataImpl();
        blobMetadata.setContainer(container);
        blobMetadata.setName(key);

        Blob blob = new BlobImpl(blobMetadata);
        blob.setPayload(sync.getJobOutput(container, jobId));
        return blob;
      }
    } catch (InterruptedException e) {
      Throwables.propagate(e);
    }
    return null;
  }