Package org.jclouds.blobstore

Examples of org.jclouds.blobstore.BlobStoreContext


      String provider = "cloudfiles-us";

      String username = args[0];
      String apiKey = args[1];

      BlobStoreContext context = ContextBuilder.newBuilder(provider)
            .credentials(username, apiKey)
            .buildView(BlobStoreContext.class);
      storage = context.getBlobStore();
      swift = context.unwrap();
   }
View Full Code Here


                .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
                .overrides(properties);
        if (endpoint != null) {
            builder = builder.endpoint(endpoint);
        }
        BlobStoreContext context = builder.build(BlobStoreContext.class);
        URI s3ProxyEndpoint = new URI(s3ProxyEndpointString);
        S3Proxy s3Proxy = new S3Proxy(context.getBlobStore(), s3ProxyEndpoint,
                localIdentity, localCredential, keyStorePath,
                keyStorePassword,
                "true".equalsIgnoreCase(forceMultiPartUpload), virtualHost);
        s3Proxy.start();
    }
View Full Code Here

   @Test
   void testContextImpl() {

      Injector injector = createInjector();
      BlobStoreContext handler = injector.getInstance(BlobStoreContext.class);
      assertEquals(handler.getClass(), BlobStoreContextImpl.class);
      ContainsValueInListStrategy valueList = injector
               .getInstance(ContainsValueInListStrategy.class);

      assertEquals(valueList.getClass(), FindMD5InUserMetadata.class);
   }
View Full Code Here

      String identity = args[0];
      String credentials = args[1];

      // Init
      BlobStoreContext context = ContextBuilder.newBuilder("glacier")
            .credentials(identity, credentials)
            .buildView(BlobStoreContext.class);

      try {
         while (chooseOption(context));
      } finally {
         context.close();
      }
   }
View Full Code Here

      if (threadcount != null)
         overrides.setProperty("jclouds.mpu.parallel.degree", threadcount); // without setting,
      // default is 4 threads
      overrides.setProperty(provider + ".identity", identity);
      overrides.setProperty(provider + ".credential", credential);
      BlobStoreContext context = new BlobStoreContextFactory().createContext(provider, HDFS_MODULES, overrides);

      try {
         long start = System.currentTimeMillis();
         Configuration conf = getConf();
         if (conf == null) {
            conf = new Configuration();
            setConf(conf);
         }
         // Create Container
         BlobStore blobStore = context.getBlobStore(); // it can be changed to sync
         // BlobStore
         blobStore.createContainerInLocation(null, containerName);
         Blob blob = blobStore.blobBuilder(objectName).payload(
               new HdfsPayload(new Path(hdfsUrl), conf))
               .contentType(MediaType.APPLICATION_OCTET_STREAM)
               .contentDisposition(objectName).build();
         long length = blob.getPayload().getContentMetadata().getContentLength();
         blobStore.putBlob(containerName, blob, multipart());

         printSpeed("Sucessfully uploaded", start, length);

      } finally {
         // Close connection
         context.close();
      }
   }  
View Full Code Here

      if (threadcount != null)
         overrides.setProperty("jclouds.mpu.parallel.degree", threadcount); // without setting,
      // default is 4 threads
      overrides.setProperty(providerId + ".identity", identity);
      overrides.setProperty(providerId + ".credential", credential);
      BlobStoreContext context = ContextBuilder.newBuilder(provider).modules(MODULES).overrides(overrides).build(BlobStoreContext.class);

      try {
         long start = System.currentTimeMillis();
         // Create Container
         BlobStore blobStore = context.getBlobStore();
         // BlobStore
         blobStore.createContainerInLocation(null, containerName);

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

         printSpeed("Sucessfully uploaded eTag(" + eTag + ")", start, length);
      } catch(HttpResponseException exception) {
         System.err.println(exception.getMessage());
         exception.printStackTrace();
      } finally {
         // Close connecton
         context.close();
         System.exit(0);
      }

   }
View Full Code Here

      String identity = args[1];
      String credential = args[2];
      String containerName = args[3];

      // Init
      BlobStoreContext context = ContextBuilder.newBuilder(provider)
                                               .credentials(identity, credential)
                                               .buildView(BlobStoreContext.class);

      try {

         // Create Container
         BlobStore blobStore = context.getBlobStore();
         blobStore.createContainerInLocation(null, containerName);
         String blobName = "test";
         ByteSource payload = ByteSource.wrap("testdata".getBytes(Charsets.UTF_8));

         // List Container Metadata
         for (StorageMetadata resourceMd : blobStore.list()) {
            if (containerName.equals(resourceMd.getName())) {
               System.out.println(resourceMd);
            }
         }

         // Add Blob
         Blob blob = blobStore.blobBuilder(blobName)
            .payload(payload)
            .contentLength(payload.size())
            .build();
         blobStore.putBlob(containerName, blob);

         // Use Provider API
         ApiMetadata apiMetadata = context.unwrap().getProviderMetadata().getApiMetadata();
         Object object = null;
         if (apiMetadata instanceof S3ApiMetadata) {
            S3Client api = context.unwrapApi(S3Client.class);
            object = api.headObject(containerName, blobName);
         } else if (apiMetadata instanceof SwiftApiMetadata) {
            SwiftClient api = context.unwrapApi(SwiftClient.class);
            object = api.getObjectInfo(containerName, blobName);
         } else if (apiMetadata instanceof AzureBlobApiMetadata) {
            RestContext<AzureBlobClient, ?> providerContext = context.unwrap();
            object = providerContext.getApi().getBlobProperties(containerName, blobName);
         } else if (apiMetadata instanceof AtmosApiMetadata) {
            AtmosClient api = context.unwrapApi(AtmosClient.class);
            object = api.headFile(containerName + "/" + blobName);
         }
         if (object != null) {
            System.out.println(object);
         }
        
      } finally {
         // Close connecton
         context.close();
         System.exit(0);
      }

   }
View Full Code Here

     * Strategy to perform any pre setup, before {@link org.apache.camel.CamelContext} is created
     */
    @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

     * Strategy to perform any pre setup, before {@link org.apache.camel.CamelContext} is created
     */
    @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

TOP

Related Classes of org.jclouds.blobstore.BlobStoreContext

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.