Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/com/emc/object/s3/S3Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ public interface S3Client {
/**
* Sets whether stale reads are allowed on <code>bucketName</code>. If true, during a temporary site outage (TSO),
* objects in the bucket may still be read from secondary sites, but these reads are not guaranteed to be strongly
* consistent (they may be stale if the primary site is inaccessible). Note that stale reads are <strong>not</strong>
* supported on {@link CreateBucketRequest#setFileSystemEnabled(Boolean) filesystem} buckets.
* consistent (they may be stale if the primary site is inaccessible).
* Note :
* That stale reads are <strong>not</strong> supported on {@link CreateBucketRequest#setFileSystemEnabled(Boolean) filesystem} buckets.
* That stale reads are <strong>supported</strong> on {@link CreateBucketRequest#setFileSystemEnabledOnADO(Boolean) filesystem} buckets.
*/
void setBucketStaleReadAllowed(String bucketName, boolean staleReadsAllowed);

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/emc/object/s3/request/CreateBucketRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class CreateBucketRequest extends AbstractBucketRequest {
private AccessControlList acl;
private String vPoolId;
private Boolean fileSystemEnabled;
private Boolean fileSystemEnabledOnADO;
private Boolean staleReadAllowed;
private Boolean encryptionEnabled;
private Long retentionPeriod;
Expand All @@ -62,6 +63,10 @@ public Map<String, List<Object>> getHeaders() {
if (acl != null) headers.putAll(acl.toHeaders());
if (vPoolId != null) RestUtil.putSingle(headers, RestUtil.EMC_VPOOL, vPoolId);
if (fileSystemEnabled != null) RestUtil.putSingle(headers, RestUtil.EMC_FS_ENABLED, fileSystemEnabled);
if (fileSystemEnabledOnADO != null) {
RestUtil.putSingle(headers, RestUtil.EMC_FS_ENABLED, fileSystemEnabledOnADO);
RestUtil.add(headers, RestUtil.EMC_TSO_READONLY, Boolean.TRUE);
}
if (staleReadAllowed != null) RestUtil.putSingle(headers, RestUtil.EMC_STALE_READ_ALLOWED, staleReadAllowed);
if (encryptionEnabled != null) RestUtil.putSingle(headers, RestUtil.EMC_ENCRYPTION_ENABLED, encryptionEnabled);
if (retentionPeriod != null) RestUtil.putSingle(headers, RestUtil.EMC_RETENTION_PERIOD, retentionPeriod);
Expand Down Expand Up @@ -99,15 +104,31 @@ public Boolean getFileSystemEnabled() {
return fileSystemEnabled;
}

public Boolean getFileSystemEnabledOnADO() {
return fileSystemEnabledOnADO;
}

/**
* Sets whether the bucket can be access via filesystem (i.e. HDFS). This will enable some internal semantics for
* directories and may affect other features (i.e.
* {@link com.emc.object.s3.S3Client#setBucketStaleReadAllowed(String, boolean) TSO support})
*/
public void setFileSystemEnabled(Boolean fileSystemEnabled) {
if(this.fileSystemEnabledOnADO != null) this.fileSystemEnabledOnADO = null;
this.fileSystemEnabled = fileSystemEnabled;
}

/**
* Sets whether the bucket can be access via filesystem (i.e. HDFS) using ADO semantics.
* This will enable some internal semantics for directories and may affect other features (i.e.
* {@link com.emc.object.s3.S3Client#setBucketStaleReadAllowed(String, boolean) TSO support})
* Note that this will override any existing file system enabled setting.
*/
public void setFileSystemEnabledOnADO(Boolean fileSystemEnabledOnADO) {
if(this.fileSystemEnabled != null) this.fileSystemEnabled = null;
this.fileSystemEnabledOnADO = fileSystemEnabledOnADO;
}

public Boolean getStaleReadAllowed() {
return staleReadAllowed;
}
Expand Down Expand Up @@ -184,10 +205,32 @@ public CreateBucketRequest withVPoolId(String vPoolId) {
return this;
}

/**
* Sets whether the bucket can be accessed via a filesystem (i.e. HDFS) and returns this request object.
*
* This will enable some internal semantics for directories and may affect other features.
* Note that this will override any existing file system enabled with ADO setting.
*
* @param fileSystemEnabled Whether to enable filesystem access on the bucket of non-ADO enabled namespace
* @return this request object
*/
public CreateBucketRequest withFileSystemEnabled(boolean fileSystemEnabled) {
setFileSystemEnabled(fileSystemEnabled);
return this;
}
/**
* Sets whether the bucket can be accessed via a filesystem (i.e. HDFS) using ADO semantics and returns this request object.
*
* This will enable some internal semantics for directories and may affect other features.
* Note that this will override any existing file system enabled setting.
*
* @param fileSystemEnabledOnADO Whether to enable filesystem access via ADO semantics on the bucket of ADO enabled namespace
* @return this request object
*/
public CreateBucketRequest withFileSystemEnabledOnADO(boolean fileSystemEnabledOnADO) {
setFileSystemEnabledOnADO(fileSystemEnabledOnADO);
return this;
}

public CreateBucketRequest withStaleReadAllowed(boolean staleReadAllowed) {
setStaleReadAllowed(staleReadAllowed);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/emc/object/util/RestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public final class RestUtil {
public static final String EMC_COPY_MODE = EMC_PREFIX + "copy-mode";
public final static String EMC_MULTIPART_COPY = EMC_PREFIX + "multipart-copy";
public final static String EMC_EMPTY_BUCKET = EMC_PREFIX + "empty-bucket";
public final static String EMC_TSO_READONLY = EMC_PREFIX + "is-tso-read-only";

public static final String TYPE_APPLICATION_OCTET_STREAM = "application/octet-stream";
public static final String TYPE_APPLICATION_XML = "application/xml";
public static final String TYPE_APPLICATION_JSON = "application/json";
Expand Down
23 changes: 21 additions & 2 deletions src/test/java/com/emc/object/s3/S3JerseyClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,29 @@ public void testCreateFilesystemBucket() {
Assume.assumeFalse("FS buckets are not supported with IAM user.", isIamUser);

String bucketName = getTestBucket() + "-y";
try {
client.createBucket(new CreateBucketRequest(bucketName).withFileSystemEnabled(true));

client.createBucket(new CreateBucketRequest(bucketName).withFileSystemEnabled(true));
client.deleteBucket(bucketName);
} catch (S3Exception e) {
Assert.assertEquals(409, e.getHttpCode());
Assert.assertEquals("InvalidBucketState", e.getErrorCode());
}
}

client.deleteBucket(bucketName);
@Test
public void testCreateFilesystemBucketOnADO() {
Assume.assumeFalse("FS buckets are not supported with IAM user.", isIamUser);

String bucketName = getTestBucket() + "-ado";
try {
client.createBucket(new CreateBucketRequest(bucketName).withFileSystemEnabledOnADO(true));

client.deleteBucket(bucketName);
} catch (S3Exception e) {
Assert.assertEquals(409, e.getHttpCode());
Assert.assertEquals("InvalidBucketState", e.getErrorCode());
}
}

@Test
Expand Down