You can iterate over the Rackspace regions to get the Cloud Files endpoints, and then you can query each endpoint to see if the container exists there. Something like the following:
package org.jclouds.examples.rackspace.cloudfiles;
import static org.jclouds.examples.rackspace.cloudfiles.Constants.PROVIDER;
import java.io.IOException; import java.util.Set;
import org.jclouds.ContextBuilder;
import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext;
import org.jclouds.blobstore.BlobStore;
public class GetRegion{
private final RegionScopedBlobStoreContext ctx;
private final String YOUR_CONTAINER = "YOUR_CONTAINER_HERE";
public static void main(String[] args) throws IOException {
GetRegion getRegion = new GetRegion(args[0], args[1]);
try {
getRegion.getRegion();
}
catch (Exception e) {
e.printStackTrace();
}
}
public GetRegion(String username, String apiKey) {
ctx = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.buildView(RegionScopedBlobStoreContext.class);
}
private void getRegion() {
Set<String> regions = ctx.configuredRegions();
for(String region:regions){
BlobStore store = ctx.blobStoreInRegion(region);
if(store.containerExists(YOUR_CONTAINER)) {
System.out.format("Container is in %s region\n", region);
}
}
}
}
To run, replace "YOUR_CONTAINER_HERE" with the name of the container and pass your Rackspace username and API key as command-line arguments (alternatively, hard-code them in for 'args[0]' and 'args[1]', respectively).