Sie können die Regionen Rackspace iterieren, um die Cloud-Dateien Endpunkte, und dann können Sie jeden Endpunkt abzufragen, um zu sehen, ob der Behälter dort vorhanden ist. Etwas wie folgt aus:
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);
}
}
}
}
ausführen zu können, ersetzen „YOUR_CONTAINER_HERE“ mit dem Namen des Containers und übergeben Sie Ihre Rackspace Benutzernamen und API-Schlüssel als Befehlszeilenargumente (alternativ fest einprogrammieren sie in für ‚args [ 0] 'bzw.' args [1] ').
Dieser Ansatz einen Aufruf an BlobStore.containerExists pro Region erfordert. –