You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/12/24 06:17:44 UTC

[GitHub] [incubator-doris] Seaven commented on a change in pull request #2463: Add fe plugin framework

Seaven commented on a change in pull request #2463: Add fe plugin framework
URL: https://github.com/apache/incubator-doris/pull/2463#discussion_r361075984
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/plugin/PluginInfo.java
 ##########
 @@ -0,0 +1,190 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.plugin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.doris.common.util.Version;
+
+public class PluginInfo {
+
+    private static final String DEFAULT_PLUGIN_PROPERTIES = "plugin.properties";
+
+    private String name;
+
+    private PluginType type;
+
+    private String description;
+
+    private Version version;
+
+    private Version javaVersion;
+
+    private String className;
+
+    private String soName;
+
+    private String source;
+
+    private String installPath;
+
+    public PluginInfo(String name, PluginType type, String description, Version version, Version javaVersion,
+                      String className, String soName, String source) {
+
+        this.name = name;
+        this.type = type;
+        this.description = description;
+        this.version = version;
+        this.javaVersion = javaVersion;
+        this.className = className;
+        this.soName = soName;
+        this.source = source;
+    }
+
+    public static PluginInfo readFromProperties(final Path propertiesPath, final String source) throws IOException {
+        final Path descriptor = propertiesPath.resolve(DEFAULT_PLUGIN_PROPERTIES);
+
+        final Map<String, String> propsMap;
+        {
+            final Properties props = new Properties();
+            try (InputStream stream = Files.newInputStream(descriptor)) {
+                props.load(stream);
+            }
+            propsMap = props.stringPropertyNames().stream()
+                    .collect(Collectors.toMap(Function.identity(), props::getProperty));
+        }
+
+        final String name = propsMap.remove("name");
+        if (null == name || name.isEmpty()) {
+            throw new IllegalArgumentException(
+                    "property [name] is missing in [" + descriptor + "]");
+        }
+
+        final String description = propsMap.remove("description");
+        if (null == description) {
 
 Review comment:
   Yeah, is unnecessary check, will remove

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org