Package org.jclouds.blobstore

Examples of org.jclouds.blobstore.BlobStore


        blobStore.clearContainer(TEST_CONTAINER);
    }

    @Test
    public void testProducerAndConsumer() throws Exception {
        BlobStore blobStore = getOsgiService(BlobStore.class);
        getInstalledBundle("CamelBlueprintJcloudsTestBundle").start();
        BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintJcloudsTestBundle)", 20000);
        CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintJcloudsTestBundle)", 20000);

        MockEndpoint mock = (MockEndpoint) ctx.getEndpoint("mock:results");
View Full Code Here


     */
    @Override
    protected void doPreSetup() throws Exception {
        BlobStoreContextFactory contextFactory = new BlobStoreContextFactory();
        BlobStoreContext blobStoreContext = contextFactory.createContext("transient", "identity", "credential");
        BlobStore blobStore = blobStoreContext.getBlobStore();
        blobStore.createContainerInLocation(null, TEST_CONTAINER);
        blobStore.clearContainer(TEST_CONTAINER);
    }
View Full Code Here

    return null;
  }

  @Override
  public void save(Cluster cluster) throws IOException {
    BlobStore store = context.getBlobStore();

    Blob blob = store.newBlob(blobName);
    blob.setPayload(serialize(cluster));
    store.putBlob(container, blob);

    LOG.info("Saved cluster state to '{}' ", context.getSigner()
      .signGetBlob(container, blobName).getEndpoint().toString());
  }
View Full Code Here

  }

  public synchronized void putIfAbsent(File file) throws FileNotFoundException {
      allocateContainer();

      BlobStore store = context.getBlobStore();
      if (!store.blobExists(container, file.getName())) {
        LOG.info("Uploading '{}' to '{}' blob cache.", file.getName(), container);

        Blob blob = context.getBlobStore().blobBuilder(container)
                .name(file.getName())
                .payload(file)
                .contentLength(file.length())
                .build();

        store.putBlob(container, blob, multipart());
      }
  }
View Full Code Here

   }

   @Test
   void testToStorageMetadata() {
      assertNull(ToStorageMetadata.INSTANCE.apply(null));
      BlobStore blobStore = getBlobStore();
      blobStore.createContainerInLocation(null, "test");
      blobStore.createDirectory("test", "one");
      Set<StorageMetadata> storageMetadataSet = ImmutableSet.<StorageMetadata>builder()
                                                            .addAll(transform(blobStore.list(), ToStorageMetadata.INSTANCE))
                                                            .build();
      assertFalse(storageMetadataSet.isEmpty());
      StorageMetadata representation = storageMetadataSet.iterator().next();
      assertEquals("test", representation.getName());
   }
View Full Code Here

   }

   @Test
   void testToBlob() {
      assertNull(ToBlob.INSTANCE.apply(null));
      BlobStore blobStore = getBlobStore();
      blobStore.createContainerInLocation(null, "container");
      blobStore.createDirectory("container", "one");

      blobStore.putBlob("container", blobStore.blobBuilder("myblob").payload(ByteSource.wrap("testcontent".getBytes())).build());
      Blob representation = ToBlob.INSTANCE.apply(blobStore.getBlob("container", "myblob"));
      assertNotNull(representation);
      assertNotNull(representation.getBlobMetadata());
   }
View Full Code Here

   private static final PrintStream out = System.out;

   @Override
   protected Object doExecute() throws Exception {
      BlobStore blobStore = getBlobStore();

      if (listAllContainers) {
         containerNames.clear();
         for (StorageMetadata containerMetadata : blobStore.list()) {
            String containerName = containerMetadata.getName();
            containerNames.add(containerName);
            cacheProvider.getProviderCacheForType("container").put(containerMetadata.getProviderId(), containerName);
         }
      } else if (containerNames.isEmpty()) {
         throw new CommandException("Must specify container names or --all");
      }

      for (String containerName : containerNames) {
         out.println(containerName + ":");
         out.println();

         ListContainerOptions options = ListContainerOptions.Builder.recursive();

         while (true) {
            PageSet<? extends StorageMetadata> blobStoreMetadatas = blobStore.list(containerName, options);
            List<String> blobNames = Lists.newArrayList();

            for (StorageMetadata blobMetadata : blobStoreMetadatas) {
               String blobName = blobMetadata.getName();
               cacheProvider.getProviderCacheForType("blob").put(blobMetadata.getProviderId(), blobName);
View Full Code Here

   @Option(name = "-d", aliases = "--display", description = "Display the content to the console", required = false, multiValued = false)
   boolean display;

   @Override
   protected Object doExecute() throws Exception {
      BlobStore blobStore = getBlobStore();

      InputSupplier<InputStream> supplier = getBlobInputStream(blobStore, containerName, blobName);

      if (display) {
         CharStreams.copy(CharStreams.newReaderSupplier(supplier, Charsets.UTF_8), System.out);
View Full Code Here

   @Option(name = "-m", aliases = "--multipart-upload", description = "Use multi-part upload", required = false, multiValued = false)
   boolean multipartUpload;

   @Override
   protected Object doExecute() throws Exception {
      BlobStore blobStore = getBlobStore();

      BlobBuilder builder = blobStore.blobBuilder(blobName);
      if (stringPayload) {
         builder = builder.payload(payload.getBytes())// use default Charset
      } else if (urlPayload) {
         InputStream input = new URL(payload).openStream();
         try {
            builder = builder.payload(ByteStreams.toByteArray(input));
         } finally {
            input.close();
         }
      } else {
         BlobBuilder.PayloadBlobBuilder payloadBuilder = builder.payload(new File(payload));
         if (!multipartUpload) {
            payloadBuilder = payloadBuilder.calculateMD5();
         }
         builder = payloadBuilder;
      }

      PutOptions options = multipartUpload ? new PutOptions().multipart(true) : PutOptions.NONE;
      write(blobStore, containerName, blobName, builder.build(), options);

      cacheProvider.getProviderCacheForType("container").put(blobStore.getContext().unwrap().getId(), containerName);
      cacheProvider.getProviderCacheForType("blob").put(blobStore.getContext().unwrap().getId(), blobName);

      return null;
   }
View Full Code Here

   @Test(groups = { "integration", "live" })
   public void testChunksAreDeletedWhenMultipartBlobIsDeleted() throws IOException, InterruptedException {
      String containerName = getContainerName();
      try {
         BlobStore blobStore = view.getBlobStore();

         long countBefore = blobStore.countBlobs(containerName);
         String blobName = "deleteme.txt";
         addMultipartBlobToContainer(containerName, blobName);

         blobStore.removeBlob(containerName, blobName);
         long countAfter = blobStore.countBlobs(containerName);

         assertEquals(countAfter, countBefore);
      } finally {
          returnContainer(containerName);
      }
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.BlobStore

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.