You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by zh...@apache.org on 2019/12/13 13:38:24 UTC
[incubator-doris] branch master updated: Add plugin definition
(#2351)
This is an automated email from the ASF dual-hosted git repository.
zhaoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new e4cc175 Add plugin definition (#2351)
e4cc175 is described below
commit e4cc17599fe39f6e7d15115b928d017de5e86700
Author: Seaven <se...@qq.com>
AuthorDate: Fri Dec 13 21:38:17 2019 +0800
Add plugin definition (#2351)
---
be/src/plugin/plugin.h | 75 ++++++++++++++++++++++
be/src/plugin/plugin_manager.h | 39 +++++++++++
.../main/java/org/apache/doris/plugin/Plugin.java | 65 +++++++++++++++++++
.../org/apache/doris/plugin/PluginManager.java | 50 +++++++++++++++
.../java/org/apache/doris/plugin/PluginType.java | 28 ++++++++
5 files changed, 257 insertions(+)
diff --git a/be/src/plugin/plugin.h b/be/src/plugin/plugin.h
new file mode 100644
index 0000000..4770650
--- /dev/null
+++ b/be/src/plugin/plugin.h
@@ -0,0 +1,75 @@
+// 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.
+
+namespace doris {
+
+#define PLUGIN_NOT_DYNAMIC_INSTALL 1UL
+#define PLUGIN_NOT_DYNAMIC_UNINSTALL 2UL
+#define PLUGIN_INSTALL_EARLY 4UL
+
+#define DORIS_PLUGIN_VERSION 001100UL
+
+/**
+ * define a plugin:
+ *
+ * declare_plugin(PLUGIN_NAME) {
+ * xx_handler,
+ * init_method,
+ * close_method,
+ * PLUGIN_NOT_DYNAMIC_INSTALL | PLUGIN_NOT_DYNAMIC_UNINSTALL,
+ * NULL,
+ * NULL
+ * } declare_plugin_end
+ *
+ */
+struct Plugin {
+ // support by type-specific plugin
+ void* handler;
+
+ // invoke when plugin install
+ int (*init)(void *);
+
+ // invoke when plugin uninstall
+ int (*close)(void *);
+
+ // flag for plugin
+ uint64_t flags;
+
+ // use to set/get variables
+ void* variable;
+
+ // return the plugin's status
+ void* status;
+};
+
+
+#define declare_plugin(NAME) \
+ __DECLARE_PLUGIN(NAME, ##NAME##_plugin_interface_version, \
+ ##NAME##_sizeof_struct_st_plugin, \
+ ##NAME##_plugin)
+
+#define __DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
+ int VERSION = DORIS_PLUGIN_VERSION; \
+ int PSIZE = sizeof(struct st_plugin); \
+ struct st_plugin DECLS[] = {
+
+
+#define declare_plugin_end \
+ , { 0, 0, 0, 0, 0, 0 } \
+ }
+
+}
diff --git a/be/src/plugin/plugin_manager.h b/be/src/plugin/plugin_manager.h
new file mode 100644
index 0000000..85b45db
--- /dev/null
+++ b/be/src/plugin/plugin_manager.h
@@ -0,0 +1,39 @@
+// 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.
+
+#include <string>
+#include <unordered_map>
+
+#include "common/status.h"
+#include "plugin/plugin.h"
+
+namespace doris {
+
+class PluginManager {
+
+public:
+ Status load_plugin(Plugin* plugin);
+
+ Status unload_plugin(Plugin* plugin);
+
+ Status get_plugin(std::string name);
+
+private:
+ std::unordered_map<std::string, Plugin*> _plugins;
+};
+
+}
\ No newline at end of file
diff --git a/fe/src/main/java/org/apache/doris/plugin/Plugin.java b/fe/src/main/java/org/apache/doris/plugin/Plugin.java
new file mode 100644
index 0000000..4c5d9ec
--- /dev/null
+++ b/fe/src/main/java/org/apache/doris/plugin/Plugin.java
@@ -0,0 +1,65 @@
+// 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.Closeable;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+
+public abstract class Plugin implements Closeable {
+ public static final int PLUGIN_DEFAULT_FLAGS = 0;
+ public static final int PLUGIN_NOT_DYNAMIC_INSTALL = 1;
+ public static final int PLUGIN_NOT_DYNAMIC_UNINSTALL = 2;
+ public static final int PLUGIN_INSTALL_EARLY = 4;
+
+ /*
+ * just one constructor
+ *
+ * public Plugin() {}
+ *
+ * public Plugin(Path installPath) {}
+ */
+
+ /**
+ * invoke when the plugin install
+ */
+ public void init() { }
+
+ /**
+ * invoke when the plugin uninstall
+ */
+ @Override
+ public void close() throws IOException { }
+
+ public int flags() {
+ return PLUGIN_DEFAULT_FLAGS;
+ }
+
+ public void setVariable(String key, String value) {
+
+ }
+
+ public Map<String, String> variable() {
+ return Collections.EMPTY_MAP;
+ }
+
+ public Map<String, String> status() {
+ return Collections.EMPTY_MAP;
+ }
+}
diff --git a/fe/src/main/java/org/apache/doris/plugin/PluginManager.java b/fe/src/main/java/org/apache/doris/plugin/PluginManager.java
new file mode 100644
index 0000000..58cc17a
--- /dev/null
+++ b/fe/src/main/java/org/apache/doris/plugin/PluginManager.java
@@ -0,0 +1,50 @@
+// 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.util.Map;
+
+import com.google.common.collect.Maps;
+
+public class PluginManager {
+
+ private final Map[] plugins = new Map[PluginType.MAX_PLUGIN_SIZE];
+
+ public PluginManager() {
+
+ for (int i = 0; i < plugins.length; i++) {
+ plugins[i] = Maps.newConcurrentMap();
+ }
+ }
+
+ public void loadPlugin(Plugin plugin) {
+
+ }
+
+ public void unloadPlugin(Plugin plugin) {
+
+ }
+
+ public Plugin getPlugin(String name) {
+ return null;
+ }
+
+ public Plugin getPlugin(String name, PluginType type) {
+ return null;
+ }
+}
diff --git a/fe/src/main/java/org/apache/doris/plugin/PluginType.java b/fe/src/main/java/org/apache/doris/plugin/PluginType.java
new file mode 100644
index 0000000..0357d5e
--- /dev/null
+++ b/fe/src/main/java/org/apache/doris/plugin/PluginType.java
@@ -0,0 +1,28 @@
+// 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;
+
+/**
+ * Describe the type of plugin
+ */
+public enum PluginType {
+ IMPORT,
+ STORAGE;
+
+ public static int MAX_PLUGIN_SIZE = PluginType.values().length;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org