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


Java PutObjectResult.setETag方法代码示例

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


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

示例1: putObject

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
@SuppressWarnings("resource")
@Override
public PutObjectResult putObject(PutObjectRequest putObjectRequest) throws AmazonClientException, AmazonServiceException {
    putObjectRequests.add(putObjectRequest);
    
    S3Object s3Object = new S3Object();
    s3Object.setBucketName(putObjectRequest.getBucketName());
    s3Object.setKey(putObjectRequest.getKey());
    if (putObjectRequest.getFile() != null) {
        try {
            s3Object.setObjectContent(new FileInputStream(putObjectRequest.getFile()));
        } catch (FileNotFoundException e) {
            throw new AmazonServiceException("Cannot store the file object.", e);
        }
    } else {
        s3Object.setObjectContent(putObjectRequest.getInputStream());
    }
    objects.add(s3Object);
    
    PutObjectResult putObjectResult = new PutObjectResult();
    putObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    return putObjectResult;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:24,代码来源:AmazonS3ClientMock.java

示例2: starting

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
@Override
protected void starting(Description description)
{
  super.starting(description);
  outputPath = new File(
      "target" + Path.SEPARATOR + description.getClassName() + Path.SEPARATOR + description.getMethodName())
          .getPath();

  Attribute.AttributeMap attributes = new Attribute.AttributeMap.DefaultAttributeMap();
  attributes.put(DAG.DAGContext.APPLICATION_ID, description.getClassName());
  attributes.put(DAG.DAGContext.APPLICATION_PATH, outputPath);
  context = mockOperatorContext(1, attributes);

  underTest = new S3Reconciler();
  underTest.setAccessKey("");
  underTest.setSecretKey("");

  underTest.setup(context);

  MockitoAnnotations.initMocks(this);
  PutObjectResult result = new PutObjectResult();
  result.setETag(outputPath);
  when(s3clientMock.putObject((PutObjectRequest)any())).thenReturn(result);
  underTest.setS3client(s3clientMock);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:26,代码来源:S3ReconcilerTest.java

示例3: createPutObjectResult

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
private static PutObjectResult createPutObjectResult(ObjectMetadata metadata) {
    final PutObjectResult result = new PutObjectResult();
    result.setVersionId(metadata.getVersionId());
    result.setSSEAlgorithm(metadata.getSSEAlgorithm());
    result.setSSECustomerAlgorithm(metadata.getSSECustomerAlgorithm());
    result.setSSECustomerKeyMd5(metadata.getSSECustomerKeyMd5());
    result.setExpirationTime(metadata.getExpirationTime());
    result.setExpirationTimeRuleId(metadata.getExpirationTimeRuleId());
    result.setETag(metadata.getETag());
    result.setMetadata(metadata);
    result.setRequesterCharged(metadata.isRequesterCharged());
    return result;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:AmazonS3Client.java

示例4: testWriteWithCancel

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
@Test
public void testWriteWithCancel()
        throws Exception {
    URI baseUri = URI.create("s3://test-bucket/scan");
    ScheduledExecutorService uploadService = Executors.newScheduledThreadPool(2);

    try {
        PutObjectResult putObjectResult = new PutObjectResult();
        putObjectResult.setETag("dummy-etag");

        AmazonS3 amazonS3 = mock(AmazonS3.class);
        when(amazonS3.putObject(argThat(putsIntoBucket("test-bucket"))))
                .thenReturn(putObjectResult);

        AmazonS3Provider amazonS3Provider = mock(AmazonS3Provider.class);
        when(amazonS3Provider.getS3ClientForBucket("test-bucket")).thenReturn(amazonS3);

        S3ScanWriter scanWriter = new S3ScanWriter(1, baseUri, Optional.of(2), new MetricRegistry(), amazonS3Provider, uploadService);

        ShardWriter shardWriter[] = new ShardWriter[2];

        for (int i=0; i < 2; i++) {
            shardWriter[i] = scanWriter.writeShardRows("table" + i, "p0", 0, i);
            shardWriter[i].getOutputStream().write("line0\n".getBytes(Charsets.UTF_8));
        }

        // Simulate canceling shardWriter[0] in response to a failure.
        shardWriter[0].closeAndCancel();
        // Close shardWriter[1] normally
        shardWriter[1].closeAndTransferAysnc(Optional.of(1));

        verifyAllTransfersComplete(scanWriter, uploadService);
    } finally {
        uploadService.shutdownNow();
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:37,代码来源:S3ScanWriterTest.java

示例5: testWriteWithClose

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
@Test
public void testWriteWithClose()
        throws Exception {

    URI baseUri = URI.create("s3://test-bucket/scan");
    ScheduledExecutorService uploadService = Executors.newScheduledThreadPool(2);

    try {
        PutObjectResult putObjectResult = new PutObjectResult();
        putObjectResult.setETag("dummy-etag");

        AmazonS3 amazonS3 = mock(AmazonS3.class);
        when(amazonS3.putObject(argThat(putsIntoBucket("test-bucket"))))
                .thenReturn(putObjectResult);

        AmazonS3Provider amazonS3Provider = mock(AmazonS3Provider.class);
        when(amazonS3Provider.getS3ClientForBucket("test-bucket")).thenReturn(amazonS3);

        S3ScanWriter scanWriter = new S3ScanWriter(1, baseUri, Optional.of(2), new MetricRegistry(), amazonS3Provider, uploadService);

        ShardWriter shardWriter[] = new ShardWriter[2];

        for (int i=0; i < 2; i++) {
            shardWriter[i] = scanWriter.writeShardRows("table" + i, "p0", 0, i);
            shardWriter[i].getOutputStream().write("line0\n".getBytes(Charsets.UTF_8));
        }

        // Simulate closing shardWriter[0] but not shardWriter[1]
        shardWriter[0].closeAndTransferAysnc(Optional.of(1));

        scanWriter.close();

        verifyAllTransfersComplete(scanWriter, uploadService);
    } finally {
        uploadService.shutdownNow();
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:38,代码来源:S3ScanWriterTest.java

示例6: mockUploadS3File

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
private PutObjectResult mockUploadS3File(String bucket, String key, byte[] contents, HashBasedTable<String, String, ByteBuffer> s3FileTable) {
    // Place the contents in the s3 file table keyed by the file's parent directory and file name
    int idx = key.lastIndexOf('/');
    String parentDir = key.substring(0, idx);
    String fileName = key.substring(idx + 1);
    // HashBasedTable is not thread-safe if multiple threads try to write to the same directory concurrently
    synchronized (s3FileTable) {
        s3FileTable.put(format("%s/%s", bucket, parentDir), fileName, ByteBuffer.wrap(contents));
    }

    PutObjectResult result = new PutObjectResult();
    result.setETag("etag");
    return result;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:15,代码来源:ScanUploaderTest.java

示例7: testS3OutputModule

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
@Test
public void testS3OutputModule() throws Exception
{
  InitiateMultipartUploadResult result = new InitiateMultipartUploadResult();
  result.setUploadId(uploadId);

  PutObjectResult objResult = new PutObjectResult();
  objResult.setETag("SuccessFullyUploaded");

  UploadPartResult partResult = new UploadPartResult();
  partResult.setPartNumber(1);
  partResult.setETag("SuccessFullyPartUploaded");

  MockitoAnnotations.initMocks(this);
  when(client.initiateMultipartUpload(any(InitiateMultipartUploadRequest.class))).thenReturn(result);
  when(client.putObject(any(PutObjectRequest.class))).thenReturn(objResult);
  when(client.uploadPart(any(UploadPartRequest.class))).thenReturn(partResult);
  when(client.completeMultipartUpload(any(CompleteMultipartUploadRequest.class))).thenReturn(completeMultiPart());

  Application app = new S3OutputModuleMockTest.Application();
  Configuration conf = new Configuration();
  conf.set("dt.operator.HDFSInputModule.prop.files", inputDir);
  conf.set("dt.operator.HDFSInputModule.prop.blockSize", "10");
  conf.set("dt.operator.HDFSInputModule.prop.blocksThreshold", "1");
  conf.set("dt.attr.CHECKPOINT_WINDOW_COUNT","20");

  conf.set("dt.operator.S3OutputModule.prop.accessKey", "accessKey");
  conf.set("dt.operator.S3OutputModule.prop.secretAccessKey", "secretKey");
  conf.set("dt.operator.S3OutputModule.prop.bucketName", "bucketKey");
  conf.set("dt.operator.S3OutputModule.prop.outputDirectoryPath", outputDir);

  Path outDir = new Path("file://" + new File(outputDir).getAbsolutePath());
  final Path outputFilePath =  new Path(outDir.toString() + File.separator + FILE);
  final FileSystem fs = FileSystem.newInstance(outDir.toUri(), new Configuration());
  LocalMode lma = LocalMode.newInstance();
  lma.prepareDAG(app, conf);
  LocalMode.Controller lc = lma.getController();
  lc.setHeartbeatMonitoringEnabled(true);

  ((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>()
  {
    @Override
    public Boolean call() throws Exception
    {
      return fs.exists(outputFilePath);
    }
  });
  lc.run(10000);

  Assert.assertTrue("output file exist", fs.exists(outputFilePath));
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:52,代码来源:S3OutputModuleMockTest.java

示例8: buildPutObjectResult

import com.amazonaws.services.s3.model.PutObjectResult; //导入方法依赖的package包/类
private PutObjectResult buildPutObjectResult(FakeS3Object object) {
    PutObjectResult result = new PutObjectResult();
    result.setETag(object.getETag());
    result.setContentMd5(object.getMd5());
    return result;
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:7,代码来源:FakeBucketsContainer.java


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