for (Location loc : blobStore.listAssignableLocations()) { if (loc.getId().equalsIgnoreCase(locationString)) { location = loc;
@Override public Set<? extends Location> listAssignableLocations() { return delegate().listAssignableLocations(); }
@Override public Set<? extends Location> listAssignableLocations() { return delegate().listAssignableLocations(); }
/** * 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; }
@Override public Set<? extends Location> listAssignableLocations() { return delegate().listAssignableLocations(); }
@Override public Set<? extends Location> listAssignableLocations() { return delegate().listAssignableLocations(); }
@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; } }
@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; } }
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); }
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); }
Set<? extends Location> locations = ctx.getBlobStore().listAssignableLocations(); for (Location location : locations) { if (!location.getId().equals(testLoc)) {
@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); } }
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; }
@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); } }
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;
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;
@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); } } }
@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); } } }
@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;
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;