use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project beam by apache.
the class S3FileSystemTest method matchNonGlobWithS3Options.
@Test
public void matchNonGlobWithS3Options() {
S3FileSystem s3FileSystem = buildMockedS3FileSystem(s3Options());
S3ResourceId path = S3ResourceId.fromUri("s3://testbucket/testdirectory/filethatexists");
long lastModifiedMillis = 1540000000000L;
ObjectMetadata s3ObjectMetadata = new ObjectMetadata();
s3ObjectMetadata.setContentLength(100);
s3ObjectMetadata.setContentEncoding("read-seek-efficient");
s3ObjectMetadata.setLastModified(new Date(lastModifiedMillis));
when(s3FileSystem.getAmazonS3Client().getObjectMetadata(argThat(new GetObjectMetadataRequestMatcher(new GetObjectMetadataRequest(path.getBucket(), path.getKey()))))).thenReturn(s3ObjectMetadata);
MatchResult result = s3FileSystem.matchNonGlobPath(path);
assertThat(result, MatchResultMatcher.create(ImmutableList.of(MatchResult.Metadata.builder().setSizeBytes(100).setLastModifiedMillis(lastModifiedMillis).setResourceId(path).setIsReadSeekEfficient(true).build())));
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project beam by apache.
the class S3FileSystemTest method matchNonGlobNotReadSeekEfficientWithS3Options.
@Test
public void matchNonGlobNotReadSeekEfficientWithS3Options() {
S3FileSystem s3FileSystem = buildMockedS3FileSystem(s3Options());
S3ResourceId path = S3ResourceId.fromUri("s3://testbucket/testdirectory/filethatexists");
long lastModifiedMillis = 1540000000000L;
ObjectMetadata s3ObjectMetadata = new ObjectMetadata();
s3ObjectMetadata.setContentLength(100);
s3ObjectMetadata.setLastModified(new Date(lastModifiedMillis));
s3ObjectMetadata.setContentEncoding("gzip");
when(s3FileSystem.getAmazonS3Client().getObjectMetadata(argThat(new GetObjectMetadataRequestMatcher(new GetObjectMetadataRequest(path.getBucket(), path.getKey()))))).thenReturn(s3ObjectMetadata);
MatchResult result = s3FileSystem.matchNonGlobPath(path);
assertThat(result, MatchResultMatcher.create(ImmutableList.of(MatchResult.Metadata.builder().setSizeBytes(100).setLastModifiedMillis(lastModifiedMillis).setResourceId(path).setIsReadSeekEfficient(false).build())));
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project beam by apache.
the class S3FileSystemTest method testMultipartCopy.
private void testMultipartCopy(S3FileSystem s3FileSystem, SSECustomerKey sseCustomerKey, long s3UploadBufferSizeBytes) {
S3ResourceId sourcePath = S3ResourceId.fromUri(s3FileSystem.getScheme() + "://bucket/from");
S3ResourceId destinationPath = S3ResourceId.fromUri(s3FileSystem.getScheme() + "://bucket/to");
InitiateMultipartUploadResult initiateMultipartUploadResult = new InitiateMultipartUploadResult();
initiateMultipartUploadResult.setUploadId("upload-id");
String sseCustomerKeyMd5 = toMd5(sseCustomerKey);
if (sseCustomerKeyMd5 != null) {
initiateMultipartUploadResult.setSSECustomerKeyMd5(sseCustomerKeyMd5);
}
when(s3FileSystem.getAmazonS3Client().initiateMultipartUpload(any(InitiateMultipartUploadRequest.class))).thenReturn(initiateMultipartUploadResult);
assertEquals(sseCustomerKeyMd5, s3FileSystem.getAmazonS3Client().initiateMultipartUpload(new InitiateMultipartUploadRequest(destinationPath.getBucket(), destinationPath.getKey())).getSSECustomerKeyMd5());
ObjectMetadata sourceObjectMetadata = new ObjectMetadata();
sourceObjectMetadata.setContentLength((long) (s3UploadBufferSizeBytes * 1.5));
sourceObjectMetadata.setContentEncoding("read-seek-efficient");
if (sseCustomerKeyMd5 != null) {
sourceObjectMetadata.setSSECustomerKeyMd5(sseCustomerKeyMd5);
}
assertGetObjectMetadata(s3FileSystem, createObjectMetadataRequest(sourcePath, sseCustomerKey), sseCustomerKeyMd5, sourceObjectMetadata);
CopyPartResult copyPartResult1 = new CopyPartResult();
copyPartResult1.setETag("etag-1");
CopyPartResult copyPartResult2 = new CopyPartResult();
copyPartResult1.setETag("etag-2");
if (sseCustomerKeyMd5 != null) {
copyPartResult1.setSSECustomerKeyMd5(sseCustomerKeyMd5);
copyPartResult2.setSSECustomerKeyMd5(sseCustomerKeyMd5);
}
CopyPartRequest copyPartRequest = new CopyPartRequest();
copyPartRequest.setSourceSSECustomerKey(sseCustomerKey);
when(s3FileSystem.getAmazonS3Client().copyPart(any(CopyPartRequest.class))).thenReturn(copyPartResult1).thenReturn(copyPartResult2);
assertEquals(sseCustomerKeyMd5, s3FileSystem.getAmazonS3Client().copyPart(copyPartRequest).getSSECustomerKeyMd5());
s3FileSystem.multipartCopy(sourcePath, destinationPath, sourceObjectMetadata);
verify(s3FileSystem.getAmazonS3Client(), times(1)).completeMultipartUpload(any(CompleteMultipartUploadRequest.class));
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project beam by apache.
the class S3FileSystemTest method matchGlobWithSlashesWithS3Options.
@Test
public void matchGlobWithSlashesWithS3Options() throws IOException {
S3FileSystem s3FileSystem = buildMockedS3FileSystem(s3Options());
S3ResourceId path = S3ResourceId.fromUri("s3://testbucket/foo/bar\\baz*");
ListObjectsV2Request request = new ListObjectsV2Request().withBucketName(path.getBucket()).withPrefix(path.getKeyNonWildcardPrefix()).withContinuationToken(null);
// Expected to be returned; prefix and wildcard/regex match
S3ObjectSummary firstMatch = new S3ObjectSummary();
firstMatch.setBucketName(path.getBucket());
firstMatch.setKey("foo/bar\\baz0");
firstMatch.setSize(100);
firstMatch.setLastModified(new Date(1540000000001L));
// Expected to not be returned; prefix matches, but substring after wildcard does not
S3ObjectSummary secondMatch = new S3ObjectSummary();
secondMatch.setBucketName(path.getBucket());
secondMatch.setKey("foo/bar/baz1");
secondMatch.setSize(200);
secondMatch.setLastModified(new Date(1540000000002L));
// Expected first request returns continuation token
ListObjectsV2Result result = new ListObjectsV2Result();
result.getObjectSummaries().add(firstMatch);
result.getObjectSummaries().add(secondMatch);
when(s3FileSystem.getAmazonS3Client().listObjectsV2(argThat(new ListObjectsV2RequestArgumentMatches(request)))).thenReturn(result);
// Expect object metadata queries for content encoding
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentEncoding("");
when(s3FileSystem.getAmazonS3Client().getObjectMetadata(anyObject())).thenReturn(metadata);
assertThat(s3FileSystem.matchGlobPaths(ImmutableList.of(path)).get(0), MatchResultMatcher.create(ImmutableList.of(MatchResult.Metadata.builder().setIsReadSeekEfficient(true).setResourceId(S3ResourceId.fromComponents("s3", firstMatch.getBucketName(), firstMatch.getKey())).setSizeBytes(firstMatch.getSize()).setLastModifiedMillis(firstMatch.getLastModified().getTime()).build())));
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project jackrabbit by apache.
the class S3RequestDecorator method decorate.
/**
* Set encryption in {@link PutObjectRequest}
*/
public PutObjectRequest decorate(PutObjectRequest request) {
switch(getDataEncryption()) {
case SSE_S3:
ObjectMetadata metadata = request.getMetadata() == null ? new ObjectMetadata() : request.getMetadata();
metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
request.setMetadata(metadata);
break;
case NONE:
break;
}
return request;
}
Aggregations