Package org.jclouds.blobstore.domain

Examples of org.jclouds.blobstore.domain.Blob


        }
      }
   }

   private void scanBlobForExpiredEntries(String blobName) {
      Blob blob = blobStore.getBlob(containerName, blobName);
      try {
         Bucket bucket = readFromBlob(blob, blobName);
         if (bucket != null) {
            if (bucket.removeExpiredEntries()) {
               upgradeLock(bucket.getBucketId());
View Full Code Here


   }

   @Override
   protected void updateBucket(Bucket bucket) throws CacheLoaderException {
      BlobBuilder builder = blobStore.blobBuilder(encodeBucketName(bucket.getBucketIdAsString()));
      Blob blob = builder.build();
      writeToBlob(blob, bucket);

      List<Future<?>> futures = asyncCommandFutures.get();
      if (futures == null) {
         // is a sync call
View Full Code Here

     * Test of getBlob method, of class FilesystemAsyncBlobStore.
     */
    public void testGetBlob() throws IOException {
        String blobKey = TestUtils.createRandomBlobKey();
        GetOptions options = null;
        Blob resultBlob;

        blobStore.createContainerInLocation(null, CONTAINER_NAME);

        resultBlob = blobStore.getBlob(CONTAINER_NAME, blobKey, options);
        assertNull(resultBlob, "Blob exists");

        // create blob
        TestUtils.createBlobsInContainer(CONTAINER_NAME, blobKey);

        resultBlob = blobStore.getBlob(CONTAINER_NAME, blobKey, options);

        assertNotNull(resultBlob, "Blob exists");
        // checks file content
        InputSupplier<FileInputStream> expectedFile =
                Files.newInputStreamSupplier(new File(
                TARGET_CONTAINER_NAME, blobKey));
        assertTrue(ByteStreams.equal(expectedFile, resultBlob.getPayload()),
                "Blob payload differs from file content");
        // metadata are verified in the test for blobMetadata, so no need to
        // perform a complete test here
        assertNotNull(resultBlob.getMetadata(), "Metadata null");
        MutableBlobMetadata metadata = resultBlob.getMetadata();
        assertEquals(blobKey, metadata.getName(), "Wrong blob metadata");
    }
View Full Code Here

    public void testRanges() throws IOException {
        blobStore.createContainerInLocation(null, CONTAINER_NAME);
        String input = "abcdefgh";
        Payload payload;
        Blob blob = blobStore.blobBuilder("test").payload(new StringPayload(input)).build();
        blobStore.putBlob(CONTAINER_NAME, blob);

        GetOptions getOptionsRangeStartAt = new GetOptions();
        getOptionsRangeStartAt.startAt(1);
        Blob blobRangeStartAt = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeStartAt);
        payload = blobRangeStartAt.getPayload();
        try {
            assertEquals(input.substring(1), Strings2.toString(payload));
        } finally {
            Closeables.closeQuietly(payload);
        }

        GetOptions getOptionsRangeTail = new GetOptions();
        getOptionsRangeTail.tail(3);
        Blob blobRangeTail = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeTail);
        payload = blobRangeTail.getPayload();
        try {
            assertEquals(input.substring(5), Strings2.toString(payload));
        } finally {
            Closeables.closeQuietly(payload);
        }

        GetOptions getOptionsFragment = new GetOptions();
        getOptionsFragment.range(4, 6);
        Blob blobFragment = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsFragment);
        payload = blobFragment.getPayload();
        try {
            assertEquals(input.substring(4, 7), Strings2.toString(payload));
        } finally {
            Closeables.closeQuietly(payload);
        }
View Full Code Here

                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
View Full Code Here

    /**
     * Create a blob with putBlob method
     */
    private void putBlobAndCheckIt(String blobKey) {
        Blob blob;

        TestUtils.fileExists(TARGET_CONTAINER_NAME + File.separator + blobKey, false);

        // create the blob
        blob = createBlob(blobKey, TestUtils.getImageForBlobPayload());
View Full Code Here

      String key = "hello";

      // NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the
      // providers.
      Blob object = view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
            .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build();
      String containerName = getContainerName();
      try {
         addBlobToContainer(containerName, object);
         validateContent(containerName, key);
View Full Code Here

      assertTrue(result, "Container exists");
   }

   public void testNewBlob() {
      String blobKey;
      Blob newBlob;

      blobKey = TestUtils.createRandomBlobKey("blobtest-", ".txt");
      newBlob = storageStrategy.newBlob(blobKey);
      assertNotNull(newBlob, "Created blob was null");
      assertNotNull(newBlob.getMetadata(), "Created blob metadata were null");
      assertEquals(newBlob.getMetadata().getName(), blobKey, "Created blob name is different");

      blobKey = TestUtils.createRandomBlobKey("blobtest-", "");
      newBlob = storageStrategy.newBlob(blobKey);
      assertEquals(newBlob.getMetadata().getName(), blobKey, "Created blob name is different");

      blobKey = TestUtils.createRandomBlobKey("asd" + FS + "asd" + FS + "asdasd" + FS + "afadsf-", "");
      newBlob = storageStrategy.newBlob(blobKey);
      assertEquals(newBlob.getMetadata().getName(), blobKey, "Created blob name is different");
   }
View Full Code Here

   public void testWritePayloadOnFile() throws IOException {
      String blobKey = TestUtils.createRandomBlobKey("writePayload-", ".img");
      File sourceFile = TestUtils.getImageForBlobPayload();
      FilePayload filePayload = new FilePayload(sourceFile);
      Blob blob = storageStrategy.newBlob(blobKey);
      blob.setPayload(filePayload);

      // write files
      storageStrategy.putBlob(CONTAINER_NAME, blob);

      // verify that the files is equal
View Full Code Here

   public void testWritePayloadOnFileInputStream() throws IOException {
      String blobKey = TestUtils.createRandomBlobKey("writePayload-", ".img");
      File sourceFile = TestUtils.getImageForBlobPayload();
      InputStreamPayload fileInputStreamPayload = new InputStreamPayload(
            new FileInputStream(sourceFile));
      Blob blob = storageStrategy.newBlob(blobKey);
      blob.setPayload(fileInputStreamPayload);

      // write files
      storageStrategy.putBlob(CONTAINER_NAME, blob);

      // verify that the files is equal
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.domain.Blob

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.