Examples of BlobStoreContext


Examples of org.jclouds.blobstore.BlobStoreContext

                     .credentials(identityValue, credentialValue)
                     .modules(ImmutableSet.<Module> of(new Log4JLoggingModule()));
            if (!Strings.isNullOrEmpty(endpointValue)) {
               builder = builder.endpoint(endpointValue);
            }
            BlobStoreContext context = builder.build(BlobStoreContext.class);
            blobStore = context.getBlobStore();
         } catch (Exception ex) {
            throw new RuntimeException("Failed to create service: " + ex.getMessage(), ex);
         }
      }
      return blobStore;
View Full Code Here

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();
      rackspace = context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
   }
View Full Code Here

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

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

Examples of org.jclouds.blobstore.BlobStoreContext

      // This property controls the number of parts being uploaded in parallel, the default is 4
      overrides.setProperty("jclouds.mpu.parallel.degree", "5");
      // This property controls the size (in bytes) of parts being uploaded in parallel, the default is 33554432 bytes = 32 MB
      overrides.setProperty("jclouds.mpu.parts.size", "67108864"); // 64 MB
     
      BlobStoreContext context = ContextBuilder.newBuilder(provider)
            .credentials(username, apiKey)
            .buildView(BlobStoreContext.class);
      storage = context.getBlobStore();
   }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStoreContext

      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

Examples of org.jclouds.blobstore.BlobStoreContext

      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);

         // Add Blob
         Blob blob = blobStore.blobBuilder("test").payload("testdata").build();
         blobStore.putBlob(containerName, blob);

         // List Container
         for (StorageMetadata resourceMd : blobStore.list()) {
            if (resourceMd.getType() == StorageType.CONTAINER || resourceMd.getType() == StorageType.FOLDER) {
               // Use Map API
               Map<String, InputStream> containerMap = context.createInputStreamMap(resourceMd.getName());
               System.out.printf("  %s: %s entries%n", resourceMd.getName(), containerMap.size());
            }
         }

         // Use Provider API
         if (context.getBackendType().getRawType().equals(RestContext.class)) {
            RestContext<?, ?> rest = context.unwrap();
            if (rest.getApi() instanceof S3Client) {
               RestContext<S3Client, S3AsyncClient> providerContext = context.unwrap();
               providerContext.getApi().getBucketLogging(containerName);
            } else if (rest.getApi() instanceof SwiftClient) {
               RestContext<SwiftClient, SwiftAsyncClient> providerContext = context.unwrap();
               providerContext.getApi().getObjectInfo(containerName, "test");
            } else if (rest.getApi() instanceof AzureBlobClient) {
               RestContext<AzureBlobClient, AzureBlobAsyncClient> providerContext = context.unwrap();
               providerContext.getApi().getBlobProperties(containerName, "test");
            } else if (rest.getApi() instanceof AtmosClient) {
               RestContext<AtmosClient, AtmosAsyncClient> providerContext = context.unwrap();
               providerContext.getApi().getSystemMetadata(containerName + "/test");
            }
         }
        
      } finally {
         // Close connecton
         context.close();
         System.exit(0);
      }

   }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStoreContext

      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, 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);

      } catch (InterruptedException e) {
         System.err.println(e.getMessage());
         e.printStackTrace();
      } catch (ExecutionException e) {
         System.err.println(e.getMessage());
         e.printStackTrace();
      } finally {
         // Close connecton
         context.close();
         System.exit(0);
      }

   }
View Full Code Here

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

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
TOP
Copyright © 2018 www.massapi.com. 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.