Package org.jclouds.blobstore

Examples of org.jclouds.blobstore.AsyncBlobStore


   public void testMultipartAsynchronouslySmallBlob() throws IOException, InterruptedException, Exception {
      String containerName = getContainerName();
     
      try {
         AsyncBlobStore asyncBlobStore = view.getAsyncBlobStore();
         asyncBlobStore.createContainerInLocation(null, containerName).get();
         Blob blob = asyncBlobStore.blobBuilder("small").payload("small").build();
         asyncBlobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()).get();

      } finally {
         returnContainer(containerName);
      }
   }
View Full Code Here


      ListenableFuture<PageSet<? extends StorageMetadata>> future = createMock(ListenableFuture.class);
      expect(future.get(anyLong(), anyObject(TimeUnit.class))).andThrow(new RuntimeException(new TimeoutException()));
      expect(future.cancel(true)).andReturn(true);
      replay(future);

      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      expect(asyncBlobStore.list(anyObject(String.class), anyObject(ListContainerOptions.class))).andReturn(future);
      replay(asyncBlobStore);

      deleter = new DeleteAllKeysInList(null, asyncBlobStore, null);
      try {
         deleter.execute(containerName, ListContainerOptions.NONE);
View Full Code Here

   public void testMultipartAsynchronouslySmallBlob() throws IOException, InterruptedException, Exception {
      String containerName = getContainerName();
     
      try {
         AsyncBlobStore asyncBlobStore = view.getAsyncBlobStore();
         asyncBlobStore.createContainerInLocation(null, containerName).get();
         Blob blob = asyncBlobStore.blobBuilder("small").payload("small").build();
         asyncBlobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()).get();

      } finally {
         returnContainer(containerName);
      }
   }
View Full Code Here

*/
@Test(groups = "unit")
public class BlobStoreUtilsTest {

   public void testCreateParentIfNeededAsyncNoPath() {
      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      String container = "container";
      Blob blob = createMock(Blob.class);
      MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

      expect(blob.getMetadata()).andReturn(md).atLeastOnce();
View Full Code Here

      verify(blob);
      verify(md);
   }

   public void testCreateParentIfNeededAsyncSinglePath() {
      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      String container = "container";
      Blob blob = createMock(Blob.class);
      MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

      expect(blob.getMetadata()).andReturn(md).atLeastOnce();
      expect(md.getName()).andReturn("rootpath/hello").atLeastOnce();
      expect(asyncBlobStore.createDirectory("container", "rootpath")).andReturn(null);

      replay(asyncBlobStore);
      replay(blob);
      replay(md);
View Full Code Here

      verify(blob);
      verify(md);
   }

   public void testCreateParentIfNeededAsyncNestedPath() {
      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      String container = "container";
      Blob blob = createMock(Blob.class);
      MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

      expect(blob.getMetadata()).andReturn(md).atLeastOnce();
      expect(md.getName()).andReturn("rootpath/subpath/hello").atLeastOnce();
      expect(asyncBlobStore.createDirectory("container", "rootpath/subpath")).andReturn(null);

      replay(asyncBlobStore);
      replay(blob);
      replay(md);
View Full Code Here

      verify(blob);
      verify(md);
   }

   public void testCreateParentIfNeededAsyncNestedPath() {
      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      String container = "container";
      Blob blob = createMock(Blob.class);
      MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

      expect(blob.getMetadata()).andReturn(md).atLeastOnce();
      expect(md.getName()).andReturn("rootpath/subpath/hello").atLeastOnce();
      expect(asyncBlobStore.createDirectory("container", "rootpath/subpath")).andReturn(null);

      replay(asyncBlobStore);
      replay(blob);
      replay(md);
View Full Code Here

   public void testMultipartAsynchronouslySmallBlob() throws IOException, InterruptedException, Exception {
      String containerName = getContainerName();
     
      try {
         AsyncBlobStore asyncBlobStore = view.getAsyncBlobStore();
         asyncBlobStore.createContainerInLocation(null, containerName).get();
         Blob blob = asyncBlobStore.blobBuilder("small").payload("small").build();
         asyncBlobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()).get();

      } finally {
         returnContainer(containerName);
      }
   }
View Full Code Here

      BlobStoreContext context = new BlobStoreContextFactory().createContext(provider, MODULES, overrides);

      try {
         long start = System.currentTimeMillis();
         // Create Container
         AsyncBlobStore blobStore = context.getAsyncBlobStore(); // it can be changed to sync
         // BlobStore
         ListenableFuture<Boolean> future = blobStore.createContainerInLocation(null, containerName);
         future.get();

         File input = new File(fileName);
         long length = input.length();
         // Add a Blob
         Blob blob = blobStore.blobBuilder(objectName).payload(input)
               .contentType(MediaType.APPLICATION_OCTET_STREAM).contentDisposition(objectName).build();
         // Upload a file
         ListenableFuture<String> futureETag = blobStore.putBlob(containerName, blob, multipart());

         // asynchronously wait for the upload
         String eTag = futureETag.get();

         printSpeed("Sucessfully uploaded eTag(" + eTag + ")", start, length);
View Full Code Here

   public void testMultipartAsynchronouslySmallBlob() throws IOException, InterruptedException, Exception {
      String containerName = getContainerName();
     
      try {
         AsyncBlobStore asyncBlobStore = view.getAsyncBlobStore();
         asyncBlobStore.createContainerInLocation(null, containerName).get();
         Blob blob = asyncBlobStore.blobBuilder("small").payload("small").build();
         asyncBlobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()).get();

      } finally {
         returnContainer(containerName);
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.AsyncBlobStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.