Skip to content
Merged
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
31 changes: 29 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/S3Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected void setProperties(Map<String, String> properties) throws DdlException
|| Boolean.parseBoolean(properties.get(S3_VALIDITY_CHECK));
LOG.debug("s3 info need check validity : {}", needCheck);
if (needCheck) {
boolean available = pingS3();
boolean available = pingS3(this.properties);
if (!available) {
throw new DdlException("S3 can't use, please check your properties");
}
Expand All @@ -149,7 +149,7 @@ protected void setProperties(Map<String, String> properties) throws DdlException
checkOptionalProperty(S3_CONNECTION_TIMEOUT_MS, DEFAULT_S3_CONNECTION_TIMEOUT_MS);
}

private boolean pingS3() {
private boolean pingS3(Map<String, String> properties) {
String bucket = "s3://" + properties.getOrDefault(S3_BUCKET, "") + "/";
Map<String, String> propertiesPing = new HashMap<>();
propertiesPing.put("AWS_ACCESS_KEY", properties.getOrDefault(S3_ACCESS_KEY, ""));
Expand Down Expand Up @@ -201,6 +201,33 @@ public void modifyProperties(Map<String, String> properties) throws DdlException
throw new DdlException("current not support modify property : " + any.get());
}
}

boolean needCheck = !this.properties.containsKey(S3_VALIDITY_CHECK)
|| Boolean.parseBoolean(this.properties.get(S3_VALIDITY_CHECK));
if (properties.containsKey(S3_VALIDITY_CHECK)) {
needCheck = Boolean.parseBoolean(properties.get(S3_VALIDITY_CHECK));
}
LOG.debug("s3 info need check validity : {}", needCheck);
if (needCheck) {
Map<String, String> s3Properties = new HashMap<>();
s3Properties.put(S3_BUCKET, properties.containsKey(S3_BUCKET) ? properties.get(S3_BUCKET) :
this.properties.getOrDefault(S3_BUCKET, ""));
s3Properties.put(S3_ACCESS_KEY, properties.containsKey(S3_ACCESS_KEY) ? properties.get(S3_ACCESS_KEY) :
this.properties.getOrDefault(S3_ACCESS_KEY, ""));
s3Properties.put(S3_SECRET_KEY, properties.containsKey(S3_SECRET_KEY) ? properties.get(S3_SECRET_KEY) :
this.properties.getOrDefault(S3_SECRET_KEY, ""));
s3Properties.put(S3_ENDPOINT, properties.containsKey(S3_ENDPOINT) ? properties.get(S3_ENDPOINT) :
this.properties.getOrDefault(S3_ENDPOINT, ""));
s3Properties.put(S3_REGION, properties.containsKey(S3_REGION) ? properties.get(S3_REGION) :
this.properties.getOrDefault(S3_REGION, ""));
s3Properties.put(S3_ROOT_PATH, properties.containsKey(S3_ROOT_PATH) ? properties.get(S3_ROOT_PATH) :
this.properties.getOrDefault(S3_ROOT_PATH, ""));
boolean available = pingS3(s3Properties);
if (!available) {
throw new DdlException("S3 can't use, please check your properties");
}
}

// modify properties
writeLock();
for (Map.Entry<String, String> kv : properties.entrySet()) {
Expand Down