Fetches the region of the bucket from the cache maintained. If the cache
doesn't have an entry, fetches the region from Amazon S3 and updates the
cache.
185689
private String fetchRegionFromCache(String bucketName) {
        String bucketRegion = bucketRegionCache.get(bucketName);
        if (bucketRegion == null) {
            if (log.isDebugEnabled()) {
                log.debug("Bucket region cache doesn't have an entry for " + bucketName
                        + ". Trying to get bucket region from Amazon S3.");
            }

            bucketRegion = getBucketRegionViaHeadRequest(bucketName);

            if (bucketRegion != null) {
                bucketRegionCache.put(bucketName, bucketRegion);
            }
        }
        if (log.isDebugEnabled()) {
            log.debug("Region for " + bucketName + " is " + bucketRegion);
        }
        return bucketRegion;
    }
223838
def get_s3_key(self):
        
        try:
            c = s3.connect_to_region(self._region,
                                     aws_access_key_id=self._aws_access_key_id,
                                     aws_secret_access_key=self._aws_secret_access_key)
            bucket = c.get_bucket(self._s3_bucket)
            key = bucket.get_key(self._s3_name)
            self._key_file = StringIO(unicode(key.get_contents_as_string().decode()))
            self._key_file.seek(0)
            key.close()
        except NoAuthHandlerFound:
            raise SergentSshException('Boto said that you should check your credentials')
        except S3ResponseError as e:
            logger.exception(e)
            raise SergentSshException('bucket %s or key %s not found' % (self._s3_bucket, self._s3_name))
708987
@Override
	public void cacheResult(CommerceRegion commerceRegion) {
		entityCache.putResult(CommerceRegionModelImpl.ENTITY_CACHE_ENABLED,
			CommerceRegionImpl.class, commerceRegion.getPrimaryKey(),
			commerceRegion);

		finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
			new Object[] { commerceRegion.getUuid(), commerceRegion.getGroupId() },
			commerceRegion);

		finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
			new Object[] {
				commerceRegion.getCommerceCountryId(), commerceRegion.getCode()
			}, commerceRegion);

		commerceRegion.resetOriginalValues();
	}
576240
@Nullable
  @WorkerThread
  private LottieComposition fetchFromCache() {
    Pair<FileExtension, InputStream> cacheResult = networkCache.fetch();
    if (cacheResult == null) {
      return null;
    }

    FileExtension extension = cacheResult.first;
    InputStream inputStream = cacheResult.second;
    LottieResult<LottieComposition> result;
    if (extension == FileExtension.ZIP) {
      result = LottieCompositionFactory.fromZipStreamSync(new ZipInputStream(inputStream), url);
    } else {
      result = LottieCompositionFactory.fromJsonInputStreamSync(inputStream, url);
    }
    if (result.getValue() != null) {
      return result.getValue();
    }
    return null;
  }
1371680
function(bucket) {
    var fs = require('fs');
    var path = require('path');
    var filePath = path.resolve('integ.buckets.json');
    var cache;
    if (fs.existsSync(filePath)) {
      try {
        cache = JSON.parse(fs.readFileSync(filePath));
        cache.buckets.push(bucket);
        fs.writeFileSync(filePath, JSON.stringify(cache));
      } catch (fileErr) {
        throw fileErr;
      }
    } else {
      cache = {};
      cache.buckets = [bucket];
      fs.writeFileSync(filePath, JSON.stringify(cache));
    }
  }
676238
def connect(cls, resource):
        
        import boto
        return boto.s3.connect_to_region(cls.get_region(resource))
728657
def update():
    '''
    
    '''

    metadata = _init()

    if S3_SYNC_ON_UPDATE:
        # sync the buckets to the local cache
        log.info('Syncing local cache from S3...')
        for saltenv, env_meta in six.iteritems(metadata):
            for bucket_files in _find_files(env_meta):
                for bucket, files in six.iteritems(bucket_files):
                    for file_path in files:
                        cached_file_path = _get_cached_file_name(bucket, saltenv, file_path)
                        log.info('%s - %s : %s', bucket, saltenv, file_path)

                        # load the file from S3 if it's not in the cache or it's old
                        _get_file_from_s3(metadata, saltenv, bucket, file_path, cached_file_path)

        log.info('Sync local cache from S3 completed.')
1035123
function requestBucketRegion(resp, done) {
    var error = resp.error;
    var req = resp.request;
    var bucket = req.params.Bucket || null;

    if (!error || !bucket || error.region || req.operation === 'listObjects' ||
        (AWS.util.isNode() && req.operation === 'headBucket') ||
        (error.statusCode === 400 && req.operation !== 'headObject') ||
        regionRedirectErrorCodes.indexOf(error.code) === -1) {
      return done();
    }
    var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects';
    var reqParams = {Bucket: bucket};
    if (reqOperation === 'listObjects') reqParams.MaxKeys = 0;
    var regionReq = req.service[reqOperation](reqParams);
    regionReq._requestRegionForBucket = bucket;
    regionReq.send(function() {
      var region = req.service.bucketRegionCache[bucket] || null;
      error.region = region;
      done();
    });
  }
1143830
@Override
    public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException {
        log.debug("region access strategy nonstrict-read-write entity update() {} {}", getInternalRegion().getCacheNamespace(), key);
        return false;
    }
155202
def _get_roots(self):
        
        region = self._get_session().region_name or r'[\w-]+'
        return (
                # S3 scheme
                # - s3://<bucket>/<key>
                's3://',

                # Virtual-hosted–style URL
                # - http://<bucket>.s3.amazonaws.com/<key>
                # - https://<bucket>.s3.amazonaws.com/<key>
                # - http://<bucket>.s3-<region>.amazonaws.com/<key>
                # - https://<bucket>.s3-<region>.amazonaws.com/<key>
                _re.compile(r'https?://[\w.-]+\.s3\.amazonaws\.com'),
                _re.compile(
                    r'https?://[\w.-]+\.s3-%s\.amazonaws\.com' % region),

                # Path-hosted–style URL
                # - http://s3.amazonaws.com/<bucket>/<key>
                # - https://s3.amazonaws.com/<bucket>/<key>
                # - http://s3-<region>.amazonaws.com/<bucket>/<key>
                # - https://s3-<region>.amazonaws.com/<bucket>/<key>
                _re.compile(r'https?://s3\.amazonaws\.com'),
                _re.compile(r'https?://s3-%s\.amazonaws\.com' % region),

                # Transfer acceleration URL
                # - http://<bucket>.s3-accelerate.amazonaws.com
                # - https://<bucket>.s3-accelerate.amazonaws.com
                # - http://<bucket>.s3-accelerate.dualstack.amazonaws.com
                # - https://<bucket>.s3-accelerate.dualstack.amazonaws.com
                _re.compile(
                    r'https?://[\w.-]+\.s3-accelerate\.amazonaws\.com'),
                _re.compile(
                    r'https?://[\w.-]+\.s3-accelerate\.dualstack'
                    r'\.amazonaws\.com'))
1062777
def s3(ctx, bucket_name, data_file, region):
    """"""
    if not ctx.data_file:
        ctx.data_file = data_file

    if not ctx.bucket_name:
        ctx.bucket_name = bucket_name

    if not ctx.region:
        ctx.region = region

    ctx.type = 's3'
1214601
def get_region(service, region, profile):
    
    _, region, _, _ = _get_profile(service, region, None, None, profile)

    return region
1121189
def iter_regions(self):
        
        # TODO: Implement BoundingBox
        # TODO: Implement sort order
        for x,z in self.regionfiles.keys():
            close_after_use = False
            if (x,z) in self.regions:
                regionfile = self.regions[(x,z)]
            else:
                # It is not yet cached.
                # Get file, but do not cache later.
                regionfile = region.RegionFile(self.regionfiles[(x,z)], chunkclass = self.chunkclass)
                regionfile.loc = Location(x=x,z=z)
                close_after_use = True
            try:
                yield regionfile
            finally:
                if close_after_use:
                    regionfile.close()
1131294
def get_region():
    
    log = logging.getLogger(mod_logger + '.get_region')

    # First get the availability zone
    availability_zone = get_availability_zone()

    if availability_zone is None:
        msg = 'Unable to determine the Availability Zone for this system, cannot determine the AWS Region'
        log.error(msg)
        return

    # Strip of the last character to get the region
    region = availability_zone[:-1]
    return region
1098207
@Override
	public Promise get(String key) {
		try {
			int pos = partitionPosition(key, true);

			// Prefix is the name of the partition / region (eg.
			// "user" from the "user.name" cache key)
			String prefix = key.substring(0, pos);
			javax.cache.Cache<String, byte[]> partition = getPartition(prefix);
			if (partition != null) {
				byte[] bytes = partition.get(key.substring(pos + 1));
				if (bytes != null) {
					Tree root = serializer.read(bytes);
					Tree content = root.get(CONTENT);
					if (content != null) {
						return Promise.resolve(content);
					}
					return Promise.resolve(root);
				}
			}
		} catch (Throwable cause) {
			logger.warn("Unable to get data from JCache!", cause);
		}
		return Promise.resolve((Object) null);
	}
994893
def shared_s3_app_bucket(self, include_region=False):
        
        if include_region:
            shared_s3_app_bucket = self.format['shared_s3_app_region_bucket'].format(**self.data)
        else:
            shared_s3_app_bucket = self.format['shared_s3_app_bucket'].format(**self.data)
        return shared_s3_app_bucket
538773
public FetchRet fetch(String url, String bucket) throws QiniuException {
        return fetch(url, bucket, null);
    }