Package org.jclouds.blobstore

Examples of org.jclouds.blobstore.BlobStore


  }

  public synchronized void putIfAbsent(File file) throws FileNotFoundException {
      allocateContainer();

      BlobStore store = context.getBlobStore();
      if (!store.blobExists(container, file.getName())) {
        LOG.info("Uploading '{}' to '{}' blob cache.", file.getName(), container);

        Blob blob = context.getBlobStore().blobBuilder(container)
                .name(file.getName())
                .payload(file)
                .contentLength(file.length())
                .build();

        store.putBlob(container, blob, multipart());
      }
  }
View Full Code Here


     */
    @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

        blobStore.clearContainer(TEST_CONTAINER);
    }

    @Test
    public void testProducerAndConsumer() throws Exception {
        BlobStore blobStore = getOsgiService(BlobStore.class);
        getInstalledBundle("CamelBlueprintJcloudsTestBundle").start();
        BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintJcloudsTestBundle)", 20000);
        CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintJcloudsTestBundle)", 20000);

        MockEndpoint mock = ctx.getEndpoint("mock:results", MockEndpoint.class);
View Full Code Here

     */
    @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

    }



    public Set<? extends StorageMetadata> getS3Buckets() throws InvalidCredentialsException {
        BlobStore store = getBlobStoreContext().getBlobStore();
        return store.list();
    }
View Full Code Here

     *
     * @param outboundConfiguration
     * @return the name of the created bucket
     */
    public String createBucket(OutboundConfiguration outboundConfiguration) throws InvalidCredentialsException {
        BlobStore s3BlobStore = getBlobStoreContext().getBlobStore();
        String bucketName = convertOutboundConnectionToBucketName(outboundConfiguration);

        Location location = null;
        if (StringUtils.hasText(outboundConfiguration.getDestination())) {
            LocationBuilder builder = new LocationBuilder();
            builder.id(outboundConfiguration.getDestination());
            builder.scope(LocationScope.REGION);
            builder.description(outboundConfiguration.getDestination());

            location = builder.build();
        }

        s3BlobStore.createContainerInLocation(location ,bucketName); //defaults to us-standard if location is null
        return bucketName;
    }
View Full Code Here

     * @param payload bytes to be written to S3.
     * @return an eTag of the object that was just created.
     */
    public String pushToS3(OutboundConfiguration outboundConfiguration, String payloadIdentifier, byte[] payload)
            throws InvalidCredentialsException {
        BlobStore s3BlobStore = getBlobStoreContext().getBlobStore();
        String bucketName = createBucket(outboundConfiguration);
        Blob blob = s3BlobStore.blobBuilder(payloadIdentifier).payload(payload).build();
        return s3BlobStore.putBlob(bucketName,blob);
    }
View Full Code Here

     *
     * @throws Exception if anything goes wrong
     */
    @Test
    public void testBucketsInEURegion() throws Exception {
        BlobStore store = awsClient.getBlobStoreContext().getBlobStore();
        LocationBuilder lb = new LocationBuilder();
        String bucketName = "euregiontest" + new Date().getTime();
        StorageMetadata bucket = null;

        try {
            lb.id(Region.EU_WEST_1)
              .scope(LocationScope.REGION)
              .description("Superfluous description to appease jclouds.");

            store.createContainerInLocation(lb.build(), bucketName);

            for (StorageMetadata sm : store.list()) {
                if (sm.getName().equals(bucketName)) {
                    bucket = sm;
                    break;
                }
            }
        } finally {
            store.deleteContainer(bucketName);
        }

        Assert.assertNotNull(bucket);
    }
View Full Code Here

    @Override
    public void applyChanges( MapChanges changes )
        throws IOException
    {
        final BlobStore blobStore = storeContext.getBlobStore();
        changes.visitMap(
            new MapChanger()
            {
                @Override
                public Writer newEntity( final EntityReference ref, EntityDescriptor entityDescriptor )
                    throws IOException
                {
                    return new StringWriter()
                    {
                        @Override
                        public void close()
                        throws IOException
                        {
                            super.close();
                            Blob blob = blobStore.blobBuilder( ref.identity() )
                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
                                .build();
                            blobStore.putBlob( container, blob );
                        }
                    };
                }

                @Override
                public Writer updateEntity( final EntityReference ref, EntityDescriptor entityDescriptor )
                    throws IOException
                {
                    if( !blobStore.blobExists( container, ref.identity() ) )
                    {
                        throw new EntityNotFoundException( ref );
                    }
                    return new StringWriter()
                    {
                        @Override
                        public void close()
                        throws IOException
                        {
                            super.close();
                            Blob blob = blobStore.blobBuilder( ref.identity() )
                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
                                .build();
                            blobStore.putBlob( container, blob );
                        }
                    };
                }

                @Override
                public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
                    throws EntityNotFoundException
                {
                    if( !blobStore.blobExists( container, ref.identity() ) )
                    {
                        throw new EntityNotFoundException( ref );
                    }
                    blobStore.removeBlob( container, ref.identity() );
                }
            }
        );
    }
View Full Code Here

        }
        storeContext = ContextBuilder.newBuilder( provider ).
            credentials( identifier, credentials ).
            overrides( asProperties( properties ) ).
            buildView( BlobStoreContext.class );
        BlobStore blobStore = storeContext.getBlobStore();
        if( !blobStore.containerExists( container ) )
        {
            if( !blobStore.createContainerInLocation( null, container ) )
            {
                throw new EntityStoreException( "Unable to create JClouds Blob Container, cannot continue." );
            }
            else
            {
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.BlobStore

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.