org.jclouds.blobstore.BlobStore.listAssignableLocations()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中org.jclouds.blobstore.BlobStore.listAssignableLocations()方法的一些代码示例,展示了BlobStore.listAssignableLocations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlobStore.listAssignableLocations()方法的具体详情如下:
包路径:org.jclouds.blobstore.BlobStore
类名称:BlobStore
方法名:listAssignableLocations

BlobStore.listAssignableLocations介绍

[英]The get locations command returns all the valid locations for containers. A location has a scope, which is typically region or zone. A region is a general area, like eu-west, where a zone is similar to a datacenter. If a location has a parent, that implies it is within that location. For example a location can be a rack, whose parent is likely to be a zone.
[中]get locations命令返回容器的所有有效位置。位置有一个范围,通常是区域或分区。区域是一个普通区域,如eu west,其中的区域类似于数据中心。如果一个位置有一个父位置,这意味着它在该位置内。例如,一个位置可以是一个机架,其父级可能是一个分区。

代码示例

代码示例来源:origin: gaul/s3proxy

for (Location loc : blobStore.listAssignableLocations()) {
  if (loc.getId().equalsIgnoreCase(locationString)) {
    location = loc;

代码示例来源:origin: org.apache.jclouds/jclouds-blobstore

@Override
public Set<? extends Location> listAssignableLocations() {
 return delegate().listAssignableLocations();
}

代码示例来源:origin: com.amysta.jclouds/jclouds-blobstore

@Override
public Set<? extends Location> listAssignableLocations() {
 return delegate().listAssignableLocations();
}

代码示例来源:origin: org.apache.camel/camel-jclouds

/**
 * Returns the {@link Location} that matches the locationId.
 */
public static Location getLocationById(BlobStore blobStore, String locationId) {
  if (blobStore != null && !Strings.isNullOrEmpty(locationId)) {
    for (Location location : blobStore.listAssignableLocations()) {
      if (locationId.equals(location.getId())) {
        return location;
      }
    }
  }
  return null;
}

代码示例来源:origin: Nextdoor/bender

@Override
public Set<? extends Location> listAssignableLocations() {
 return delegate().listAssignableLocations();
}

代码示例来源:origin: apache/jclouds

@Override
public Set<? extends Location> listAssignableLocations() {
 return delegate().listAssignableLocations();
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
  protected Object doExecute() throws Exception {
   BlobStore blobStore = getBlobStore();
   List<String> locationNames = Lists.newArrayList();

   for (Location loc : blobStore.listAssignableLocations()) {
     locationNames.add(loc.getId());
   }

   Collections.sort(locationNames);
   for (String locationName : locationNames) {
     System.out.println(locationName);
   }

   return null;
  }
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
  protected Object doExecute() throws Exception {
   BlobStore blobStore = getBlobStore();

   Location location = null;
   if (!locationString.isEmpty()) {
     for (Location loc : blobStore.listAssignableLocations()) {
      if (loc.getId().equalsIgnoreCase(locationString)) {
        location = loc;
        break;
      }
     }
     if (location == null) {
      throw new IllegalArgumentException("unknown location: " + locationString);
     }
   }

   for (String container : containerNames) {
     boolean created = blobStore.createContainerInLocation(location, container);
     if (!created) {
      if (blobStore.containerExists(container)) {
        throw new Exception("Container already exists: " + container);
      }

      throw new Exception("Could not create container: " + container);
     }
   }
   return null;
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

static Location findNonDefaultLocationOrSkip(BlobStore blobStore, Location defaultLocation) {
 List<? extends Location> locs = Lists.newArrayList(Iterables.filter(blobStore.listAssignableLocations(),
      Predicates.not(Predicates.equalTo(defaultLocation))));
 if (locs.size() == 0)
   throw new SkipException("No non-default location found in " + locs);
 // try to use a diverse location
 Collections.shuffle(locs);
 return locs.get(0);
}

代码示例来源:origin: apache/jclouds

static Location findNonDefaultLocationOrSkip(BlobStore blobStore, Location defaultLocation) {
 Iterable<? extends Location> iterable = Iterables.filter(blobStore.listAssignableLocations(),
      Predicates.not(Predicates.equalTo(defaultLocation)));
 List<? extends Location> locs = Lists.newArrayList(iterable);
 if (locs.size() == 0)
   throw new SkipException("No non-default location found in " + locs);
 // try to use a diverse location
 Collections.shuffle(locs);
 return locs.get(0);
}

代码示例来源:origin: jenkinsci/jclouds-plugin

Set<? extends Location> locations = ctx.getBlobStore().listAssignableLocations();
for (Location location : locations) {
  if (!location.getId().equals(testLoc)) {

代码示例来源:origin: apache/jclouds

@Test
public void testLocationsMatch() {
 RegionScopedBlobStoreContext ctx = RegionScopedBlobStoreContext.class.cast(view);
 for (String regionId : ctx.getConfiguredRegions()) {
   Set<? extends Location> locations = ctx.getBlobStore(regionId).listAssignableLocations();
   assertEquals(locations.size(), 1, "expected one region " + regionId + " " + locations);
   Location location = locations.iterator().next();
   assertEquals(location.getId(), regionId, "region id " + regionId + " didn't match getId(): " + location);
 }
}

代码示例来源:origin: jenkinsci/jclouds-plugin

public ListBoxModel doFillLocationIdItems(@QueryParameter String providerName,
    @QueryParameter String credentialsId,
    @QueryParameter String endPointUrl) {
  ListBoxModel m = new ListBoxModel();
  m.add("None specified", "");
  if (null == Util.fixEmptyAndTrim(credentialsId)) {
    return m;
  }
  // Remove empty text/whitespace from the fields.
  providerName = Util.fixEmptyAndTrim(providerName);
  endPointUrl = Util.fixEmptyAndTrim(endPointUrl);
  try (BlobStoreContext ctx = ctx(providerName, credentialsId, endPointUrl, true)) {
    LocationHelper.fillLocations(m, ctx.getBlobStore().listAssignableLocations());
  } catch (Exception ex) {
    LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
  }
  return m;
}

代码示例来源:origin: apache/jclouds

@Override
  protected boolean locationEquals(Location location1, Location location2) {
   Location usStandard = null;
   for (Location location : view.getBlobStore().listAssignableLocations()) {
     if (location.getId().equals("us-standard")) {
      usStandard = location;
      break;
     }
   }
   return super.locationEquals(location1 == null ? usStandard : location1,
                 location2 == null ? usStandard : location2);
  }
}

代码示例来源:origin: org.apache.whirr/whirr-core

private void updateDefaultLocation(ClusterSpec spec) throws IOException {
 if (spec.getBlobStoreLocationId() != null) {
  for(Location loc : context.getBlobStore().listAssignableLocations()) {
   if (loc.getId().equals(spec.getBlobStoreLocationId())) {
    defaultLocation = loc;
    "Using default blob store location.", spec.getTemplate().getLocationId());
  } else {
   for (Location loc : context.getBlobStore().listAssignableLocations()) {
    if (containsAny(loc.getIso3166Codes(), computeIsoCodes)) {
     defaultLocation = loc;

代码示例来源:origin: apache/attic-whirr

private void updateDefaultLocation(ClusterSpec spec) throws IOException {
 if (spec.getBlobStoreLocationId() != null) {
  for(Location loc : context.getBlobStore().listAssignableLocations()) {
   if (loc.getId().equals(spec.getBlobStoreLocationId())) {
    defaultLocation = loc;
    "Using default blob store location.", spec.getTemplate().getLocationId());
  } else {
   for (Location loc : context.getBlobStore().listAssignableLocations()) {
    if (containsAny(loc.getIso3166Codes(), computeIsoCodes)) {
     defaultLocation = loc;

代码示例来源:origin: apache/jclouds

@Test(groups = { "integration", "live" })
public void testAllLocations() throws InterruptedException {
 for (final Location location : view.getBlobStore().listAssignableLocations()) {
   final String containerName = getScratchContainerName();
   try {
    System.err.printf(" >> creating container in location %s%n", location);
    view.getBlobStore().createContainerInLocation(location, containerName);
    System.err.printf(" << call complete.. checking%n");
    assertConsistencyAware(new Runnable() {
      @Override
      public void run() {
       PageSet<? extends StorageMetadata> list = view.getBlobStore().list();
       assert Iterables.any(list, new Predicate<StorageMetadata>() {
         public boolean apply(StorageMetadata md) {
          return containerName.equals(md.getName()) && locationEquals(location, md.getLocation());
         }
       }) : String.format("container %s/%s not found in list %s", location, containerName, list);
       assertTrue(view.getBlobStore().containerExists(containerName), containerName);
      }
    });
   } finally {
    recycleContainerAndAddToPool(containerName);
   }
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test(groups = { "integration", "live" })
public void testAllLocations() throws InterruptedException {
 for (final Location location : view.getBlobStore().listAssignableLocations()) {
   final String containerName = getScratchContainerName();
   try {
    System.err.printf(" >> creating container in location %s%n", location);
    view.getBlobStore().createContainerInLocation(location, containerName);
    System.err.printf(" << call complete.. checking%n");
    assertConsistencyAware(new Runnable() {
      @Override
      public void run() {
       PageSet<? extends StorageMetadata> list = view.getBlobStore().list();
       assert Iterables.any(list, new Predicate<StorageMetadata>() {
         public boolean apply(StorageMetadata md) {
          return containerName.equals(md.getName()) && location.equals(md.getLocation());
         }
       }) : String.format("container %s/%s not found in list %s", location, containerName, list);
       assertTrue(view.getBlobStore().containerExists(containerName), containerName);
      }
    });
   } finally {
    recycleContainer(containerName);
   }
 }
}

代码示例来源:origin: apache/jclouds

@Test(groups = { "integration", "live" })
public void testGetAssignableLocations() throws Exception {
 for (Location location : view.getBlobStore().listAssignableLocations()) {
   System.err.printf("location %s%n", location);
   assert location.getId() != null : location;

代码示例来源:origin: jclouds/legacy-jclouds

if (view.unwrap() instanceof Location)
  assertProvider(Location.class.cast(view.unwrap()));
for (Location location : view.getBlobStore().listAssignableLocations()) {
  System.err.printf("location %s%n", location);
  assert location.getId() != null : location;

相关文章