当前位置: 首页>>代码示例>>Java>>正文


Java AmazonS3URI.getBucket方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3URI.getBucket方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3URI.getBucket方法的具体用法?Java AmazonS3URI.getBucket怎么用?Java AmazonS3URI.getBucket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.AmazonS3URI的用法示例。


在下文中一共展示了AmazonS3URI.getBucket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setConf

import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
@Override
public void setConf(AbstractConfig config) {
  this.config = (GeoIpOperationConfig) config;
  AmazonS3Client client = this.s3Factory.newInstance();

  AmazonS3URI uri = new AmazonS3URI(this.config.getGeoLiteDb());
  GetObjectRequest req = new GetObjectRequest(uri.getBucket(), uri.getKey());
  S3Object obj = client.getObject(req);

  try {
    this.databaseReader =
        new DatabaseReader.Builder(obj.getObjectContent()).withCache(new CHMCache()).build();
  } catch (IOException e) {
    throw new ConfigurationException("Unable to read " + this.config.getGeoLiteDb(), e);
  }
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:17,代码来源:GeoIpOperationFactory.java

示例2: parse

import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
/**
 * Parse string representing an AWS S3 URI
 */
protected void parse(String s3UriStr) {
	s3uri = new AmazonS3URI(s3UriStr);
	bucketName = s3uri.getBucket();
	key = s3uri.getKey();

	// Parse and set region
	String regionStr = s3uri.getRegion();
	try {
		//			if (regionStr == null) regionStr = Config.get().getString(Config.AWS_REGION, DEFAULT_AWS_REGION);
		//			region = Region.getRegion(Regions.valueOf(regionStr.toUpperCase()));
		if (regionStr != null) region = Region.getRegion(Regions.valueOf(regionStr.toUpperCase()));
	} catch (Exception e) {
		throw new RuntimeException("Cannot parse AWS region '" + regionStr + "'", e);
	}
}
 
开发者ID:pcingola,项目名称:BigDataScript,代码行数:19,代码来源:DataS3.java

示例3: BucketKey

import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
public BucketKey(String inputFilePath, String outputFilePath){
    AmazonS3URI srcURI = new AmazonS3URI(inputFilePath);
    AmazonS3URI destURI = new AmazonS3URI(outputFilePath);
    this.srcBucket = srcURI.getBucket();
    this.srcKey = srcURI.getKey();
    this.destBucket = destURI.getBucket();
    this.destPrefix = destURI.getKey();
}
 
开发者ID:awslabs,项目名称:s3-inventory-usage-examples,代码行数:9,代码来源:BucketKey.java

示例4: submitCopyJobsFromListing

import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
private void submitCopyJobsFromListing(
    AmazonS3URI sourceS3Uri,
    final AmazonS3URI targetS3Uri,
    ListObjectsRequest request,
    ObjectListing listing) {
  LOG.debug("Found objects to copy {}, for request {}/{}", listing.getObjectSummaries(), request.getBucketName(),
      request.getPrefix());
  List<S3ObjectSummary> objectSummaries = listing.getObjectSummaries();
  for (final S3ObjectSummary s3ObjectSummary : objectSummaries) {
    String fileName = StringUtils.removeStart(s3ObjectSummary.getKey(), sourceS3Uri.getKey());
    final String targetKey = Strings.nullToEmpty(targetS3Uri.getKey()) + fileName;
    LOG.info("copying object from '{}/{}' to '{}/{}'", s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey(),
        targetS3Uri.getBucket(), targetKey);

    CopyObjectRequest copyObjectRequest = new CopyObjectRequest(s3ObjectSummary.getBucketName(),
        s3ObjectSummary.getKey(), targetS3Uri.getBucket(), targetKey);

    TransferStateChangeListener stateChangeListener = new TransferStateChangeListener() {

      @Override
      public void transferStateChanged(Transfer transfer, TransferState state) {
        if (state == TransferState.Completed) {
          // NOTE: running progress doesn't seem to be reported correctly.
          // transfer.getProgress().getBytesTransferred() is always 0. Unsure what is the cause of this at this moment
          // so just printing total bytes when completed.
          LOG.debug("copied object from '{}/{}' to '{}/{}': {} bytes transferred", s3ObjectSummary.getBucketName(),
              s3ObjectSummary.getKey(), targetS3Uri.getBucket(), targetKey,
              transfer.getProgress().getTotalBytesToTransfer());
        }
      }
    };
    Copy copy = transferManager.copy(copyObjectRequest, srcClient, stateChangeListener);
    totalBytesToReplicate += copy.getProgress().getTotalBytesToTransfer();
    copyJobs.add(copy);
  }
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:37,代码来源:S3S3Copier.java

示例5: putByteSequence

import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
@Override
public void putByteSequence(ByteSequence byteSequence, Key key, @Nullable MutableObjectMetadata metadata)
        throws IOException {
    @Nullable String byteSequenceBucket = null;
    @Nullable String byteSequenceKey = null;
    @Nullable URI byteSequenceURI = byteSequence.getURI();
    if (byteSequenceURI != null && "s3".equals(byteSequenceURI.getScheme())) {
        byteSequenceBucket = byteSequenceURI.getAuthority();
        byteSequenceKey = byteSequenceURI.getPath();
    }

    if (byteSequenceBucket == null || byteSequenceBucket.isEmpty() || byteSequenceKey == null
            || byteSequenceKey.isEmpty()) {
        @Nullable AmazonS3URI amazonS3URI = uriToAmazonS3Uri(byteSequenceURI);
        if (amazonS3URI != null) {
            byteSequenceBucket = amazonS3URI.getBucket();
            byteSequenceKey = amazonS3URI.getKey();
        }
    }

    boolean wroteByteSequence = false;
    if (byteSequenceBucket != null && !byteSequenceBucket.isEmpty() && byteSequenceKey != null
            && !byteSequenceKey.isEmpty()) {
        // Best case: If the byte sequence originates from S3, simply perform a S3 copy operation
        try {
            s3Connection.getS3Client().copyObject(
                byteSequenceBucket, byteSequenceKey, bucketName, targetPath(key).toString()
            );
            wroteByteSequence = true;
        } catch (AmazonClientException exception) {
            log.info(String.format(
                "Request for S3 server-side copy from 's3://%s/%s' to '%s' failed. This is not yet a "
                    + "problem, will attempt client-side copy instead.",
                byteSequenceBucket, byteSequenceKey, createS3Uri(targetPath(key))
            ), exception);
        }
    }

    if (!wroteByteSequence) {
        try (
            InputStream inputStream = byteSequence.newInputStream();
            OutputStream outputStream
                = s3Connection.newBufferedOutputStream(bucketName, targetPath(key).toString())
        ) {
            copy(inputStream, outputStream);
        }
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:49,代码来源:S3StagingArea.java

示例6: loadFromTo

import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
/**
 * A method that creates an InputStream on a specific range of the file.
 * InputStream classes wrapping order can be reversed.
 *
 * @param obj    target file URI
 * @param offset range start position
 * @param end    range end position
 * @return an InputStream object on the specific range of the file.
 */
public InputStream loadFromTo(AmazonS3URI obj, long offset, long end) {
    GetObjectRequest rangeObjectRequest = new GetObjectRequest(obj.getBucket(), obj.getKey());
    rangeObjectRequest.setRange(offset, end);
    S3Object s3Object = client.getAws().getObject(rangeObjectRequest);
    PerformanceMonitor.logRequest();
    S3ObjectInputStream objectStream = s3Object.getObjectContent();
    return new MonitoredInputStream(new BufferedInputStream(objectStream));
}
 
开发者ID:epam,项目名称:htsjdk-s3-plugin,代码行数:18,代码来源:S3InputStreamFactory.java


注:本文中的com.amazonaws.services.s3.AmazonS3URI.getBucket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。