Examples of BlobStore


Examples of org.jclouds.blobstore.BlobStore

   @Argument(index = 1, name = "blobNames", description = "The names of the blobs", required = true, multiValued = true)
   List<String> blobNames = new LinkedList<String>();

   @Override
   protected Object doExecute() throws Exception {
      BlobStore blobStore = getBlobStore();
      for (String blobName : blobNames) {
         blobStore.removeBlob(container, blobName);
         cacheProvider.getProviderCacheForType("blob").remove(blobStore.getContext().unwrap().getId(),
                  blobName);
      }
      return null;
   }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

   @Argument(index = 0, name = "containerNames", description = "The name of the container", required = true, multiValued = true)
   List<String> containerNames = Lists.newLinkedList();

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

      for (String container : containerNames) {
         blobStore.clearContainer(container);
      }
      return null;
   }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

   protected BlobStore getBlobStore() throws IOException {
      if ((name == null && provider == null && api == null) && (blobStoreServices != null && blobStoreServices.size() == 1)) {
         return blobStoreServices.get(0);
      }

      BlobStore blobStore = null;
      if (propertiesFile != null) {
         EnvHelper.loadProperties(new File(propertiesFile));
      }
      String providerValue = EnvHelper.getBlobStoreProvider(provider);
      String apiValue = EnvHelper.getBlobStoreApi(api);
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

                context = builder.name(id).credentials(identity, credential)
                        .modules(ImmutableSet.<Module>of(new Log4JLoggingModule(), new ManagementLifecycle(BaseManagementContext.INSTANCE)))
                        .overrides(props)
                        .build(BlobStoreContext.class);

                BlobStore blobStore = context.getBlobStore();
                newRegistration = bundleContext.registerService(
                        BlobStore.class.getName(), blobStore, properties);

                //If all goes well move the pending pid to the active pids.
                if (pendingPids.containsKey(pid)) {
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

        }

        if (JcloudsConstants.BLOBSTORE.endsWith(endpointType)) {
            if (uriParts.length >= 2) {
                String provider = uriParts[1];
                BlobStore blobStore = getBlobStoreForProvider(provider);
                endpoint = new JcloudsBlobStoreEndpoint(uri, this, blobStore);
            } else {
                throw new Exception("Invalid Endpoint URI. It should contains a valid provider name");
            }
        } else if (JcloudsConstants.COMPUTE.endsWith(endpointType)) {
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

   public void testMultipartChunkedFileStream() throws IOException, InterruptedException {
       Files.copy(oneHundredOneConstitutions, new File("target/const.txt"));
       String containerName = getContainerName();

       try {
           BlobStore blobStore = view.getBlobStore();
           blobStore.createContainerInLocation(null, containerName);
           Blob blob = blobStore.blobBuilder("const.txt")
                   .payload(new File("target/const.txt")).contentMD5(oneHundredOneConstitutionsMD5).build();
           blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
       } finally {
           returnContainer(containerName);
       }
   }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

    }

    private BlobStore createBlobStore(String providerOrApi, String identity, String credential, Iterable<? extends Module> modules, Properties props) {
        ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi).credentials(identity, credential).modules(modules).overrides(props);
        BlobStoreContext context = builder.build(BlobStoreContext.class);
        BlobStore blobStore = context.getBlobStore();
        return blobStore;
    }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

        }

        @Override
        public InputStream getInputStream() throws IOException {
            try {
                BlobStore blobStore = ServiceHelper.getService(id, providerOrApi, blobStores);
                if (blobStore == null && url.getUserInfo() != null) {
                    String userInfo = url.getUserInfo();
                    String[] ui = userInfo.split(":");
                    if (ui != null && ui.length == 2) {
                        String identity = ui[0];
                        String credential = ui[1];
                        blobStore = createBlobStore(providerOrApi, identity, credential, new LinkedHashSet<Module>(), new Properties());
                        blobStores.add(blobStore);
                    }
                }
                if (blobStore == null) {
                    throw new IOException("BlobStore service not available for provider " + providerOrApi);
                }
                if (!blobStore.containerExists(containerName)) {
                    throw new IOException("Container " + containerName + " does not exists");
                } else if (!blobStore.blobExists(containerName, blobName)) {
                    throw new IOException("Blob " + blobName + " does not exists");
                }

                Blob blob = blobStore.getBlob(containerName, blobName);

                return blob.getPayload().getInput();
            } catch (Exception e) {
                throw (IOException) new IOException("Error opening blob protocol url").initCause(e);
            }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

        }

        @Override
        public OutputStream getOutputStream() throws IOException {
            try {
                final BlobStore blobStore = ServiceHelper.getService(id, providerOrApi, blobStores);
                if (!blobStore.containerExists(containerName)) {
                    blobStore.createContainerInLocation(null, containerName);
                }

                final CountDownLatch readLatch = new CountDownLatch(1);
                final File tmpDir = Files.createTempDir();
                final File tmpBlob = File.createTempFile("blob", null, tmpDir);

                FileOutputStream out = new FileOutputStream(tmpBlob) {
                    @Override
                    public void close() throws IOException {
                        readLatch.countDown();
                    }
                };

                Runnable putBlob = new Runnable() {
                    @Override
                    public void run() {
                        try {
                            readLatch.await();
                            Blob blob = blobStore.blobBuilder(blobName).payload(tmpBlob).build();
                            blobStore.putBlob(containerName, blob);
                            tmpBlob.delete();
                            tmpDir.delete();
                        } catch (InterruptedException e) {
                            logger.error("Interrupted while waiting on blob read.", e);
                        }
View Full Code Here

Examples of org.jclouds.blobstore.BlobStore

   private static final PrintStream out = System.out;

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

      ListContainerOptions options = ListContainerOptions.Builder.recursive();
      if (directoryPath != null) {
         options = options.inDirectory(directoryPath);
      }

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

         for (StorageMetadata blobMetadata : blobStoreMetadatas) {
            String blobName = blobMetadata.getName();
            // do not add to cacheProvider since long lists will cause OutOfMemoryError
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.