deardeng commented on code in PR #10693:
URL: https://github.com/apache/doris/pull/10693#discussion_r917532186
##########
fe/fe-core/src/main/java/org/apache/doris/policy/StoragePolicy.java:
##########
@@ -149,26 +190,55 @@ public void init(final Map<String, String> props) throws
AnalysisException {
if (!hasCooldownDatetime && !hasCooldownTtl) {
throw new AnalysisException(COOLDOWN_DATETIME + " or " +
COOLDOWN_TTL + " must be set");
}
- if
(!Catalog.getCurrentCatalog().getResourceMgr().containsResource(this.storageResource))
{
- throw new AnalysisException("storage resource doesn't exist: " +
this.storageResource);
+
+ // no set ttl use -1
+ if (!hasCooldownTtl) {
+ this.cooldownTtl = "-1";
+ }
+
+ Resource r = checkIsS3ResourceAndExist(this.storageResource);
+ if (!((S3Resource) r).policyAddToSet(super.getPolicyName()) &&
!ifNotExists) {
+ throw new AnalysisException("this policy has been added to s3
resource once, policy has been created.");
+ }
+ this.md5Checksum = calcPropertiesMd5();
+ }
+
+ private static Resource checkIsS3ResourceAndExist(final String
storageResource) throws AnalysisException {
+ // check storage_resource type is S3, current just support S3
+ Resource resource =
+
Optional.ofNullable(Catalog.getCurrentCatalog().getResourceMgr().getResource(storageResource))
+ .orElseThrow(() -> new AnalysisException("storage resource
doesn't exist: " + storageResource));
+
+ if (resource.getType() != Resource.ResourceType.S3) {
+ throw new AnalysisException("current storage policy just support
resource type S3");
}
+ return resource;
}
/**
* Use for SHOW POLICY.
**/
public List<String> getShowInfo() throws AnalysisException {
- String props = "";
+ final String[] props = {""};
Review Comment:
java lambda syntax, in the lambda function, i will change props[0] as ref.
no use props[1], props[2].
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]