Package org.jclouds.blobstore.options

Examples of org.jclouds.blobstore.options.ListContainerOptions


   @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();
            cacheProvider.getProviderCacheForType("blob").put(blobMetadata.getProviderId(), blobName);
            blobNames.add(blobName);
         }

         Collections.sort(blobNames);
         for (String blobName : blobNames) {
            out.println(blobName);
         }

         String marker = blobStoreMetadatas.getNextMarker();
         if (marker == null) {
            break;
         }

         options = options.afterMarker(marker);
      }
      return null;
   }


        pendingExchanges = 0;

        Queue<Exchange> queue = new LinkedList<Exchange>();
        String directory = endpoint.getDirectory();

        ListContainerOptions opt = new ListContainerOptions();

        if (!Strings.isNullOrEmpty(directory)) {
            opt = opt.inDirectory(directory);
        }

        for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll).recursive())) {
            String blobName = md.getName();
            if (md.getType().equals(StorageType.BLOB)) {
                if (!Strings.isNullOrEmpty(blobName)) {
                    InputStream body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName);
                    if (body != null) {

        shutdownRunningTask = null;
        pendingExchanges = 0;

        Queue<Exchange> queue = new LinkedList<Exchange>();

        ListContainerOptions opt = new ListContainerOptions();

        for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll))) {
            String blobName = md.getName();
            Object body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName, Thread.currentThread().getContextClassLoader());
            Exchange exchange = endpoint.createExchange();
            exchange.getIn().setBody(body);
            exchange.setProperty(JcloudsConstants.BLOB_NAME, blobName);

      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);
               blobNames.add(blobName);
            }

            Collections.sort(blobNames);
            for (String blobName : blobNames) {
               out.println("    " + blobName);
            }

            String marker = blobStoreMetadatas.getNextMarker();
            if (marker == null) {
               break;
            }

            options = options.afterMarker(marker);
         }

         out.println();
      }
      return null;

                        PageSet<? extends StorageMetadata> list;
                        if (eager && marker == null) {
                           list = firstList;
                           marker = firstMarker;
                        } else {
                           ListContainerOptions nextOptions = marker == null ? containerOptions : containerOptions.clone().afterMarker(marker);
                           list = blobStore.list(container, nextOptions);
                           marker = list.getNextMarker();
                        }
                        iterator = list.iterator();
                     }

   void executeOneIteration(
         final String containerName,
         ListContainerOptions listOptions, final Semaphore semaphore,
         final Set<ListenableFuture<Void>> outstandingFutures,
         final AtomicBoolean deleteFailure, final boolean blocking) {
      ListContainerOptions options = listOptions.clone();
      String message = getMessage(containerName, listOptions);
      if (options.isRecursive()) {
         message += " recursively";
      }
      logger.debug(message);

      PageSet<? extends StorageMetadata> listing = getListing(containerName,
            options, semaphore, outstandingFutures, deleteFailure);
      while (listing != null && !listing.isEmpty()) {
         try {
            // Remove blobs and now-empty subdirectories.
            deleteBlobsAndEmptyDirs(containerName, options, listing, semaphore,
                  deleteFailure, outstandingFutures);
         } catch (TimeoutException te) {
            logger.debug("TimeoutException while deleting blobs: {}",
                  te.getMessage());
            cancelOutstandingFutures(outstandingFutures);
            deleteFailure.set(true);
         }

         String marker = listing.getNextMarker();
         if (marker != null) {
            logger.debug("%s with marker %s", message, marker);
            options = options.afterMarker(marker);
            listing = getListing(containerName, options, semaphore,
                  outstandingFutures, deleteFailure);
         } else {
            break;
         }

    private void checkForContainerContent(final String containerName, Set<String> expectedBlobKeys) {
        checkForContainerContent(containerName, null, expectedBlobKeys);
    }

    private void checkForContainerContent(final String containerName, String inDirectory, Set<String> expectedBlobKeys) {
        ListContainerOptions options = ListContainerOptions.Builder.recursive();
        if (null != inDirectory && !"".equals(inDirectory))
            options.inDirectory(inDirectory);

        PageSet<? extends StorageMetadata> blobsRetrieved = blobStore.list(containerName, options);
        for (Iterator<? extends StorageMetadata> it = blobsRetrieved.iterator(); it.hasNext();) {
           // TODO: FluentIterable
           if (it.next().getType() != StorageType.BLOB) {

        pendingExchanges = 0;

        Queue<Exchange> queue = new LinkedList<Exchange>();
        String directory = endpoint.getDirectory();

        ListContainerOptions opt = new ListContainerOptions();

        if (!Strings.isNullOrEmpty(directory)) {
            opt = opt.inDirectory(directory);
        }

        for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll).recursive())) {
            String blobName = md.getName();
            if (md.getType().equals(StorageType.BLOB)) {
                if (!Strings.isNullOrEmpty(blobName)) {
                    InputStream body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName);
                    if (body != null) {

        shutdownRunningTask = null;
        pendingExchanges = 0;

        Queue<Exchange> queue = new LinkedList<Exchange>();

        ListContainerOptions opt = new ListContainerOptions();

        for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll))) {
            String blobName = md.getName();
            Object body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName, Thread.currentThread().getContextClassLoader());
            Exchange exchange = endpoint.createExchange();
            exchange.getIn().setBody(body);
            exchange.setProperty(JcloudsConstants.BLOB_NAME, blobName);

public class ListContainerOptionsToBlobStoreListContainerOptions
         implements
         Function<org.jclouds.openstack.swift.options.ListContainerOptions[], ListContainerOptions> {
   public ListContainerOptions apply(
            org.jclouds.openstack.swift.options.ListContainerOptions[] optionsList) {
      ListContainerOptions options = new ListContainerOptions();
      if (optionsList.length != 0) {
         if (optionsList[0].getPath() != null && !optionsList[0].getPath().equals("")) {
            options.inDirectory(optionsList[0].getPath());
         }
         if (optionsList[0].getPrefix() != null && !optionsList[0].getPrefix().equals("")) {
            options.inDirectory(optionsList[0].getPrefix());
            options.recursive();
         }
         if (optionsList[0].getMarker() != null) {
            options.afterMarker(optionsList[0].getMarker());
         }
         options.maxResults(optionsList[0].getMaxResults());
      }
      return options;
   }

TOP

Related Classes of org.jclouds.blobstore.options.ListContainerOptions

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.