Swift-Keystone multipart objects upload example

336 views
Skip to first unread message

dominik

unread,
Feb 11, 2013, 6:01:14 AM2/11/13
to jcl...@googlegroups.com
Hi,
Is there any working example where large objects are uploaded into Swift secured with Keystone ?
I can see that there is a AsyncBlobStore object but I can't find any example how to create it from context ?

I was trying :

BlobStoreContext context = ContextBuilder.newBuilder("swift-keystone").overrides(properties).build(BlobStoreContext.class);
///store = context.getBlobStore();
asyncStore = context.getAsyncBlobStore();

but it doesn't work, when I execute putBlob(container, blob, multipart()) method I get error:

backend type: org.jclouds.rest.RestContext<org.jclouds.openstack.swift.SwiftKeystoneClient, org.jclouds.openstack.swift.SwiftKeystoneAsyncClient> not assignable from org.jclouds.rest.RestContext<org.jclouds.openstack.swift.SwiftClient, org.jclouds.openstack.swift.SwiftAsyncClient>

Thanks,
Dominik T.

Everett Toews

unread,
Feb 15, 2013, 9:20:16 AM2/15/13
to jcl...@googlegroups.com
Hi Dominik,

It's an issue with setting up your Context. Have a look at the init() method in the List Containers example in the pull request below. It will show you how to setup the Context properly.


Sorry having to link you to a PR. Eventually this example will be available at


HTH,
Everett

--
You received this message because you are subscribed to the Google Groups "jclouds" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jclouds+u...@googlegroups.com.
To post to this group, send email to jcl...@googlegroups.com.
Visit this group at http://groups.google.com/group/jclouds?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

dominik

unread,
Feb 19, 2013, 4:40:18 AM2/19/13
to jcl...@googlegroups.com
Hi,
Thank you for the answer! I've created Context in that way but when I try tu run:

Blob blob = storage.blobBuilder(objectName).payload(file)
            .contentType(MediaType.APPLICATION_OCTET_STREAM)
            .contentDisposition(objectName).build();
         
storage.putBlob(containerName, blob, multipart());

I'm having error:

java.lang.IllegalArgumentException: backend type: org.jclouds.rest.RestContext<org.jclouds.openstack.swift.SwiftKeystoneClient, org.jclouds.openstack.swift.SwiftKeystoneAsyncClient> not assignable from org.jclouds.rest.RestContext<org.jclouds.openstack.swift.SwiftClient, org.jclouds.openstack.swift.SwiftAsyncClient>
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:119)
    at org.jclouds.internal.BaseView.unwrap(BaseView.java:52)
    at org.jclouds.openstack.swift.blobstore.strategy.internal.SequentialMultipartUploadStrategy.execute(SequentialMultipartUploadStrategy.java:51)
    at org.jclouds.openstack.swift.blobstore.SwiftBlobStore.putBlob(SwiftBlobStore.java:214)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.inject.internal.DelegatingInvocationHandler.invoke(DelegatingInvocationHandler.java:37)
    at $Proxy77.putBlob(Unknown Source)

Thanks,
Dominik

Everett Toews

unread,
Feb 19, 2013, 11:57:28 AM2/19/13
to jcl...@googlegroups.com
Hi Dominik,

Can you provide a gist [1] or pastie [2] with your code in it?

I'd like to see exactly how you're creating your BlobStoreContext and RestContext.

Thanks,
Everett

Everett Toews

unread,
Feb 19, 2013, 12:16:30 PM2/19/13
to jcl...@googlegroups.com
Oh...and what version of jclouds are you using?

dominik

unread,
Feb 20, 2013, 3:14:31 AM2/20/13
to jcl...@googlegroups.com
Hi,
My code is on http://pastie.org/6234793
I'm using jclouds 1.5.4

Thanks,
Dominik

Everett Toews

unread,
Feb 20, 2013, 11:07:41 PM2/20/13
to jcl...@googlegroups.com
Hi Dominik,

I'm at a bit of a loss here. I tried your example *exactly* as you have it in the pastie, naturally with different values for the SWIFT_* variables and the File, and it worked just fine for me using 1.5.4.

I grabbed jclouds 1.5.4 using ant and this build.xml file. You can see my directory listing too.


When I was troubleshooting your problem, I actually hit a issue in the cloudfiles API similar to the error you're getting. I fixed the issue there and made the same fix in the swift-keystone API just to be consistent across the two. Those fixes will be in jclouds 1.5.8 which should be released early next week. What you're doing in 1.5.4 seems like it should work but maybe 1.5.8 will work for you too. 

If you'd like to do some early testing, you can try out the snapshot builds. See the Using the jclouds Snapshot Builds section in


Hope that works out for you.

dominik

unread,
Feb 25, 2013, 4:19:07 AM2/25/13
to jcl...@googlegroups.com
Hi,
Hmm, I've tested the code with jclouds 1.5.4 as you suggested on two machines, one hosted by Linux, one by MacOs and I've the same error. I've also used a snapshot build 1.5.7 and the error still appears.
I'm using Java 1.6.0_21 and 1.6.0_35 on second machine. Code http://pastie.org/6234793

Thanks,
Dominik
Reply all
Reply to author
Forward
0 new messages