Exemplo n.º 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;
 }
Exemplo n.º 2
0
 /**
  * Deletes the container and all its blobs. Inventories will be retrieved until the container is
  * gone. Since inventories need 24 hours to be updated this operation may take days.
  *
  * @param container container name
  * @see <a href="http://aws.amazon.com/glacier/faqs/#data-inventories" />
  */
 @Override
 public void deleteContainer(String container) {
   // attempt to delete possibly-empty vault to avoid inventory retrieval
   if (!sync.deleteVault(container)) {
     deletePathAndEnsureGone(container);
   }
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
 /**
  * Deletes the blob.
  *
  * @param container container name
  * @param key blob name
  */
 @Override
 public void removeBlob(String container, String key) {
   sync.deleteArchive(container, key);
 }
Exemplo n.º 5
0
 /**
  * Stores a blob in a container. The blob name will be ignored, since it's not supported by
  * Glacier.
  *
  * @param container container name
  * @param blob blob to upload
  * @return the blob name
  */
 @Override
 public String putBlob(String container, Blob blob) {
   return sync.uploadArchive(container, blob.getPayload());
 }
Exemplo n.º 6
0
 /**
  * Creates a container. Location is currently ignored.
  *
  * @param location currently ignored
  * @param container container name
  * @return true if the container was created, false otherwise
  */
 @Override
 public boolean createContainerInLocation(@Nullable Location location, String container) {
   return sync.createVault(container) != null;
 }
Exemplo n.º 7
0
 /**
  * Checks if the container exists. This implementation invokes {@link
  * GlacierClient#describeVault(String)}.
  *
  * @param container container name
  * @return true if the vault exists, false otherwise
  */
 @Override
 public boolean containerExists(String container) {
   return sync.describeVault(container) != null;
 }
Exemplo n.º 8
0
 /**
  * Lists the containers.
  *
  * @return a PageSet of StorageMetadata
  */
 @Override
 public PageSet<? extends StorageMetadata> list() {
   return vaultsToContainers.apply(sync.listVaults());
 }
Exemplo n.º 9
0
 @Override
 protected boolean deleteAndVerifyContainerGone(String container) {
   return sync.deleteVault(container);
 }