/** * 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; }
/** * 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); } }
/** * 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; }
/** * Deletes the blob. * * @param container container name * @param key blob name */ @Override public void removeBlob(String container, String key) { sync.deleteArchive(container, key); }
/** * 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()); }
/** * 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; }
/** * 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; }
/** * Lists the containers. * * @return a PageSet of StorageMetadata */ @Override public PageSet<? extends StorageMetadata> list() { return vaultsToContainers.apply(sync.listVaults()); }
@Override protected boolean deleteAndVerifyContainerGone(String container) { return sync.deleteVault(container); }