Skip to content

Commit

Permalink
Merge pull request #1894 from t-rana/issues/OAK-11266
Browse files Browse the repository at this point in the history
OAK-11266 : Create a new mode GCP for Blob cloud
  • Loading branch information
rishabhdaim authored Dec 13, 2024
2 parents 9bc52a5 + 2cfc549 commit c410780
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,20 @@ public void setBucket(String bucket) {
*/
public void setProperties(Properties properties) {
this.properties = properties;
setRemoteStorageMode();
}

private void setRemoteStorageMode() {
String s3EndPoint = properties.getProperty(S3Constants.S3_END_POINT, "");
if (s3EndPoint.contains("googleapis")) {
if (properties.get(S3Constants.MODE) == RemoteStorageMode.S3) {
LOG.warn("Mismatch between remote storage mode and s3EndPoint, overriding mode to GCP");
}
properties.put(S3Constants.MODE, RemoteStorageMode.GCP);
return;
}
// default mode is S3
properties.put(S3Constants.MODE, RemoteStorageMode.S3);
}

@Override
Expand Down Expand Up @@ -1350,4 +1364,12 @@ public KeyRenameThread(String oldKey) {
this.oldKey = oldKey;
}
}

/**
* Enum to indicate remote storage mode
*/
private enum RemoteStorageMode {
S3,
GCP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ public final class S3Constants {
*/
public static final String PROXY_PORT = "proxyPort";

/**
* Constant to set remote storage mode
*/
public static final String MODE = "mode";

public static final String PRESIGNED_HTTP_UPLOAD_URI_EXPIRY_SECONDS = "presignedHttpUploadURIExpirySeconds";

public static final String PRESIGNED_HTTP_DOWNLOAD_URI_EXPIRY_SECONDS = "presignedHttpDownloadURIExpirySeconds";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void setUp() throws Exception {
@Test
public void testAccessParamLeakOnError() throws Exception {
expectedEx.expect(RepositoryException.class);
expectedEx.expectMessage("Could not initialize S3 from {s3Region=us-standard, intValueKey=25}");
expectedEx.expectMessage("Could not initialize S3 from {mode=S3, s3Region=us-standard, intValueKey=25}");

props.put(S3Constants.ACCESS_KEY, "abcd");
props.put(S3Constants.SECRET_KEY, "123456");
Expand Down

0 comments on commit c410780

Please sign in to comment.