morningman commented on code in PR #22048:
URL: https://github.com/apache/doris/pull/22048#discussion_r1335780256
##########
.gitignore:
##########
@@ -114,3 +114,14 @@ lru_cache_test
/conf/log4j2-spring.xml
/fe/fe-core/src/test/resources/real-help-resource.zip
/ui/dist
+
+# ignore pom.xml
+/**/pom.xml
Review Comment:
why ignore pom?
##########
fe/fe-core/src/main/java/org/apache/doris/policy/StoragePolicy.java:
##########
@@ -177,29 +178,42 @@ public void init(final Map<String, String> props, boolean
ifNotExists) throws An
this.cooldownTtl =
getSecondsByCooldownTtl(props.get(COOLDOWN_TTL));
}
- checkIsS3ResourceAndExist(this.storageResource);
+ checkResourceIsExist(this.storageResource);
if (!addResourceReference() && !ifNotExists) {
- throw new AnalysisException("this policy has been added to s3
resource once, policy has been created.");
+ throw new AnalysisException("this policy has been added to s3 or
hdfs resource, policy has been created.");
}
}
- private static Resource checkIsS3ResourceAndExist(final String
storageResource) throws AnalysisException {
- // check storage_resource type is S3, current just support S3
+ private static Resource checkResourceIsExist(final String storageResource)
throws AnalysisException {
Resource resource =
Optional.ofNullable(Env.getCurrentEnv().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_COOLDOWN");
- }
Map<String, String> properties = resource.getCopiedProperties();
- if (!properties.containsKey(S3Properties.ROOT_PATH)) {
- throw new AnalysisException(String.format(
- "Missing [%s] in '%s' resource", S3Properties.ROOT_PATH,
storageResource));
- }
- if (!properties.containsKey(S3Properties.BUCKET)) {
- throw new AnalysisException(String.format(
- "Missing [%s] in '%s' resource", S3Properties.BUCKET,
storageResource));
+ switch (resource.getType()) {
+ case S3:
+ if (!properties.containsKey(S3Properties.ROOT_PATH)) {
+ throw new AnalysisException(String.format(
+ "Missing [%s] in '%s' resource",
S3Properties.ROOT_PATH, storageResource));
+ }
+ if (!properties.containsKey(S3Properties.BUCKET)) {
+ throw new AnalysisException(String.format(
+ "Missing [%s] in '%s' resource", S3Properties.BUCKET,
storageResource));
+ }
+ break;
+ case HDFS:
+ if (!properties.containsKey(HdfsResource.HADOOP_FS_NAME)) {
+ throw new AnalysisException(String.format(
+ "Missing [%s] in '%s' resource",
HdfsResource.HADOOP_FS_NAME, storageResource));
+ }
+ if (!properties.containsKey(HdfsResource.HADOOP_USER_NAME)) {
Review Comment:
I think username is not a required parameter.
And better define the required parameters in a `final static` field, such as
`Set<string> required_paramaters`
--
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]