當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。