diff --git a/.gitignore b/.gitignore
index 4e0f9461..6ef74f47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,12 @@
*.iml
**/target/*
.vscode
+**/node_modules/*
+**/dist/*
+zeus-starter/src/main/resources/public/
+.bdb/
+zeus-webapp/src/main/java/com/zmops/iot/web/analyse/service/Test.java
+logs/
+**/assets/node/*
+iot-server/server-starter/assets/*
+iot-server/server-starter/pages/*
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..568e7a2d
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "zeus-iot-ui"]
+ path = zeus-iot-ui
+ url = https://github.com/zmops/zeus-iot-ui.git
+[submodule "camel-zabbix-agent"]
+ path = camel-zabbix-agent
+ url = https://github.com/zmops/camel-zabbix-agent.git
diff --git a/.muse/config.toml b/.muse/config.toml
new file mode 100644
index 00000000..344d17e4
--- /dev/null
+++ b/.muse/config.toml
@@ -0,0 +1,2 @@
+jdk8 = true
+setup = ".muse/setup.sh"
diff --git a/.muse/setup.sh b/.muse/setup.sh
new file mode 100644
index 00000000..6bc9e756
--- /dev/null
+++ b/.muse/setup.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+git submodule update --init --recursive
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..1acf21ee
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,214 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed 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.
+
+=======================================================================
+zeus-iot Subcomponents:
+
+The zeus-iot project contains subcomponents with separate copyright
+notices and license terms. Your use of the source code for the these
+subcomponents is subject to the terms and conditions of the following
+licenses.
+
+proto files from iot-server: https://github.com/apache/skywalking Apache 2.0
+mvnw files from https://github.com/takari/maven-wrapper Apache 2.0
+
+proto files from zeus-common,zeus-core https://github.com/stylefeng/Guns LGPL-3.0
\ No newline at end of file
diff --git a/README.md b/README.md
index 2cdb7ba9..2e85535d 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,96 @@
-## Zeus IOT 宙斯物联网分布式采集平台
+
+Zeus IoT is the world's first open source IoT distributed collection platform based on Zabbix
+
-![Version](https://img.shields.io/badge/version-1.0.0--RELEASE-brightgreen)
+----
+
+[![GitHub stars](https://img.shields.io/github/stars/zmops/zeus-iot.svg?label=Stars&logo=github)](https://github.com/zmops/zeus-iot)
+[![GitHub issues](https://img.shields.io/github/issues/zmops/zeus-iot?label=Issuess&logo=github)](https://github.com/zmops/zeus-iot)
+[![GitHub forks](https://img.shields.io/github/forks/zmops/zeus-iot?label=Forks&logo=github)](https://github.com/zmops/zeus-iot)
+![Version](https://img.shields.io/badge/version-1.0.0--BETA-brightgreen)
[![QQ群736541577](https://img.shields.io/badge/QQ群-736541577-brightgreen)](https://qm.qq.com/cgi-bin/qm/qr?k=CcWBdkXjkgt99bBu5d_-1TeS36DhCkU4&jump_from=webapi)
-### 简介
+## Abstract
+[Zeus IoT](https://www.zmops.com/) is a **distributed IoT collection, analysis, and storage platform**,It is the world's first IoT open source platform based on zabbix secondary development, all this relies on a group of engineers with rich experience in zabbix development.It is hoped that through the community’s open source ecology, continuous improvement and continuous updates will make some contributions to the development of the Internet of Things industry.
+
+The following screenshots give a close insight into Zeus IoT.
+
+
+
Home Screen
+
Device Resources
+
+
+
+
+
+
+
Realtime Data
+
System Users
+
+
+
+
+
+
+
+## Technology stack
+- Basic components: **[Zabbix 5.4+](https://www.zabbix.com)**
+- Database: **PostgreSQL12+ , [TDEngine 2.2+](https://www.taosdata.com)**
+- Webapp: **SpringBoot 2 , [Ebean](https://ebean.io/) , Vue Element , Socket.IO**
+- IoT Server: **[Apache Camel 2.2](https://camel.apache.org/) , Modular design**
+- Visualization: **[Grafana 8.0+](https://grafana.com/grafana/)**
+
+## Features
+
+ 🏆Based on zabbix secondary development
+ Based on the powerful Zabbix for interface secondary development, with industrial-grade stability and powerful performance.
+
+
+ 🥇Based on Apache Camel as the pre-routing rule
+ Very powerful rule-based routing engine, supports 300+ module access, including IoT protocols, born for low code; one line of code can start the protocol service interface.
+
+
+ 🥉Use TDEngine for time series data storage by default
+ TDEngine is an ultra-high performance distributed database designed and optimized for time series data.
+
+
+ ⚔️IoT Server is developed with a modular architecture
+ IoT Server adopts the Skywalking modular architecture design, which can dynamically configure and enable modules, which is very easy to expand; at the same time, combined with the multi-point collection of Zabbix Proxy, a modular cluster can be implemented well.
+
+
+ 🏹Natural distributed collection architecture
+ Thanks to Zabbix's excellent architecture design, it has natural distributed collection capabilities, can be well horizontally expanded, and has the ability to cross-region and cross-network collection
+
+
+## Architecture
+
+![Architecture](docs/images/arch.gif)
+
+---
+
+## Installation
+The Zeus IoT production environment can only be installed on a Linux system, either Centos7 or Ubuntu 18.04. In the development and test environment: The IoT Server service can be developed and debugged in the Windows environment.
+
+### Quick Start
+- Centos7/Redhat7
-**Zeus-IOT**是
+ ```shell
+ curl -sL https://github.com/zmops/zeus-iot/raw/develop/docs/centos/install.sh | bash -s install
+ ```
-### 快速安装
+- Ubuntu 18.04
-Zeus-IOT 支持 Centos 7、Ubuntu 20.04、Debain 10 、Kylin、UOS 等基于x86_64平台的 Linux 操作系统。
+ ```shell
+ curl -sL https://github.com/zmops/zeus-iot/raw/develop/docs/ubuntu/install.sh | bash -s install
+ ```
+After Zeus IoT is successfully installed, you can use http://IP:9090 to access the ZeusIoT Console with the default account and password (Admin/zabbix).
-```shell
-curl -L https://github.com/zmops/zeus-iot/blob/develop/docs/quick-install.sh | bash
-```
+> For more detailed installation and deployment instructions, please visit our official website document center
+## Demo Environment
-访问 `http://` 登录 Zeus-IOT 系统。[快速开始](./docs/quick-start.rst)
+Using the account `Admin / zabbix` to log in the [demo environment](https://zeusdemo.zmops.cn/). Please note the account is granted view access.
diff --git a/dist-material/bin/IOTServerStart.sh b/dist-material/bin/IOTServerStart.sh
deleted file mode 100644
index e69de29b..00000000
diff --git a/dist-material/bin/IoTServer.bat b/dist-material/bin/IoTServer.bat
new file mode 100644
index 00000000..76473277
--- /dev/null
+++ b/dist-material/bin/IoTServer.bat
@@ -0,0 +1,37 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+@REM contributor license agreements. See the NOTICE file distributed with
+@REM this work for additional information regarding copyright ownership.
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+@REM (the "License"); you may not use this file except in compliance with
+@REM the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+
+@echo off
+
+setlocal
+set IOT_PROCESS_TITLE=Zeus-IoT-Server
+set IOT_SERVER_HOME=%~dp0%..
+set IOT_OPTS="-Xms1024M -Xmx1024M -Diot.logDir=%IOT_SERVER_HOME%\logs -Duser.timezone=GMT+08"
+
+set CLASSPATH=%IOT_SERVER_HOME%\config;.;
+set CLASSPATH=%IOT_SERVER_HOME%\iot-server-libs\*;%CLASSPATH%
+
+if defined JAVA_HOME (
+ set _EXECJAVA="%JAVA_HOME%\bin\java"
+)
+
+if not defined JAVA_HOME (
+ echo "JAVA_HOME not set."
+ set _EXECJAVA=java
+)
+
+start "%IOT_PROCESS_TITLE%" %_EXECJAVA% "%IOT_OPTS%" -cp "%CLASSPATH%" com.zmops.zeus.iot.server.starter.IoTServerStartUp
+endlocal
diff --git a/dist-material/bin/IoTServer.sh b/dist-material/bin/IoTServer.sh
new file mode 100644
index 00000000..4e9ecd48
--- /dev/null
+++ b/dist-material/bin/IoTServer.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+# 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.
+
+PRG="$0"
+PRGDIR=$(dirname "$PRG")
+[ -z "$IOT_HOME" ] && IOT_HOME=$(cd "$PRGDIR/.." > /dev/null || exit 1; pwd)
+
+IOT_LOG_DIR="${IOT_LOG_DIR:-${IOT_HOME}/logs}"
+JAVA_OPTS="${JAVA_OPTS:- -Xms256M -Xmx512M}"
+
+if [ ! -d "${IOT_LOG_DIR}" ]; then
+ mkdir -p "${IOT_LOG_DIR}"
+fi
+
+_RUNJAVA=${JAVA_HOME}/bin/java
+[ -z "$JAVA_HOME" ] && _RUNJAVA=java
+
+CLASSPATH="$IOT_HOME/config:$CLASSPATH"
+for i in "$IOT_HOME"/iot-server-libs/*.jar
+do
+ CLASSPATH="$i:$CLASSPATH"
+done
+
+IOT_OPTIONS=" -Diot.logDir=${IOT_LOG_DIR} -Duser.timezone=GMT+08"
+
+eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${IOT_OPTIONS} -classpath $CLASSPATH com.zmops.zeus.iot.server.starter.IoTServerStartUp \
+ &> ${IOT_LOG_DIR}/zeus_iot.log &"
+
+if [ $? -eq 0 ]; then
+ sleep 1
+ echo "Zeus IOT started successfully!"
+else
+ echo "Zeus IoT Server started failure!"
+ exit 1
+fi
diff --git a/dist-material/bin/IoTServerInit.bat b/dist-material/bin/IoTServerInit.bat
new file mode 100644
index 00000000..36a68e61
--- /dev/null
+++ b/dist-material/bin/IoTServerInit.bat
@@ -0,0 +1,37 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+@REM contributor license agreements. See the NOTICE file distributed with
+@REM this work for additional information regarding copyright ownership.
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+@REM (the "License"); you may not use this file except in compliance with
+@REM the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+
+@echo off
+
+setlocal
+set IOT_PROCESS_TITLE=IoT-Server-Collector
+set IOT_SERVER_HOME=%~dp0%..
+set IOT_OPTS="-Xms256M -Xmx512M -Diot.logDir=%IOT_SERVER_HOME%\logs"
+
+set CLASSPATH=%IOT_SERVER_HOME%\config;.;
+set CLASSPATH=%IOT_SERVER_HOME%\iot-server-libs\*;%CLASSPATH%
+
+if defined JAVA_HOME (
+ set _EXECJAVA="%JAVA_HOME%\bin\java"
+)
+
+if not defined JAVA_HOME (
+ echo "JAVA_HOME not set."
+ set _EXECJAVA=java
+)
+
+start "%IOT_PROCESS_TITLE%" %_EXECJAVA% "%IOT_OPTS%" -cp "%CLASSPATH%" -Dmode=init com.zmops.zeus.iot.server.starter.IoTServerStartUp
+endlocal
diff --git a/dist-material/bin/IoTServerInit.sh b/dist-material/bin/IoTServerInit.sh
new file mode 100644
index 00000000..5a047c87
--- /dev/null
+++ b/dist-material/bin/IoTServerInit.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env sh
+# 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.
+
+PRG="$0"
+PRGDIR=$(dirname "$PRG")
+[ -z "$IOT_SERVER_HOME" ] && IOT_SERVER_HOME=$(cd "$PRGDIR/.." > /dev/null || exit 1; pwd)
+
+IOT_LOG_DIR="${IOT_SERVER_HOME}/logs"
+JAVA_OPTS="${JAVA_OPTS:- -Xms256M -Xmx512M}"
+
+if [ ! -d "${IOT_SERVER_HOME}/logs" ]; then
+ mkdir -p "${IOT_LOG_DIR}"
+fi
+
+_RUNJAVA=${JAVA_HOME}/bin/java
+[ -z "$JAVA_HOME" ] && _RUNJAVA=java
+
+CLASSPATH="$IOT_SERVER_HOME/config:$CLASSPATH"
+for i in "$IOT_SERVER_HOME"/iot-server-libs/*.jar
+do
+ CLASSPATH="$i:$CLASSPATH"
+done
+
+IOT_OPTIONS=" -Diot.logDir=${IOT_LOG_DIR}"
+
+eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${IOT_OPTIONS} -classpath $CLASSPATH -Dmode=init com.zmops.zeus.iot.server.starter.IoTServerStartUp \
+ 2>${IOT_LOG_DIR}/iot_server.log 1> /dev/null &"
+
+if [ $? -eq 0 ]; then
+ sleep 1
+ echo "Zeus IoT Server started successfully!"
+else
+ echo "Zeus IoT Server started failure!"
+ exit 1
+fi
diff --git a/dist-material/bin/IoTServerNoInit.bat b/dist-material/bin/IoTServerNoInit.bat
new file mode 100644
index 00000000..97e7322f
--- /dev/null
+++ b/dist-material/bin/IoTServerNoInit.bat
@@ -0,0 +1,37 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+@REM contributor license agreements. See the NOTICE file distributed with
+@REM this work for additional information regarding copyright ownership.
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+@REM (the "License"); you may not use this file except in compliance with
+@REM the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+
+@echo off
+
+setlocal
+set IOT_PROCESS_TITLE=IoT-Server-Collector
+set IOT_SERVER_HOME=%~dp0%..
+set IOT_OPTS="-Xms256M -Xmx512M -Diot.logDir=%IOT_SERVER_HOME%\logs"
+
+set CLASSPATH=%IOT_SERVER_HOME%\config;.;
+set CLASSPATH=%IOT_SERVER_HOME%\iot-server-libs\*;%CLASSPATH%
+
+if defined JAVA_HOME (
+ set _EXECJAVA="%JAVA_HOME%\bin\java"
+)
+
+if not defined JAVA_HOME (
+ echo "JAVA_HOME not set."
+ set _EXECJAVA=java
+)
+
+start "%IOT_PROCESS_TITLE%" %_EXECJAVA% "%IOT_OPTS%" -cp "%CLASSPATH%" -Dmode=no-init com.zmops.zeus.iot.server.starter.IoTServerStartUp
+endlocal
diff --git a/dist-material/bin/IoTServerNoInit.sh b/dist-material/bin/IoTServerNoInit.sh
new file mode 100644
index 00000000..a7e17b73
--- /dev/null
+++ b/dist-material/bin/IoTServerNoInit.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env sh
+# 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.
+
+PRG="$0"
+PRGDIR=$(dirname "$PRG")
+[ -z "$IOT_SERVER_HOME" ] && IOT_SERVER_HOME=$(cd "$PRGDIR/.." > /dev/null || exit 1; pwd)
+
+IOT_LOG_DIR=${IOT_LOG_DIR:-"${IOT_SERVER_HOME}/logs"}
+JAVA_OPTS="${JAVA_OPTS:- -Xms512M -Xmx1024M}"
+
+if [ ! -d "${IOT_SERVER_HOME}/logs" ]; then
+ mkdir -p "${IOT_LOG_DIR}"
+fi
+
+_RUNJAVA=${JAVA_HOME}/bin/java
+[ -z "$JAVA_HOME" ] && _RUNJAVA=java
+
+CLASSPATH="$IOT_SERVER_HOME/config:$CLASSPATH"
+for i in "$IOT_SERVER_HOME"/iot-server-libs/*.jar
+do
+ CLASSPATH="$i:$CLASSPATH"
+done
+
+IOT_OPTIONS=" -Diot.logDir=${IOT_LOG_DIR}"
+
+eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${IOT_OPTIONS} -classpath $CLASSPATH -Dmode=no-init com.zmops.zeus.iot.server.starter.IoTServerStartUp \
+ 2>${IOT_LOG_DIR}/iot_server.log 1> /dev/null &"
+
+if [ $? -eq 0 ]; then
+ sleep 1
+ echo "Zeus IoT Server started successfully!"
+else
+ echo "Zeus IoT Server started failure!"
+ exit 1
+fi
diff --git a/dist-material/bin/sql/zabbix_event.sql b/dist-material/bin/sql/zabbix_event.sql
new file mode 100644
index 00000000..f7c3c539
--- /dev/null
+++ b/dist-material/bin/sql/zabbix_event.sql
@@ -0,0 +1,109 @@
+CREATE OR REPLACE FUNCTION "public"."event_notify"("channel" text, "routing_key" text, "message" text)
+ RETURNS "pg_catalog"."void" AS $BODY$
+ select pg_notify(channel, routing_key || '$$' || message);
+$BODY$
+ LANGUAGE sql STABLE
+ COST 100;
+
+
+
+
+
+
+ CREATE OR REPLACE FUNCTION "public"."events_problem_trace"()
+ RETURNS "pg_catalog"."trigger" AS $BODY$
+DECLARE
+ v_eventid INT;
+ v_event_json TEXT;
+BEGIN
+ CASE TG_OP
+ WHEN 'INSERT' THEN v_eventid := NEW.eventid;
+ select row_to_json(x)
+ into v_event_json
+ from (SELECT p."eventid", p."objectid", p."clock", p."r_clock", p."name", p."acknowledged", p."severity",tag.tag,tag."value" tagValue from problem p Inner JOIN (select eventid,tag,value from event_tag where tag ='__alarm__' ) tag on tag.eventid=p.eventid where p.source=0 and p.eventid = v_eventid) x;
+ WHEN 'UPDATE' THEN v_eventid := NEW.eventid;
+ select row_to_json(x)
+ into v_event_json
+ from (SELECT p."eventid", p."objectid", p."clock", p."r_clock", p."name", p."acknowledged", p."severity",tag.tag,tag."value" tagValue from problem p Inner JOIN (select eventid,tag,value from event_tag where tag ='__alarm__' ) tag on tag.eventid=p.eventid where p.source=0 and p.eventid = v_eventid) x;
+ ELSE RETURN NULL;
+ END CASE;
+
+ perform event_notify('zabbix_pg_event', 'events', v_event_json);
+
+ RETURN NULL;
+END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE STRICT
+ COST 100;
+
+
+
+
+
+
+
+
+ CREATE OR REPLACE FUNCTION "public"."events_tag_trace"()
+ RETURNS "pg_catalog"."trigger" AS $BODY$
+DECLARE
+ v_eventid INT;
+ v_event_json TEXT;
+BEGIN
+ CASE TG_OP
+ WHEN 'INSERT' THEN v_eventid := NEW.eventid;
+ select row_to_json(x)
+ into v_event_json
+ from (select e.eventid,e.objectid,e.name,tag.tag,tag.value tagValue from events e LEFT JOIN (select eventid,tag,value from event_tag where tag = '__event__' ) tag on tag.eventid=e.eventid where e.source=0 and e.eventid = v_eventid) x;
+ ELSE RETURN NULL;
+ END CASE;
+
+ perform event_notify('zabbix_pg_event', 'events', v_event_json);
+
+ RETURN NULL;
+END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE STRICT
+ COST 100;
+
+
+
+
+
+
+ CREATE OR REPLACE FUNCTION "public"."events_trace"()
+ RETURNS "pg_catalog"."trigger" AS $BODY$
+DECLARE
+ v_eventid INT;
+ v_event_json TEXT;
+BEGIN
+ CASE TG_OP
+ WHEN 'INSERT' THEN v_eventid := NEW.eventid;
+ select row_to_json(x)
+ into v_event_json
+ from (select e.eventid,e.objectid,e.name,tag.tag,tag.value tagValue from events e Inner JOIN (select triggerid,tag,value from trigger_tag where tag in ('__online__','__offline__','__execute__','__scene__') ) tag on tag.triggerid=e.objectid where e.source=0 and e.eventid = v_eventid) x;
+ ELSE RETURN NULL;
+ END CASE;
+
+ perform event_notify('zabbix_pg_event', 'events', v_event_json);
+
+ RETURN NULL;
+END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE STRICT
+ COST 100;
+
+
+
+ CREATE TRIGGER "events_trigger" AFTER INSERT ON "public"."events"
+FOR EACH ROW
+EXECUTE PROCEDURE "public"."events_trace"();
+
+
+CREATE TRIGGER "events_problem_trigger" AFTER INSERT OR UPDATE OF "r_clock", "acknowledged" ON "public"."problem"
+FOR EACH ROW
+EXECUTE PROCEDURE "public"."events_problem_trace"();
+
+
+CREATE TRIGGER "tag_trigger" AFTER INSERT ON "public"."event_tag"
+FOR EACH ROW
+EXECUTE PROCEDURE "public"."events_tag_trace"();
\ No newline at end of file
diff --git a/dist-material/bin/sql/zeus-iot.sql b/dist-material/bin/sql/zeus-iot.sql
new file mode 100644
index 00000000..7c6f4837
--- /dev/null
+++ b/dist-material/bin/sql/zeus-iot.sql
@@ -0,0 +1,2557 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : 172.16.60.130-专业演示LOT
+ Source Server Type : PostgreSQL
+ Source Server Version : 130004
+ Source Host : 172.16.60.130:5432
+ Source Catalog : zeus-iot-开源空库不要删
+ Source Schema : public
+
+ Target Server Type : PostgreSQL
+ Target Server Version : 130004
+ File Encoding : 65001
+
+ Date: 21/01/2022 13:56:30
+*/
+
+
+-- ----------------------------
+-- Sequence structure for device_online_report_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."device_online_report_id_seq";
+CREATE SEQUENCE "public"."device_online_report_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for devices_groups_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."devices_groups_id_seq";
+CREATE SEQUENCE "public"."devices_groups_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for event_trigger_record_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."event_trigger_record_id_seq";
+CREATE SEQUENCE "public"."event_trigger_record_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for mail_setting_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."mail_setting_id_seq";
+CREATE SEQUENCE "public"."mail_setting_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for media_type_setting_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."media_type_setting_id_seq";
+CREATE SEQUENCE "public"."media_type_setting_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for messages_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."messages_id_seq";
+CREATE SEQUENCE "public"."messages_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for notice_record_record_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."notice_record_record_id_seq";
+CREATE SEQUENCE "public"."notice_record_record_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for product_event_relation_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."product_event_relation_id_seq";
+CREATE SEQUENCE "public"."product_event_relation_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for product_event_tags_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."product_event_tags_id_seq";
+CREATE SEQUENCE "public"."product_event_tags_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for product_event_time_interval_event_time_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."product_event_time_interval_event_time_id_seq";
+CREATE SEQUENCE "public"."product_event_time_interval_event_time_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for product_service_relation_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."product_service_relation_id_seq";
+CREATE SEQUENCE "public"."product_service_relation_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for product_status_function_relation_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."product_status_function_relation_id_seq";
+CREATE SEQUENCE "public"."product_status_function_relation_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for product_type_product_type_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."product_type_product_type_id_seq";
+CREATE SEQUENCE "public"."product_type_product_type_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for protocol_component_protocol_component_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."protocol_component_protocol_component_id_seq";
+CREATE SEQUENCE "public"."protocol_component_protocol_component_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for protocol_gateway_protocol_gateway_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."protocol_gateway_protocol_gateway_id_seq";
+CREATE SEQUENCE "public"."protocol_gateway_protocol_gateway_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for protocol_service_protocol_service_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."protocol_service_protocol_service_id_seq";
+CREATE SEQUENCE "public"."protocol_service_protocol_service_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for scenes_trigger_record_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."scenes_trigger_record_id_seq";
+CREATE SEQUENCE "public"."scenes_trigger_record_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for service_execute_record_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."service_execute_record_id_seq";
+CREATE SEQUENCE "public"."service_execute_record_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for service_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."service_id_seq";
+CREATE SEQUENCE "public"."service_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for service_param_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."service_param_id_seq";
+CREATE SEQUENCE "public"."service_param_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for session_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."session_id_seq";
+CREATE SEQUENCE "public"."session_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for sys_user_group_user_group_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."sys_user_group_user_group_id_seq";
+CREATE SEQUENCE "public"."sys_user_group_user_group_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for sys_user_user_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."sys_user_user_id_seq";
+CREATE SEQUENCE "public"."sys_user_user_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 9223372036854775807
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for tag_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."tag_id_seq";
+CREATE SEQUENCE "public"."tag_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for task_info_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."task_info_id_seq";
+CREATE SEQUENCE "public"."task_info_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Sequence structure for token_token_id_seq
+-- ----------------------------
+DROP SEQUENCE IF EXISTS "public"."token_token_id_seq";
+CREATE SEQUENCE "public"."token_token_id_seq"
+INCREMENT 1
+MINVALUE 1
+MAXVALUE 2147483647
+START 1
+CACHE 1;
+
+-- ----------------------------
+-- Table structure for device
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."device";
+CREATE TABLE "public"."device" (
+ "device_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default",
+ "product_id" int8,
+ "status" varchar(16) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8,
+ "type" varchar(16) COLLATE "pg_catalog"."default",
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default",
+ "addr" varchar(255) COLLATE "pg_catalog"."default",
+ "position" varchar(64) COLLATE "pg_catalog"."default",
+ "online" int2 DEFAULT 1,
+ "latest_online" timestamp(6),
+ "proxy_id" int8,
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."device"."device_id" IS '设备ID';
+COMMENT ON COLUMN "public"."device"."name" IS '设备名称';
+COMMENT ON COLUMN "public"."device"."product_id" IS '关联产品';
+COMMENT ON COLUMN "public"."device"."status" IS '状态';
+COMMENT ON COLUMN "public"."device"."remark" IS '备注';
+COMMENT ON COLUMN "public"."device"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."device"."create_user" IS '创建者';
+COMMENT ON COLUMN "public"."device"."update_time" IS '系统时间';
+COMMENT ON COLUMN "public"."device"."update_user" IS '修改者';
+COMMENT ON COLUMN "public"."device"."type" IS '设备类型';
+COMMENT ON COLUMN "public"."device"."zbx_id" IS 'zbx主机ID';
+COMMENT ON COLUMN "public"."device"."addr" IS '设备地址';
+COMMENT ON COLUMN "public"."device"."position" IS '地址坐标';
+COMMENT ON COLUMN "public"."device"."online" IS '是否在线 1是 0否';
+COMMENT ON COLUMN "public"."device"."latest_online" IS '最近在线时间';
+COMMENT ON COLUMN "public"."device"."proxy_id" IS '代理ID';
+COMMENT ON COLUMN "public"."device"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of device
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for device_group
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."device_group";
+CREATE TABLE "public"."device_group" (
+ "device_group_id" int8 NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
+ "create_user" int8,
+ "create_time" timestamp(6),
+ "update_user" int8,
+ "update_time" timestamp(6),
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."device_group"."device_group_id" IS '主机组ID';
+COMMENT ON COLUMN "public"."device_group"."name" IS '主机组名称';
+COMMENT ON COLUMN "public"."device_group"."remark" IS '备注';
+COMMENT ON COLUMN "public"."device_group"."zbx_id" IS 'zabbix 主机组ID';
+COMMENT ON COLUMN "public"."device_group"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."device_group"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."device_group"."update_user" IS '更新人';
+COMMENT ON COLUMN "public"."device_group"."update_time" IS '更新时间';
+COMMENT ON COLUMN "public"."device_group"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of device_group
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for device_online_report
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."device_online_report";
+CREATE TABLE "public"."device_online_report" (
+ "id" int8 NOT NULL DEFAULT nextval('device_online_report_id_seq'::regclass),
+ "create_time" varchar(10) COLLATE "pg_catalog"."default",
+ "online" int4,
+ "offline" int4,
+ "type" int2,
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."device_online_report"."online" IS '在线数';
+COMMENT ON COLUMN "public"."device_online_report"."offline" IS '离线数';
+COMMENT ON COLUMN "public"."device_online_report"."type" IS '设备类型';
+COMMENT ON COLUMN "public"."device_online_report"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of device_online_report
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for devices_groups
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."devices_groups";
+CREATE TABLE "public"."devices_groups" (
+ "id" int8 NOT NULL DEFAULT nextval('devices_groups_id_seq'::regclass),
+ "device_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "device_group_id" int8 NOT NULL
+)
+;
+COMMENT ON COLUMN "public"."devices_groups"."id" IS 'ID';
+COMMENT ON COLUMN "public"."devices_groups"."device_id" IS '设备ID';
+COMMENT ON COLUMN "public"."devices_groups"."device_group_id" IS '设备组ID';
+
+-- ----------------------------
+-- Records of devices_groups
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for event_trigger_record
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."event_trigger_record";
+CREATE TABLE "public"."event_trigger_record" (
+ "id" int4 NOT NULL DEFAULT nextval('event_trigger_record_id_seq'::regclass),
+ "event_name" varchar(128) COLLATE "pg_catalog"."default",
+ "event_value" varchar(255) COLLATE "pg_catalog"."default",
+ "device_id" varchar(64) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "key" varchar(64) COLLATE "pg_catalog"."default",
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."event_trigger_record"."event_name" IS '事件名称';
+COMMENT ON COLUMN "public"."event_trigger_record"."event_value" IS '事件发生时的值';
+COMMENT ON COLUMN "public"."event_trigger_record"."device_id" IS '设备ID';
+COMMENT ON COLUMN "public"."event_trigger_record"."create_time" IS '发生时间';
+COMMENT ON COLUMN "public"."event_trigger_record"."key" IS '事件标识';
+COMMENT ON COLUMN "public"."event_trigger_record"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of event_trigger_record
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for mail_setting
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."mail_setting";
+CREATE TABLE "public"."mail_setting" (
+ "host" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
+ "port" int4 NOT NULL,
+ "account" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
+ "password" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
+ "sender" varchar(100) COLLATE "pg_catalog"."default",
+ "ssl" int4 NOT NULL DEFAULT 0,
+ "tls" int4 NOT NULL DEFAULT 0,
+ "severity" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
+ "silent" int2 NOT NULL DEFAULT 3,
+ "id" int4 NOT NULL DEFAULT nextval('mail_setting_id_seq'::regclass),
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."mail_setting"."host" IS 'smtp服务器地址';
+COMMENT ON COLUMN "public"."mail_setting"."port" IS 'smtp服务器端口';
+COMMENT ON COLUMN "public"."mail_setting"."account" IS 'smtp登陆账号';
+COMMENT ON COLUMN "public"."mail_setting"."password" IS 'smtp密码';
+COMMENT ON COLUMN "public"."mail_setting"."sender" IS '发送邮箱';
+COMMENT ON COLUMN "public"."mail_setting"."ssl" IS '1-是 0-否';
+COMMENT ON COLUMN "public"."mail_setting"."tls" IS '1-是 0-否';
+COMMENT ON COLUMN "public"."mail_setting"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of mail_setting
+-- ----------------------------
+INSERT INTO "public"."mail_setting" VALUES ('172.16.2.221', 587, 'sanshi@zmops.cn', 'Zmops@0610', 'sanshi@zmops.cn', 0, 1, '54', 3, 1, NULL);
+
+-- ----------------------------
+-- Table structure for media_type_setting
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."media_type_setting";
+CREATE TABLE "public"."media_type_setting" (
+ "id" int4 NOT NULL DEFAULT nextval('media_type_setting_id_seq'::regclass),
+ "type" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "template" text COLLATE "pg_catalog"."default",
+ "webhooks" text COLLATE "pg_catalog"."default",
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."media_type_setting"."type" IS '类型';
+COMMENT ON COLUMN "public"."media_type_setting"."template" IS '消息模板';
+COMMENT ON COLUMN "public"."media_type_setting"."webhooks" IS '推送配置';
+COMMENT ON COLUMN "public"."media_type_setting"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of media_type_setting
+-- ----------------------------
+INSERT INTO "public"."media_type_setting" VALUES (1, 'wechat', '
+{
+ "content": "广州今日天气:29度,大部分多云,降雨概率:80%",
+ "mentioned_list":["wangqing","@all"],
+ "mentioned_mobile_list":["13800001111","@all"]
+ }
+', '{"url":"https://oapi.dingtalk.com/robot/send?access_token=dd0f8a3340c15ec0f1d54b91980584c1127abe6dd143a964d44385647bc15124"}', NULL);
+INSERT INTO "public"."media_type_setting" VALUES (2, 'dingtalk', '{
+ "msgtype":"text",
+ "text": {
+ "content":"%s"
+ }
+}', '{"url":"https://oapi.dingtalk.com/robot/send?access_token=dd","secret":"5c60"}', NULL);
+INSERT INTO "public"."media_type_setting" VALUES (3, 'feishu', '{
+ "msg_type":"text",
+ "content": {
+ "text":"%s"
+ }
+}', '{"url":"https://open.feishu.cn/open-apis/bot/v2/hook/c43e56f","secret":"xoaP"}', NULL);
+
+-- ----------------------------
+-- Table structure for messages
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."messages";
+CREATE TABLE "public"."messages" (
+ "classify" int4 NOT NULL,
+ "title" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
+ "content" text COLLATE "pg_catalog"."default",
+ "clock" int4 NOT NULL,
+ "module" varchar(100) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
+ "readed" int2 DEFAULT 0,
+ "user_id" int8,
+ "id" int8 NOT NULL DEFAULT nextval('messages_id_seq'::regclass)
+)
+;
+COMMENT ON COLUMN "public"."messages"."classify" IS '消息的类型';
+COMMENT ON COLUMN "public"."messages"."module" IS '消息跳转的模块';
+COMMENT ON COLUMN "public"."messages"."readed" IS '是否已读 1-是 0-否';
+
+-- ----------------------------
+-- Records of messages
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for notice_record
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."notice_record";
+CREATE TABLE "public"."notice_record" (
+ "record_id" int4 NOT NULL DEFAULT nextval('notice_record_record_id_seq'::regclass),
+ "user_id" int4,
+ "problem_id" varchar(32) COLLATE "pg_catalog"."default",
+ "notice_type" int4,
+ "notice_status" varchar(255) COLLATE "pg_catalog"."default",
+ "notice_msg" varchar(2550) COLLATE "pg_catalog"."default",
+ "alarm_info" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
+ "receive_account" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
+ "creat_time" timestamp(6) NOT NULL
+)
+;
+COMMENT ON COLUMN "public"."notice_record"."record_id" IS '通知记录表主键id';
+COMMENT ON COLUMN "public"."notice_record"."user_id" IS '用户id';
+COMMENT ON COLUMN "public"."notice_record"."problem_id" IS '告警id';
+COMMENT ON COLUMN "public"."notice_record"."notice_type" IS '通知类型(1:sms 2:email 3:wechat 4:dingtalk)';
+COMMENT ON COLUMN "public"."notice_record"."notice_status" IS '通知状态';
+COMMENT ON COLUMN "public"."notice_record"."notice_msg" IS '通知消息';
+COMMENT ON COLUMN "public"."notice_record"."alarm_info" IS '告警信息';
+COMMENT ON COLUMN "public"."notice_record"."receive_account" IS '接收账号';
+COMMENT ON COLUMN "public"."notice_record"."creat_time" IS '创建时间';
+
+-- ----------------------------
+-- Records of notice_record
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for problem
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."problem";
+CREATE TABLE "public"."problem" (
+ "event_id" int8 NOT NULL,
+ "object_id" int8 NOT NULL DEFAULT '0'::bigint,
+ "name" varchar(2048) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying,
+ "acknowledged" int4 NOT NULL DEFAULT 0,
+ "severity" int4 NOT NULL DEFAULT 0,
+ "clock" timestamp(6),
+ "r_clock" timestamp(6),
+ "device_id" varchar(64) COLLATE "pg_catalog"."default"
+)
+;
+
+-- ----------------------------
+-- Records of problem
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product";
+CREATE TABLE "public"."product" (
+ "product_id" int8 NOT NULL,
+ "group_id" int8,
+ "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "type" varchar(64) COLLATE "pg_catalog"."default",
+ "manufacturer" varchar(255) COLLATE "pg_catalog"."default",
+ "model" varchar(255) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8,
+ "product_code" varchar(255) COLLATE "pg_catalog"."default",
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default",
+ "icon" text COLLATE "pg_catalog"."default",
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."product"."product_id" IS '产品ID';
+COMMENT ON COLUMN "public"."product"."group_id" IS '产品组ID';
+COMMENT ON COLUMN "public"."product"."name" IS '产品名称';
+COMMENT ON COLUMN "public"."product"."type" IS '设备类型';
+COMMENT ON COLUMN "public"."product"."manufacturer" IS '厂商';
+COMMENT ON COLUMN "public"."product"."model" IS '型号';
+COMMENT ON COLUMN "public"."product"."remark" IS '备注描述';
+COMMENT ON COLUMN "public"."product"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."product"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."product"."update_time" IS '更新时间';
+COMMENT ON COLUMN "public"."product"."update_user" IS '更新人';
+COMMENT ON COLUMN "public"."product"."product_code" IS '产品编号';
+COMMENT ON COLUMN "public"."product"."zbx_id" IS 'Zabbix对应模板ID';
+COMMENT ON COLUMN "public"."product"."icon" IS '图片';
+COMMENT ON COLUMN "public"."product"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of product
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_attribute
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_attribute";
+CREATE TABLE "public"."product_attribute" (
+ "attr_id" int8 NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "key" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "units" varchar(16) COLLATE "pg_catalog"."default",
+ "source" varchar(16) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "product_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "create_user" int8,
+ "create_time" timestamp(6),
+ "update_user" int8,
+ "update_time" timestamp(6),
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default",
+ "value_type" varchar(16) COLLATE "pg_catalog"."default",
+ "dep_attr_id" int8,
+ "template_id" int8,
+ "delay" int2,
+ "unit" varchar(4) COLLATE "pg_catalog"."default",
+ "valuemapid" varchar(8) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_attribute"."attr_id" IS '属性ID';
+COMMENT ON COLUMN "public"."product_attribute"."name" IS '属性名称';
+COMMENT ON COLUMN "public"."product_attribute"."key" IS '属性标识Key';
+COMMENT ON COLUMN "public"."product_attribute"."units" IS '数字类型单位';
+COMMENT ON COLUMN "public"."product_attribute"."source" IS '数据来源';
+COMMENT ON COLUMN "public"."product_attribute"."remark" IS '备注描述';
+COMMENT ON COLUMN "public"."product_attribute"."product_id" IS '产品ID';
+COMMENT ON COLUMN "public"."product_attribute"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."product_attribute"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."product_attribute"."update_user" IS '更新人';
+COMMENT ON COLUMN "public"."product_attribute"."update_time" IS '更新时间';
+COMMENT ON COLUMN "public"."product_attribute"."zbx_id" IS 'itemid';
+COMMENT ON COLUMN "public"."product_attribute"."value_type" IS '值类型';
+COMMENT ON COLUMN "public"."product_attribute"."dep_attr_id" IS '依赖属性ID';
+COMMENT ON COLUMN "public"."product_attribute"."template_id" IS '继承的属性ID';
+COMMENT ON COLUMN "public"."product_attribute"."delay" IS '取数间隔';
+COMMENT ON COLUMN "public"."product_attribute"."unit" IS '取数间隔单位 s m h ';
+COMMENT ON COLUMN "public"."product_attribute"."valuemapid" IS '值映射ID';
+
+-- ----------------------------
+-- Records of product_attribute
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_attribute_event
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_attribute_event";
+CREATE TABLE "public"."product_attribute_event" (
+ "attr_id" int8 NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "key" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "units" varchar(16) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "product_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "create_user" int8,
+ "create_time" timestamp(6),
+ "update_user" int8,
+ "update_time" timestamp(6),
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default",
+ "value_type" varchar(16) COLLATE "pg_catalog"."default",
+ "template_id" int8,
+ "event_level" char(1) COLLATE "pg_catalog"."default",
+ "source" varchar(16) COLLATE "pg_catalog"."default",
+ "delay" int2,
+ "unit" varchar(4) COLLATE "pg_catalog"."default",
+ "valuemapid" varchar(8) COLLATE "pg_catalog"."default",
+ "dep_attr_id" int8
+)
+;
+COMMENT ON COLUMN "public"."product_attribute_event"."attr_id" IS '属性ID';
+COMMENT ON COLUMN "public"."product_attribute_event"."name" IS '属性名称';
+COMMENT ON COLUMN "public"."product_attribute_event"."key" IS '属性标识Key';
+COMMENT ON COLUMN "public"."product_attribute_event"."units" IS '数字类型单位';
+COMMENT ON COLUMN "public"."product_attribute_event"."remark" IS '备注描述';
+COMMENT ON COLUMN "public"."product_attribute_event"."product_id" IS '产品ID';
+COMMENT ON COLUMN "public"."product_attribute_event"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."product_attribute_event"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."product_attribute_event"."update_user" IS '更新人';
+COMMENT ON COLUMN "public"."product_attribute_event"."update_time" IS '更新时间';
+COMMENT ON COLUMN "public"."product_attribute_event"."zbx_id" IS 'itemid';
+COMMENT ON COLUMN "public"."product_attribute_event"."value_type" IS '值类型';
+COMMENT ON COLUMN "public"."product_attribute_event"."template_id" IS '继承的属性ID';
+COMMENT ON COLUMN "public"."product_attribute_event"."event_level" IS '事件级别';
+COMMENT ON COLUMN "public"."product_attribute_event"."source" IS '数据来源';
+COMMENT ON COLUMN "public"."product_attribute_event"."delay" IS '取数间隔';
+COMMENT ON COLUMN "public"."product_attribute_event"."unit" IS '取数间隔单位 s m h ';
+COMMENT ON COLUMN "public"."product_attribute_event"."valuemapid" IS '值映射ID';
+COMMENT ON COLUMN "public"."product_attribute_event"."dep_attr_id" IS '依赖属性ID';
+
+-- ----------------------------
+-- Records of product_attribute_event
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_event
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_event";
+CREATE TABLE "public"."product_event" (
+ "event_rule_id" int8 NOT NULL,
+ "event_rule_name" varchar(255) COLLATE "pg_catalog"."default",
+ "event_level" varchar(1) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8,
+ "exp_logic" varchar(10) COLLATE "pg_catalog"."default",
+ "event_notify" varchar(1) COLLATE "pg_catalog"."default",
+ "status" varchar(8) COLLATE "pg_catalog"."default",
+ "classify" varchar(2) COLLATE "pg_catalog"."default",
+ "task_id" int4,
+ "trigger_type" int2,
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."product_event"."event_rule_id" IS '告警规则ID';
+COMMENT ON COLUMN "public"."product_event"."event_rule_name" IS '告警规则名称';
+COMMENT ON COLUMN "public"."product_event"."event_level" IS '告警等级';
+COMMENT ON COLUMN "public"."product_event"."remark" IS '备注';
+COMMENT ON COLUMN "public"."product_event"."exp_logic" IS 'and 或者 or';
+COMMENT ON COLUMN "public"."product_event"."event_notify" IS '0 否 1 是';
+COMMENT ON COLUMN "public"."product_event"."classify" IS '0 告警 1场景联动';
+COMMENT ON COLUMN "public"."product_event"."task_id" IS '任务ID';
+COMMENT ON COLUMN "public"."product_event"."trigger_type" IS '触发类型 0-条件触发 1-定时触发';
+COMMENT ON COLUMN "public"."product_event"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of product_event
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_event_expression
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_event_expression";
+CREATE TABLE "public"."product_event_expression" (
+ "event_exp_id" int8 NOT NULL,
+ "event_rule_id" int8,
+ "function" varchar(16) COLLATE "pg_catalog"."default",
+ "scope" varchar(10) COLLATE "pg_catalog"."default",
+ "condition" varchar(10) COLLATE "pg_catalog"."default",
+ "value" varchar(255) COLLATE "pg_catalog"."default",
+ "product_attr_key" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "device_id" varchar(255) COLLATE "pg_catalog"."default",
+ "unit" varchar(16) COLLATE "pg_catalog"."default",
+ "product_attr_id" int8,
+ "product_attr_type" varchar(4) COLLATE "pg_catalog"."default",
+ "period" varchar(8) COLLATE "pg_catalog"."default",
+ "attr_value_type" varchar(8) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_event_expression"."event_exp_id" IS '告警函数ID';
+COMMENT ON COLUMN "public"."product_event_expression"."event_rule_id" IS '告警规则ID';
+COMMENT ON COLUMN "public"."product_event_expression"."product_attr_key" IS 'item key';
+COMMENT ON COLUMN "public"."product_event_expression"."device_id" IS '设备ID';
+COMMENT ON COLUMN "public"."product_event_expression"."product_attr_id" IS '属性ID';
+COMMENT ON COLUMN "public"."product_event_expression"."product_attr_type" IS '属性类型 属性 事件';
+COMMENT ON COLUMN "public"."product_event_expression"."period" IS '取值周期 时间 周期';
+COMMENT ON COLUMN "public"."product_event_expression"."attr_value_type" IS '属性值类型';
+
+-- ----------------------------
+-- Records of product_event_expression
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_event_relation
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_event_relation";
+CREATE TABLE "public"."product_event_relation" (
+ "id" int8 NOT NULL DEFAULT nextval('product_event_relation_id_seq'::regclass),
+ "event_rule_id" int8 NOT NULL,
+ "relation_id" varchar(64) COLLATE "pg_catalog"."default",
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default",
+ "inherit" varchar(4) COLLATE "pg_catalog"."default" DEFAULT '0'::character varying,
+ "status" varchar(8) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_event_relation"."event_rule_id" IS '规则ID';
+COMMENT ON COLUMN "public"."product_event_relation"."relation_id" IS '关联产品或设备ID';
+COMMENT ON COLUMN "public"."product_event_relation"."zbx_id" IS 'trigger id';
+COMMENT ON COLUMN "public"."product_event_relation"."inherit" IS '是否来自产品';
+COMMENT ON COLUMN "public"."product_event_relation"."status" IS '状态';
+COMMENT ON COLUMN "public"."product_event_relation"."remark" IS '备注';
+
+-- ----------------------------
+-- Records of product_event_relation
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_event_service
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_event_service";
+CREATE TABLE "public"."product_event_service" (
+ "event_rule_id" int8,
+ "service_id" int8,
+ "device_id" varchar(64) COLLATE "pg_catalog"."default",
+ "execute_device_id" varchar(64) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_event_service"."event_rule_id" IS '告警规则ID';
+COMMENT ON COLUMN "public"."product_event_service"."service_id" IS '产品服务ID';
+COMMENT ON COLUMN "public"."product_event_service"."device_id" IS '关联产品或设备ID';
+COMMENT ON COLUMN "public"."product_event_service"."execute_device_id" IS '执行目标设备ID';
+
+-- ----------------------------
+-- Records of product_event_service
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_event_tags
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_event_tags";
+CREATE TABLE "public"."product_event_tags" (
+ "id" int4 NOT NULL DEFAULT nextval('product_event_tags_id_seq'::regclass),
+ "event_rule_id" int8 NOT NULL,
+ "tag_zbx_id" int4 NOT NULL
+)
+;
+COMMENT ON COLUMN "public"."product_event_tags"."id" IS '自增ID';
+COMMENT ON COLUMN "public"."product_event_tags"."event_rule_id" IS '告警规则ID';
+COMMENT ON COLUMN "public"."product_event_tags"."tag_zbx_id" IS 'zabbix tag id';
+
+-- ----------------------------
+-- Records of product_event_tags
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_event_time_interval
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_event_time_interval";
+CREATE TABLE "public"."product_event_time_interval" (
+ "event_time_id" int4 NOT NULL DEFAULT nextval('product_event_time_interval_event_time_id_seq'::regclass),
+ "event_rule_id" int8 NOT NULL,
+ "start_time" int4,
+ "end_time" int4,
+ "day_of_weeks" varchar(16) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_event_time_interval"."event_time_id" IS '告警函数ID';
+COMMENT ON COLUMN "public"."product_event_time_interval"."event_rule_id" IS '告警规则ID';
+COMMENT ON COLUMN "public"."product_event_time_interval"."start_time" IS '开始时间';
+COMMENT ON COLUMN "public"."product_event_time_interval"."end_time" IS '结束时间';
+COMMENT ON COLUMN "public"."product_event_time_interval"."day_of_weeks" IS '周几';
+
+-- ----------------------------
+-- Records of product_event_time_interval
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_service
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_service";
+CREATE TABLE "public"."product_service" (
+ "id" int8 NOT NULL DEFAULT nextval('service_id_seq'::regclass),
+ "name" varchar(64) COLLATE "pg_catalog"."default",
+ "mark" varchar(64) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "async" varchar(16) COLLATE "pg_catalog"."default" DEFAULT 1
+)
+;
+COMMENT ON COLUMN "public"."product_service"."name" IS '服务名称';
+COMMENT ON COLUMN "public"."product_service"."mark" IS '服务标识';
+COMMENT ON COLUMN "public"."product_service"."remark" IS '备注';
+COMMENT ON COLUMN "public"."product_service"."async" IS '执行方式 0-同步 1-异步';
+
+-- ----------------------------
+-- Records of product_service
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_service_param
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_service_param";
+CREATE TABLE "public"."product_service_param" (
+ "id" int8 NOT NULL DEFAULT nextval('service_param_id_seq'::regclass),
+ "service_id" int8,
+ "key" varchar(32) COLLATE "pg_catalog"."default",
+ "name" varchar(32) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "value" varchar(255) COLLATE "pg_catalog"."default",
+ "device_id" varchar(64) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_service_param"."service_id" IS '服务ID';
+COMMENT ON COLUMN "public"."product_service_param"."key" IS '参数标识';
+COMMENT ON COLUMN "public"."product_service_param"."name" IS '参数名称';
+COMMENT ON COLUMN "public"."product_service_param"."remark" IS '备注';
+COMMENT ON COLUMN "public"."product_service_param"."value" IS '参数值';
+COMMENT ON COLUMN "public"."product_service_param"."device_id" IS '关联设备ID';
+
+-- ----------------------------
+-- Records of product_service_param
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_service_relation
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_service_relation";
+CREATE TABLE "public"."product_service_relation" (
+ "service_id" int8 NOT NULL,
+ "relation_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "id" int8 NOT NULL DEFAULT nextval('product_service_relation_id_seq'::regclass),
+ "inherit" varchar(4) COLLATE "pg_catalog"."default" DEFAULT 0
+)
+;
+COMMENT ON COLUMN "public"."product_service_relation"."inherit" IS '是否继承';
+
+-- ----------------------------
+-- Records of product_service_relation
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_status_function
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_status_function";
+CREATE TABLE "public"."product_status_function" (
+ "rule_function" varchar(10) COLLATE "pg_catalog"."default",
+ "rule_status" int2 DEFAULT 1,
+ "create_user" int8,
+ "update_user" int8,
+ "create_time" timestamp(6),
+ "update_time" timestamp(6),
+ "rule_id" int8 NOT NULL,
+ "rule_condition" varchar(255) COLLATE "pg_catalog"."default",
+ "rule_function_recovery" varchar(10) COLLATE "pg_catalog"."default",
+ "rule_condition_recovery" varchar(255) COLLATE "pg_catalog"."default",
+ "attr_id" int8,
+ "attr_id_recovery" int8,
+ "unit" varchar(8) COLLATE "pg_catalog"."default",
+ "unit_recovery" varchar(8) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_status_function"."rule_function" IS '''nodata'' or ''last''';
+COMMENT ON COLUMN "public"."product_status_function"."rule_status" IS '0 or 1';
+COMMENT ON COLUMN "public"."product_status_function"."rule_id" IS '触发器ID,离线 上线';
+COMMENT ON COLUMN "public"."product_status_function"."rule_condition" IS '''5m'' or ''4''';
+COMMENT ON COLUMN "public"."product_status_function"."rule_function_recovery" IS '''nodata'' or ''last''';
+COMMENT ON COLUMN "public"."product_status_function"."rule_condition_recovery" IS '''5m'' or ''4''';
+COMMENT ON COLUMN "public"."product_status_function"."attr_id" IS 'trigger attrId';
+COMMENT ON COLUMN "public"."product_status_function"."attr_id_recovery" IS 'recovery attrId';
+
+-- ----------------------------
+-- Records of product_status_function
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_status_function_relation
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_status_function_relation";
+CREATE TABLE "public"."product_status_function_relation" (
+ "rule_id" int8 NOT NULL,
+ "relation_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "id" int8 NOT NULL DEFAULT nextval('product_status_function_relation_id_seq'::regclass),
+ "inherit" varchar(4) COLLATE "pg_catalog"."default" DEFAULT 0,
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default",
+ "zbx_id_recovery" varchar(32) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."product_status_function_relation"."inherit" IS '是否继承自产品 1是0否';
+COMMENT ON COLUMN "public"."product_status_function_relation"."zbx_id" IS 'zabbix trigger id';
+COMMENT ON COLUMN "public"."product_status_function_relation"."zbx_id_recovery" IS 'zbx recovery trigger id';
+
+-- ----------------------------
+-- Records of product_status_function_relation
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for product_type
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."product_type";
+CREATE TABLE "public"."product_type" (
+ "id" int4 NOT NULL DEFAULT nextval('product_type_product_type_id_seq'::regclass),
+ "pid" int4,
+ "name" varchar(32) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "pids" varchar(255) COLLATE "pg_catalog"."default",
+ "create_user" int8,
+ "create_time" timestamp(6),
+ "update_user" int8,
+ "update_time" timestamp(6),
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."product_type"."name" IS '分类名称';
+COMMENT ON COLUMN "public"."product_type"."remark" IS '备注';
+COMMENT ON COLUMN "public"."product_type"."pids" IS '所有父ID';
+COMMENT ON COLUMN "public"."product_type"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."product_type"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."product_type"."update_user" IS '更新人';
+COMMENT ON COLUMN "public"."product_type"."update_time" IS '更新时间';
+COMMENT ON COLUMN "public"."product_type"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of product_type
+-- ----------------------------
+INSERT INTO "public"."product_type" VALUES (1, 0, '默认产品分组', NULL, '[0],', NULL, NULL, NULL, NULL, NULL);
+
+-- ----------------------------
+-- Table structure for protocol_component
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."protocol_component";
+CREATE TABLE "public"."protocol_component" (
+ "protocol_component_id" int8 NOT NULL DEFAULT nextval('protocol_component_protocol_component_id_seq'::regclass),
+ "name" varchar(64) COLLATE "pg_catalog"."default",
+ "effect_proxy" varchar(255) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "status" varchar(4) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8,
+ "tenant_id" int8,
+ "protocol_type" varchar(8) COLLATE "pg_catalog"."default",
+ "file_name" varchar(255) COLLATE "pg_catalog"."default",
+ "unique_id" varchar(16) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."protocol_component"."name" IS '组件名称';
+COMMENT ON COLUMN "public"."protocol_component"."effect_proxy" IS '影响的代理';
+COMMENT ON COLUMN "public"."protocol_component"."remark" IS '备注';
+COMMENT ON COLUMN "public"."protocol_component"."status" IS '状态 0-待上传 1-未发布 2-已发布';
+COMMENT ON COLUMN "public"."protocol_component"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."protocol_component"."create_user" IS '创建者';
+COMMENT ON COLUMN "public"."protocol_component"."update_time" IS '系统时间';
+COMMENT ON COLUMN "public"."protocol_component"."update_user" IS '修改者';
+COMMENT ON COLUMN "public"."protocol_component"."tenant_id" IS '租户ID';
+COMMENT ON COLUMN "public"."protocol_component"."protocol_type" IS '协议类型';
+COMMENT ON COLUMN "public"."protocol_component"."file_name" IS '协议JAR包名称';
+COMMENT ON COLUMN "public"."protocol_component"."unique_id" IS '唯一ID';
+
+-- ----------------------------
+-- Records of protocol_component
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for protocol_gateway
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."protocol_gateway";
+CREATE TABLE "public"."protocol_gateway" (
+ "protocol_gateway_id" int8 NOT NULL DEFAULT nextval('protocol_gateway_protocol_gateway_id_seq'::regclass),
+ "name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "protocol_type" varchar(4) COLLATE "pg_catalog"."default",
+ "protocol_component_id" int8,
+ "protocol_service_id" int8,
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8,
+ "tenant_id" int8,
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "status" varchar(4) COLLATE "pg_catalog"."default",
+ "qos" int2
+)
+;
+COMMENT ON COLUMN "public"."protocol_gateway"."name" IS '名称';
+COMMENT ON COLUMN "public"."protocol_gateway"."protocol_type" IS '类型';
+COMMENT ON COLUMN "public"."protocol_gateway"."protocol_component_id" IS '协议组件ID';
+COMMENT ON COLUMN "public"."protocol_gateway"."protocol_service_id" IS '协议服务ID';
+COMMENT ON COLUMN "public"."protocol_gateway"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."protocol_gateway"."create_user" IS '创建者';
+COMMENT ON COLUMN "public"."protocol_gateway"."update_time" IS '系统时间';
+COMMENT ON COLUMN "public"."protocol_gateway"."update_user" IS '修改者';
+COMMENT ON COLUMN "public"."protocol_gateway"."tenant_id" IS '租户ID';
+COMMENT ON COLUMN "public"."protocol_gateway"."remark" IS '备注';
+COMMENT ON COLUMN "public"."protocol_gateway"."status" IS '网关状态';
+COMMENT ON COLUMN "public"."protocol_gateway"."qos" IS 'Qos';
+
+-- ----------------------------
+-- Records of protocol_gateway
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for protocol_gateway_mqtt
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."protocol_gateway_mqtt";
+CREATE TABLE "public"."protocol_gateway_mqtt" (
+ "protocol_gateway_id" int8 NOT NULL,
+ "topic" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "protocol_component_id" int8 NOT NULL
+)
+;
+COMMENT ON COLUMN "public"."protocol_gateway_mqtt"."protocol_gateway_id" IS '设备协议ID';
+COMMENT ON COLUMN "public"."protocol_gateway_mqtt"."topic" IS 'mqtt client 协议 TOPIC';
+COMMENT ON COLUMN "public"."protocol_gateway_mqtt"."protocol_component_id" IS '协议组件ID';
+
+-- ----------------------------
+-- Records of protocol_gateway_mqtt
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for protocol_service
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."protocol_service";
+CREATE TABLE "public"."protocol_service" (
+ "protocol_service_id" int8 NOT NULL DEFAULT nextval('protocol_service_protocol_service_id_seq'::regclass),
+ "name" varchar(64) COLLATE "pg_catalog"."default",
+ "protocol_type" varchar(4) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "effect_proxy" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8,
+ "tenant_id" int8,
+ "url" varchar(128) COLLATE "pg_catalog"."default",
+ "ip" varchar(16) COLLATE "pg_catalog"."default",
+ "port" int2,
+ "msg_length" int2,
+ "client_id" varchar(32) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."protocol_service"."name" IS '名称';
+COMMENT ON COLUMN "public"."protocol_service"."protocol_type" IS '协议类型';
+COMMENT ON COLUMN "public"."protocol_service"."remark" IS '备注';
+COMMENT ON COLUMN "public"."protocol_service"."effect_proxy" IS '影响的代理';
+COMMENT ON COLUMN "public"."protocol_service"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."protocol_service"."create_user" IS '创建者';
+COMMENT ON COLUMN "public"."protocol_service"."update_time" IS '系统时间';
+COMMENT ON COLUMN "public"."protocol_service"."update_user" IS '修改者';
+COMMENT ON COLUMN "public"."protocol_service"."tenant_id" IS '租户ID';
+COMMENT ON COLUMN "public"."protocol_service"."url" IS 'URL';
+COMMENT ON COLUMN "public"."protocol_service"."ip" IS 'ip地址';
+COMMENT ON COLUMN "public"."protocol_service"."port" IS '端口';
+COMMENT ON COLUMN "public"."protocol_service"."msg_length" IS '消息长度';
+
+-- ----------------------------
+-- Records of protocol_service
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for proxy
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."proxy";
+CREATE TABLE "public"."proxy" (
+ "id" int8 NOT NULL,
+ "name" varchar(64) COLLATE "pg_catalog"."default",
+ "mode" varchar(16) COLLATE "pg_catalog"."default" DEFAULT '0'::character varying,
+ "address" varchar(32) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "tls_accept" int4 DEFAULT 1,
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8,
+ "zbx_id" varchar(16) COLLATE "pg_catalog"."default",
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."proxy"."name" IS '代理名称';
+COMMENT ON COLUMN "public"."proxy"."mode" IS '代理模式';
+COMMENT ON COLUMN "public"."proxy"."address" IS '代理服务器地址';
+COMMENT ON COLUMN "public"."proxy"."remark" IS '描述';
+COMMENT ON COLUMN "public"."proxy"."tls_accept" IS '加密方式';
+COMMENT ON COLUMN "public"."proxy"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."proxy"."create_user" IS '创建者';
+COMMENT ON COLUMN "public"."proxy"."update_time" IS '系统时间';
+COMMENT ON COLUMN "public"."proxy"."update_user" IS '修改者';
+COMMENT ON COLUMN "public"."proxy"."zbx_id" IS 'zbx ID';
+COMMENT ON COLUMN "public"."proxy"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of proxy
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for scenes_trigger_record
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."scenes_trigger_record";
+CREATE TABLE "public"."scenes_trigger_record" (
+ "id" int8 NOT NULL DEFAULT nextval('scenes_trigger_record_id_seq'::regclass),
+ "create_time" timestamp(6),
+ "rule_name" varchar(64) COLLATE "pg_catalog"."default",
+ "rule_id" int8,
+ "trigger_type" varchar(16) COLLATE "pg_catalog"."default",
+ "trigger_user" int8,
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."scenes_trigger_record"."create_time" IS '触发时间';
+COMMENT ON COLUMN "public"."scenes_trigger_record"."rule_name" IS '场景联动名称';
+COMMENT ON COLUMN "public"."scenes_trigger_record"."rule_id" IS '场景联动ID';
+COMMENT ON COLUMN "public"."scenes_trigger_record"."trigger_type" IS '触发类型 手动 自动';
+COMMENT ON COLUMN "public"."scenes_trigger_record"."trigger_user" IS '触发人';
+COMMENT ON COLUMN "public"."scenes_trigger_record"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of scenes_trigger_record
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for service_execute_record
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."service_execute_record";
+CREATE TABLE "public"."service_execute_record" (
+ "id" int8 NOT NULL DEFAULT nextval('service_execute_record_id_seq'::regclass),
+ "create_time" timestamp(6),
+ "service_name" varchar(64) COLLATE "pg_catalog"."default",
+ "param" varchar(255) COLLATE "pg_catalog"."default",
+ "device_id" varchar(64) COLLATE "pg_catalog"."default",
+ "execute_type" varchar(16) COLLATE "pg_catalog"."default",
+ "execute_user" int8,
+ "execute_rule_id" int8,
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."service_execute_record"."service_name" IS '服务名称';
+COMMENT ON COLUMN "public"."service_execute_record"."param" IS '执行参数';
+COMMENT ON COLUMN "public"."service_execute_record"."device_id" IS '设备ID';
+COMMENT ON COLUMN "public"."service_execute_record"."execute_type" IS '执行方式 手动触发 场景触发';
+COMMENT ON COLUMN "public"."service_execute_record"."execute_user" IS '执行人 执行方式未手动触发时有值';
+COMMENT ON COLUMN "public"."service_execute_record"."execute_rule_id" IS '执行场景ID';
+COMMENT ON COLUMN "public"."service_execute_record"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of service_execute_record
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for session
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."session";
+CREATE TABLE "public"."session" (
+ "id" int4 NOT NULL DEFAULT nextval('session_id_seq'::regclass),
+ "key" varchar(255) COLLATE "pg_catalog"."default",
+ "value" varchar COLLATE "pg_catalog"."default"
+)
+;
+
+-- ----------------------------
+-- Records of session
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for sys_config
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_config";
+CREATE TABLE "public"."sys_config" (
+ "id" int8 NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "dict_flag" char(1) COLLATE "pg_catalog"."default" NOT NULL,
+ "dict_type_id" int8,
+ "value" varchar(255) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "create_user" int8,
+ "update_user" int8,
+ "create_time" timestamp(6),
+ "update_time" timestamp(6),
+ "status" varchar(8) COLLATE "pg_catalog"."default" DEFAULT 'ENABLE'::character varying
+)
+;
+COMMENT ON COLUMN "public"."sys_config"."id" IS '主键ID';
+COMMENT ON COLUMN "public"."sys_config"."name" IS '名称';
+COMMENT ON COLUMN "public"."sys_config"."code" IS '属性编码标识';
+COMMENT ON COLUMN "public"."sys_config"."dict_flag" IS '是否是字典中的值';
+COMMENT ON COLUMN "public"."sys_config"."dict_type_id" IS '字典类型的编码';
+COMMENT ON COLUMN "public"."sys_config"."value" IS '属性值,如果是字典中的类型,则为dict的code';
+COMMENT ON COLUMN "public"."sys_config"."remark" IS '备注';
+COMMENT ON COLUMN "public"."sys_config"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."sys_config"."update_user" IS '更新人';
+COMMENT ON COLUMN "public"."sys_config"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."sys_config"."update_time" IS '修改时间';
+COMMENT ON COLUMN "public"."sys_config"."status" IS '是否可修改 ENABLE可以 DISABLE不可';
+
+-- ----------------------------
+-- Records of sys_config
+-- ----------------------------
+INSERT INTO "public"."sys_config" VALUES (1143324237579165697, '验证码开关', 'ZEUS_KAPTCHA_OPEN', 'Y', 1106120265689055233, 'DISABLE', '是否开启验证码', 1, 1, '2019-06-24 12:46:43', '2021-08-03 16:38:12.432', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1143468689664876546, '管理系统名称', 'ZEUS_SYSTEM_NAME', 'N', NULL, 'ZEUS-IOT', '管理系统名称', 1, 1, '2019-06-25 18:39:15', '2021-08-09 17:17:30.189', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1143468867767607297, '默认系统密码', 'ZEUS_DEFAULT_PASSWORD', 'N', NULL, '111111', '默认系统密码', 1, 1, '2019-06-25 18:39:57', '2021-08-03 16:38:12.432', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1143468867767607298, '用户角色ID', 'ZEUS_ADMIN_ROLE_ID', 'N', NULL, '3', '用户角色ID', 1, 1, NULL, NULL, 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1143469008025133058, 'OAuth2登录用户的账号标识', 'ZEUS_OAUTH2_PREFIX', 'N', NULL, 'oauth2', 'OAuth2登录用户的账号标识', 1, 1, '2019-06-25 18:40:31', '2021-08-03 16:38:12.432', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370496, '全局主机组Id', 'ZEUS_HOST_GROUP_ID', 'Y', NULL, '19', '全局主机和模板组ID', NULL, NULL, NULL, NULL, 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370498, 'Zeus发布的编号', 'ZEUS_SYSTEM_RELEASE_VERSION', 'N', NULL, '10', '用于防止浏览器缓存相关的js和css', 1, 1, '2019-07-02 12:42:30', '2021-08-03 16:38:12.432', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370499, '文件上传路径', 'ZEUS_FILE_UPLOAD_PATH', 'N', NULL, '/tmp', '文件上传默认目录', 1, 1, '2019-08-30 09:10:40', '2021-08-03 16:38:12.432', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370502, '获取token的header标识', 'ZEUS_TOKEN_HEADER_NAME', 'N', NULL, 'Authorization', '获取token的header标识', 1, 1, '2019-10-16 23:02:39', '2021-08-03 16:38:12.432', 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370602, '获取系统地密钥加密字符', 'ZEUS_JWT_SECRET', 'N', NULL, 'xoav75nyxl4dsm0av1md1zi3wszntan4', '获取系统地密钥加密字符', 1, 1, '2019-10-16 23:02:39', '2021-11-15 11:16:23.993', 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1143468867767607207, '默认租户角色ID', 'ZEUS_TENANT_ROLE_ID', 'N', NULL, '2', '默认租户角色ID', 1, 122, '2019-06-25 18:39:57', '2021-09-28 09:46:39.421', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1143468867767607208, '单点登录开关', 'ZEUS_SIGN_IN', 'N', NULL, 'ENABLE', '是否启用单点登录', 1, 1, '2019-06-25 18:39:57', '2021-08-03 16:38:12.432', 'ENABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370497, '离线回调ActionId', 'ZEUS_OFFLINE_ACTION_ID', 'Y', NULL, '15', '回调动作ID', NULL, NULL, NULL, NULL, 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370501, '获取系统地密钥过期时间', 'ZEUS_JWT_SECRET_EXPIRE', 'N', NULL, '864000000', '获取系统地密钥过期时间(单位:秒),默认1天', 1, 1, '2019-10-16 23:02:39', '2021-08-03 16:38:12.432', 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370503, '告警回调ActionId', 'ZEUS_ALARM_ACTION_ID', 'Y', NULL, '16', '回调动作ID', NULL, NULL, NULL, NULL, 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370504, '动作回调ActionId', 'ZEUS_EXEC_ACTION_ID', 'Y', NULL, '17', '回调动作ID', NULL, NULL, NULL, NULL, 'DISABLE');
+INSERT INTO "public"."sys_config" VALUES (1145915627211370505, '事件回调ActionId', 'ZEUS_EVENT_ACTION_ID', 'Y', NULL, '18', '回调动作ID', NULL, NULL, NULL, NULL, 'DISABLE');
+
+-- ----------------------------
+-- Table structure for sys_dict
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_dict";
+CREATE TABLE "public"."sys_dict" (
+ "dict_id" int8 NOT NULL,
+ "dict_type_id" int8 NOT NULL,
+ "code" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "status" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
+ "sort" int4,
+ "remark" varchar(1000) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "update_time" timestamp(6),
+ "create_user" int8,
+ "update_user" int8,
+ "groups" varchar(64) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."sys_dict"."dict_id" IS '字典id';
+COMMENT ON COLUMN "public"."sys_dict"."dict_type_id" IS '所属字典类型的id';
+COMMENT ON COLUMN "public"."sys_dict"."code" IS '字典编码';
+COMMENT ON COLUMN "public"."sys_dict"."name" IS '字典名称';
+COMMENT ON COLUMN "public"."sys_dict"."status" IS '状态(字典)';
+COMMENT ON COLUMN "public"."sys_dict"."sort" IS '排序';
+COMMENT ON COLUMN "public"."sys_dict"."remark" IS '字典的描述';
+COMMENT ON COLUMN "public"."sys_dict"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."sys_dict"."update_time" IS '更新时间';
+COMMENT ON COLUMN "public"."sys_dict"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."sys_dict"."update_user" IS '修改人';
+COMMENT ON COLUMN "public"."sys_dict"."groups" IS '分组';
+COMMENT ON TABLE "public"."sys_dict" IS '基础字典';
+
+-- ----------------------------
+-- Records of sys_dict
+-- ----------------------------
+INSERT INTO "public"."sys_dict" VALUES (1106120532442595330, 1106120208097067009, 'M', '男', 'ENABLE', NULL, '', '2019-03-14 17:11:00', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120574163337218, 1106120208097067009, 'F', '女', 'ENABLE', NULL, '', '2019-03-14 17:11:10', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120645697191938, 1106120265689055233, 'ENABLE', '启用', 'ENABLE', NULL, '', '2019-03-14 17:11:27', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120699468169217, 1106120265689055233, 'DISABLE', '禁用', 'ENABLE', NULL, '', '2019-03-14 17:11:40', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120784318939137, 1106120322450571266, 'ENABLE', '启用', 'ENABLE', NULL, '', '2019-03-14 17:12:00', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120825993543682, 1106120322450571266, 'FREEZE', '冻结', 'ENABLE', 1, '', '2019-03-14 17:12:10', '2019-03-16 10:56:36', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120875872206849, 1106120322450571266, 'DELETED', '已删除', 'ENABLE', -1221, '', '2019-03-14 17:12:22', '2019-03-16 10:56:53', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120935070613505, 1106120388036902914, 'Y', '删除', 'ENABLE', 23333, '', '2019-03-14 17:12:36', '2019-03-16 10:58:53', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1106120968910258177, 1106120388036902914, 'N', '未删除', 'ENABLE', 1212211221, '', '2019-03-14 17:12:44', '2019-03-16 10:59:03', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1149218674746355713, 1149217131989069826, 'BASE_SYSTEM', '基础功能', 'ENABLE', 1, '系统管理平台', '2019-07-11 15:27:38', '2020-01-01 17:14:45', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533174626959361, 1160532704105742337, '00101', '办公审批', 'ENABLE', 10, '', '2019-08-11 20:47:25', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533264645111810, 1160532704105742337, '00102', '行政审批', 'ENABLE', 20, '', '2019-08-11 20:47:47', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533377727741954, 1160532775455047681, 'KEY_LEAVE', '请假流程标识', 'ENABLE', 10, '', '2019-08-11 20:48:14', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533455343337474, 1160532775455047681, 'KEY_FINANCE', '财务流程标识', 'ENABLE', 20, '', '2019-08-11 20:48:32', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533574843252737, 1160532886713155585, '00401', '事假', 'ENABLE', 10, '', '2019-08-11 20:49:01', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533625615302658, 1160532886713155585, '00402', '婚假', 'ENABLE', 20, '', '2019-08-11 20:49:13', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533707215486977, 1160532886713155585, '00403', '产假', 'ENABLE', 30, '', '2019-08-11 20:49:32', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533765403066370, 1160532886713155585, '00404', '病假', 'ENABLE', 40, '', '2019-08-11 20:49:46', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533863834992641, 1160532886713155585, '00405', '公假', 'ENABLE', 50, '', '2019-08-11 20:50:09', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160533945309347841, 1160532886713155585, '00406', '年假', 'ENABLE', 60, '', '2019-08-11 20:50:29', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1160534007389241346, 1160532886713155585, '00407', '其他', 'ENABLE', 70, '', '2019-08-11 20:50:44', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1212300736972668929, 1149217131989069826, 'ENT_FUNC', '企业功能', 'ENABLE', 20, '企业功能', '2020-01-01 17:13:14', NULL, 1, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423166477712343040, 1423160140530053120, 'DICTTYPE', '字典类型', 'ENABLE', 1, '测试', '2021-08-05 14:18:24.098', '2021-08-05 14:18:24.098', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423234510216499200, 1423160140530053120, 'DICTTYPE4', '字典类型4', 'ENABLE', 1, '测试', '2021-08-05 18:48:44.31', '2021-08-05 18:48:44.31', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423234906741895168, 1423160140530053120, 'DICTTYPE5', '字典类型5', 'ENABLE', 1, '测试', '2021-08-05 18:50:18.848', '2021-08-05 18:50:18.848', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423235174556626944, 1423160140530053120, 'DICTTYPE6', '字典类型6', 'ENABLE', 1, '测试', '2021-08-05 18:51:22.701', '2021-08-05 18:51:22.701', 1, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423464964597334017, 1160532886713155586, '1', '直连设备', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423464964597334018, 1160532886713155586, '2', '网关子设备', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423464964597334019, 1160532886713155586, '3', '网关设备', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199425, 1160532886713155587, 'wechat', '企业微信', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199426, 1160532886713155587, 'dingtalk', '钉钉', 'ENABLE', 2, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199427, 1160532886713155587, 'feishu', '飞书', 'ENABLE', 3, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199428, 1160532886713155588, '2', '主动上报', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199430, 1160532886713155588, '18', '根据单个属性预处理', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199431, 1160532886713155590, '3', '整数', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199433, 1160532886713155590, '1', '字符', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199434, 1160532886713155590, '4', '文本', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199435, 1160532886713155589, '%', '百分比', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '常用单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199436, 1160532886713155589, 'count', '次', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '常用单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199437, 1160532886713155589, 'r/min', '转每分钟', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '常用单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199438, 1160532886713155589, 'nm', '纳米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '长度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199439, 1160532886713155589, 'μm', '微米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '长度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199440, 1160532886713155589, 'mm', '毫米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '长度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199441, 1160532886713155589, 'cm', '厘米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '长度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199442, 1160532886713155589, 'm', '米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '长度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199443, 1160532886713155589, 'km', '千米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '长度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199444, 1160532886713155589, 'mm²', '平方毫米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '面积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199445, 1160532886713155589, 'cm²', '平方厘米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '面积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199446, 1160532886713155589, 'm²', '平方米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '面积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199447, 1160532886713155589, 'km²', '平方千米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '面积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199448, 1160532886713155589, 'hm²', '公顷', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '面积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199449, 1160532886713155589, 'd', '天', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '时间单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199450, 1160532886713155589, 'h', '小时', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '时间单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199451, 1160532886713155589, 'min', '分钟', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '时间单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199452, 1160532886713155589, 's', '秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '时间单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199453, 1160532886713155589, 'ms', '毫秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '时间单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199454, 1160532886713155589, 'μs', '微秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '时间单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199455, 1160532886713155589, 'ns', '纳秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '时间单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199456, 1160532886713155589, 'mm³', '立方毫米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '体积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199457, 1160532886713155589, 'cm³', '立方厘米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '体积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199458, 1160532886713155589, 'm³', '立方米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '体积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199459, 1160532886713155589, 'km³', '立方千米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '体积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199460, 1160532886713155589, 'm³/s', '立方米每秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199461, 1160532886713155589, 'km³/s', '立方千米每秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199462, 1160532886713155589, 'cm³/s', '立方厘米每秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199463, 1160532886713155589, 'l/s', '升每秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199464, 1160532886713155589, 'm³/h', '立方米每小时', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199465, 1160532886713155589, 'km³/h', '立方千米每小时', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199466, 1160532886713155589, 'cm³/h', '立方厘米每小时', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199467, 1160532886713155589, 'l/h', '升每小时', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '流量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199468, 1160532886713155589, 'mL', '毫升', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '容积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199469, 1160532886713155589, 'L', '升', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '容积单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199470, 1160532886713155589, 'mg', '毫克', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '质量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199471, 1160532886713155589, 'g', '克', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '质量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199472, 1160532886713155589, 'kg', '千克', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '质量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199473, 1160532886713155589, 't', '吨', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '质量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199474, 1160532886713155589, 'Pa', '帕斯卡', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '压力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199475, 1160532886713155589, 'kPa', '千帕斯卡', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '压力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199476, 1160532886713155589, 'N', '牛顿', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199477, 1160532886713155589, 'N.m', '牛·米', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199432, 1160532886713155590, '0', '浮点数', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199478, 1160532886713155589, 'K', '开尔文', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '温度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199479, 1160532886713155589, '℃', '摄氏度', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '温度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199480, 1160532886713155589, '℉', '华氏度', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '温度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199481, 1160532886713155589, 'J', '焦耳', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '能量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199482, 1160532886713155589, 'cal', '卡', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '能量单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199483, 1160532886713155589, 'W', '瓦特', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '功率单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199484, 1160532886713155589, 'kW', '千瓦特', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '功率单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199485, 1160532886713155589, 'rad', '弧度', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '角度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199486, 1160532886713155589, '°', '度', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '角度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199487, 1160532886713155589, '′', '[角]分', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '角度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199488, 1160532886713155589, '″', '[角]秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '角度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199489, 1160532886713155589, 'Hz', '赫兹', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '频率单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199490, 1160532886713155589, 'MHz', '兆赫兹', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '频率单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199491, 1160532886713155589, 'GHz', 'G赫兹', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '频率单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199492, 1160532886713155589, 'm/s', '米每秒', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '速度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199493, 1160532886713155589, 'km/h', '千米每小时', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '速度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199494, 1160532886713155589, 'kn', '节', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '速度单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199495, 1160532886713155589, 'V', '伏特', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199496, 1160532886713155589, 'kV', '千伏', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199497, 1160532886713155589, 'mV', '毫伏', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199498, 1160532886713155589, 'μV', '微伏', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199499, 1160532886713155589, 'A', '安培', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199500, 1160532886713155589, 'Ω', '欧姆', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199501, 1160532886713155589, 'KΩ', '千欧', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199502, 1160532886713155589, 'MΩ', '兆欧', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199503, 1160532886713155589, 'eV', '电子伏', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199504, 1160532886713155589, 'kW·h', '千瓦·时', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '电力单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199505, 1160532886713155589, 'kgce', 'Kg标准煤', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '能源单位');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199506, 1160532886713155591, '25', 'Replace', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '文本');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199507, 1160532886713155591, '4', 'Trim', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '文本');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199508, 1160532886713155591, '2', 'Right trim', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '文本');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199509, 1160532886713155591, '3', 'Left trim', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '文本');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199510, 1160532886713155591, '11', 'XML XPath', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '结构化数据');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199511, 1160532886713155591, '12', 'JSONPath', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '结构化数据');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199512, 1160532886713155591, '13', 'In range', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '验证');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199514, 1160532886713155591, '1', '自定义倍数', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '自定义计算');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199517, 1160532886713155591, '7', '八进制转十进制', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '数制转换');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199518, 1160532886713155591, '8', '十六进制转十进制', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '数制转换');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199519, 1160532886713155591, '21', 'JavaScript', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, '自定义脚本');
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199525, 1440492220332449792, '5', '紧急', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199526, 1440492220332449792, '4', '高级', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199527, 1440492220332449792, '3', '中级', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199528, 1440492220332449792, '1', '信息', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199529, 1440492220332449792, '2', '低级', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199531, 1160532886713155588, '0', 'Agent 采集', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1428599180229115911, 1428599180229115904, '0', '', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199532, 1440492220332449793, '8', 'CoAp', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199533, 1440492220332449793, '7', 'WEBSOCKET SSL', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199534, 1440492220332449793, '6', 'WEBSOCKET', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199535, 1440492220332449793, '5', 'HTTP', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199536, 1440492220332449793, '4', 'UDP', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199537, 1440492220332449793, '3', 'TCP', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199538, 1440492220332449793, '1', 'MQTT', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199539, 1440492220332449793, '2', 'MQTT TLS', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199540, 1440492220332449793, '9', 'CoAp DTLS', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199541, 1440492220332449794, '0', '待上传', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199542, 1440492220332449794, '1', '未发布', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199543, 1440492220332449794, '2', '已发布', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199544, 1440492220332449795, '0', 'MQTT 服务端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199545, 1440492220332449795, '1', 'MQTT 客户端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199546, 1440492220332449795, '2', 'TCP 服务端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199547, 1440492220332449795, '3', 'TCP 客户端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199548, 1440492220332449795, '4', 'UDP', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199549, 1440492220332449795, '5', 'HTTP 服务端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199550, 1440492220332449795, '6', 'HTTP 客户端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199551, 1440492220332449795, '7', 'WEBSOKCET 服务端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199552, 1440492220332449795, '8', 'WEBSOKCET 客户端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199553, 1440492220332449795, '9', 'CoAP 服务端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199554, 1440492220332449795, '10', 'CoAP 客户端', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1428599180229115912, 1428599180229115904, '1', '是', 'ENABLE', 1, NULL, NULL, '2021-11-09 10:13:24.229', NULL, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1429987619034984449, 1142859918022911591, '1', '异步', 'ENABLE', NULL, NULL, NULL, '2021-11-09 10:19:22.483', NULL, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1429987619034984450, 1142859918022911591, '0', '同步', 'ENABLE', NULL, NULL, NULL, '2021-11-09 10:19:45.177', NULL, 1, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199555, 1440492220332449796, '1', '已停止', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO "public"."sys_dict" VALUES (1423897784372199556, 1440492220332449796, '0', '已启动', 'ENABLE', 1, NULL, NULL, NULL, NULL, NULL, NULL);
+
+-- ----------------------------
+-- Table structure for sys_dict_type
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_dict_type";
+CREATE TABLE "public"."sys_dict_type" (
+ "dict_type_id" int8 NOT NULL,
+ "code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "remark" varchar(1000) COLLATE "pg_catalog"."default",
+ "system_flag" char(1) COLLATE "pg_catalog"."default" NOT NULL,
+ "status" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
+ "sort" int4,
+ "create_time" timestamp(6),
+ "create_user" int8,
+ "update_time" timestamp(6),
+ "update_user" int8
+)
+;
+COMMENT ON COLUMN "public"."sys_dict_type"."dict_type_id" IS '字典类型id';
+COMMENT ON COLUMN "public"."sys_dict_type"."code" IS '字典类型编码';
+COMMENT ON COLUMN "public"."sys_dict_type"."name" IS '字典类型名称';
+COMMENT ON COLUMN "public"."sys_dict_type"."remark" IS '字典描述';
+COMMENT ON COLUMN "public"."sys_dict_type"."system_flag" IS '是否是系统字典,Y-是,N-否';
+COMMENT ON COLUMN "public"."sys_dict_type"."status" IS '状态(字典)';
+COMMENT ON COLUMN "public"."sys_dict_type"."sort" IS '排序';
+COMMENT ON COLUMN "public"."sys_dict_type"."create_time" IS '添加时间';
+COMMENT ON COLUMN "public"."sys_dict_type"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."sys_dict_type"."update_time" IS '修改时间';
+COMMENT ON COLUMN "public"."sys_dict_type"."update_user" IS '修改人';
+COMMENT ON TABLE "public"."sys_dict_type" IS '字典类型表';
+
+-- ----------------------------
+-- Records of sys_dict_type
+-- ----------------------------
+INSERT INTO "public"."sys_dict_type" VALUES (1106120208097067009, 'SEX', '性别', '', 'Y', 'ENABLE', 4, '2019-03-14 17:09:43', 1, NULL, NULL);
+INSERT INTO "public"."sys_dict_type" VALUES (1106120265689055233, 'STATUS', '状态', '', 'Y', 'ENABLE', 3, '2019-03-14 17:09:57', 1, NULL, NULL);
+INSERT INTO "public"."sys_dict_type" VALUES (1106120322450571266, 'ACCOUNT_STATUS', '账号状态', '', 'Y', 'ENABLE', 40, '2019-03-14 17:10:10', 1, '2019-08-11 20:46:38', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1106120388036902914, 'DEL_FLAG', '是否删除', '', 'Y', 'ENABLE', 2, '2019-03-14 17:10:26', 1, '2019-03-27 16:26:31', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1149217131989069826, 'SYSTEM_TYPE', '系统分类', '系统所有分类的维护', 'Y', 'ENABLE', 50, '2019-07-11 15:21:30', 1, '2019-08-11 20:46:47', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532704105742337, 'FLOW_CATEGARY', '工作流分类', '工作流分类', 'Y', 'ENABLE', 60, '2019-08-11 20:45:33', 1, NULL, NULL);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532775455047681, 'FLOW_KEY', '工作流标识', '工作流标识', 'Y', 'ENABLE', 70, '2019-08-11 20:45:50', 1, NULL, NULL);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532886713155585, 'LEAVE_TYPE', '请假类型', '请假类型', 'Y', 'ENABLE', 80, '2019-08-11 20:46:17', 1, '2019-08-11 20:46:23', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532886713155586, 'DEVICE_TYPE', '设备类型', '设备类型', 'Y', 'ENABLE', 1, '2019-08-11 20:46:17', 1, '2019-08-11 20:46:23', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532886713155587, 'MEDIA_TYPE', '通知类型', '通知类型', 'N', 'ENABLE', 1, '2019-08-11 20:46:17', 1, '2019-08-11 20:46:23', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532886713155588, 'ATTR_TYPE', '产品属性类型', '产品属性类型', 'Y', 'ENABLE', 1, '2019-08-11 20:46:17', 1, '2019-08-11 20:46:23', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532886713155589, 'UNITS', '产品属性单位', '产品属性单位', 'Y', 'ENABLE', 1, '2019-08-11 20:46:17', 1, '2019-08-11 20:46:23', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532886713155590, 'DATA_TYPE', '产品属性值类型', '产品属性值类型', 'Y', 'ENABLE', 1, '2019-08-11 20:46:17', 1, '2019-08-11 20:46:23', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1160532886713155591, 'DATA_PRE_TYPE', '数据预处理方法名称', '数据预处理方法名称', 'Y', 'ENABLE', 1, '2019-08-11 20:46:17', 1, '2019-08-11 20:46:23', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1423160140530053120, 'DICTTYPE', '字典类型', '测试', 'N', 'ENABLE', NULL, '2021-08-05 13:53:13.196', 1, '2021-08-05 13:53:13.196', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1428599180229115904, 'WHETHER', '是否', '是否', 'N', 'ENABLE', NULL, '2021-08-20 14:06:01.311', 1, '2021-08-20 14:06:01.311', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1440492220332449792, 'EVENT_LEVEL', '告警级别', '告警级别', 'N', 'ENABLE', NULL, '2021-09-22 09:44:43.035', 1, '2021-09-22 09:44:43.102', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1440492220332449793, 'PROTOCOL_TYPE', '协议类型', '协议类型', 'N', 'ENABLE', NULL, '2021-09-22 09:44:43.035', 1, '2021-09-22 09:44:43.102', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1440492220332449794, 'PROTOCOL_COMPONENT_STATUS', '协议組件状态', '协议組件状态', 'N', 'ENABLE', NULL, '2021-09-22 09:44:43.035', 1, '2021-09-22 09:44:43.102', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1440492220332449795, 'PROTOCOL_SERVICE_TYPE', '协议服务类型', '协议服务类型', 'N', 'ENABLE', NULL, '2021-09-22 09:44:43.035', 1, '2021-09-22 09:44:43.102', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1440492220332449796, 'PROTOCOL_GATEWAY_STATUS', '协议网关状态', '协议网关状态', 'N', 'ENABLE', NULL, '2021-09-22 09:44:43.035', 1, '2021-09-22 09:44:43.102', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1455807294571880448, '456456', '456456', '', 'N', 'ENABLE', NULL, '2021-11-03 16:01:21.274', 1, '2021-11-09 10:13:16.934', 1);
+INSERT INTO "public"."sys_dict_type" VALUES (1142859918022911591, 'EXECUTE_TYPE', '服务执行方式', '服务执行方式', 'N', 'ENABLE', 1, NULL, NULL, '2021-11-09 10:33:52.458', 1);
+
+-- ----------------------------
+-- Table structure for sys_login_log
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_login_log";
+CREATE TABLE "public"."sys_login_log" (
+ "log_name" varchar(255) COLLATE "pg_catalog"."default",
+ "user_id" int8,
+ "succeed" varchar(255) COLLATE "pg_catalog"."default",
+ "message" text COLLATE "pg_catalog"."default",
+ "ip_address" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "login_log_id" int8 NOT NULL,
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."sys_login_log"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of sys_login_log
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for sys_menu
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_menu";
+CREATE TABLE "public"."sys_menu" (
+ "menu_id" int8 NOT NULL,
+ "code" varchar(255) COLLATE "pg_catalog"."default",
+ "pcode" varchar(255) COLLATE "pg_catalog"."default",
+ "pcodes" varchar(255) COLLATE "pg_catalog"."default",
+ "name" varchar(255) COLLATE "pg_catalog"."default",
+ "icon" varchar(255) COLLATE "pg_catalog"."default",
+ "url" varchar(255) COLLATE "pg_catalog"."default",
+ "sort" int2,
+ "levels" int2,
+ "menu_flag" varchar(32) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "status" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "update_time" timestamp(6),
+ "create_user" int8,
+ "update_user" int8,
+ "admin_flag" varchar(32) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."sys_menu"."menu_id" IS '菜单ID';
+COMMENT ON COLUMN "public"."sys_menu"."code" IS '菜单编号';
+COMMENT ON COLUMN "public"."sys_menu"."pcode" IS '菜单父编号';
+COMMENT ON COLUMN "public"."sys_menu"."pcodes" IS '当前菜单的所有父菜单编号';
+COMMENT ON COLUMN "public"."sys_menu"."name" IS '菜单名称';
+COMMENT ON COLUMN "public"."sys_menu"."icon" IS '菜单图标';
+COMMENT ON COLUMN "public"."sys_menu"."url" IS 'URL地址';
+COMMENT ON COLUMN "public"."sys_menu"."sort" IS '菜单排序号';
+COMMENT ON COLUMN "public"."sys_menu"."levels" IS '菜单层级';
+COMMENT ON COLUMN "public"."sys_menu"."menu_flag" IS '是否是菜单(字典)';
+COMMENT ON COLUMN "public"."sys_menu"."remark" IS '备注';
+COMMENT ON COLUMN "public"."sys_menu"."status" IS '菜单状态(字典)';
+COMMENT ON COLUMN "public"."sys_menu"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."sys_menu"."update_time" IS '修改时间';
+COMMENT ON COLUMN "public"."sys_menu"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."sys_menu"."update_user" IS '修改人';
+COMMENT ON COLUMN "public"."sys_menu"."admin_flag" IS '是否是超级管理员菜单';
+
+-- ----------------------------
+-- Records of sys_menu
+-- ----------------------------
+INSERT INTO "public"."sys_menu" VALUES (169, 'analyse', '0', '[0],', '统计分析', NULL, '/analyse', 1, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (179, 'alarmList', 'alarm', '[0],[alarm],', '告警记录', NULL, '/alarm/alarmList', 3, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (191, 'alarmAnalyse', 'alarm', '[0],[alarm],', '告警分析', NULL, '/alarm/analyse', 3, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (193, 'scene ', 'rule', '[0],[rule],', '场景联动', NULL, '/rule/scene', 3, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (105, 'system', '0', '[0],', '系统管理', NULL, '/system', 11, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (106, 'userMgr', '0', '[0],', '用户管理', NULL, '/userMgr', 10, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (107, 'mgr_add', 'mgr', '[0],[userMgr],[mgr],', '添加用户', NULL, '/mgr/add', 1, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (108, 'mgr_edit', 'mgr', '[0],[userMgr],[mgr],', '修改用户', NULL, '/mgr/edit', 2, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (109, 'mgr_delete', 'mgr', '[0],[userMgr],[mgr],', '删除用户', NULL, '/mgr/delete', 3, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (110, 'reset', 'mgr', '[0],[userMgr],[mgr],', '重置密码', NULL, '/mgr/reset', 4, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (113, 'mgr_setRole', 'mgr', '[0],[userMgr],[mgr],', '分配角色', NULL, '/mgr/setRole', 7, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (114, 'role', 'system', '[0],[system],', '角色管理', NULL, '/system/role', 111, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'Y');
+INSERT INTO "public"."sys_menu" VALUES (115, 'role_add', 'role', '[0],[system],[role],', '添加角色', NULL, '/role/add', 1, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (116, 'role_edit', 'role', '[0],[system],[role],', '修改角色', NULL, '/role/edit', 2, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (117, 'role_remove', 'role', '[0],[system],[role],', '删除角色', NULL, '/role/remove', 3, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (119, 'menu', 'system', '[0],[system],', '菜单管理', NULL, '/menu', 50, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (128, 'businessLog', 'log', '[0],[log],', '业务日志', NULL, '/log/businessLog', 91, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (132, 'dict', 'system', '[0],[system],', '系统字典', NULL, '/system/dictType', 113, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'Y');
+INSERT INTO "public"."sys_menu" VALUES (133, 'loginLog', 'log', '[0],[log],', '登录日志', NULL, '/log/loginLog', 92, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (138, 'dict_add', 'dict', '[0],[system],[dict],', '添加字典', NULL, '/dictType/addItem', 1, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (139, 'dict_update', 'dict', '[0],[system],[dict],', '修改字典', NULL, '/dictType/editItem', 1, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (140, 'dict_delete', 'dict', '[0],[system],[dict],', '删除字典', NULL, '/dictType/delete', 1, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (151, 'menu_list', 'menu', '[0],[system],[menu],', '菜单列表', NULL, '/menu/list', 5, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (156, 'dict_list', 'dict', '[0],[system],[dict],', '字典列表', NULL, '/dict/list', 5, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (158, 'log_list', 'log', '[0],[system],[log],', '日志列表', NULL, '/log/list', 2, 3, 'N', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (164, 'role_list', 'role', '[0],[system],[role],', '角色列表', NULL, '/role/list', 7, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (167, 'mgr_list', 'mgr', '[0],[userMgr],[mgr],', '用户列表', NULL, '/mgr/list', 10, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (168, 'usrGrp', 'userMgr', '[0],[userMgr],', '用户组管理', NULL, '/userMgr/userGroup', 102, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (170, 'dev_mgr', '0', '[0],', '设备管理', NULL, '/deviceMgr', 3, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (171, 'product_mgr', '0', '[0],', '产品管理', NULL, '/productMgr', 4, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (173, 'view', '0', '[0],', '可视化', NULL, '/view', 99, 1, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (174, 'auth', 'system', '[0],[system],', '平台授权', NULL, '/system/auth', 60, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'Y');
+INSERT INTO "public"."sys_menu" VALUES (176, 'dev_log', 'analyse', '[0],[analyse],', '设备日志', NULL, '/analyse/devLog', 3, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (177, 'dev', 'dev_mgr', '[0],[dev_mgr],', '设备', NULL, '/deviceMgr/device', 41, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (178, 'dev_group', 'dev_mgr', '[0],[dev_mgr],', '设备组', NULL, '/deviceMgr/deviceGroup', 42, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (180, 'product', 'product_mgr', '[0],[product_mgr],', '产品', NULL, '/productMgr/product', 51, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (181, 'product_type', 'product_mgr', '[0],[product_mgr],', '产品分类', NULL, '/productMgr/productType', 52, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (183, 'grafana', 'view', '[0],[view],', 'Grafana配置', NULL, '/view/grafana', 3, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (184, 'log', '0', '[0],', '系统日志', NULL, '/log', 9, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (186, 'sysParam', 'system', '[0],[system],', '系统参数', NULL, '/system/sysParam', 114, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'Y');
+INSERT INTO "public"."sys_menu" VALUES (187, 'media', 'system', '[0],[system],', '通知配置', NULL, '/system/media', 115, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (189, 'home', 'analyse', '[0],[analyse],', '全局概览', NULL, '/analyse/home', 1, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (190, 'latest', 'analyse', '[0],[analyse],', '最新数据', NULL, '/analyse/latest', 1, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (192, 'alarm', '0', '[0],', '告警管理', NULL, '/alarm', 6, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (194, 'rule', '0', '[0],', '规则引擎', NULL, '/rule', 5, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (195, 'process', 'rule', '[0],[rule],', '流程配置', NULL, '/rule/process', 4, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (196, 'api', 'dev_mgr', '[0],[dev_mgr],', '设备调试', NULL, '/deviceMgr/debug', 43, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (197, 'about', '0', '[0],', '关于我们', NULL, '/about', 99, 1, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (198, 'realTime', '0', '[0],', '平台监控', NULL, '/realTime', 7, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (199, 'proxyInfo', 'system', '[0],[system],', '代理配置', NULL, '/system/proxyInfo', 116, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (200, 'proxyMonitor', 'realTime', '[0],[realTime],', '代理监控', NULL, '/realTime/proxy', 82, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (201, 'grafana', 'analyse', '[0],[analyse],', '数据大屏', NULL, '/analyse/grafana', 5, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (202, 'dev_add', 'dev', '[0],[dev_mgr],[dev],', '增加设备', NULL, '/deviceMgr/device/add', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (203, 'dev_update', 'dev', '[0],[dev_mgr],[dev],', '修改设备', NULL, '/deviceMgr/device/update', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (204, 'dev_delete', 'dev', '[0],[dev_mgr],[dev],', '删除设备', NULL, '/deviceMgr/device/delete', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (205, 'dev_list', 'dev', '[0],[dev_mgr],[dev],', '设备列表', NULL, '/deviceMgr/device/list', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (206, 'dev_detail', 'dev', '[0],[dev_mgr],[dev],', '设备详情', NULL, '/deviceMgr/device/detail', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (207, 'product_add', 'product', '[0],[product_mgr],[product],', '增加产品', NULL, '/productMgr/product', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (208, 'product_update', 'product', '[0],[product_mgr],[product],', '修改产品', NULL, '/productMgr/product', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (209, 'product_delete', 'product', '[0],[product_mgr],[product],', '删除产品', NULL, '/productMgr/product', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (210, 'product_list', 'product', '[0],[product_mgr],[product],', '产品列表', NULL, '/productMgr/product', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (118, 'role_setAuthority', 'role', '[0],[system],[role],', '配置菜单', NULL, '/role/setAuthority', 4, 3, 'N', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (120, 'menu_add', 'menu', '[0],[system],[menu],', '添加菜单', NULL, '/menu/add', 1, 3, 'N', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (121, 'menu_edit', 'menu', '[0],[system],[menu],', '修改菜单', NULL, '/menu/edit', 2, 3, 'N', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (122, 'menu_remove', 'menu', '[0],[system],[menu],', '删除菜单', NULL, '/menu/remove', 3, 3, 'N', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (219, 'distributed', 'dev_mgr', '[0],[dev_mgr],', '设备分布', NULL, '/deviceMgr/distributed', 3, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (220, 'platformLog', '0', '[0],', '平台日志', NULL, '/platformLog', 8, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (221, 'platformLog_event', 'platformLog', '[0],[platformLog],', '事件日志', NULL, '/platformLog/event', 34, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (222, 'platformLog_service', 'platformLog', '[0],[platformLog],', '服务日志', NULL, '/platformLog/service', 33, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (223, 'platformLog_alert', 'platformLog', '[0],[platformLog],', '告警日志', NULL, '/platformLog/alert', 31, 2, 'Y', NULL, 'DISABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (224, 'platformLog_linkage', 'platformLog', '[0],[platformLog],', '联动日志', NULL, '/platformLog/linkage', 32, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (225, 'visualization', '0', '[0],', '可视化', NULL, '/visualization', 2, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (226, 'visualization_distributed', 'visualization', '[0],[visualization],', '设备分布', NULL, '/visualization/distributed', 21, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (227, 'visualization_grafana', 'visualization', '[0],[visualization],', 'Grafana', NULL, '/visualization/grafana', 22, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (228, 'visualization_building', 'visualization', '[0],[visualization],', '楼宇场景', NULL, '/visualization/building', 23, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (229, 'agreement', '0', '[0],', '协议管理', NULL, '/agreement', 6, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (230, 'agreement_module', 'agreement', '[0],[agreement],', '协议组件', NULL, '/agreement/module', 6, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (231, 'agreement_communication', 'agreement', '[0],[agreement],', '通信服务', NULL, '/agreement/communication', 6, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (232, 'agreement_gateway', 'agreement', '[0],[agreement],', '协议网关', NULL, '/agreement/gateway', 6, 1, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (211, 'product_detail', 'product', '[0],[product_mgr],[product],', '产品详情', NULL, '/productMgr/product', 3, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (212, 'tenant', 'system', '[0],[system],', '租户管理', NULL, '/system/tenant', 112, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'Y');
+INSERT INTO "public"."sys_menu" VALUES (213, 'tenant_add', 'tenant', '[0],[system],', '租户增加', NULL, '/system/tenant', 10, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (214, 'tenant_update', 'tenant', '[0],[system],', '租户修改', NULL, '/system/tenant', 10, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (215, 'tenant_list', 'tenant', '[0],[system],', '租户列表', NULL, '/system/tenant', 10, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (216, 'tenant_delete', 'tenant', '[0],[system],', '租户删除', NULL, '/system/tenant', 10, 3, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (217, 'mgr', 'userMgr', '[0],[userMgr],', '用户', NULL, '/userMgr/user', 101, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+INSERT INTO "public"."sys_menu" VALUES (218, 'platform', 'realTime', '[0],[realTime],', '主服务监控', NULL, '/realTime/platform', 81, 2, 'Y', NULL, 'ENABLE', NULL, NULL, NULL, NULL, 'N');
+
+-- ----------------------------
+-- Table structure for sys_operation_log
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_operation_log";
+CREATE TABLE "public"."sys_operation_log" (
+ "operation_log_id" int8 NOT NULL,
+ "log_type" varchar(32) COLLATE "pg_catalog"."default",
+ "log_name" varchar(255) COLLATE "pg_catalog"."default",
+ "user_id" int8,
+ "class_name" varchar(255) COLLATE "pg_catalog"."default",
+ "method" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(6),
+ "succeed" varchar(32) COLLATE "pg_catalog"."default",
+ "message" text COLLATE "pg_catalog"."default",
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."sys_operation_log"."operation_log_id" IS '操作日志ID';
+COMMENT ON COLUMN "public"."sys_operation_log"."log_type" IS '日志类型【字典】';
+COMMENT ON COLUMN "public"."sys_operation_log"."log_name" IS '日志名称';
+COMMENT ON COLUMN "public"."sys_operation_log"."user_id" IS '用户ID';
+COMMENT ON COLUMN "public"."sys_operation_log"."class_name" IS '类名称';
+COMMENT ON COLUMN "public"."sys_operation_log"."method" IS '方法名称';
+COMMENT ON COLUMN "public"."sys_operation_log"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."sys_operation_log"."succeed" IS '是否成功【字典】';
+COMMENT ON COLUMN "public"."sys_operation_log"."message" IS '备注';
+COMMENT ON COLUMN "public"."sys_operation_log"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of sys_operation_log
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for sys_role
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_role";
+CREATE TABLE "public"."sys_role" (
+ "role_id" int8 NOT NULL,
+ "name" varchar(255) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "sort" int2,
+ "create_user" int8,
+ "update_user" int8,
+ "create_time" timestamp(6),
+ "update_time" timestamp(6)
+)
+;
+
+-- ----------------------------
+-- Records of sys_role
+-- ----------------------------
+INSERT INTO "public"."sys_role" VALUES (1, '超级管理员', 'administrator', 1, NULL, 1, NULL, '2021-08-17 10:57:36.612');
+
+-- ----------------------------
+-- Table structure for sys_role_menu
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_role_menu";
+CREATE TABLE "public"."sys_role_menu" (
+ "role_id" int8,
+ "menu_id" int8
+)
+;
+
+-- ----------------------------
+-- Records of sys_role_menu
+-- ----------------------------
+INSERT INTO "public"."sys_role_menu" VALUES (1, 232);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 231);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 230);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 229);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 228);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 227);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 227);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 226);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 226);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 225);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 225);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 224);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 224);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 223);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 222);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 222);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 221);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 221);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 220);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 220);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 219);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 218);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 218);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 217);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 217);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 217);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 216);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 215);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 214);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 213);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 212);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 211);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 211);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 210);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 210);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 209);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 209);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 208);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 208);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 207);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 207);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 206);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 206);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 205);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 205);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 204);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 204);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 203);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 203);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 202);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 202);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 201);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 200);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 200);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 199);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 199);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 198);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 198);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 197);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 196);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 196);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 195);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 194);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 194);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 193);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 193);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 192);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 192);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 191);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 190);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 189);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 189);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 188);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 187);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 187);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 186);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 185);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 184);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 184);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 183);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 182);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 181);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 181);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 180);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 180);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 179);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 179);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 178);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 178);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 177);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 177);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 176);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 175);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 174);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 173);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 172);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 171);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 171);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 170);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 170);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 169);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 169);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 168);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 168);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 168);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 167);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 167);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 167);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 164);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 156);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 140);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 139);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 138);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 133);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 133);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 132);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 128);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 128);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 122);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 121);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 120);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 119);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 118);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 117);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 116);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 115);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 114);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 113);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 113);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 113);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 112);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 111);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 110);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 110);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 110);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 109);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 109);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 109);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 108);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 108);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 108);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 107);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 107);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 107);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 106);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 106);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 106);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 106);
+INSERT INTO "public"."sys_role_menu" VALUES (1, 105);
+INSERT INTO "public"."sys_role_menu" VALUES (2, 105);
+
+-- ----------------------------
+-- Table structure for sys_user
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_user";
+CREATE TABLE "public"."sys_user" (
+ "account" varchar(32) COLLATE "pg_catalog"."default",
+ "password" varchar(32) COLLATE "pg_catalog"."default",
+ "salt" varchar(32) COLLATE "pg_catalog"."default",
+ "name" varchar(64) COLLATE "pg_catalog"."default",
+ "email" varchar(64) COLLATE "pg_catalog"."default",
+ "phone" varchar(16) COLLATE "pg_catalog"."default",
+ "role_id" int8,
+ "user_group_id" int8,
+ "status" varchar(32) COLLATE "pg_catalog"."default",
+ "create_user" int8,
+ "update_user" int8,
+ "create_time" timestamp(6),
+ "update_time" timestamp(6),
+ "user_id" int8 NOT NULL DEFAULT nextval('sys_user_user_id_seq'::regclass),
+ "zbx_token" varchar(255) COLLATE "pg_catalog"."default",
+ "zbx_id" varchar(64) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."sys_user"."account" IS '登陆账号名';
+COMMENT ON COLUMN "public"."sys_user"."password" IS '密码';
+COMMENT ON COLUMN "public"."sys_user"."salt" IS '密码盐';
+COMMENT ON COLUMN "public"."sys_user"."name" IS '用户名';
+COMMENT ON COLUMN "public"."sys_user"."email" IS '电子邮箱地址';
+COMMENT ON COLUMN "public"."sys_user"."phone" IS '手机号';
+COMMENT ON COLUMN "public"."sys_user"."role_id" IS '角色ID';
+COMMENT ON COLUMN "public"."sys_user"."user_group_id" IS '用户组ID';
+COMMENT ON COLUMN "public"."sys_user"."status" IS '状态';
+COMMENT ON COLUMN "public"."sys_user"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."sys_user"."update_user" IS '修改人';
+COMMENT ON COLUMN "public"."sys_user"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."sys_user"."update_time" IS '更新时间';
+COMMENT ON COLUMN "public"."sys_user"."user_id" IS '用户ID';
+COMMENT ON COLUMN "public"."sys_user"."zbx_token" IS 'zabbix 登陆 token';
+COMMENT ON COLUMN "public"."sys_user"."zbx_id" IS 'zabbix 用户ID';
+COMMENT ON COLUMN "public"."sys_user"."remark" IS '备注';
+COMMENT ON COLUMN "public"."sys_user"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of sys_user
+-- ----------------------------
+INSERT INTO "public"."sys_user" VALUES ('root', '17db03c22596b7609c7c9704f16663e0', 'abcdef', '超级管理员', '888888@qq.com', '13812345678', 1, 1437232484602372096, 'ENABLE', 1, 1, '2021-07-30 21:43:02.686', '2021-07-30 21:43:02.686', 1, '5859e004e8d2a23e6c330c3f9cd277e2', '4', NULL, NULL);
+INSERT INTO "public"."sys_user" VALUES ('Admin', 'cbde417443393372dbac9c185a6ec159', 'gt3zs', '超级管理员', '', '', 1, 1437232484602372096, 'ENABLE', 1, 1, '2021-09-28 09:38:33.668', '2021-09-28 09:38:33.668', 122, 'f6ce31c5f70bf40fae2067087254202c', '1', NULL, NULL);
+
+-- ----------------------------
+-- Table structure for sys_user_group
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_user_group";
+CREATE TABLE "public"."sys_user_group" (
+ "group_name" varchar(255) COLLATE "pg_catalog"."default",
+ "zbx_id" varchar(32) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(0),
+ "create_user" int8,
+ "update_time" timestamp(0),
+ "update_user" int8,
+ "status" varchar(32) COLLATE "pg_catalog"."default" DEFAULT 1,
+ "user_group_id" int8 NOT NULL,
+ "tenant_id" int8
+)
+;
+COMMENT ON COLUMN "public"."sys_user_group"."tenant_id" IS '租户ID';
+
+-- ----------------------------
+-- Records of sys_user_group
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for sys_usrgrp_devicegrp
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."sys_usrgrp_devicegrp";
+CREATE TABLE "public"."sys_usrgrp_devicegrp" (
+ "user_group_id" int8,
+ "device_group_id" int8
+)
+;
+
+-- ----------------------------
+-- Records of sys_usrgrp_devicegrp
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for tag
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."tag";
+CREATE TABLE "public"."tag" (
+ "sid" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
+ "tag" varchar(64) COLLATE "pg_catalog"."default",
+ "value" varchar(64) COLLATE "pg_catalog"."default",
+ "id" int4 NOT NULL DEFAULT nextval('tag_id_seq'::regclass),
+ "template_id" int4,
+ "create_user" int8,
+ "update_user" int8,
+ "create_time" timestamp(6),
+ "update_time" timestamp(6)
+)
+;
+COMMENT ON COLUMN "public"."tag"."sid" IS '所属ID';
+COMMENT ON COLUMN "public"."tag"."tag" IS '标签';
+COMMENT ON COLUMN "public"."tag"."value" IS '标签值';
+COMMENT ON COLUMN "public"."tag"."id" IS 'ID';
+COMMENT ON COLUMN "public"."tag"."template_id" IS '继承的ID';
+COMMENT ON COLUMN "public"."tag"."create_user" IS '创建人';
+COMMENT ON COLUMN "public"."tag"."update_user" IS '修改人';
+COMMENT ON COLUMN "public"."tag"."create_time" IS '创建时间';
+COMMENT ON COLUMN "public"."tag"."update_time" IS '更新时间';
+
+-- ----------------------------
+-- Records of tag
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for task_info
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."task_info";
+CREATE TABLE "public"."task_info" (
+ "id" int4 NOT NULL DEFAULT nextval('task_info_id_seq'::regclass),
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "task_timeout" int4 NOT NULL,
+ "task_fail_retry_count" int4 NOT NULL,
+ "trigger_status" varchar(8) COLLATE "pg_catalog"."default" NOT NULL,
+ "trigger_last_time" int8 NOT NULL,
+ "trigger_next_time" int8 NOT NULL,
+ "misfire_strategy" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+ "schedule_type" varchar(255) COLLATE "pg_catalog"."default",
+ "schedule_conf" varchar(255) COLLATE "pg_catalog"."default",
+ "executor_param" text COLLATE "pg_catalog"."default",
+ "create_time" timestamp(0),
+ "create_user" int8,
+ "update_time" timestamp(0),
+ "update_user" int8
+)
+;
+COMMENT ON COLUMN "public"."task_info"."id" IS '任务ID';
+COMMENT ON COLUMN "public"."task_info"."remark" IS '任务描述';
+COMMENT ON COLUMN "public"."task_info"."task_timeout" IS '任务执行超时时间';
+COMMENT ON COLUMN "public"."task_info"."task_fail_retry_count" IS '失败重试次数';
+COMMENT ON COLUMN "public"."task_info"."trigger_status" IS '调度状态:DISABLE-停止,ENABLE-运行';
+COMMENT ON COLUMN "public"."task_info"."trigger_last_time" IS '上次调度时间';
+COMMENT ON COLUMN "public"."task_info"."trigger_next_time" IS '下次调度时间';
+COMMENT ON COLUMN "public"."task_info"."misfire_strategy" IS '调度过期策略';
+COMMENT ON COLUMN "public"."task_info"."schedule_type" IS '调度类型';
+COMMENT ON COLUMN "public"."task_info"."schedule_conf" IS '调度配置,值含义取决于调度类型';
+COMMENT ON COLUMN "public"."task_info"."executor_param" IS '任务执行参数';
+
+-- ----------------------------
+-- Records of task_info
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for tenant_info
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."tenant_info";
+CREATE TABLE "public"."tenant_info" (
+ "tenant_id" int8 NOT NULL,
+ "name" varchar(64) COLLATE "pg_catalog"."default",
+ "remark" varchar(255) COLLATE "pg_catalog"."default",
+ "create_time" timestamp(0),
+ "create_user" int8,
+ "update_time" timestamp(0),
+ "update_user" int8,
+ "account" varchar(32) COLLATE "pg_catalog"."default",
+ "contact" varchar(16) COLLATE "pg_catalog"."default",
+ "phone" varchar(16) COLLATE "pg_catalog"."default",
+ "status" varchar(8) COLLATE "pg_catalog"."default"
+)
+;
+COMMENT ON COLUMN "public"."tenant_info"."name" IS '租户名称';
+COMMENT ON COLUMN "public"."tenant_info"."account" IS '租户管理员 账号';
+COMMENT ON COLUMN "public"."tenant_info"."contact" IS '联系人';
+COMMENT ON COLUMN "public"."tenant_info"."phone" IS '电话';
+COMMENT ON COLUMN "public"."tenant_info"."status" IS '状态';
+
+-- ----------------------------
+-- Records of tenant_info
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for token
+-- ----------------------------
+DROP TABLE IF EXISTS "public"."token";
+CREATE TABLE "public"."token" (
+ "name" varchar(64) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
+ "description" text COLLATE "pg_catalog"."default" DEFAULT ''::text,
+ "user_id" int8 NOT NULL,
+ "token" varchar(256) COLLATE "pg_catalog"."default" NOT NULL,
+ "status" varchar(8) COLLATE "pg_catalog"."default" NOT NULL DEFAULT 0,
+ "expires_at" int4 NOT NULL DEFAULT 0,
+ "token_id" int4 NOT NULL DEFAULT nextval('token_token_id_seq'::regclass),
+ "account" varchar(32) COLLATE "pg_catalog"."default"
+)
+;
+
+-- ----------------------------
+-- Records of token
+-- ----------------------------
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."device_online_report_id_seq"
+OWNED BY "public"."device_online_report"."id";
+SELECT setval('"public"."device_online_report_id_seq"', 21, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."devices_groups_id_seq"
+OWNED BY "public"."devices_groups"."id";
+SELECT setval('"public"."devices_groups_id_seq"', 196, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."event_trigger_record_id_seq"
+OWNED BY "public"."event_trigger_record"."id";
+SELECT setval('"public"."event_trigger_record_id_seq"', 2, false);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."mail_setting_id_seq"
+OWNED BY "public"."mail_setting"."id";
+SELECT setval('"public"."mail_setting_id_seq"', 2, false);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."media_type_setting_id_seq"
+OWNED BY "public"."media_type_setting"."id";
+SELECT setval('"public"."media_type_setting_id_seq"', 2, false);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."messages_id_seq"
+OWNED BY "public"."messages"."id";
+SELECT setval('"public"."messages_id_seq"', 234, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."notice_record_record_id_seq"
+OWNED BY "public"."notice_record"."record_id";
+SELECT setval('"public"."notice_record_record_id_seq"', 2, false);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."product_event_relation_id_seq"
+OWNED BY "public"."product_event_relation"."id";
+SELECT setval('"public"."product_event_relation_id_seq"', 62, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."product_event_tags_id_seq"
+OWNED BY "public"."product_event_tags"."id";
+SELECT setval('"public"."product_event_tags_id_seq"', 3, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."product_event_time_interval_event_time_id_seq"
+OWNED BY "public"."product_event_time_interval"."event_time_id";
+SELECT setval('"public"."product_event_time_interval_event_time_id_seq"', 9, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."product_service_relation_id_seq"
+OWNED BY "public"."product_service_relation"."id";
+SELECT setval('"public"."product_service_relation_id_seq"', 24, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."product_status_function_relation_id_seq"
+OWNED BY "public"."product_status_function_relation"."id";
+SELECT setval('"public"."product_status_function_relation_id_seq"', 8, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."product_type_product_type_id_seq"
+OWNED BY "public"."product_type"."id";
+SELECT setval('"public"."product_type_product_type_id_seq"', 226, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."protocol_component_protocol_component_id_seq"
+OWNED BY "public"."protocol_component"."protocol_component_id";
+SELECT setval('"public"."protocol_component_protocol_component_id_seq"', 7, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."protocol_gateway_protocol_gateway_id_seq"
+OWNED BY "public"."protocol_gateway"."protocol_gateway_id";
+SELECT setval('"public"."protocol_gateway_protocol_gateway_id_seq"', 9, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."protocol_service_protocol_service_id_seq"
+OWNED BY "public"."protocol_service"."protocol_service_id";
+SELECT setval('"public"."protocol_service_protocol_service_id_seq"', 6, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."scenes_trigger_record_id_seq"
+OWNED BY "public"."scenes_trigger_record"."id";
+SELECT setval('"public"."scenes_trigger_record_id_seq"', 3, false);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."service_execute_record_id_seq"
+OWNED BY "public"."service_execute_record"."id";
+SELECT setval('"public"."service_execute_record_id_seq"', 2, false);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."service_id_seq"
+OWNED BY "public"."product_service"."id";
+SELECT setval('"public"."service_id_seq"', 33, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."service_param_id_seq"
+OWNED BY "public"."product_service_param"."id";
+SELECT setval('"public"."service_param_id_seq"', 19, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."session_id_seq"
+OWNED BY "public"."session"."id";
+SELECT setval('"public"."session_id_seq"', 6, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."sys_user_group_user_group_id_seq"
+OWNED BY "public"."sys_user_group"."user_group_id";
+SELECT setval('"public"."sys_user_group_user_group_id_seq"', 30, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."sys_user_user_id_seq"
+OWNED BY "public"."sys_user"."user_id";
+SELECT setval('"public"."sys_user_user_id_seq"', 123, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."tag_id_seq"
+OWNED BY "public"."tag"."id";
+SELECT setval('"public"."tag_id_seq"', 196, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."task_info_id_seq"
+OWNED BY "public"."task_info"."id";
+SELECT setval('"public"."task_info_id_seq"', 3, true);
+
+-- ----------------------------
+-- Alter sequences owned by
+-- ----------------------------
+ALTER SEQUENCE "public"."token_token_id_seq"
+OWNED BY "public"."token"."token_id";
+SELECT setval('"public"."token_token_id_seq"', 19, true);
+
+-- ----------------------------
+-- Primary Key structure for table device
+-- ----------------------------
+ALTER TABLE "public"."device" ADD CONSTRAINT "device_pkey" PRIMARY KEY ("device_id");
+
+-- ----------------------------
+-- Primary Key structure for table device_group
+-- ----------------------------
+ALTER TABLE "public"."device_group" ADD CONSTRAINT "device_group_pkey" PRIMARY KEY ("device_group_id");
+
+-- ----------------------------
+-- Primary Key structure for table device_online_report
+-- ----------------------------
+ALTER TABLE "public"."device_online_report" ADD CONSTRAINT "device_online_report_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table devices_groups
+-- ----------------------------
+ALTER TABLE "public"."devices_groups" ADD CONSTRAINT "devices_groups_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table event_trigger_record
+-- ----------------------------
+ALTER TABLE "public"."event_trigger_record" ADD CONSTRAINT "event_trigger_record_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table mail_setting
+-- ----------------------------
+ALTER TABLE "public"."mail_setting" ADD CONSTRAINT "mail_setting_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table media_type_setting
+-- ----------------------------
+ALTER TABLE "public"."media_type_setting" ADD CONSTRAINT "media_type_setting_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table messages
+-- ----------------------------
+ALTER TABLE "public"."messages" ADD CONSTRAINT "messages_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table notice_record
+-- ----------------------------
+ALTER TABLE "public"."notice_record" ADD CONSTRAINT "notice_record_pkey" PRIMARY KEY ("record_id");
+
+-- ----------------------------
+-- Primary Key structure for table problem
+-- ----------------------------
+ALTER TABLE "public"."problem" ADD CONSTRAINT "problem_pkey" PRIMARY KEY ("event_id");
+
+-- ----------------------------
+-- Primary Key structure for table product
+-- ----------------------------
+ALTER TABLE "public"."product" ADD CONSTRAINT "product_pkey" PRIMARY KEY ("product_id");
+
+-- ----------------------------
+-- Primary Key structure for table product_attribute
+-- ----------------------------
+ALTER TABLE "public"."product_attribute" ADD CONSTRAINT "product_attribute_pkey" PRIMARY KEY ("attr_id");
+
+-- ----------------------------
+-- Primary Key structure for table product_attribute_event
+-- ----------------------------
+ALTER TABLE "public"."product_attribute_event" ADD CONSTRAINT "product_attribute_copy1_pkey" PRIMARY KEY ("attr_id");
+
+-- ----------------------------
+-- Primary Key structure for table product_event
+-- ----------------------------
+ALTER TABLE "public"."product_event" ADD CONSTRAINT "product_event_pkey" PRIMARY KEY ("event_rule_id");
+
+-- ----------------------------
+-- Primary Key structure for table product_event_expression
+-- ----------------------------
+ALTER TABLE "public"."product_event_expression" ADD CONSTRAINT "product_event_copy1_pkey1" PRIMARY KEY ("event_exp_id");
+
+-- ----------------------------
+-- Primary Key structure for table product_event_relation
+-- ----------------------------
+ALTER TABLE "public"."product_event_relation" ADD CONSTRAINT "product_event_relation_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Indexes structure for table product_event_service
+-- ----------------------------
+CREATE INDEX "eventRuleId" ON "public"."product_event_service" USING btree (
+ "event_rule_id" "pg_catalog"."int8_ops" ASC NULLS LAST
+);
+CREATE INDEX "serviceId" ON "public"."product_event_service" USING btree (
+ "service_id" "pg_catalog"."int8_ops" ASC NULLS LAST
+);
+
+-- ----------------------------
+-- Primary Key structure for table product_event_tags
+-- ----------------------------
+ALTER TABLE "public"."product_event_tags" ADD CONSTRAINT "product_event_tags_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table product_event_time_interval
+-- ----------------------------
+ALTER TABLE "public"."product_event_time_interval" ADD CONSTRAINT "product_event_time_interval_pkey" PRIMARY KEY ("event_time_id");
+
+-- ----------------------------
+-- Primary Key structure for table product_service
+-- ----------------------------
+ALTER TABLE "public"."product_service" ADD CONSTRAINT "service_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table product_service_param
+-- ----------------------------
+ALTER TABLE "public"."product_service_param" ADD CONSTRAINT "service_param_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table product_service_relation
+-- ----------------------------
+ALTER TABLE "public"."product_service_relation" ADD CONSTRAINT "product_service_relation_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table product_status_function
+-- ----------------------------
+ALTER TABLE "public"."product_status_function" ADD CONSTRAINT "product_status_function_pkey" PRIMARY KEY ("rule_id");
+
+-- ----------------------------
+-- Primary Key structure for table product_status_function_relation
+-- ----------------------------
+ALTER TABLE "public"."product_status_function_relation" ADD CONSTRAINT "product_status_function_relation_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table product_type
+-- ----------------------------
+ALTER TABLE "public"."product_type" ADD CONSTRAINT "product_type_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table protocol_component
+-- ----------------------------
+ALTER TABLE "public"."protocol_component" ADD CONSTRAINT "protocol_component_pkey" PRIMARY KEY ("protocol_component_id");
+
+-- ----------------------------
+-- Primary Key structure for table protocol_gateway
+-- ----------------------------
+ALTER TABLE "public"."protocol_gateway" ADD CONSTRAINT "protocol_gateway_pkey" PRIMARY KEY ("protocol_gateway_id");
+
+-- ----------------------------
+-- Primary Key structure for table protocol_service
+-- ----------------------------
+ALTER TABLE "public"."protocol_service" ADD CONSTRAINT "protocol_service_pkey" PRIMARY KEY ("protocol_service_id");
+
+-- ----------------------------
+-- Primary Key structure for table proxy
+-- ----------------------------
+ALTER TABLE "public"."proxy" ADD CONSTRAINT "proxy_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table scenes_trigger_record
+-- ----------------------------
+ALTER TABLE "public"."scenes_trigger_record" ADD CONSTRAINT "scenes_trigger_record_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table service_execute_record
+-- ----------------------------
+ALTER TABLE "public"."service_execute_record" ADD CONSTRAINT "service_execute_record_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table session
+-- ----------------------------
+ALTER TABLE "public"."session" ADD CONSTRAINT "session_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_config
+-- ----------------------------
+ALTER TABLE "public"."sys_config" ADD CONSTRAINT "sys_config_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_dict
+-- ----------------------------
+ALTER TABLE "public"."sys_dict" ADD CONSTRAINT "sys_dict_pkey" PRIMARY KEY ("dict_id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_dict_type
+-- ----------------------------
+ALTER TABLE "public"."sys_dict_type" ADD CONSTRAINT "sys_dict_type_pkey" PRIMARY KEY ("dict_type_id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_login_log
+-- ----------------------------
+ALTER TABLE "public"."sys_login_log" ADD CONSTRAINT "sys_login_log_pkey" PRIMARY KEY ("login_log_id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_menu
+-- ----------------------------
+ALTER TABLE "public"."sys_menu" ADD CONSTRAINT "sys_menu_pkey" PRIMARY KEY ("menu_id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_operation_log
+-- ----------------------------
+ALTER TABLE "public"."sys_operation_log" ADD CONSTRAINT "sys_operation_log_pkey" PRIMARY KEY ("operation_log_id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_role
+-- ----------------------------
+ALTER TABLE "public"."sys_role" ADD CONSTRAINT "sys_role_pkey" PRIMARY KEY ("role_id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_user
+-- ----------------------------
+ALTER TABLE "public"."sys_user" ADD CONSTRAINT "sys_user_pkey" PRIMARY KEY ("user_id");
+
+-- ----------------------------
+-- Primary Key structure for table sys_user_group
+-- ----------------------------
+ALTER TABLE "public"."sys_user_group" ADD CONSTRAINT "sys_user_group_pkey" PRIMARY KEY ("user_group_id");
+
+-- ----------------------------
+-- Primary Key structure for table tag
+-- ----------------------------
+ALTER TABLE "public"."tag" ADD CONSTRAINT "tag_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table task_info
+-- ----------------------------
+ALTER TABLE "public"."task_info" ADD CONSTRAINT "task_info_pkey" PRIMARY KEY ("id");
+
+-- ----------------------------
+-- Primary Key structure for table tenant_info
+-- ----------------------------
+ALTER TABLE "public"."tenant_info" ADD CONSTRAINT "tenant_pkey" PRIMARY KEY ("tenant_id");
+
+-- ----------------------------
+-- Primary Key structure for table token
+-- ----------------------------
+ALTER TABLE "public"."token" ADD CONSTRAINT "token_pkey" PRIMARY KEY ("token_id");
diff --git a/dist-material/bin/startup.bat b/dist-material/bin/startup.bat
new file mode 100644
index 00000000..611631e0
--- /dev/null
+++ b/dist-material/bin/startup.bat
@@ -0,0 +1,22 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+@REM contributor license agreements. See the NOTICE file distributed with
+@REM this work for additional information regarding copyright ownership.
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+@REM (the "License"); you may not use this file except in compliance with
+@REM the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+
+@echo off
+
+setlocal
+call "%~dp0"\IoTServer.bat start
+call "%~dp0"\webappService.bat start
+endlocal
diff --git a/dist-material/bin/startup.sh b/dist-material/bin/startup.sh
new file mode 100644
index 00000000..0ff60e71
--- /dev/null
+++ b/dist-material/bin/startup.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+source /etc/profile
+PRG="$0"
+PRGDIR=`dirname "$PRG"`
+IOT_EXE=IoTServer.sh
+WEBAPP_EXE=webappService.sh
+
+"$PRGDIR"/"$IOT_EXE"
+
+"$PRGDIR"/"$WEBAPP_EXE"
diff --git a/dist-material/bin/stop.sh b/dist-material/bin/stop.sh
new file mode 100755
index 00000000..a8c8db0f
--- /dev/null
+++ b/dist-material/bin/stop.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+set -x
+
+status=`ps -ef | grep zeus-iot-bin | grep java | grep -v grep | awk '{print $2}' | wc -l`
+
+while [ $status -ne 0 ]
+do
+ for i in `ps -ef | grep zeus-iot-bin | grep java | grep -v grep | awk '{print $2}'`
+ do
+ kill -9 $i
+ done
+ status=`ps -ef | grep zeus-iot-bin | grep java | grep -v grep | awk '{print $2}' | wc -l`
+done
\ No newline at end of file
diff --git a/dist-material/bin/webappService.bat b/dist-material/bin/webappService.bat
new file mode 100644
index 00000000..33879bbf
--- /dev/null
+++ b/dist-material/bin/webappService.bat
@@ -0,0 +1,41 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+@REM contributor license agreements. See the NOTICE file distributed with
+@REM this work for additional information regarding copyright ownership.
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+@REM (the "License"); you may not use this file except in compliance with
+@REM the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+
+@echo off
+
+setlocal
+set WEBAPP_PROCESS_TITLE=Zeus-Webapp
+set WEBAPP_HOME=%~dp0%..
+set JARPATH=%WEBAPP_HOME%\webapp
+set WEBAPP_LOG_DIR=%WEBAPP_HOME%\logs
+
+if not exist "%WEBAPP_LOG_DIR%" (
+ mkdir "%WEBAPP_LOG_DIR%"
+)
+
+set LOG_FILE_LOCATION=%WEBAPP_LOG_DIR%\webapp.log
+
+if defined JAVA_HOME (
+ set _EXECJAVA="%JAVA_HOME%\bin\java"
+)
+
+if not defined JAVA_HOME (
+ echo "JAVA_HOME not set."
+ set _EXECJAVA=java
+)
+
+start "%WEBAPP_PROCESS_TITLE%" %_EXECJAVA% -jar %JARPATH%/zeus-webapp.jar --spring.config.location=%JARPATH%/webapp.yml --logging.file=%LOG_FILE_LOCATION%
+endlocal
diff --git a/dist-material/bin/webappService.sh b/dist-material/bin/webappService.sh
new file mode 100644
index 00000000..235fd0de
--- /dev/null
+++ b/dist-material/bin/webappService.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# 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.
+
+PRG="$0"
+PRGDIR=$(dirname "$PRG")
+[ -z "$WEBAPP_HOME" ] && WEBAPP_HOME=$(cd "$PRGDIR/.." > /dev/null || exit 1; pwd)
+
+WEBAPP_LOG_DIR="${WEBAPP_LOG_DIR:-${WEBAPP_HOME}/logs}"
+JAVA_OPTS="${JAVA_OPTS:- -Xms512M -Xmx1024M}"
+JAR_PATH="${WEBAPP_HOME}/webapp"
+
+if [ ! -d "${WEBAPP_LOG_DIR}" ]; then
+ mkdir -p "${WEBAPP_LOG_DIR}"
+fi
+
+LOG_FILE_LOCATION=${WEBAPP_LOG_DIR}/webapp.log
+
+_RUNJAVA=${JAVA_HOME}/bin/java
+[ -z "$JAVA_HOME" ] && _RUNJAVA=java
+
+eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} -jar ${JAR_PATH}/zeus-webapp.jar \
+ --spring.config.location=${JAR_PATH}/webapp.yml \
+ --logging.file=${LOG_FILE_LOCATION} \
+ &> ${WEBAPP_LOG_DIR}/webapp-console.log &"
+
+if [ $? -eq 0 ]; then
+ sleep 1
+ echo "Zeus Web Application started successfully!"
+else
+ echo "Zeus Web Application started failure!"
+ exit 1
+fi
diff --git a/dist-material/log4j2.xml b/dist-material/log4j2.xml
new file mode 100644
index 00000000..094421a4
--- /dev/null
+++ b/dist-material/log4j2.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+ ${sys:iot.logDir}
+
+
+
+
+ %d - %c - %L [%t] %-5p %x - %m%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
new file mode 100644
index 00000000..740e9b7a
--- /dev/null
+++ b/docker/docker-compose.yaml
@@ -0,0 +1,237 @@
+version: '3.5'
+services:
+ zabbix-server:
+ image: zabbix/zabbix-server-pgsql:alpine-5.4-latest
+ ports:
+ - "10051:10051"
+ volumes:
+ - /etc/localtime:/etc/localtime:ro
+ - /etc/timezone:/etc/timezone:ro
+ - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro
+ - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro
+ - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw
+ - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro
+ - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro
+ - ./zbx_env/var/lib/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys:ro
+ - ./zbx_env/var/lib/zabbix/mibs:/var/lib/zabbix/mibs:ro
+ - ./zbx_env/var/lib/zabbix/snmptraps:/var/lib/zabbix/snmptraps:ro
+ ulimits:
+ nproc: 65535
+ nofile:
+ soft: 20000
+ hard: 40000
+ deploy:
+ resources:
+ limits:
+ cpus: '0.70'
+ memory: 1G
+ reservations:
+ cpus: '0.5'
+ memory: 512M
+ env_file:
+ - ./env_vars/.env_db_pgsql
+ - ./env_vars/.env_srv
+ secrets:
+ - POSTGRES_USER
+ - POSTGRES_PASSWORD
+ depends_on:
+ - postgres-server
+ networks:
+ zbx_net_backend:
+ aliases:
+ - zabbix-server
+ - zabbix-server-pgsql
+ - zabbix-server-alpine-pgsql
+ - zabbix-server-pgsql-alpine
+ zbx_net_frontend:
+# devices:
+# - "/dev/ttyUSB0:/dev/ttyUSB0"
+ stop_grace_period: 30s
+ sysctls:
+ - net.ipv4.ip_local_port_range=1024 65000
+ - net.ipv4.conf.all.accept_redirects=0
+ - net.ipv4.conf.all.secure_redirects=0
+ - net.ipv4.conf.all.send_redirects=0
+ labels:
+ com.zabbix.description: "Zabbix server with PostgreSQL database support"
+ com.zabbix.company: "Zabbix LLC"
+ com.zabbix.component: "zabbix-server"
+ com.zabbix.dbtype: "pgsql"
+ com.zabbix.os: "alpine"
+
+
+ zabbix-web-nginx-pgsql:
+ image: zabbix/zabbix-web-nginx-pgsql:alpine-5.4-latest
+ ports:
+ - "80:8080"
+ - "443:8443"
+ volumes:
+ - /etc/localtime:/etc/localtime:ro
+ - /etc/timezone:/etc/timezone:ro
+ - ./zbx_env/etc/ssl/nginx:/etc/ssl/nginx:ro
+ - ./zbx_env/usr/share/zabbix/modules/:/usr/share/zabbix/modules/:ro
+# - ./env_vars/.ZBX_DB_CA_FILE:/run/secrets/root-ca.pem:ro
+# - ./env_vars/.ZBX_DB_CERT_FILE:/run/secrets/client-cert.pem:ro
+# - ./env_vars/.ZBX_DB_KEY_FILE:/run/secrets/client-key.pem:ro
+ deploy:
+ resources:
+ limits:
+ cpus: '0.70'
+ memory: 512M
+ reservations:
+ cpus: '0.5'
+ memory: 256M
+ env_file:
+ - ./env_vars/.env_db_pgsql
+ - ./env_vars/.env_web
+ secrets:
+ - POSTGRES_USER
+ - POSTGRES_PASSWORD
+ depends_on:
+ - postgres-server
+ - zabbix-server
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:8080/"]
+ interval: 10s
+ timeout: 5s
+ retries: 3
+ start_period: 30s
+ networks:
+ zbx_net_backend:
+ aliases:
+ - zabbix-web-nginx-pgsql
+ - zabbix-web-nginx-alpine-pgsql
+ - zabbix-web-nginx-pgsql-alpine
+ zbx_net_frontend:
+ stop_grace_period: 10s
+ sysctls:
+ - net.core.somaxconn=65535
+ labels:
+ com.zabbix.description: "Zabbix frontend on Nginx web-server with PostgreSQL database support"
+ com.zabbix.company: "Zabbix LLC"
+ com.zabbix.component: "zabbix-frontend"
+ com.zabbix.webserver: "nginx"
+ com.zabbix.dbtype: "pgsql"
+ com.zabbix.os: "alpine"
+
+ zabbix-agent:
+ image: zabbix/zabbix-agent:alpine-5.4-latest
+ ports:
+ - "10050:10050"
+ volumes:
+ - /etc/localtime:/etc/localtime:ro
+ - /etc/timezone:/etc/timezone:ro
+ - ./zbx_env/etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d:ro
+ - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro
+ - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro
+ - ./zbx_env/var/lib/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys:ro
+ deploy:
+ resources:
+ limits:
+ cpus: '0.2'
+ memory: 128M
+ reservations:
+ cpus: '0.1'
+ memory: 64M
+ mode: global
+ env_file:
+ - ./env_vars/.env_agent
+ privileged: true
+ pid: "host"
+ networks:
+ zbx_net_backend:
+ aliases:
+ - zabbix-agent
+ - zabbix-agent-passive
+ - zabbix-agent-alpine
+ stop_grace_period: 5s
+ labels:
+ com.zabbix.description: "Zabbix agent"
+ com.zabbix.company: "Zabbix LLC"
+ com.zabbix.component: "zabbix-agentd"
+ com.zabbix.os: "alpine"
+
+
+ postgres-server:
+ image: postgres:13-alpine
+# command: -c ssl=on -c ssl_cert_file=/run/secrets/server-cert.pem -c ssl_key_file=/run/secrets/server-key.pem -c ssl_ca_file=/run/secrets/root-ca.pem
+ volumes:
+ - ./zbx_env/var/lib/postgresql/data:/var/lib/postgresql/data:rw
+ - ./env_vars/.ZBX_DB_CA_FILE:/run/secrets/root-ca.pem:ro
+ - ./env_vars/.ZBX_DB_CERT_FILE:/run/secrets/server-cert.pem:ro
+ - ./env_vars/.ZBX_DB_KEY_FILE:/run/secrets/server-key.pem:ro
+ env_file:
+ - ./env_vars/.env_pg_db
+ secrets:
+ - POSTGRES_USER
+ - POSTGRES_PASSWORD
+ stop_grace_period: 1m
+ networks:
+ zbx_net_backend:
+ aliases:
+ - postgres-server
+ - pgsql-server
+ - pgsql-database
+
+
+ zeus-iot-server:
+ build: .
+ ports:
+ - "9090:9090"
+ - "9080:9080"
+ - "12800:12800"
+ - "12900:12900"
+ env_file:
+ - ./env_vars/.env_zeus_iot
+ - ./env_vars/.env_pg_db
+ stop_grace_period: 1m
+ depends_on:
+ - postgres-server
+ - zabbix-server
+ - zabbix-web-nginx-pgsql
+ networks:
+ zeus_net:
+ aliases:
+ - zeus-iot-server
+ - zeus-iot-web
+ zbx_net_frontend:
+ zbx_net_backend:
+ db_data_pgsql:
+ image: busybox
+ volumes:
+ - ./zbx_env/var/lib/postgresql/data:/var/lib/postgresql/data:rw
+
+
+networks:
+ zbx_net_frontend:
+ driver: bridge
+ driver_opts:
+ com.docker.network.enable_ipv6: "false"
+ ipam:
+ driver: default
+ config:
+ - subnet: 172.16.238.0/24
+ zbx_net_backend:
+ driver: bridge
+ driver_opts:
+ com.docker.network.enable_ipv6: "false"
+ internal: true
+ ipam:
+ driver: default
+ config:
+ - subnet: 172.16.239.0/24
+ zeus_net:
+ driver: bridge
+ driver_opts:
+ com.docker.network.enable_ipv6: "false"
+ internal: true
+ ipam:
+ driver: default
+ config:
+ - subnet: 172.16.240.0/24
+
+secrets:
+ POSTGRES_USER:
+ file: ./env_vars/.POSTGRES_USER
+ POSTGRES_PASSWORD:
+ file: ./env_vars/.POSTGRES_PASSWORD
diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh
new file mode 100755
index 00000000..e7a84abb
--- /dev/null
+++ b/docker/docker-entrypoint.sh
@@ -0,0 +1,342 @@
+#!/bin/bash
+
+set -o pipefail
+
+set +e
+set -x
+# Script trace mode
+if [ "${DEBUG_MODE,,}" == "true" ]; then
+ set -o xtrace
+fi
+
+# usage: file_env VAR [DEFAULT]
+# as example: file_env 'MYSQL_PASSWORD' 'zabbix'
+# (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file)
+# unsets the VAR_FILE afterwards and just leaving VAR
+file_env() {
+ local var="$1"
+ local fileVar="${var}_FILE"
+ local defaultValue="${2:-}"
+
+ if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
+ echo "**** Both variables $var and $fileVar are set (but are exclusive)"
+ exit 1
+ fi
+
+ local val="$defaultValue"
+
+ if [ "${!var:-}" ]; then
+ val="${!var}"
+ echo "** Using ${var} variable from ENV"
+ elif [ "${!fileVar:-}" ]; then
+ if [ ! -f "${!fileVar}" ]; then
+ echo "**** Secret file \"${!fileVar}\" is not found"
+ exit 1
+ fi
+ val="$(< "${!fileVar}")"
+ echo "** Using ${var} variable from secret file"
+ fi
+ export "$var"="$val"
+ unset "$fileVar"
+}
+
+escape_spec_char() {
+ local var_value=$1
+
+ var_value="${var_value//\\/\\\\}"
+ var_value="${var_value//[$'\n']/}"
+ var_value="${var_value//\//\\/}"
+ var_value="${var_value//./\\.}"
+ var_value="${var_value//\*/\\*}"
+ var_value="${var_value//^/\\^}"
+ var_value="${var_value//\$/\\\$}"
+ var_value="${var_value//\&/\\\&}"
+ var_value="${var_value//\[/\\[}"
+ var_value="${var_value//\]/\\]}"
+
+ echo "$var_value"
+}
+
+
+
+# Check prerequisites for PostgreSQL database
+check_variables_postgresql() {
+ file_env POSTGRES_USER
+ file_env POSTGRES_PASSWORD
+
+ : ${DB_SERVER_HOST:="postgres-server"}
+ : ${DB_SERVER_PORT:="5432"}
+
+ DB_SERVER_ROOT_USER=${POSTGRES_USER:-"postgres"}
+ DB_SERVER_ROOT_PASS=${POSTGRES_PASSWORD:-""}
+
+ DB_SERVER_ZEUS_USER=${POSTGRES_USER:-"postgres"}
+ DB_SERVER_ZEUS_PASS=${POSTGRES_PASSWORD:-"postgres"}
+
+ : ${DB_SERVER_SCHEMA:="public"}
+
+ DB_SERVER_DBNAME=${POSTGRES_DB:-"zeus-iot"}
+
+ : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"}
+}
+
+check_db_connect_postgresql() {
+ echo "********************"
+ echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
+ echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
+ echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
+ echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
+ if [ "${DEBUG_MODE,,}" == "true" ]; then
+ echo "* DB_SERVER_ZEUS_USER: ${DB_SERVER_ZEUS_USER}"
+ echo "* DB_SERVER_ZEUS_PASS: ${DB_SERVER_ZEUS_PASS}"
+ fi
+ echo "********************"
+
+ if [ -n "${DB_SERVER_ZEUS_PASS}" ]; then
+ export PGPASSWORD="${DB_SERVER_ZEUS_PASS}"
+ fi
+
+ WAIT_TIMEOUT=5
+
+ if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then
+ PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
+ export PGOPTIONS
+ fi
+
+ if [ -n "${ZEUS_DBTLSCONNECT}" ]; then
+ export PGSSLMODE=${ZEUS_DBTLSCONNECT//_/-}
+ export PGSSLROOTCERT=${ZEUS_DBTLSCAFILE}
+ export PGSSLCERT=${ZEUS_DBTLSCERTFILE}
+ export PGSSLKEY=${ZEUS_DBTLSKEYFILE}
+ fi
+
+ while true :
+ do
+ psql --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --quiet 1>/dev/null 2>&1 && break
+ psql --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --dbname ${DB_SERVER_DBNAME} --quiet 1>/dev/null 2>&1 && break
+
+ echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
+ sleep $WAIT_TIMEOUT
+ done
+
+ unset PGPASSWORD
+ unset PGOPTIONS
+ unset PGSSLMODE
+ unset PGSSLROOTCERT
+ unset PGSSLCERT
+ unset PGSSLKEY
+}
+
+psql_query() {
+ query=$1
+ db=$2
+
+ local result=""
+
+ if [ -n "${DB_SERVER_ZEUS_PASS}" ]; then
+ export PGPASSWORD="${DB_SERVER_ZEUS_PASS}"
+ fi
+
+ if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then
+ PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
+ export PGOPTIONS
+ fi
+
+ if [ -n "${ZBX_DBTLSCONNECT}" ]; then
+ export PGSSLMODE=${ZBX_DBTLSCONNECT//_/-}
+ export PGSSLROOTCERT=${ZBX_DBTLSCAFILE}
+ export PGSSLCERT=${ZBX_DBTLSCERTFILE}
+ export PGSSLKEY=${ZBX_DBTLSKEYFILE}
+ fi
+
+ result=$(psql --no-align --quiet --tuples-only --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \
+ --username "${DB_SERVER_ROOT_USER}" --command "$query" --dbname "$db" 2>/dev/null);
+
+ unset PGPASSWORD
+ unset PGOPTIONS
+ unset PGSSLMODE
+ unset PGSSLROOTCERT
+ unset PGSSLCERT
+ unset PGSSLKEY
+
+ echo $result
+}
+
+create_db_database_postgresql() {
+ DB_EXISTS=$(psql_query "SELECT 1 AS result FROM pg_database WHERE datname='${DB_SERVER_DBNAME}'" "${DB_SERVER_DBNAME}")
+
+ if [ -z ${DB_EXISTS} ]; then
+ echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..."
+
+ if [ -n "${DB_SERVER_ZEUS_PASS}" ]; then
+ export PGPASSWORD="${DB_SERVER_ZEUS_PASS}"
+ fi
+
+ if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then
+ PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
+ export PGOPTIONS
+ fi
+
+ if [ -n "${ZBX_DBTLSCONNECT}" ]; then
+ export PGSSLMODE=${ZBX_DBTLSCONNECT//_/-}
+ export PGSSLROOTCERT=${ZBX_DBTLSCAFILE}
+ export PGSSLCERT=${ZBX_DBTLSCERTFILE}
+ export PGSSLKEY=${ZBX_DBTLSKEYFILE}
+ fi
+
+ createdb --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" --username "${DB_SERVER_ROOT_USER}" \
+ --owner "${DB_SERVER_ZEUS_USER}" "${DB_SERVER_DBNAME}"
+
+ unset PGPASSWORD
+ unset PGOPTIONS
+ unset PGSSLMODE
+ unset PGSSLROOTCERT
+ unset PGSSLCERT
+ unset PGSSLKEY
+ else
+ echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!"
+ fi
+
+ psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" "${DB_SERVER_DBNAME}" 1>/dev/null
+}
+
+create_db_schema_postgresql() {
+ ZEUS_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid =
+ c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'tag'" "${DB_SERVER_DBNAME}")
+
+# if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then
+# echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists."
+# ZEUS_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}")
+# fi
+
+ if [ -z "${ZEUS_TABLE_EXISTS}" ]; then
+ echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL"
+
+
+ if [ -n "${DB_SERVER_ZEUS_PASS}" ]; then
+ export PGPASSWORD="${DB_SERVER_ZEUS_PASS}"
+ fi
+
+ if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then
+ PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
+ export PGOPTIONS
+ fi
+
+ if [ -n "${ZBX_DBTLSCONNECT}" ]; then
+ export PGSSLMODE=${ZBX_DBTLSCONNECT//_/-}
+ export PGSSLROOTCERT=${ZBX_DBTLSCAFILE}
+ export PGSSLCERT=${ZBX_DBTLSCERTFILE}
+ export PGSSLKEY=${ZBX_DBTLSKEYFILE}
+ fi
+
+ cat /zeus-iot-bin/bin/sql/zeus-iot.sql | psql --quiet \
+ --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \
+ --username "${DB_SERVER_ZEUS_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1
+
+ unset PGPASSWORD
+ unset PGOPTIONS
+ unset PGSSLMODE
+ unset PGSSLROOTCERT
+ unset PGSSLCERT
+ unset PGSSLKEY
+ fi
+}
+
+
+# Get zabbix api token
+
+get_zbx_apitoken() {
+
+ WAIT_TIMEOUT=5
+
+ ZBX_API_URL="http://${ZEUS_ZABBIX_HOST}:${ZEUS_ZABBIX_PORT}/api_jsonrpc.php"
+
+ data='{"jsonrpc": "2.0","method": "user.login","params":{"user":"Admin","password":"zabbix"},"id":1,"auth":null}'
+
+ # Check zbx ui is ok
+
+ while true :
+ do
+
+ res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $ZBX_API_URL"`
+
+ if auth=`echo $res | python -c 'import sys, json; print(json.load(sys.stdin)["result"])' 2> /dev/null`;then
+ break
+ fi
+ echo "**** zabbix-web-nginx-pgsql is not available. Waiting $WAIT_TIMEOUT seconds..."
+ sleep $WAIT_TIMEOUT
+ done
+
+
+ # Check token
+ data='{"jsonrpc": "2.0","method": "token.get","params":{"output": ["tokenid"], "filter": {"name": "zeus"}},"id":1,"auth":"'${auth}'"}'
+ res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $ZBX_API_URL"`
+ if ! tokenid=`echo $res | python -c 'import sys, json; print(json.load(sys.stdin)["result"][0]["tokenid"])' 2> /dev/null`;then
+ data='{"jsonrpc": "2.0","method": "token.create","params":{"name":"zeus","userid":"1"},"id":1,"auth":"'${auth}'"}'
+ res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $ZBX_API_URL"`
+ tokenid=`echo $res | python -c 'import sys, json; print(json.load(sys.stdin)["result"]["tokenids"][0])'`
+ fi
+
+ # Get API token
+ data='{"jsonrpc": "2.0","method": "token.generate","params":["'${tokenid}'"],"id":1,"auth":"'${auth}'"}'
+ res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $ZBX_API_URL"`
+ token=`echo $res | python -c 'import sys, json; print(json.load(sys.stdin)["result"][0]["token"])'`
+ export ZBXAPITOKEN=$token
+
+}
+
+
+
+prepare_server() {
+ echo "** Preparing Zeus IoT Server"
+
+ check_variables_postgresql
+ check_db_connect_postgresql
+ create_db_database_postgresql
+ create_db_schema_postgresql
+ get_zbx_apitoken
+
+}
+
+#################################################
+startiot() {
+
+ [ -z "$IOT_HOME" ] && IOT_HOME=/zeus-iot-bin
+ JAVA_OPTS="${JAVA_OPTS:- -Xms256M -Xmx512M}"
+ _RUNJAVA=${JAVA_HOME}/bin/java
+ [ -z "$JAVA_HOME" ] && _RUNJAVA=java
+
+ CLASSPATH="$IOT_HOME/config"
+ for i in "$IOT_HOME"/iot-server-libs/*.jar
+ do
+ CLASSPATH="$i:$CLASSPATH"
+ done
+
+ IOT_OPTIONS=" -Duser.timezone=GMT+08"
+
+ eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${IOT_OPTIONS} -classpath $CLASSPATH com.zmops.zeus.iot.server.starter.IoTServerStartUp &> /dev/stdout &"
+}
+
+startwebapp() {
+
+ [ -z "$WEBAPP_HOME" ] && WEBAPP_HOME=/zeus-iot-bin
+
+ JAVA_OPTS="${JAVA_OPTS:- -Xms512M -Xmx1024M}"
+ JAR_PATH="${WEBAPP_HOME}/webapp"
+
+ _RUNJAVA=${JAVA_HOME}/bin/java
+ [ -z "$JAVA_HOME" ] && _RUNJAVA=java
+
+ sed -i "s%\(zbxApiToken: \).*%\1${ZBXAPITOKEN}%g" ${JAR_PATH}/webapp.yml
+
+ eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} -jar ${JAR_PATH}/zeus-webapp.jar \
+ --spring.config.location=${JAR_PATH}/webapp.yml"
+
+}
+
+
+prepare_server
+startiot
+startwebapp
+
+#################################################
diff --git a/docker/dockerfile b/docker/dockerfile
new file mode 100644
index 00000000..5d17aec1
--- /dev/null
+++ b/docker/dockerfile
@@ -0,0 +1,18 @@
+FROM alpine:latest
+
+RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
+
+RUN apk update \
+ && apk add --no-cache tzdata curl python2 openjdk8-jre bash postgresql-client \
+ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
+ && echo Asia/Shanghai > /etc/timezone \
+ && rm -rf /var/cache/apk/*
+
+ADD https://xxxxx/zeus-iot/zeus-iot-bin.tar.gz /
+RUN tar -xf zeus-iot-bin.tar.gz
+COPY log4j2.xml /zeus-iot-bin/config/log4j2.xml
+COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
+EXPOSE 9090
+ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
+
+
diff --git a/docker/env_vars/.POSTGRES_PASSWORD b/docker/env_vars/.POSTGRES_PASSWORD
new file mode 100644
index 00000000..f1349944
--- /dev/null
+++ b/docker/env_vars/.POSTGRES_PASSWORD
@@ -0,0 +1 @@
+postgres
diff --git a/docker/env_vars/.POSTGRES_USER b/docker/env_vars/.POSTGRES_USER
new file mode 100644
index 00000000..f1349944
--- /dev/null
+++ b/docker/env_vars/.POSTGRES_USER
@@ -0,0 +1 @@
+postgres
diff --git a/docker/env_vars/.env_agent b/docker/env_vars/.env_agent
new file mode 100644
index 00000000..a2f9be2a
--- /dev/null
+++ b/docker/env_vars/.env_agent
@@ -0,0 +1,37 @@
+# ZBX_SOURCEIP=
+# ZBX_DEBUGLEVEL=3
+# ZBX_ENABLEREMOTECOMMANDS=0 # Deprecated since 5.0.0
+# ZBX_LOGREMOTECOMMANDS=0
+# ZBX_HOSTINTERFACE= # Available since 4.4.0
+# ZBX_HOSTINTERFACEITEM= # Available since 4.4.0
+# ZBX_SERVER_HOST=zabbix-server
+# ZBX_PASSIVE_ALLOW=true
+# ZBX_PASSIVESERVERS=
+# ZBX_ACTIVE_ALLOW=true
+# ZBX_ACTIVESERVERS=
+# ZBX_LISTENIP=
+# ZBX_STARTAGENTS=3
+# ZBX_HOSTNAME=
+# ZBX_HOSTNAMEITEM=system.hostname
+# ZBX_METADATA=
+# ZBX_METADATAITEM=
+# ZBX_REFRESHACTIVECHECKS=120
+# ZBX_BUFFERSEND=5
+# ZBX_BUFFERSIZE=100
+# ZBX_MAXLINESPERSECOND=20
+# ZBX_ALIAS=""
+# ZBX_TIMEOUT=3
+# ZBX_UNSAFEUSERPARAMETERS=0
+# ZBX_LOADMODULE="dummy1.so,dummy2.so,dummy10.so"
+# ZBX_TLSCONNECT=unencrypted
+# ZBX_TLSACCEPT=unencrypted
+# ZBX_TLSCAFILE=
+# ZBX_TLSCRLFILE=
+# ZBX_TLSSERVERCERTISSUER=
+# ZBX_TLSSERVERCERTSUBJECT=
+# ZBX_TLSCERTFILE=
+# ZBX_TLSKEYFILE=
+# ZBX_TLSPSKIDENTITY=
+# ZBX_TLSPSKFILE=
+# ZBX_DENYKEY=system.run[*]
+# ZBX_ALLOWKEY=
diff --git a/docker/env_vars/.env_db_pgsql b/docker/env_vars/.env_db_pgsql
new file mode 100644
index 00000000..30be4ad2
--- /dev/null
+++ b/docker/env_vars/.env_db_pgsql
@@ -0,0 +1,11 @@
+# DB_SERVER_HOST=postgres-server
+# DB_SERVER_PORT=5432
+# POSTGRES_USER=zabbix
+POSTGRES_USER_FILE=/run/secrets/POSTGRES_USER
+# POSTGRES_PASSWORD=zabbix
+POSTGRES_PASSWORD_FILE=/run/secrets/POSTGRES_PASSWORD
+# POSTGRES_DB=zabbix
+POSTGRES_DB=zabbix
+# DB_SERVER_SCHEMA=public
+# ENABLE_TIMESCALEDB=true
+# POSTGRES_USE_IMPLICIT_SEARCH_PATH=false
diff --git a/docker/env_vars/.env_pg_db b/docker/env_vars/.env_pg_db
new file mode 100644
index 00000000..e1d285ef
--- /dev/null
+++ b/docker/env_vars/.env_pg_db
@@ -0,0 +1,10 @@
+# DB_SERVER_HOST=postgres-server
+# DB_SERVER_PORT=5432
+POSTGRES_USER=postgres
+# POSTGRES_USER_FILE=/run/secrets/POSTGRES_USER
+POSTGRES_PASSWORD=postgres
+# POSTGRES_PASSWORD_FILE=/run/secrets/POSTGRES_PASSWORD
+# POSTGRES_DB=zabbix
+# DB_SERVER_SCHEMA=public
+# ENABLE_TIMESCALEDB=true
+# POSTGRES_USE_IMPLICIT_SEARCH_PATH=false
diff --git a/docker/env_vars/.env_srv b/docker/env_vars/.env_srv
new file mode 100644
index 00000000..35c1ce6e
--- /dev/null
+++ b/docker/env_vars/.env_srv
@@ -0,0 +1,62 @@
+# ZBX_LISTENIP=
+# ZBX_HISTORYSTORAGEURL=http://elasticsearch:9200/ # Available since 3.4.5
+# ZBX_HISTORYSTORAGETYPES=uint,dbl,str,log,text # Available since 3.4.5
+# ZBX_DBTLSCONNECT=required # Available since 5.0.0
+# ZBX_DBTLSCAFILE=/run/secrets/root-ca.pem # Available since 5.0.0
+# ZBX_DBTLSCERTFILE=/run/secrets/client-cert.pem # Available since 5.0.0
+# ZBX_DBTLSKEYFILE=/run/secrets/client-key.pem # Available since 5.0.0
+# ZBX_DBTLSCIPHER= # Available since 5.0.0
+# ZBX_DBTLSCIPHER13= # Available since 5.0.0
+# ZBX_DEBUGLEVEL=3
+# ZBX_STARTPOLLERS=5
+# ZBX_IPMIPOLLERS=0
+# ZBX_STARTPREPROCESSORS=3 # Available since 3.4.0
+# ZBX_STARTPOLLERSUNREACHABLE=1
+# ZBX_STARTTRAPPERS=5
+# ZBX_STARTPINGERS=1
+# ZBX_STARTDISCOVERERS=1
+# ZBX_STARTHTTPPOLLERS=1
+# ZBX_STARTTIMERS=1
+# ZBX_STARTESCALATORS=1
+# ZBX_STARTALERTERS=3 # Available since 3.4.0
+ZBX_JAVAGATEWAY_ENABLE=true
+# ZBX_JAVAGATEWAY=zabbix-java-gateway
+# ZBX_JAVAGATEWAYPORT=10052
+ZBX_STARTJAVAPOLLERS=5
+# ZBX_STARTVMWARECOLLECTORS=0
+# ZBX_VMWAREFREQUENCY=60
+# ZBX_VMWAREPERFFREQUENCY=60
+# ZBX_VMWARECACHESIZE=8M
+# ZBX_VMWARETIMEOUT=10
+ZBX_ENABLE_SNMP_TRAPS=true
+# ZBX_SOURCEIP=
+# ZBX_HOUSEKEEPINGFREQUENCY=1
+# ZBX_MAXHOUSEKEEPERDELETE=5000
+# ZBX_SENDERFREQUENCY=30
+# ZBX_CACHESIZE=8M
+# ZBX_CACHEUPDATEFREQUENCY=60
+# ZBX_STARTDBSYNCERS=4
+# ZBX_HISTORYCACHESIZE=16M
+# ZBX_HISTORYINDEXCACHESIZE=4M
+# ZBX_TRENDCACHESIZE=4M
+# ZBX_VALUECACHESIZE=8M
+# ZBX_TIMEOUT=4
+# ZBX_TRAPPERTIMEOUT=300
+# ZBX_UNREACHABLEPERIOD=45
+# ZBX_UNAVAILABLEDELAY=60
+# ZBX_UNREACHABLEDELAY=15
+# ZBX_LOGSLOWQUERIES=3000
+# ZBX_EXPORTFILESIZE=
+# ZBX_STARTPROXYPOLLERS=1
+# ZBX_PROXYCONFIGFREQUENCY=3600
+# ZBX_PROXYDATAFREQUENCY=1
+# ZBX_LOADMODULE="dummy1.so,dummy2.so,dummy10.so"
+# ZBX_TLSCAFILE=
+# ZBX_TLSCRLFILE=
+# ZBX_TLSCERTFILE=
+# ZBX_TLSKEYFILE=
+# ZBX_VAULTDBPATH=
+# ZBX_VAULTURL=https://127.0.0.1:8200
+# VAULT_TOKEN=
+# ZBX_STARTREPORTWRITERS=0
+# ZBX_WEBSERVICEURL=http://zabbix-web-service:10053/report
diff --git a/docker/env_vars/.env_web b/docker/env_vars/.env_web
new file mode 100644
index 00000000..ae96d1ad
--- /dev/null
+++ b/docker/env_vars/.env_web
@@ -0,0 +1,27 @@
+# ZBX_SERVER_HOST=zabbix-server
+# ZBX_SERVER_PORT=10051
+ZBX_SERVER_NAME=Composed installation
+# ZBX_DB_ENCRYPTION=true # Available since 5.0.0
+# ZBX_DB_KEY_FILE=/run/secrets/client-key.pem # Available since 5.0.0
+# ZBX_DB_CERT_FILE=/run/secrets/client-cert.pem # Available since 5.0.0
+# ZBX_DB_CA_FILE=/run/secrets/root-ca.pem # Available since 5.0.0
+# ZBX_DB_VERIFY_HOST=false # Available since 5.0.0
+# ZBX_DB_CIPHER_LIST= # Available since 5.0.0
+# ZBX_VAULTDBPATH=
+# ZBX_VAULTURL=https://127.0.0.1:8200
+# VAULT_TOKEN=
+# ZBX_HISTORYSTORAGEURL=http://elasticsearch:9200/ # Available since 3.4.5
+# ZBX_HISTORYSTORAGETYPES=['uint', 'dbl', 'str', 'text', 'log'] # Available since 3.4.5
+# ZBX_SSO_SETTINGS=[] # Available since 5.0.0
+# ENABLE_WEB_ACCESS_LOG=true
+# ZBX_MAXEXECUTIONTIME=600
+# ZBX_MEMORYLIMIT=128M
+# ZBX_POSTMAXSIZE=16M
+# ZBX_UPLOADMAXFILESIZE=2M
+# ZBX_MAXINPUTTIME=300
+# ZBX_SESSION_NAME=zbx_sessionid
+# Timezone one of: http://php.net/manual/en/timezones.php
+# PHP_TZ=Europe/Riga
+# ZBX_DENY_GUI_ACCESS=false
+# ZBX_GUI_ACCESS_IP_RANGE=['127.0.0.1']
+# ZBX_GUI_WARNING_MSG=Zabbix is under maintenance.
diff --git a/docker/env_vars/.env_web_service b/docker/env_vars/.env_web_service
new file mode 100644
index 00000000..1d473f10
--- /dev/null
+++ b/docker/env_vars/.env_web_service
@@ -0,0 +1,9 @@
+# ZBX_DEBUGLEVEL=3
+ZBX_ALLOWEDIP=zabbix-server
+# ZBX_LISTENPORT=10053
+# ZBX_LISTENIP=
+# ZBX_TIMEOUT=3
+# ZBX_TLSACCEPT=unencrypted
+# ZBX_TLSCAFILE=
+# ZBX_TLSCERTFILE=
+# ZBX_TLSKEYFILE=
diff --git a/docker/env_vars/.env_zeus_iot b/docker/env_vars/.env_zeus_iot
new file mode 100644
index 00000000..e4251021
--- /dev/null
+++ b/docker/env_vars/.env_zeus_iot
@@ -0,0 +1,5 @@
+ZEUS_ZABBIX_HOST=zabbix-web-nginx-pgsql
+ZEUS_ZABBIX_PORT=8080
+ZEUS_ZABBIX_API_URL=/api_jsonrpc.php
+ZEUS_DB_HOST=postgres-server
+
diff --git a/docker/log4j2.xml b/docker/log4j2.xml
new file mode 100644
index 00000000..ddb7b819
--- /dev/null
+++ b/docker/log4j2.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/README.md b/docs/README.md
index 61dd488d..94fb7d69 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1 +1,326 @@
-### Zeus IOT Document
\ No newline at end of file
+[toc]
+
+# Zeus IoT Document
+
+> Zeus IoT 基于 zabbix-5.4 安装。
+
+## Zeus IoT 系统安装配置要求
+
+- **硬件依赖**
+
+ 目前 Zeus IoT 支持 Linux x86_64 系统平台,其它系统平台测试中。
+
+ | 配置规格 | 系统平台 | CPU | 内存 | 存储 |
+ | -------- | ------------ | ---- | ---- | ------ |
+ | 最低配置 | Linux x86_64 | 2 核 | 4 GB | 100 GB |
+ | 推荐配置 | Linux x86_64 | 4 核 | 8 GB | 500 GB |
+
+- **软件依赖**
+
+ | 操作系统 | Centos 7.0+/Redhat 7.0+/Ubuntu 18.04+ |
+ | -------- | ------------------------------------- |
+ | JDK | 1.8 |
+ | 数据库 | PostgreSQL 12+/InfluxDB/TDengine-2.2x |
+ | 数据采集 | Zabbix Server 5.4.x |
+ | 数据代理 | Zabbix Proxy 5.4.x |
+ | 可视化 | Grafana 7.x |
+
+## 快速安装
+
+> 简化 zabbix 安装部署,方便客户快速使用 Zeus IoT 产品。
+
+系统终端执行以下命令快速安装
+
+- Centos7/Redhat7
+
+ ```shell
+ curl -sL https://github.com/zmops/zeus-iot/raw/develop/docs/centos/install.sh | bash -s install
+ ```
+
+- Ubuntu 20.04
+
+ ```shell
+ curl -sL https://github.com/zmops/zeus-iot/raw/develop/docs/ubuntu/install.sh | bash -s install
+ ```
+
+## 自定义安装
+
+> 自定义安装是在本身已有 zabbix 或需要分开部署 zabbix 和 zeus-iot 服务。
+
+### 安装 zabbix 服务
+
+> **zabbix 安装可参照**[zabbix官网](https://www.zabbix.com/download) 。**这里就不做详细介绍**。
+
+:bulb: **建议使用 PostgreSQL 数据库,因为 zeus-iot-ui 使用的是 PostgreSQL 数据库。**
+
+
+
+#### zabbix 系统优化
+
+- **修改 zabbix 时区**
+ - 管理员用户登录 zabbix 管理界面进入 "**管理(Administrator)**" ----- "**一般()**" ----- "**Default time zone**" 选择 "(UTC+08:00) Asia/Shanghai"
+ - 普通用户登录 zabbix 管理界面进入 "**User settings**" ----- "**Profile**" ----- "**Time zone**" 选择 "(UTC+08:00) Asia/Shanghai"
+
+### 安装 zeus-iot 系统
+
+#### 安装 PostgreSQL 数据库
+
+- Centos/RedHat
+
+ ```shell
+ # 安装 PostgreSQL 仓库源:
+ sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
+
+ # 安装 PostgreSQL:
+ sudo yum install -y postgresql13-server
+
+ # 初始化数据库并启动:
+ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
+ sudo systemctl enable postgresql-13
+ sudo systemctl start postgresql-13
+ ```
+
+
+- Ubuntu
+
+ ```shell
+ # 安装 PostgreSQL 仓库源:
+ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
+
+ # 安装 PostgreSQL:
+ sudo apt-get update && sudo apt-get -y install postgresql
+ ```
+
+
+
+#### 获取 zeus-iot 程序包
+
+- 直接下载 release 包
+
+ ```shell
+
+ ```
+
+- 从源码编译
+
+ ```shell
+ git clone https://github.com/zmops/zeus-iot.git
+ cd zeus-iot && git submodule update --init --recursive
+ mvn clean package -U -Dmaven.test.skip=true
+ ```
+
+ 💡 编译好的安装包在 dist 目录下。文件名为 `zeus-iot-bin.tar.gz` 。部署时只需解压即可。
+
+#### 初始化系统服务
+
+1、 创建数据库
+
+```shell
+sudo -u postgres createdb -E Unicode -T template0 zeus-iot
+```
+
+2、 导入 SQL
+
+```shell
+# 解压安装包,初始化 sql 在安装目录下。
+cat zeus-iot.sql | sudo -u postgres psql zeus-iot
+```
+
+3、 安装 JDK 驱动
+
+```shell
+# Centos/Redhat 安装
+yum install java-1.8.0-openjdk.x86_64 -y
+# Ubuntu 安装
+apt install openjdk-8-jdk -y
+```
+
+#### 服务启动配置
+
+> zeus-iot 主要由 zeus-iot-server 和 webapp 两个服务组成,配置文件分别是 ``./zeus-iot-bin/conf/application.yml`` 和 ``./zeus-iot-bin/webapp/webapp.yml``。
+
+##### 配置 zabbix token
+
+1、登录 zabbix 管理界面进入 "**User settings**" ----- "**API tokens**" ----- "**Create API token**"
+
+2、创建名为 zeus 的 API token, 取消 "**Set expiration date and time**" 的勾选项。确定后会生成 Auth token,点击 "**Copy to clipboard**" 复制token。
+
+3、配置 zeus-iot 连接 zabbix token
+
+ vim ./zeus-iot-bin/webapp/webapp.yml
+
+ ...
+ forest:
+ log-enabled: false
+ timeout: 5000
+ variables:
+ ...
+ zbxServerPort: ${ZEUS_ZABBIX_PORT:80}
+ zbxApiToken: 4d3ed2be23a3f325d6ccaaaeab76bbdc6a559f3c608e523f9906ea923f7d61c5 # 修改此处token信息
+ ...
+ ...
+
+##### 其它启动参数配置
+
+- 直接修改配置文件
+
+ 以修改 zabbix 信息为例:
+
+ ```
+ vim ./zeus-iot-bin/webapp/webapp.yml
+
+ forest:
+ log-enabled: false
+ timeout: 5000
+ variables:
+ ## Zabbix API IP And ServerIp and ServerPort
+ zbxServerIp: ${ZEUS_ZABBIX_HOST:127.0.0.1}
+ zbxServerPort: ${ZEUS_ZABBIX_PORT:80}
+ zbxApiToken: 4d3ed2be23a3f325d6ccaaaeab76bbdc6a559f3c608e523f9906ea923f7d61c5
+ taosUrl: http://${ZEUS_TAOS_HOST:127.0.0.1}:${ZEUS_TAOS_REST_PORT:6041}/rest/sql/${ZEUS_TAOS_DB:zeus_data}
+ taosUser: root
+ taosPwd: taosdata
+ ```
+
+
+
+
+- 通过配置环境变量的方式修改(临时修改)
+
+ zeus-iot 支持环境变量配置启动,可以通过 ``export ZEUS_ZABBIX_HOST=127.0.0.1`` 申明环境变量。
+
+#### 启动服务
+
+> zeus-iot 默认需要连接 taos 数据库,所以启动前请先[配置taos数据库](#配置 taos 数据库)
+
+```shell
+# 启动
+./zeus-iot-bin/bin/startup.sh
+
+# 停止
+./zeus-iot-bin/bin/stop.sh
+```
+
+
+
+
+配置 taos 数据库
+================
+
+安装 taos 数据库
+----------------
+
+### 获取 taos 数据库
+
+> 可通过[涛思官网](https://www.taosdata.com/en/getting-started/)获取安装包
+
+:bulb: zeus-iot 默认使用 **RESTful connector** 连接涛思数据库。
+
+### 安装 taos 数据库
+
+- **Centos/Redhat 安装**
+
+ ```shell
+rpm -ivh TDengine-server-2.2.0.2-Linux-x64.rpm
+ ```
+
+- **Ubuntu/Debain 安装**
+
+ ```shell
+ dpkg -i TDengine-server-2.2.0.2-Linux-x64.deb
+ ```
+
+:bulb: 这里只介绍单机版涛思安装部署,安装时是以交互式安装,只需按回车。如要安装集群版涛思需要查阅 [涛思官网文档](https://www.taosdata.com/en/documentation/)
+
+- **启动 taos**
+
+ ```shell
+systemctl start taosd
+ ```
+
+- **创建 zeus_data 数据库**
+
+ ```shell
+ # linux 命令行登录taos
+ taos
+
+ # 创建 zeus_data 数据库
+ taos> create database zeus_data;
+ ```
+
+启用 zabbix 导出功能
+---------------------
+
+修改 zabbix-server.conf 配置文件,找到如下配置项:
+
+```bash
+### Option: ExportDir
+# Directory for real time export of events, history and trends in newline delimited JSON format.
+# If set, enables real time export.
+#
+# Mandatory: no
+# Default:
+ExportDir=/data
+
+### Option: ExportFileSize
+# Maximum size per export file in bytes.
+# Only used for rotation if ExportDir is set.
+#
+# Mandatory: no
+# Range: 1M-1G
+# Default:
+ExportFileSize=1G
+
+### Option: ExportType
+# List of comma delimited types of real time export - allows to control export entities by their
+# type (events, history, trends) individually.
+# Valid only if ExportDir is set.
+#
+# Mandatory: no
+# Default:
+ExportType=history
+```
+
+
+
+- ExportDir=/data/zabbix_history 配置导出目录
+- ExportFileSize=1G 配置导出文件的大小
+- ExportType=history 配置导出的数据表
+
+
+创建导出的目录并重启 zabbix-server 使配置生效
+
+```shell
+mkdir -p /data/zabbix_history
+systemctl restart zabbix-server
+```
+
+
+修改 zeus-iot 数据库连接
+--------------------------
+
+```
+# 停止 zeus-iot 服务
+./zeus-iot-bin/bin/stop.sh
+
+# 修改数据连接配置如下
+vim ./zeus-iot-bin/conf/application.yml
+ ...
+ # tdengine storage realtime
+ storage:
+ selector: ${ZS_STORAGE:tdengine}
+ tdengine:
+ url: ${ZS_STORAGE_TDENGINE_URL:jdbc:TAOS://127.0.0.1:6030/zeus_data} # TDEngine jdbcUrl
+ user: ${ZS_STORAGE_TDENGINE_USER:root}
+ password: ${ZS_STORAGE_TDENGINE_PASSWORD:taosdata}
+ ...
+
+```
+
+## 启动 zeus-iot 服务
+
+```shell
+ ./zeus-iot-bin/bin/startup.sh
+```
+
diff --git a/docs/centos/install.sh b/docs/centos/install.sh
new file mode 100755
index 00000000..1bb445af
--- /dev/null
+++ b/docs/centos/install.sh
@@ -0,0 +1,541 @@
+#!/usr/bin/env bash
+
+
+ROOT_UID=0
+release=Centos
+basename=$(pwd)
+zabbixsrc=$basename/zabbix-5.0.30
+INSTALLDIR=/opt/zeus
+ZABBIX_HOME=$INSTALLDIR/zabbix
+PHP_CONF=/etc/opt/rh/rh-php73
+sqldir=$basename/zabbix-5.0.30/database/postgresql
+PGDATA=$INSTALLDIR/pgdata
+zeusurl=
+
+function logprint() {
+ if [ $? != 0 ]; then
+ echo -e "\033[31m Error: $1 \033[0m"
+ exit
+ fi
+}
+
+function syscheck() {
+ # 安装前准备
+ ## 系统环境检测
+ #
+
+ if [ "$(uname)" != Linux ]; then
+ echo -e "\033[31m Error: 该脚本只适用 Linux 系统 \033[0m"
+ exit
+ fi
+
+ if [ "$UID" -ne "$ROOT_UID" ]; then
+ echo -e "\033[31m Error: 请使用root账户执行安装 \033[0m"
+ exit
+ fi
+ ### 操作系统
+ if [ ! -f /etc/redhat-release ]; then
+ if [[ "$(cat /etc/issue)" =~ ^Ubuntu* ]]; then
+ release=Ubuntu
+ fi
+ fi
+ ### 网络
+ if ! ping -c 3 mirrors.tuna.tsinghua.edu.cn &>/dev/null; then
+ echo -e "\033[31m Error: 无法访问外网 。。。 \033[0m"
+ exit
+ fi
+
+ ### cpu、mem、disk
+ cores=$(grep 10)printf("%s\t%d\n",$7,$3/1024/1024)}' | grep -v -c "/boot")
+
+ if [ "$cores" -lt 0 ] || [ "$memstotal" -lt 0 ] || [ "$disks" -eq 0 ]; then
+ echo -e "\033[31m Error: 要求系统最低配置为 CPU 2核 内存 4GB 存储空间 100G \033[0m"
+ exit
+ fi
+}
+
+## 系统环境初始化
+function InitSystem() {
+ echo -e -n "\033[32mStep1: 初始化系统安装环境 .... \033[0m"
+ if ! hostnamectl set-hostname zeus-server; then
+ echo -e "\033[31m Error: 主机名修改失败\033[0m"
+ exit
+ fi
+
+ ### 修改时区
+ if ! ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime; then
+ echo -e "\033[31m Error: 时区修改失败\033[0m"
+ exit 0
+ fi
+
+ ### 关闭Selinux
+ setenforce 0 || true
+ sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
+
+ ### 加强对抗SYN Flood的能力
+ echo "net.ipv4.tcp_syncookies = 1" >>/etc/sysctl.conf
+
+ ### linux文件打开数量限制
+ ###/etc/security/limits.conf & /etc/rc.local
+ echo "* soft nofile 65535" >>/etc/security/limits.conf
+ echo "* hard nofile 65535 " >>/etc/security/limits.conf
+ echo "ulimit -SHn 65535" >>/etc/rc.local
+
+ ### 添加用户
+ if ! id zeus &> /dev/null; then
+ groupadd --system zeus || true
+ useradd --system -g zeus zeus || true
+ fi
+
+ ### 添加安装目录
+ [ ! -d $INSTALLDIR ] && mkdir -p $INSTALLDIR
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+# 开始安装
+## 配置 YUM 源
+function AddInstallRepo() {
+
+ echo -e -n "\033[32mStep2: 配置安装 YUM 源 .... \033[0m"
+ ### 备份原有yum
+ mv /etc/yum.repos.d/* /tmp/
+ ### 基础 YUM 源
+ ### Postgresql && php
+ tee /etc/yum.repos.d/Centos-Base.repo </dev/null
+[base]
+name=CentOS-\$releasever - Base
+baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
+gpgcheck=0
+
+[updates]
+name=CentOS-\$releasever - Updates
+baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
+gpgcheck=0
+enabled=1
+
+[extras]
+name=CentOS-\$releasever - Extras
+baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
+gpgcheck=0
+enabled=1
+
+[epel]
+name=Extra Packages for Enterprise Linux 7 - \$basearch
+baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/\$basearch
+failovermethod=priority
+enabled=1
+gpgcheck=0
+
+[centos-sclo-rh]
+name=CentOS-7 - SCLo rh
+baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/7/sclo/\$basearch/rh/
+gpgcheck=0
+enabled=1
+
+[pgdg13]
+name=PostgreSQL 13 for RHEL/CentOS \$releasever - \$basearch
+baseurl=https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/13/redhat/rhel-\$releasever-\$basearch
+enabled=1
+gpgcheck=0
+
+EOL
+
+ yum clean all 1>/dev/null && yum makecache 1>/dev/null
+ yum -y install java-1.8.0-openjdk expect 1> /dev/null
+ logprint "yum源配置失败"
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+## 安装 PostgreSQL
+function PGInstall() {
+ echo -e -n "\033[32mStep3: 安装 PostgreSQL .... \033[0m"
+ yum -y install postgresql13.x86_64 \
+ postgresql13-devel.x86_64 \
+ postgresql13-plpython3.x86_64 1>/dev/null
+
+ logprint "yum安装postgresql失败"
+
+ ### 创建 PostgreSQL 用户
+ ### 修改启动文件
+
+ [ ! -d $PGDATA ] && mkdir -p $PGDATA
+ if ! chown postgres. $PGDATA; then
+ echo "修改PGDATA用户失败"
+ exit
+ fi
+
+ startfile=/usr/lib/systemd/system/postgresql-13.service
+ #sed -i 's/\(^User\=\).*/\1zeus/g' $startfile
+ #sed -i 's/\(^Group\=\).*/\1zeus/g' $startfile
+ sed -i "s#\(^Environment\=PGDATA\=\).*#\1$INSTALLDIR\/pgdata#g" $startfile
+ systemctl daemon-reload
+ ### 初始化数据库
+ /usr/pgsql-13/bin/postgresql-13-setup initdb 1>/dev/null
+ logprint "初始化PG错误"
+
+ #echo "shared_preload_libraries = 'timescaledb'" >>/opt/zeus/pgdata/postgresql.conf
+ ### 启动数据库
+ systemctl enable postgresql-13 &>/dev/null
+ systemctl start postgresql-13
+ ### 修改数据库管理员密码
+ cd /tmp || exit
+ sudo -u postgres /usr/pgsql-13/bin/psql -c "ALTER USER postgres WITH PASSWORD 'postgres';" 1> /dev/null
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+## 编译安装 zabbix 5.4
+function ZbxInstall() {
+ echo -e -n "\033[32mStep4: 编译安装 zabbix .... \033[0m"
+ ### 安装编译依赖
+ cd "$basename" || exit
+ yum -y install vim \
+ wget \
+ gcc \
+ gcc-c++ \
+ net-snmp \
+ net-snmp-libs \
+ net-snmp-utils \
+ net-snmp-devel \
+ libssh2-devel \
+ OpenIPMI-devel \
+ libevent-devel \
+ libcurl-devel \
+ libxml2 \
+ libxml2-devel 1>/dev/null
+
+ ### 创建 zabbix 用户
+ groupadd --system zabbix || true
+ useradd --system -g zabbix -d $INSTALLDIR/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix || true
+
+ wget -c https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.30.tar.gz -o /dev/null -O - | tar -xz
+ logprint "下载zabbix源码失败,请检查网络。。。"
+
+ cd "$zabbixsrc" && ./configure --prefix=$ZABBIX_HOME \
+ --enable-server \
+ --enable-agent \
+ --with-postgresql=/usr/pgsql-13/bin/pg_config \
+ --with-net-snmp \
+ --with-libcurl \
+ --with-libxml2 \
+ --with-openipmi \
+ --with-openssl \
+ --with-ssh2 1>/dev/null
+ logprint "zabbix编译异常"
+
+ make install 1>/dev/null
+ logprint "zabbix编译异常"
+ ### 前端内容部署
+ mv ui $ZABBIX_HOME/zabbix && chown zeus. $ZABBIX_HOME/zabbix -R
+ mv $ZABBIX_HOME/zabbix/conf/zabbix.conf.php.example $ZABBIX_HOME/zabbix/conf/zabbix.conf.php
+ sed -i "s/\($DB\['PASSWORD'\]\s*=\).*/\1 'zabbix';/g" $ZABBIX_HOME/zabbix/conf/zabbix.conf.php
+ sed -i "s/\($DB\['TYPE'\]\s*=\).*/\1 \'POSTGRESQL\';/g" $ZABBIX_HOME/zabbix/conf/zabbix.conf.php
+ echo -e "\033[32m [ OK ] \033[0m"
+ ### 数据初始化
+ echo -e -n "\033[32mStep5: 初始化 zabbix 数据库 .... \033[0m"
+ cd /tmp/ || exit
+ sudo -u postgres createuser zabbix
+ sudo -u postgres /usr/pgsql-13/bin/psql -c "ALTER USER zabbix WITH PASSWORD 'zabbix';" 1> /dev/null
+ sudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix
+ cat $zabbixsrc/database/postgresql/schema.sql | sudo -u zabbix psql zabbix 1>/dev/null
+ cat $zabbixsrc/database/postgresql/images.sql | sudo -u zabbix psql zabbix 1>/dev/null
+ cat $zabbixsrc/database/postgresql/data.sql | sudo -u zabbix psql zabbix 1>/dev/null
+# echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix &>/dev/null
+# cat $zabbixsrc/database/postgresql/timescaledb.sql | sudo -u zabbix psql zabbix 1>/dev/null
+#
+ echo -e "\033[32m [ OK ] \033[0m"
+ cd "$basename" || exit
+ ### 配置zabbix配置文件
+ echo -e -n "\033[32mStep6: 启动 zabbix .... \033[0m"
+ sed -i 's/^# DBPassword=/DBPassword=zabbix/g' $ZABBIX_HOME/etc/zabbix_server.conf
+ ### 配置启动文件
+ tee /usr/lib/systemd/system/zabbix-server.service </dev/null
+[Unit]
+Description=Zabbix Server
+
+After=network.target
+After=postgresql-13.service
+
+[Service]
+Environment="CONFFILE=$ZABBIX_HOME/etc/zabbix_server.conf"
+EnvironmentFile=-/etc/default/zabbix-server
+Type=forking
+Restart=on-failure
+PIDFile=/tmp/zabbix_server.pid
+KillMode=control-group
+ExecStart=$ZABBIX_HOME/sbin/zabbix_server -c \$CONFFILE
+ExecStop=/bin/kill -SIGTERM \$MAINPID
+RestartSec=10s
+TimeoutSec=0
+
+[Install]
+WantedBy=multi-user.target
+EOL
+
+ tee /usr/lib/systemd/system/zabbix-agent.service </dev/null
+[Unit]
+Description=Zabbix Agent
+After=network.target
+
+[Service]
+Environment="CONFFILE=$ZABBIX_HOME/etc/zabbix_agentd.conf"
+EnvironmentFile=-/etc/default/zabbix-agent
+Type=forking
+Restart=on-failure
+PIDFile=/tmp/zabbix_agentd.pid
+KillMode=control-group
+ExecStart=$ZABBIX_HOME/sbin/zabbix_agentd -c \$CONFFILE
+ExecStop=/bin/kill -SIGTERM \$MAINPID
+RestartSec=10s
+User=zabbix
+Group=zabbix
+
+[Install]
+WantedBy=multi-user.target
+EOL
+
+ systemctl daemon-reload
+ systemctl enable zabbix-server &> /dev/null
+ systemctl enable zabbix-agent &> /dev/null
+ systemctl start zabbix-server
+ systemctl start zabbix-agent
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+## 安装 php
+function PHPInstall() {
+ echo -e -n "\033[32mStep7: 安装 zabbix-web .... \033[0m"
+ yum -y install rh-php73.x86_64 \
+ rh-php73-php-fpm.x86_64 \
+ rh-php73-php-bcmath.x86_64 \
+ rh-php73-php-gd.x86_64 \
+ rh-php73-php-mbstring.x86_64 \
+ rh-php73-php-ldap.x86_64 \
+ rh-php73-php-pgsql.x86_64 1>/dev/null
+
+ ### php配置文件修改
+ sed -i 's/post_max_size = 8M/post_max_size = 16M/' $PHP_CONF/php.ini
+ sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/' $PHP_CONF/php.ini
+ sed -i 's/max_execution_time = 30/max_execution_time = 300/' $PHP_CONF/php.ini
+ sed -i 's/max_input_time = 60/max_input_time = 300/' $PHP_CONF/php.ini
+ sed -i 's/; date.timezone =/date.timezone = "Asia\/Shanghai"/' $PHP_CONF/php.ini
+ sed -i 's/user = apache/user = zeus/g' $PHP_CONF/php-fpm.d/www.conf
+ sed -i 's/group = apache/group = zeus/g' $PHP_CONF/php-fpm.d/www.conf
+ sed -i 's/;listen.owner = nobody/listen.owner = zeus/g' $PHP_CONF/php-fpm.d/www.conf
+ sed -i 's/;listen.group = nobody/listen.group = zeus/g' $PHP_CONF/php-fpm.d/www.conf
+ sed -i 's/\(^listen =\).*/\1\/var\/run\/php-fpm.sock/g' $PHP_CONF/php-fpm.d/www.conf
+ chmod 777 /var/opt/rh/rh-php73/lib/php/session -R
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+function WebInstall() {
+ echo -e -n "\033[32mStep8: 启动 zabbix-web .... \033[0m"
+ ## 安装 nginx
+ yum -y install nginx 1>/dev/null
+
+
+ cd $INSTALLDIR
+
+ ## 编辑 nginx 配置文件
+ tee /etc/nginx/conf.d/zabbix.conf </dev/null
+server {
+ listen 80;
+
+ location / {
+ rewrite ^/(.*) http://\$host:9090/$1 permanent;
+ }
+
+ location /zabbix {
+ alias $ZABBIX_HOME/zabbix;
+ index index.html index.htm index.php;
+ }
+
+ location ~ ^/zabbix/.+\.php$ {
+ fastcgi_pass unix:/var/run/php-fpm.sock;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $ZABBIX_HOME\$fastcgi_script_name;
+ include fastcgi_params;
+
+ fastcgi_param QUERY_STRING \$query_string;
+ fastcgi_param REQUEST_METHOD \$request_method;
+ fastcgi_param CONTENT_TYPE \$content_type;
+ fastcgi_param CONTENT_LENGTH \$content_length;
+
+ fastcgi_intercept_errors on;
+ fastcgi_ignore_client_abort off;
+ fastcgi_connect_timeout 60;
+ fastcgi_send_timeout 180;
+ fastcgi_read_timeout 180;
+ fastcgi_buffer_size 128k;
+ fastcgi_buffers 4 256k;
+ fastcgi_busy_buffers_size 256k;
+ fastcgi_temp_file_write_size 256k;
+ }
+}
+EOL
+
+ ## 修改 nginx 配置用户
+ sed -i 's/user nginx;/user zeus;/g' /etc/nginx/nginx.conf
+ systemctl enable rh-php73-php-fpm &> /dev/null
+ systemctl enable nginx &> /dev/null
+ systemctl start rh-php73-php-fpm
+ systemctl start nginx
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+
+
+function gettoken(){
+ ## 获取 API 永久 token
+ local zabbix_api_url=http://127.0.0.1/zabbix/api_jsonrpc.php
+ local data='{"jsonrpc": "2.0","method": "user.login","params":{"user":"Admin","password":"zabbix"},"id":1,"auth":null}'
+ local res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $zabbix_api_url"`
+ local auth=`echo $res | python -c 'import sys, json; print(json.load(sys.stdin)["result"])'`
+ local data='{"jsonrpc": "2.0","method": "token.create","params":{"name":"zeus","userid":"1"},"id":1,"auth":"'${auth}'"}'
+ local res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $zabbix_api_url"`
+ local tokenid=`echo $res | python -c 'import sys, json; print(json.load(sys.stdin)["result"]["tokenids"][0])'`
+ local data='{"jsonrpc": "2.0","method": "token.generate","params":["'${tokenid}'"],"id":1,"auth":"'${auth}'"}'
+ local res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $zabbix_api_url"`
+ token=`echo $res | python -c 'import sys, json; print(json.load(sys.stdin)["result"][0]["token"])'`
+}
+
+
+function taosinstall() {
+ ### taos 数据安装
+ echo -e -n "\033[32mStep9: 安装 taos 数据库 .... \033[0m"
+ expect << EOF 1> /dev/null
+ spawn rpm -ivh https://www.taosdata.com/assets-download/TDengine-server-2.2.0.2-Linux-x64.rpm
+ expect {
+ "*one:" { send "\n";exp_continue}
+ "*skip:" { send "\n" }
+ }
+EOF
+ ## 启动taos
+ systemctl enable taosd &> /dev/null
+ systemctl start taosd
+ logprint "taos安装失败"
+
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+
+function ZeusInstall() {
+ echo -e -n "\033[32mStep11: 安装 Zeus-IoT 服务 .... \033[0m"
+ cd $INSTALLDIR || exit
+ ## 创建taos 数据库
+ taos -s "create database zeus_data" 1> /dev/null
+ wget -c $zeusurl -o /dev/null -O - | tar -xz
+ logprint "zeusiot下载失败,检查网络"
+ gettoken
+ logprint "zabbix-token获取失败"
+ ## 数据库导入
+ sudo -u postgres createdb -E Unicode -T template0 zeus-iot
+ logprint "数据库创建失败"
+ cat ./zeus-iot-bin/bin/sql/zeus-iot.sql | sudo -u postgres psql zeus-iot &>/dev/null
+ logprint "文件未找到"
+ sed -i "s%\(zbxApiToken: \).*%\1$token%" ./zeus-iot-bin/webapp/webapp.yml
+ ./zeus-iot-bin/bin/startup.sh 1> /dev/null
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+function clearsys() {
+
+
+ # 清理用户
+ if ! id zeus; then
+ userdell zeus
+ fi
+
+ function kill9() {
+ status=`ps -ef | grep $1 | grep -v grep | awk '{print $2}' | wc -l`
+
+ if [ $status -ne 0 ]
+ then
+ for i in `ps -ef | grep $1 | grep -v grep | awk '{print $2}'`
+ do
+ kill -9 $i
+ done
+ fi
+ }
+
+ # 清理应用
+ ## 清理 zeus
+ kill9 zeus-iot-bin
+
+ [ -d /opt/zeus/zeus-iot-bin ] && rm -rf /opt/zeus/zeus-iot-bin
+
+ ## 清理 taos
+ systemctl stop taosd &> /dev/null
+
+ kill9 taosd
+
+ rpm -e tdengine-2.2.0.2-3.x86_64 &> /dev/null
+
+ [ -d /usr/local/taos ] && rm -rf /usr/local/taos
+
+ ## 清理 zabbix
+ systemctl stop zabbix-server zabbix-agent &> /dev/null
+
+ kill9 zabbix_server
+ kill9 zabbix_agent
+
+ [ -d /opt/zeus/zabbix ] && rm -rf /opt/zeus/zabbix
+ [ -f /usr/lib/systemd/system/zabbix-server.service ] && rm -rf /usr/lib/systemd/system/zabbix-server.service
+ [ -f /usr/lib/systemd/system/zabbix-agent.service ] && rm -rf /usr/lib/systemd/system/zabbix-agent.service
+
+ ## 清理 postgresql 数据库
+ systemctl stop postgresql-13 &> /dev/null
+
+ kill9 postmaster
+
+ yum remove postgresql13 -y &> /dev/null
+
+ [ -d /opt/zeus/pgdata ] && rm -rf /opt/zeus/pgdata
+ [ -f /usr/lib/systemd/system/postgresql-13.service ] && rm -rf /usr/lib/systemd/system/postgresql-13.service
+
+ ## 清理 nginx
+ systemctl stop nginx &> nginx
+
+ kill9 nginx
+ yum remove nginx -y &> /dev/null
+ [ -f /usr/lib/systemd/system/nginx ] && rm -rf /usr/lib/systemd/system/nginx
+}
+
+
+function sendmsg() {
+ echo "zabbix 部分已安装成功,zeus iot 可以参照 www.zmops.com 官方文档自定义安装。"
+ echo ""
+ echo "zabbix server 访问地址: http:///zabbix"
+ echo ""
+ echo "登录用户名:Admin"
+ echo "登录密 码:zabbix"
+}
+
+##
+
+
+function main() {
+ case $1 in
+ install)
+ syscheck
+ InitSystem
+ AddInstallRepo
+ PGInstall
+ ZbxInstall
+ PHPInstall
+ WebInstall
+ taosinstall
+ ;;
+ clear)
+ clearsys
+ ;;
+ *)
+ echo "请输入 install|clear"
+ exit 1
+ ;;
+ esac
+}
+
+if main $1 ;then
+ sendmsg
+fi
diff --git a/docs/images/arch.gif b/docs/images/arch.gif
new file mode 100644
index 00000000..26e047c7
Binary files /dev/null and b/docs/images/arch.gif differ
diff --git a/docs/images/snapshot_1.jpg b/docs/images/snapshot_1.jpg
new file mode 100644
index 00000000..030a22ef
Binary files /dev/null and b/docs/images/snapshot_1.jpg differ
diff --git a/docs/images/snapshot_2.jpg b/docs/images/snapshot_2.jpg
new file mode 100644
index 00000000..9f41a22f
Binary files /dev/null and b/docs/images/snapshot_2.jpg differ
diff --git a/docs/images/snapshot_3.jpg b/docs/images/snapshot_3.jpg
new file mode 100644
index 00000000..7eea22b9
Binary files /dev/null and b/docs/images/snapshot_3.jpg differ
diff --git a/docs/images/snapshot_4.jpg b/docs/images/snapshot_4.jpg
new file mode 100644
index 00000000..691ceb7e
Binary files /dev/null and b/docs/images/snapshot_4.jpg differ
diff --git a/docs/images/zeus-iot-logo-1.png b/docs/images/zeus-iot-logo-1.png
new file mode 100644
index 00000000..b219ed98
Binary files /dev/null and b/docs/images/zeus-iot-logo-1.png differ
diff --git a/docs/images/zeus-iot-logo.png b/docs/images/zeus-iot-logo.png
new file mode 100644
index 00000000..5d495582
Binary files /dev/null and b/docs/images/zeus-iot-logo.png differ
diff --git a/docs/quick-install.sh b/docs/quick-install.sh
deleted file mode 100755
index 4b8379ae..00000000
--- a/docs/quick-install.sh
+++ /dev/null
@@ -1,383 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-ROOT_UID=0
-E_NOTROOT=67
-E_BADOD=68
-release=Centos
-basename=$(pwd)
-zabbixsrc=$basename/zabbix-5.4.3
-ZABBIX_HOME=/opt/zeus/zabbix
-PHP_CONF=/etc/opt/rh/rh-php73
-sqldir=$basename/zabbix-5.4.3/database/postgresql
-PGDATA=/opt/zeus/pgdata
-
-function logprint() {
- if [ $? != 0 ]; then
- echo "$1"
- exit
- fi
-}
-
-# 安装前准备
-## 系统环境检测
-if [ "$(uname)" != Linux ]; then
- echo "该脚本只使用 Linux 系统"
- exit $E_BADOD
-fi
-
-if [ "$UID" -ne "$ROOT_UID" ]; then
- echo "Must be root to install"
- exit $E_NOTROOT
-fi
-### 操作系统
-if [ ! -f /etc/redhat-release ]; then
- if [[ "$(cat /etc/issue)" =~ ^Ubuntu* ]]; then
- release=Ubuntu
- fi
-fi
-### 网络
-if ! ping -c 3 mirrors.aliyun.com &>/dev/null; then
- echo "网络异常。。。"
- exit
-fi
-
-### cpu、mem、disk
-cores=$(grep 10)printf("%s\t%d\n",$7,$3/1024/1024)}' | grep -v -c "/boot")
-
-if [ "$cores" -lt 0 ] || [ "$memstotal" -lt 0 ] || [ "$disks" -eq 0 ]; then
- echo "要求最低配置为 CPU 2核 内存 4GB 存储空间 100G"
- exit 70
-fi
-
-## 系统环境初始化
-echo "初始化系统环境"
-if ! hostnamectl set-hostname zeus-server; then
- echo "主机名修改失败"
- exit
-fi
-
-### 修改时区
-if ! ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime; then
- echo "时区修改失败"
- exit 0
-fi
-
-### 关闭Selinux
-setenforce 0 || true
-sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
-
-### 加强对抗SYN Flood的能力
-echo "net.ipv4.tcp_syncookies = 1" >>/etc/sysctl.conf
-
-### linux文件打开数量限制
-###/etc/security/limits.conf & /etc/rc.local
-echo "* soft nofile 65535" >>/etc/security/limits.conf
-echo "* hard nofile 65535 " >>/etc/security/limits.conf
-echo "ulimit -SHn 65535" >>/etc/rc.local
-
-### 添加用户
-groupadd --system zeus || true
-useradd --system -g zeus zeus || true
-
-### 添加安装目录
-[ ! -d /opt/zeus ] && mkdir -p /opt/zeus
-
-# 开始安装
-## 配置 YUM 源
-### 基础 YUM 源
-if ! curl -s -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo; then
- echo "YUM 仓库配置异常,请检查网络"
-fi
-sed -i '/mirrors.aliyuncs.com/,/mirrors.cloud.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
-### Postgresql && timescaleDB
-tee /etc/yum.repos.d/postgresql_timescaledb.repo </dev/null
-[epel]
-name=Extra Packages for Enterprise Linux 7 - \$basearch
-baseurl=http://mirrors.aliyun.com/epel/7/\$basearch
-failovermethod=priority
-enabled=1
-gpgcheck=0
-
-[timescale_timescaledb]
-name=timescale_timescaledb
-baseurl=https://packagecloud.io/timescale/timescaledb/el/$(rpm -E %{rhel})/\$basearch
-gpgcheck=0
-enabled=1
-
-[centos-sclo-rh]
-name=CentOS-7 - SCLo rh
-baseurl=https://mirrors.aliyun.com/centos/7/sclo/\$basearch/rh/
-gpgcheck=0
-enabled=1
-
-[pgdg-common]
-name=PostgreSQL common RPMs for RHEL/CentOS \$releasever - \$basearch
-baseurl=https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-\$releasever-\$basearch
-enabled=1
-gpgcheck=0
-
-
-[pgdg13]
-name=PostgreSQL 13 for RHEL/CentOS \$releasever - \$basearch
-baseurl=https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-\$releasever-\$basearch
-enabled=1
-gpgcheck=0
-
-[pgdg12]
-name=PostgreSQL 12 for RHEL/CentOS \$releasever - \$basearch
-baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-\$releasever-\$basearch
-enabled=1
-gpgcheck=0
-EOL
-
-echo "配置安装 YUM 源 。。。"
-yum clean all 1>/dev/null && yum makecache 1>/dev/null
-logprint "yum 源配置失败详细看安装日志输出"
-
-## 安装 PostgreSQL
-
-yum -y install postgresql13.x86_64 \
- postgresql13-devel.x86_64 \
- postgresql13-plpython3.x86_64 \
- timescaledb-2-postgresql-13.x86_64 1>/dev/null
-
-logprint "yum 源配置失败详细看安装日志输出"
-
-### 创建 PostgreSQL 用户
-### 修改启动文件
-echo "安装 PG-timescaledb "
-[ ! -d $PGDATA ] && mkdir -p $PGDATA
-if ! chown postgres. $PGDATA; then
- echo "修改PGDATA用户失败"
- exit
-fi
-
-startfile=/usr/lib/systemd/system/postgresql-13.service
-#sed -i 's/\(^User\=\).*/\1zeus/g' $startfile
-#sed -i 's/\(^Group\=\).*/\1zeus/g' $startfile
-sed -i 's/\(^Environment\=PGDATA\=\).*/\1\/opt\/zeus\/pgdata/g' $startfile
-### 初始化数据库
-echo "开始初始化 PG"
-/usr/pgsql-13/bin/postgresql-13-setup initdb 1>/dev/null
-logprint "初始化错误"
-
-echo "shared_preload_libraries = 'timescaledb'" >>/opt/zeus/pgdata/postgresql.conf
-### 启动数据库
-systemctl enable postgresql-13 &>/dev/null
-systemctl start postgresql-13
-### 修改数据库管理员密码
-cd /tmp || exit
-sudo -u postgres /usr/pgsql-13/bin/psql -c "ALTER USER postgres WITH PASSWORD 'zeusiot';" 2>/tmp/pg.log
-cd "$basename" || exit
-
-## 编译安装 zabbix 5.4
-echo "编译 zabbix"
-### 安装编译依赖
-yum -y install vim \
- wget \
- gcc \
- gcc-c++ \
- net-snmp \
- net-snmp-libs \
- net-snmp-utils \
- net-snmp-devel \
- libssh2-devel \
- OpenIPMI-devel \
- libevent-devel \
- libcurl-devel \
- libxml2 \
- libxml2-devel 1>/dev/null
-
-### 创建 zabbix 用户
-groupadd --system zabbix || true
-useradd --system -g zabbix -d /opt/zeus/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix || true
-
-wget -c https://cdn.zabbix.com/zabbix/sources/stable/5.4/zabbix-5.4.3.tar.gz -o /dev/null -O - | tar -xz
-logprint "下载zabbix源码失败,请检查网络。。。"
-
-cd "$zabbixsrc" && ./configure --prefix=$ZABBIX_HOME \
- --enable-server \
- --enable-agent \
- --with-postgresql=/usr/pgsql-13/bin/pg_config \
- --with-net-snmp \
- --with-libcurl \
- --with-libxml2 \
- --with-openipmi \
- --with-openssl \
- --with-ssh2 1>/dev/null
-logprint "zabbix 编译异常"
-echo "安装 zabbix"
-make install 1>/dev/null
-logprint "zabbix 编译异常"
-### 前端内容部署
-mv ui $ZABBIX_HOME/web && chown zeus. $ZABBIX_HOME/web -R
-mv $ZABBIX_HOME/web/conf/zabbix.conf.php.example $ZABBIX_HOME/web/conf/zabbix.conf.php
-sed -i "s/\($DB\['PASSWORD'\]\s*=\).*/\1 'zabbix';/g" $ZABBIX_HOME/web/conf/zabbix.conf.php
-sed -i "s/\($DB\['TYPE'\]\s*=\).*/\1 \'POSTGRESQL\';/g" $ZABBIX_HOME/web/conf/zabbix.conf.php
-
-### 数据初始化
-echo "初始化 zabbix 数据库"
-cd /tmp/ || exit
-sudo -u postgres createuser zabbix
-sudo -u postgres /usr/pgsql-13/bin/psql -c "ALTER USER zabbix WITH PASSWORD 'zabbix';"
-sudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix
-cat $zabbixsrc/database/postgresql/schema.sql | sudo -u zabbix psql zabbix 1>/dev/null
-cat $zabbixsrc/database/postgresql/images.sql | sudo -u zabbix psql zabbix 1>/dev/null
-cat $zabbixsrc/database/postgresql/data.sql | sudo -u zabbix psql zabbix 1>/dev/null
-echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix &>/dev/null
-cat $zabbixsrc/database/postgresql/timescaledb.sql | sudo -u zabbix psql zabbix 1>/dev/null
-cd "$basename" || exit
-### 配置zabbix配置文件
-echo "启动zabbix"
-sed -i 's/^# DBPassword=/DBPassword=zabbix/g' $ZABBIX_HOME/etc/zabbix_server.conf
-### 配置启动文件
-tee /usr/lib/systemd/system/zabbix-server.service </dev/null
-[Unit]
-Description=Zabbix Server
-
-After=network.target
-After=postgresql-13.service
-
-[Service]
-Environment="CONFFILE=$ZABBIX_HOME/etc/zabbix_server.conf"
-EnvironmentFile=-/etc/default/zabbix-server
-Type=forking
-Restart=on-failure
-PIDFile=/tmp/zabbix_server.pid
-KillMode=control-group
-ExecStart=$ZABBIX_HOME/sbin/zabbix_server -c \$CONFFILE
-ExecStop=/bin/kill -SIGTERM \$MAINPID
-RestartSec=10s
-TimeoutSec=0
-
-[Install]
-WantedBy=multi-user.target
-EOL
-
-tee /usr/lib/systemd/system/zabbix-agent.service </dev/null
-[Unit]
-Description=Zabbix Agent
-After=network.target
-
-[Service]
-Environment="CONFFILE=$ZABBIX_HOME/etc/zabbix_agentd.conf"
-EnvironmentFile=-/etc/default/zabbix-agent
-Type=forking
-Restart=on-failure
-PIDFile=/tmp/zabbix_agentd.pid
-KillMode=control-group
-ExecStart=$ZABBIX_HOME/sbin/zabbix_agentd -c \$CONFFILE
-ExecStop=/bin/kill -SIGTERM \$MAINPID
-RestartSec=10s
-User=zabbix
-Group=zabbix
-
-[Install]
-WantedBy=multi-user.target
-EOL
-
-systemctl daemon-reload
-systemctl enable zabbix-server
-systemctl enable zabbix-agent
-systemctl start zabbix-server
-systemctl start zabbix-agent
-
-## 安装 php
-echo "安装 zabbix-web"
-yum -y install rh-php73.x86_64 \
- rh-php73-php-fpm.x86_64 \
- rh-php73-php-bcmath.x86_64 \
- rh-php73-php-gd.x86_64 \
- rh-php73-php-mbstring.x86_64 \
- rh-php73-php-ldap.x86_64 \
- rh-php73-php-pgsql.x86_64 1>/dev/null
-
-### php配置文件修改
-sed -i 's/post_max_size = 8M/post_max_size = 16M/' $PHP_CONF/php.ini
-sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/' $PHP_CONF/php.ini
-sed -i 's/max_execution_time = 30/max_execution_time = 300/' $PHP_CONF/php.ini
-sed -i 's/max_input_time = 60/max_input_time = 300/' $PHP_CONF/php.ini
-sed -i 's/; date.timezone =/date.timezone = "Asia\/Shanghai"/' $PHP_CONF/php.ini
-sed -i 's/user = apache/user = zeus/g' $PHP_CONF/php-fpm.d/www.conf
-sed -i 's/group = apache/group = zeus/g' $PHP_CONF/php-fpm.d/www.conf
-sed -i 's/;listen.owner = nobody/listen.owner = zeus/g' $PHP_CONF/php-fpm.d/www.conf
-sed -i 's/;listen.group = nobody/listen.group = zeus/g' $PHP_CONF/php-fpm.d/www.conf
-sed -i 's/\(^listen =\).*/\1\/var\/run\/php-fpm.sock/g' $PHP_CONF/php-fpm.d/www.conf
-
-## 安装 nginx
-yum -y install nginx 1>/dev/null
-
-## 编辑 nginx 配置文件
-tee /etc/nginx/conf.d/zabbix.conf </dev/null
-server {
- listen 80;
-# server_name example.com;
-
- root $ZABBIX_HOME/web;
-
- index index.php;
-
- location = /favicon.ico {
- log_not_found off;
- }
-
- location / {
- try_files \$uri \$uri/ =404;
- }
-
- location /assets {
- access_log off;
- expires 10d;
- }
-
- location ~ /\.ht {
- deny all;
- }
-
- location ~ /(api\/|conf[^\.]|include|locale|vendor) {
- deny all;
- return 404;
- }
-
- location ~ [^/]\.php(/|$) {
- fastcgi_pass unix:/var/run/php-fpm.sock;
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_index index.php;
-
- fastcgi_param DOCUMENT_ROOT $ZABBIX_HOME/web;
- fastcgi_param SCRIPT_FILENAME $ZABBIX_HOME/web\$fastcgi_script_name;
- fastcgi_param PATH_TRANSLATED $ZABBIX_HOME/web\$fastcgi_script_name;
-
- include fastcgi_params;
- fastcgi_param QUERY_STRING \$query_string;
- fastcgi_param REQUEST_METHOD \$request_method;
- fastcgi_param CONTENT_TYPE \$content_type;
- fastcgi_param CONTENT_LENGTH \$content_length;
-
- fastcgi_intercept_errors on;
- fastcgi_ignore_client_abort off;
- fastcgi_connect_timeout 60;
- fastcgi_send_timeout 180;
- fastcgi_read_timeout 180;
- fastcgi_buffer_size 128k;
- fastcgi_buffers 4 256k;
- fastcgi_busy_buffers_size 256k;
- fastcgi_temp_file_write_size 256k;
- }
-}
-EOL
-
-## 修改 nginx 配置用户
-sed -i 's/user nginx;/user zeus;/g' /etc/nginx/nginx.conf
-systemctl enable rh-php73-php-fpm
-systemctl enable nginx
-systemctl start rh-php73-php-fpm
-systemctl start nginx
-
-echo "安装完成。。。请访问 "http://localIP""
-
-##
-# 安装结束
diff --git a/docs/quick-start.rst b/docs/quick-start.rst
index 094b387c..76155834 100644
--- a/docs/quick-start.rst
+++ b/docs/quick-start.rst
@@ -1,2 +1,2 @@
-赶快体验自己的 Zeus-IOT
-======================
\ No newline at end of file
+Quickly experience Zeus-IOT
+===========================
diff --git a/docs/ubuntu/install.sh b/docs/ubuntu/install.sh
new file mode 100644
index 00000000..be3dd2c9
--- /dev/null
+++ b/docs/ubuntu/install.sh
@@ -0,0 +1,310 @@
+#!/usr/bin/env bash
+set -e
+# 初始化系统
+
+function logprint() {
+ if [ $? != 0 ]; then
+ echo "$1"
+ exit
+ fi
+}
+
+# 安装前准备
+## 系统环境检测
+function syscheck() {
+
+ if [ "$(uname)" != Linux ]; then
+ echo "该脚本只使用 Linux 系统"
+ exit 1
+ fi
+
+ if [ "$UID" -ne 0 ]; then
+ echo "Must be root to install"
+ exit 1
+ fi
+ ### 操作系统
+ if [ ! -f /etc/redhat-release ]; then
+ if [[ "$(cat /etc/issue)" =~ ^Ubuntu* ]]; then
+ release=Ubuntu
+ fi
+ fi
+ ### 网络
+ if ! ping -c 3 mirrors.tuna.tsinghua.edu.cn &>/dev/null; then
+ echo "网络异常。。。"
+ exit
+ fi
+
+ ### cpu、mem、disk
+ cores=$(grep 10)printf("%s\t%d\n",$7,$3/1024/1024)}' | grep -v -c "/boot")
+
+ if [ "$cores" -lt 0 ] || [ "$memstotal" -lt 0 ] || [ "$disks" -eq 0 ]; then
+ echo "要求最低配置为 CPU 2核 内存 4GB 存储空间 100G"
+ exit 70
+ fi
+}
+
+
+function InitSystem() {
+ echo -e -n "\033[32mStep1: 初始化系统安装环境 .... \033[0m"
+ ## 修改主机名
+ if ! hostnamectl set-hostname zeus-server; then
+ echo "主机名修改失败"
+ exit
+ fi
+
+
+ ## 修改时区
+ if ! ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime; then
+ echo "时区修改失败"
+ exit 0
+ fi
+ ## 更新下载源
+ cp /etc/apt/sources.list /etc/apt/sources.listbak
+ sed -i 's%\(^deb http\{0,1\}\:\/\/\).*\(/ubuntu.*\)%\1mirrors.tuna.tsinghua.edu.cn\2%g' /etc/apt/sources.list
+ apt-get update 1> /dev/null && apt-get install -y ca-certificates 1> /dev/null
+ #sed -i 's/http/https/g' /etc/apt/sources.list
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+function AddInstallRepo() {
+ echo -e -n "\033[32mStep2: 配置安装 YUM 源 .... \033[0m"
+ ## 安装PGsql源
+ echo "deb https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/apt/ $(lsb_release -c -s)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list &> /dev/null
+ wget --quiet -O - https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/apt/ACCC4CF8.asc | sudo apt-key add - 1> /dev/null
+ #sudo sh -c "echo 'deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main' > /etc/apt/sources.list.d/timescaledb.list"
+ #wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add -
+ ## 安装zabbix 5.4 源
+ wget --quiet -c https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-1+ubuntu$(lsb_release -r -s)_all.deb 1> /dev/null
+ dpkg -i zabbix-release_5.4-1+ubuntu$(lsb_release -r -s)_all.deb 1> /dev/null
+ apt-get update 1> /dev/null && apt-get install -y openjdk-8-jdk expect 1> /dev/null
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+function PGInstall() {
+ echo -e -n "\033[32mStep3: 安装 PostgreSQL .... \033[0m"
+ # PG 安装
+ apt-get install postgresql-13 -y 1> /dev/null
+ #echo "shared_preload_libraries = 'timescaledb'" >> /etc/postgresql/13/main/postgresql.conf
+ cd /tmp || exit
+ sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';" 1> /dev/null
+ systemctl restart postgresql 1> /dev/null
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+function ZbxInstall() {
+ echo -e -n "\033[32mStep4: 安装 zabbix .... \033[0m"
+ # zabbix 安装
+ apt-get install zabbix-server-pgsql zabbix-frontend-php php-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent -y 1> /dev/null
+
+ PHPCONF=/etc/php/$(ls /etc/php/)/fpm/php.ini
+
+ # 初始化 zabbix 配置
+ cd /tmp || exit
+ sudo -u postgres createuser zabbix
+ sudo -u postgres psql -c "ALTER USER zabbix WITH PASSWORD 'zabbix';" 1> /dev/null
+ sudo -u postgres createdb -O zabbix zabbix
+ zcat /usr/share/doc/zabbix-sql-scripts/postgresql/create.sql.gz | sudo -u zabbix psql zabbix 1> /dev/null
+ #echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix
+ #cat /usr/share/doc/zabbix-sql-scripts/postgresql/timescaledb.sql | sudo -u zabbix psql zabbix 1>/dev/null
+
+ sed -i 's/^# DBPassword=/DBPassword=zabbix/g' /etc/zabbix/zabbix_server.conf
+ mv /usr/share/zabbix/conf/zabbix.conf.php.example /usr/share/zabbix/conf/zabbix.conf.php
+ sed -i "s/\($DB\['PASSWORD'\]\s*=\).*/\1 'zabbix';/g" /usr/share/zabbix/conf/zabbix.conf.php
+ sed -i "s/\($DB\['TYPE'\]\s*=\).*/\1 \'POSTGRESQL\';/g" /usr/share/zabbix/conf/zabbix.conf.php
+ # 修改 php 配置
+ sed -i 's/post_max_size = 8M/post_max_size = 16M/' $PHPCONF
+ sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/' $PHPCONF
+ sed -i 's/max_execution_time = 30/max_execution_time = 300/' $PHPCONF
+ sed -i 's/max_input_time = 60/max_input_time = 300/' $PHPCONF
+ sed -i 's/; date.timezone =/date.timezone = "Asia\/Shanghai"/' $PHPCONF
+ # 修改 nginx 配置
+ sed -i '/sites-enabled/d' /etc/nginx/nginx.conf
+ sed -i '/listen/s/#//' /etc/nginx/conf.d/zabbix.conf
+ sed -i '/listen/s/80/8871/' /etc/nginx/conf.d/zabbix.conf
+
+ # 配置 zabbix web
+
+ tee /etc/nginx/conf.d/zeus.conf </dev/null
+server {
+ listen 80;
+
+ location /zabbix {
+ alias /usr/share/zabbix;
+ index index.html index.htm index.php;
+ }
+
+ location ~ ^/zabbix/.+\.php$ {
+ fastcgi_pass unix:/var/run/php/zabbix.sock;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME /usr/share\$fastcgi_script_name;
+ include fastcgi_params;
+
+ fastcgi_param QUERY_STRING \$query_string;
+ fastcgi_param REQUEST_METHOD \$request_method;
+ fastcgi_param CONTENT_TYPE \$content_type;
+ fastcgi_param CONTENT_LENGTH \$content_length;
+
+ fastcgi_intercept_errors on;
+ fastcgi_ignore_client_abort off;
+ fastcgi_connect_timeout 60;
+ fastcgi_send_timeout 180;
+ fastcgi_read_timeout 180;
+ fastcgi_buffer_size 128k;
+ fastcgi_buffers 4 256k;
+ fastcgi_busy_buffers_size 256k;
+ fastcgi_temp_file_write_size 256k;
+ }
+
+}
+EOL
+
+ systemctl restart zabbix-server zabbix-agent nginx php$(ls /etc/php/)-fpm
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+
+function gettoken(){
+ ## 获取 API 永久 token
+ local zabbix_api_url=http://127.0.0.1/zabbix/api_jsonrpc.php
+ local data='{"jsonrpc": "2.0","method": "user.login","params":{"user":"Admin","password":"zabbix"},"id":1,"auth":null}'
+ local res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $zabbix_api_url"`
+ local auth=`echo $res | python3 -c 'import sys, json; print(json.load(sys.stdin)["result"])'`
+ local data='{"jsonrpc": "2.0","method": "token.create","params":{"name":"zeus","userid":"1"},"id":1,"auth":"'${auth}'"}'
+ local res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $zabbix_api_url"`
+ local tokenid=`echo $res | python3 -c 'import sys, json; print(json.load(sys.stdin)["result"]["tokenids"][0])'`
+ local data='{"jsonrpc": "2.0","method": "token.generate","params":["'${tokenid}'"],"id":1,"auth":"'${auth}'"}'
+ local res=`eval exec "curl -d '$data' -H 'Content-Type: application/json' -X POST -s $zabbix_api_url"`
+ token=`echo $res | python3 -c 'import sys, json; print(json.load(sys.stdin)["result"][0]["token"])'`
+}
+
+
+function taosinstall() {
+ ### taos 数据安装
+ echo -e -n "\033[32mStep5: 安装 taos 数据库 .... \033[0m"
+ wget --quiet -c https://www.taosdata.com/assets-download/TDengine-server-2.2.0.2-Linux-x64.deb 1> /dev/null
+ expect << EOF 1> /dev/null
+ spawn dpkg -i TDengine-server-2.2.0.2-Linux-x64.deb
+ expect {
+ "*one:" { send "\n";exp_continue}
+ "*skip:" { send "\n" }
+ }
+EOF
+ systemctl enable taosd 1> /dev/null
+ systemctl start taosd 1> /dev/null
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+
+function ZeusInstall() {
+ echo -e -n "\033[32mStep6: 安装 Zeus-IoT 服务 .... \033[0m"
+ [ ! -d /opt/zeus ] && mkdir -p /opt/zeus
+ cd /opt/zeus || exit
+ ## 创建taos 数据库
+ taos -s "create database zeus_data" 1> /dev/null
+ wget -c https:///zeus-iot/zeus-iot-bin.tar.gz -o /dev/null -O - | tar -xz
+ gettoken
+ ## 数据库导入
+ sudo -u postgres createdb -E Unicode -T template0 zeus-iot
+ cat ./zeus-iot-bin/bin/sql/zeus-iot.sql | sudo -u postgres psql zeus-iot &>/dev/null
+ logprint "文件未找到"
+ sed -i "s%\(zbxApiToken: \).*%\1$token%" ./zeus-iot-bin/webapp/webapp.yml
+ #sed -i '19i export ZEUS_DB_PASSWORD=zeusiot' ./zeus-iot-bin/bin/startup.sh
+ ./zeus-iot-bin/bin/startup.sh 1> /dev/null
+ echo -e "\033[32m [ OK ] \033[0m"
+}
+
+
+function sendmsg() {
+ echo "zabbix 部分已安装成功,zeus iot 可以参照 www.zmops.com 官方文档自定义安装。"
+ echo ""
+ echo "zabbix server 访问地址: http:///zabbix"
+ echo ""
+ echo "登录用户名:Admin"
+ echo "登录密 码:zabbix"
+}
+
+
+function clearsys() {
+
+ function kill9() {
+ status=`ps -ef | grep $1 | grep -v grep | awk '{print $2}' | wc -l`
+
+ if [ $status -ne 0 ]
+ then
+ for i in `ps -ef | grep $1 | grep -v grep | awk '{print $2}'`
+ do
+ kill -9 $i
+ done
+ fi
+ }
+
+ # 清理应用
+ ## 清理 zeus
+ kill9 zeus-iot-bin
+
+ [ -d /opt/zeus/zeus-iot-bin ] && rm -rf /opt/zeus/zeus-iot-bin
+
+ ## 清理 taos
+ systemctl stop taosd &> /dev/null
+
+ kill9 taosd
+
+ apt-get remove tdengine &> /dev/null
+
+ [ -d /usr/local/taos ] && rm -rf /usr/local/taos
+
+ ## 清理 zabbix
+ systemctl stop zabbix-server zabbix-agent &> /dev/null
+
+ kill9 zabbix_server
+ kill9 zabbix_agent
+
+ [ -f /lib/systemd/system/zabbix-server.service ] && rm -rf /lib/systemd/system/zabbix-server.service
+ [ -f /lib/systemd/system/zabbix-agent.service ] && rm -rf /lib/systemd/system/zabbix-agent.service
+
+ ## 清理 postgresql 数据库
+ systemctl stop postgresql &> /dev/null
+
+ kill9 postmaster
+
+ apt-get remove postgresql-13 -y &> /dev/null
+
+ [ -d /opt/zeus/pgdata ] && rm -rf /opt/zeus/pgdata
+ [ -f /lib/systemd/system/postgresql.service ] && rm -rf /lib/systemd/system/postgresql.service
+
+ ## 清理 nginx
+ systemctl stop nginx &> nginx
+
+ kill9 nginx
+ apt-get remove nginx -y &> /dev/null
+ [ -f /lib/systemd/system/nginx ] && rm -rf /lib/systemd/system/nginx
+}
+
+
+
+function main() {
+ case $1 in
+ install)
+ syscheck
+ InitSystem
+ AddInstallRepo
+ PGInstall
+ ZbxInstall
+ taosinstall
+ ;;
+ clear)
+ clearsys
+ ;;
+ *)
+ echo "请输入 install|clear"
+ exit 1
+ ;;
+ esac
+}
+
+if main $1 ;then
+ sendmsg
+fi
+
diff --git a/iot-common/iot-datacarrier/pom.xml b/iot-common/iot-datacarrier/pom.xml
deleted file mode 100644
index 8fc7799b..00000000
--- a/iot-common/iot-datacarrier/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
- 4.0.0
-
- com.zmops
- iot-datacarrier
- 1.0-beta
-
- iot-datacarrier
-
- http://www.example.com
-
-
- UTF-8
- 1.7
- 1.7
-
-
-
-
- junit
- junit
- 4.11
- test
-
-
-
-
-
-
-
-
- maven-clean-plugin
- 3.1.0
-
-
-
- maven-resources-plugin
- 3.0.2
-
-
- maven-compiler-plugin
- 3.8.0
-
-
- maven-surefire-plugin
- 2.22.1
-
-
- maven-jar-plugin
- 3.0.2
-
-
- maven-install-plugin
- 2.5.2
-
-
- maven-deploy-plugin
- 2.8.2
-
-
-
- maven-site-plugin
- 3.7.1
-
-
- maven-project-info-reports-plugin
- 3.0.0
-
-
-
-
-
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/DataCarrier.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/DataCarrier.java
deleted file mode 100644
index 6a33305b..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/DataCarrier.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier;
-
-
-import com.zmops.zeus.iot.server.datacarrier.buffer.BufferStrategy;
-import com.zmops.zeus.iot.server.datacarrier.buffer.Channels;
-import com.zmops.zeus.iot.server.datacarrier.consumer.ConsumeDriver;
-import com.zmops.zeus.iot.server.datacarrier.consumer.ConsumerPool;
-import com.zmops.zeus.iot.server.datacarrier.consumer.IConsumer;
-import com.zmops.zeus.iot.server.datacarrier.consumer.IDriver;
-import com.zmops.zeus.iot.server.datacarrier.partition.IDataPartitioner;
-import com.zmops.zeus.iot.server.datacarrier.partition.SimpleRollingPartitioner;
-
-/**
- * DataCarrier main class. use this instance to set Producer/Consumer Model.
- */
-public class DataCarrier {
- private final Channels channels;
- private IDriver driver;
- private final String name;
-
- public DataCarrier(int channelSize, int bufferSize) {
- this("DEFAULT", channelSize, bufferSize);
- }
-
- public DataCarrier(String name, int channelSize, int bufferSize) {
- this(name, name, channelSize, bufferSize);
- }
-
- public DataCarrier(String name, String envPrefix, int channelSize, int bufferSize) {
- this(name, envPrefix, channelSize, bufferSize, BufferStrategy.BLOCKING);
- }
-
- public DataCarrier(String name, String envPrefix, int channelSize, int bufferSize, BufferStrategy strategy) {
- this.name = name;
- bufferSize = EnvUtil.getInt(envPrefix + "_BUFFER_SIZE", bufferSize);
- channelSize = EnvUtil.getInt(envPrefix + "_CHANNEL_SIZE", channelSize);
- channels = new Channels<>(channelSize, bufferSize, new SimpleRollingPartitioner(), strategy);
- }
-
- public DataCarrier(int channelSize, int bufferSize, BufferStrategy strategy) {
- this("DEFAULT", "DEFAULT", channelSize, bufferSize, strategy);
- }
-
- /**
- * set a new IDataPartitioner. It will cover the current one or default one.(Default is {@link
- * SimpleRollingPartitioner}
- *
- * @param dataPartitioner to partition data into different channel by some rules.
- * @return DataCarrier instance for chain
- */
- public DataCarrier setPartitioner(IDataPartitioner dataPartitioner) {
- this.channels.setPartitioner(dataPartitioner);
- return this;
- }
-
- /**
- * produce data to buffer, using the given {@link BufferStrategy}.
- *
- * @return false means produce data failure. The data will not be consumed.
- */
- public boolean produce(T data) {
- if (driver != null) {
- if (!driver.isRunning(channels)) {
- return false;
- }
- }
-
- return this.channels.save(data);
- }
-
- /**
- * set consumeDriver to this Carrier. consumer begin to run when {@link DataCarrier#produce} begin to work.
- *
- * @param consumerClass class of consumer
- * @param num number of consumer threads
- */
- public DataCarrier consume(Class extends IConsumer> consumerClass, int num, long consumeCycle) {
- if (driver != null) {
- driver.close(channels);
- }
- driver = new ConsumeDriver(this.name, this.channels, consumerClass, num, consumeCycle);
- driver.begin(channels);
- return this;
- }
-
- /**
- * set consumeDriver to this Carrier. consumer begin to run when {@link DataCarrier#produce} begin to work with 20
- * millis consume cycle.
- *
- * @param consumerClass class of consumer
- * @param num number of consumer threads
- */
- public DataCarrier consume(Class extends IConsumer> consumerClass, int num) {
- return this.consume(consumerClass, num, 20);
- }
-
- /**
- * set consumeDriver to this Carrier. consumer begin to run when {@link DataCarrier#produce} begin to work.
- *
- * @param consumer single instance of consumer, all consumer threads will all use this instance.
- * @param num number of consumer threads
- */
- public DataCarrier consume(IConsumer consumer, int num, long consumeCycle) {
- if (driver != null) {
- driver.close(channels);
- }
- driver = new ConsumeDriver(this.name, this.channels, consumer, num, consumeCycle);
- driver.begin(channels);
- return this;
- }
-
- /**
- * set consumeDriver to this Carrier. consumer begin to run when {@link DataCarrier#produce} begin to work with 20
- * millis consume cycle.
- *
- * @param consumer single instance of consumer, all consumer threads will all use this instance.
- * @param num number of consumer threads
- */
- public DataCarrier consume(IConsumer consumer, int num) {
- return this.consume(consumer, num, 20);
- }
-
- /**
- * Set a consumer pool to manage the channels of this DataCarrier. Then consumerPool could use its own consuming
- * model to adjust the consumer thread and throughput.
- */
- public DataCarrier consume(ConsumerPool consumerPool, IConsumer consumer) {
- driver = consumerPool;
- consumerPool.add(this.name, channels, consumer);
- driver.begin(channels);
- return this;
- }
-
- /**
- * shutdown all consumer threads, if consumer threads are running. Notice {@link BufferStrategy}: if {@link
- * BufferStrategy} == {@link BufferStrategy#BLOCKING}, shutdown consumeDriver maybe cause blocking when producing.
- * Better way to change consumeDriver are use {@link DataCarrier#consume}
- */
- public void shutdownConsumers() {
- if (driver != null) {
- driver.close(channels);
- }
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/EnvUtil.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/EnvUtil.java
deleted file mode 100644
index a94dcdbe..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/EnvUtil.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier;
-
-/**
- * Read value from system env.
- */
-public class EnvUtil {
- public static int getInt(String envName, int defaultValue) {
- int value = defaultValue;
- String envValue = System.getenv(envName);
- if (envValue != null) {
- try {
- value = Integer.parseInt(envValue);
- } catch (NumberFormatException e) {
-
- }
- }
- return value;
- }
-
- public static long getLong(String envName, long defaultValue) {
- long value = defaultValue;
- String envValue = System.getenv(envName);
- if (envValue != null) {
- try {
- value = Long.parseLong(envValue);
- } catch (NumberFormatException e) {
-
- }
- }
- return value;
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/ArrayBlockingQueueBuffer.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/ArrayBlockingQueueBuffer.java
deleted file mode 100644
index 8cdfbc62..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/ArrayBlockingQueueBuffer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.buffer;
-
-import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-
-/**
- * The buffer implementation based on JDK ArrayBlockingQueue.
- *
- * This implementation has better performance in server side. We are still trying to research whether this is suitable
- * for agent side, which is more sensitive about blocks.
- */
-public class ArrayBlockingQueueBuffer implements QueueBuffer {
- private BufferStrategy strategy;
- private ArrayBlockingQueue queue;
- private int bufferSize;
-
- ArrayBlockingQueueBuffer(int bufferSize, BufferStrategy strategy) {
- this.strategy = strategy;
- this.queue = new ArrayBlockingQueue(bufferSize);
- this.bufferSize = bufferSize;
- }
-
- @Override
- public boolean save(T data) {
- //only BufferStrategy.BLOCKING
- try {
- queue.put(data);
- } catch (InterruptedException e) {
- // Ignore the error
- return false;
- }
- return true;
- }
-
- @Override
- public void setStrategy(BufferStrategy strategy) {
- this.strategy = strategy;
- }
-
- @Override
- public void obtain(List consumeList) {
- queue.drainTo(consumeList);
- }
-
- @Override
- public int getBufferSize() {
- return bufferSize;
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/Buffer.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/Buffer.java
deleted file mode 100644
index 8cf6b233..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/Buffer.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.buffer;
-
-
-import com.zmops.zeus.iot.server.datacarrier.common.AtomicRangeInteger;
-
-import java.util.List;
-
-/**
- * Self implementation ring queue.
- */
-public class Buffer implements QueueBuffer {
- private final Object[] buffer;
- private BufferStrategy strategy;
- private final AtomicRangeInteger index;
-
- Buffer(int bufferSize, BufferStrategy strategy) {
- buffer = new Object[bufferSize];
- this.strategy = strategy;
- index = new AtomicRangeInteger(0, bufferSize);
- }
-
- @Override
- public void setStrategy(BufferStrategy strategy) {
- this.strategy = strategy;
- }
-
- @Override
- public boolean save(T data) {
- int i = index.getAndIncrement();
- if (buffer[i] != null) {
- if (strategy == BufferStrategy.IF_POSSIBLE) {
- return false;
- }
- }
- buffer[i] = data;
- return true;
- }
-
- @Override
- public int getBufferSize() {
- return buffer.length;
- }
-
- @Override
- public void obtain(List consumeList) {
- this.obtain(consumeList, 0, buffer.length);
- }
-
- void obtain(List consumeList, int start, int end) {
- for (int i = start; i < end; i++) {
- if (buffer[i] != null) {
- consumeList.add((T) buffer[i]);
- buffer[i] = null;
- }
- }
- }
-
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/Channels.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/Channels.java
deleted file mode 100644
index cb24ec37..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/Channels.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.buffer;
-
-
-import com.zmops.zeus.iot.server.datacarrier.partition.IDataPartitioner;
-
-/**
- * Channels of Buffer It contains all buffer data which belongs to this channel. It supports several strategy when
- * buffer is full. The Default is BLOCKING
Created by wusheng on 2016/10/25.
- */
-public class Channels {
- private final QueueBuffer[] bufferChannels;
- private IDataPartitioner dataPartitioner;
- private final BufferStrategy strategy;
- private final long size;
-
- public Channels(int channelSize, int bufferSize, IDataPartitioner partitioner, BufferStrategy strategy) {
- this.dataPartitioner = partitioner;
- this.strategy = strategy;
- bufferChannels = new QueueBuffer[channelSize];
- for (int i = 0; i < channelSize; i++) {
- if (BufferStrategy.BLOCKING.equals(strategy)) {
- bufferChannels[i] = new ArrayBlockingQueueBuffer<>(bufferSize, strategy);
- } else {
- bufferChannels[i] = new Buffer<>(bufferSize, strategy);
- }
- }
- // noinspection PointlessArithmeticExpression
- size = 1L * channelSize * bufferSize; // it's not pointless, it prevents numeric overflow before assigning an integer to a long
- }
-
- public boolean save(T data) {
- int index = dataPartitioner.partition(bufferChannels.length, data);
- int retryCountDown = 1;
- if (BufferStrategy.IF_POSSIBLE.equals(strategy)) {
- int maxRetryCount = dataPartitioner.maxRetryCount();
- if (maxRetryCount > 1) {
- retryCountDown = maxRetryCount;
- }
- }
- for (; retryCountDown > 0; retryCountDown--) {
- if (bufferChannels[index].save(data)) {
- return true;
- }
- }
- return false;
- }
-
- public void setPartitioner(IDataPartitioner dataPartitioner) {
- this.dataPartitioner = dataPartitioner;
- }
-
- /**
- * override the strategy at runtime. Notice, this will override several channels one by one. So, when running
- * setStrategy, each channel may use different BufferStrategy
- */
- public void setStrategy(BufferStrategy strategy) {
- for (QueueBuffer buffer : bufferChannels) {
- buffer.setStrategy(strategy);
- }
- }
-
- /**
- * get channelSize
- */
- public int getChannelSize() {
- return this.bufferChannels.length;
- }
-
- public long size() {
- return size;
- }
-
- public QueueBuffer getBuffer(int index) {
- return this.bufferChannels[index];
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/common/AtomicRangeInteger.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/common/AtomicRangeInteger.java
deleted file mode 100644
index dac9a527..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/common/AtomicRangeInteger.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.common;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicIntegerArray;
-
-public class AtomicRangeInteger extends Number implements Serializable {
- private static final long serialVersionUID = -4099792402691141643L;
- private AtomicIntegerArray values;
-
- private static final int VALUE_OFFSET = 15;
-
- private int startValue;
- private int endValue;
-
- public AtomicRangeInteger(int startValue, int maxValue) {
- this.values = new AtomicIntegerArray(31);
- this.values.set(VALUE_OFFSET, startValue);
- this.startValue = startValue;
- this.endValue = maxValue - 1;
- }
-
- public final int getAndIncrement() {
- int next;
- do {
- next = this.values.incrementAndGet(VALUE_OFFSET);
- if (next > endValue && this.values.compareAndSet(VALUE_OFFSET, next, startValue)) {
- return endValue;
- }
- }
- while (next > endValue);
-
- return next - 1;
- }
-
- public final int get() {
- return this.values.get(VALUE_OFFSET);
- }
-
- @Override
- public int intValue() {
- return this.values.get(VALUE_OFFSET);
- }
-
- @Override
- public long longValue() {
- return this.values.get(VALUE_OFFSET);
- }
-
- @Override
- public float floatValue() {
- return this.values.get(VALUE_OFFSET);
- }
-
- @Override
- public double doubleValue() {
- return this.values.get(VALUE_OFFSET);
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/BulkConsumePool.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/BulkConsumePool.java
deleted file mode 100644
index 2c5131ee..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/BulkConsumePool.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.consumer;
-
-
-import com.zmops.zeus.iot.server.datacarrier.EnvUtil;
-import com.zmops.zeus.iot.server.datacarrier.buffer.Channels;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-
-/**
- * BulkConsumePool works for consuming data from multiple channels(DataCarrier instances), with multiple {@link
- * MultipleChannelsConsumer}s.
- *
- * In typical case, the number of {@link MultipleChannelsConsumer} should be less than the number of channels.
- */
-public class BulkConsumePool implements ConsumerPool {
- private List allConsumers;
- private volatile boolean isStarted = false;
-
- public BulkConsumePool(String name, int size, long consumeCycle) {
- size = EnvUtil.getInt(name + "_THREAD", size);
- allConsumers = new ArrayList(size);
- for (int i = 0; i < size; i++) {
- MultipleChannelsConsumer multipleChannelsConsumer = new MultipleChannelsConsumer("DataCarrier." + name + ".BulkConsumePool." + i + ".Thread", consumeCycle);
- multipleChannelsConsumer.setDaemon(true);
- allConsumers.add(multipleChannelsConsumer);
- }
- }
-
- @Override
- synchronized public void add(String name, Channels channels, IConsumer consumer) {
- MultipleChannelsConsumer multipleChannelsConsumer = getLowestPayload();
- multipleChannelsConsumer.addNewTarget(channels, consumer);
- }
-
- /**
- * Get the lowest payload consumer thread based on current allocate status.
- *
- * @return the lowest consumer.
- */
- private MultipleChannelsConsumer getLowestPayload() {
- MultipleChannelsConsumer winner = allConsumers.get(0);
- for (int i = 1; i < allConsumers.size(); i++) {
- MultipleChannelsConsumer option = allConsumers.get(i);
- if (option.size() < winner.size()) {
- winner = option;
- }
- }
- return winner;
- }
-
- /**
- *
- */
- @Override
- public boolean isRunning(Channels channels) {
- return isStarted;
- }
-
- @Override
- public void close(Channels channels) {
- for (MultipleChannelsConsumer consumer : allConsumers) {
- consumer.shutdown();
- }
- }
-
- @Override
- public void begin(Channels channels) {
- if (isStarted) {
- return;
- }
- for (MultipleChannelsConsumer consumer : allConsumers) {
- consumer.start();
- }
- isStarted = true;
- }
-
- /**
- * The creator for {@link BulkConsumePool}.
- */
- public static class Creator implements Callable {
- private String name;
- private int size;
- private long consumeCycle;
-
- public Creator(String name, int poolSize, long consumeCycle) {
- this.name = name;
- this.size = poolSize;
- this.consumeCycle = consumeCycle;
- }
-
- @Override
- public ConsumerPool call() {
- return new BulkConsumePool(name, size, consumeCycle);
- }
-
- public static int recommendMaxSize() {
- return Runtime.getRuntime().availableProcessors() * 2;
- }
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumeDriver.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumeDriver.java
deleted file mode 100644
index d84c4c53..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumeDriver.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.consumer;
-
-
-import com.zmops.zeus.iot.server.datacarrier.buffer.Channels;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * Pool of consumers
Created by wusheng on 2016/10/25.
- */
-public class ConsumeDriver implements IDriver {
- private boolean running;
- private ConsumerThread[] consumerThreads;
- private Channels channels;
- private ReentrantLock lock;
-
- public ConsumeDriver(String name, Channels channels, Class extends IConsumer> consumerClass, int num,
- long consumeCycle) {
- this(channels, num);
- for (int i = 0; i < num; i++) {
- consumerThreads[i] = new ConsumerThread("DataCarrier." + name + ".Consumer." + i + ".Thread", getNewConsumerInstance(consumerClass), consumeCycle);
- consumerThreads[i].setDaemon(true);
- }
- }
-
- public ConsumeDriver(String name, Channels channels, IConsumer prototype, int num, long consumeCycle) {
- this(channels, num);
- prototype.init();
- for (int i = 0; i < num; i++) {
- consumerThreads[i] = new ConsumerThread("DataCarrier." + name + ".Consumer." + i + ".Thread", prototype, consumeCycle);
- consumerThreads[i].setDaemon(true);
- }
-
- }
-
- private ConsumeDriver(Channels channels, int num) {
- running = false;
- this.channels = channels;
- consumerThreads = new ConsumerThread[num];
- lock = new ReentrantLock();
- }
-
- private IConsumer getNewConsumerInstance(Class extends IConsumer> consumerClass) {
- try {
- IConsumer inst = consumerClass.getDeclaredConstructor().newInstance();
- inst.init();
- return inst;
- } catch (InstantiationException e) {
- throw new ConsumerCannotBeCreatedException(e);
- } catch (IllegalAccessException e) {
- throw new ConsumerCannotBeCreatedException(e);
- } catch (NoSuchMethodException e) {
- throw new ConsumerCannotBeCreatedException(e);
- } catch (InvocationTargetException e) {
- throw new ConsumerCannotBeCreatedException(e);
- }
- }
-
- @Override
- public void begin(Channels channels) {
- if (running) {
- return;
- }
- lock.lock();
- try {
- this.allocateBuffer2Thread();
- for (ConsumerThread consumerThread : consumerThreads) {
- consumerThread.start();
- }
- running = true;
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public boolean isRunning(Channels channels) {
- return running;
- }
-
- private void allocateBuffer2Thread() {
- int channelSize = this.channels.getChannelSize();
- /**
- * if consumerThreads.length < channelSize
- * each consumer will process several channels.
- *
- * if consumerThreads.length == channelSize
- * each consumer will process one channel.
- *
- * if consumerThreads.length > channelSize
- * there will be some threads do nothing.
- */
- for (int channelIndex = 0; channelIndex < channelSize; channelIndex++) {
- int consumerIndex = channelIndex % consumerThreads.length;
- consumerThreads[consumerIndex].addDataSource(channels.getBuffer(channelIndex));
- }
-
- }
-
- @Override
- public void close(Channels channels) {
- lock.lock();
- try {
- this.running = false;
- for (ConsumerThread consumerThread : consumerThreads) {
- consumerThread.shutdown();
- }
- } finally {
- lock.unlock();
- }
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerCannotBeCreatedException.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerCannotBeCreatedException.java
deleted file mode 100644
index 726feec2..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerCannotBeCreatedException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.consumer;
-
-public class ConsumerCannotBeCreatedException extends RuntimeException {
- ConsumerCannotBeCreatedException(Throwable t) {
- super(t);
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerPoolFactory.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerPoolFactory.java
deleted file mode 100644
index af114378..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerPoolFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.consumer;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Callable;
-
-/**
- * Consumer Pool Factory provides global management for all Consumer Pool.
- */
-public enum ConsumerPoolFactory {
- INSTANCE;
-
- private final Map pools;
-
- ConsumerPoolFactory() {
- pools = new HashMap<>();
- }
-
- public synchronized boolean createIfAbsent(String poolName, Callable creator) throws Exception {
- if (pools.containsKey(poolName)) {
- return false;
- } else {
- pools.put(poolName, creator.call());
- return true;
- }
- }
-
- public ConsumerPool get(String poolName) {
- return pools.get(poolName);
- }
-
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerThread.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerThread.java
deleted file mode 100644
index f22d9284..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerThread.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.consumer;
-
-
-import com.zmops.zeus.iot.server.datacarrier.buffer.Buffer;
-import com.zmops.zeus.iot.server.datacarrier.buffer.QueueBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ConsumerThread extends Thread {
- private volatile boolean running;
- private IConsumer consumer;
- private List dataSources;
- private long consumeCycle;
-
- ConsumerThread(String threadName, IConsumer consumer, long consumeCycle) {
- super(threadName);
- this.consumer = consumer;
- running = false;
- dataSources = new ArrayList(1);
- this.consumeCycle = consumeCycle;
- }
-
- /**
- * add whole buffer to consume
- */
- void addDataSource(QueueBuffer sourceBuffer) {
- this.dataSources.add(new DataSource(sourceBuffer));
- }
-
- @Override
- public void run() {
- running = true;
-
- final List consumeList = new ArrayList(1500);
- while (running) {
- if (!consume(consumeList)) {
- try {
- Thread.sleep(consumeCycle);
- } catch (InterruptedException e) {
- }
- }
- }
-
- // consumer thread is going to stop
- // consume the last time
- consume(consumeList);
-
- consumer.onExit();
- }
-
- private boolean consume(List consumeList) {
- for (DataSource dataSource : dataSources) {
- dataSource.obtain(consumeList);
- }
-
- if (!consumeList.isEmpty()) {
- try {
- consumer.consume(consumeList);
- } catch (Throwable t) {
- consumer.onError(consumeList, t);
- } finally {
- consumeList.clear();
- }
- return true;
- }
- return false;
- }
-
- void shutdown() {
- running = false;
- }
-
- /**
- * DataSource is a refer to {@link Buffer}.
- */
- class DataSource {
- private QueueBuffer sourceBuffer;
-
- DataSource(QueueBuffer sourceBuffer) {
- this.sourceBuffer = sourceBuffer;
- }
-
- void obtain(List consumeList) {
- sourceBuffer.obtain(consumeList);
- }
- }
-}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/MultipleChannelsConsumer.java b/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/MultipleChannelsConsumer.java
deleted file mode 100644
index ff66d9b1..00000000
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/MultipleChannelsConsumer.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.datacarrier.consumer;
-
-
-import com.zmops.zeus.iot.server.datacarrier.buffer.Channels;
-import com.zmops.zeus.iot.server.datacarrier.buffer.QueueBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * MultipleChannelsConsumer represent a single consumer thread, but support multiple channels with their {@link
- * IConsumer}s
- */
-public class MultipleChannelsConsumer extends Thread {
- private volatile boolean running;
- private volatile ArrayList consumeTargets;
- @SuppressWarnings("NonAtomicVolatileUpdate")
- private volatile long size;
- private final long consumeCycle;
-
- public MultipleChannelsConsumer(String threadName, long consumeCycle) {
- super(threadName);
- this.consumeTargets = new ArrayList();
- this.consumeCycle = consumeCycle;
- }
-
- @Override
- public void run() {
- running = true;
-
- final List consumeList = new ArrayList(2000);
- while (running) {
- boolean hasData = false;
- for (Group target : consumeTargets) {
- boolean consume = consume(target, consumeList);
- hasData = hasData || consume;
- }
-
- if (!hasData) {
- try {
- Thread.sleep(consumeCycle);
- } catch (InterruptedException e) {
- }
- }
- }
-
- // consumer thread is going to stop
- // consume the last time
- for (Group target : consumeTargets) {
- consume(target, consumeList);
-
- target.consumer.onExit();
- }
- }
-
- private boolean consume(Group target, List consumeList) {
- for (int i = 0; i < target.channels.getChannelSize(); i++) {
- QueueBuffer buffer = target.channels.getBuffer(i);
- buffer.obtain(consumeList);
- }
-
- if (!consumeList.isEmpty()) {
- try {
- target.consumer.consume(consumeList);
- } catch (Throwable t) {
- target.consumer.onError(consumeList, t);
- } finally {
- consumeList.clear();
- }
- return true;
- }
- return false;
- }
-
- /**
- * Add a new target channels.
- */
- public void addNewTarget(Channels channels, IConsumer consumer) {
- Group group = new Group(channels, consumer);
- // Recreate the new list to avoid change list while the list is used in consuming.
- ArrayList newList = new ArrayList();
- for (Group target : consumeTargets) {
- newList.add(target);
- }
- newList.add(group);
- consumeTargets = newList;
- size += channels.size();
- }
-
- public long size() {
- return size;
- }
-
- void shutdown() {
- running = false;
- }
-
- private static class Group {
- private Channels channels;
- private IConsumer consumer;
-
- public Group(Channels channels, IConsumer consumer) {
- this.channels = channels;
- this.consumer = consumer;
- }
- }
-}
diff --git a/iot-common/iot-eventbus/pom.xml b/iot-common/iot-eventbus/pom.xml
deleted file mode 100644
index 6a3d5e21..00000000
--- a/iot-common/iot-eventbus/pom.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- iot-common
- com.zmops
- 1.0-beta
-
- 4.0.0
-
-
- iot-eventbus
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/iot-common/iot-util/pom.xml b/iot-common/iot-util/pom.xml
deleted file mode 100644
index d1bdc7a4..00000000
--- a/iot-common/iot-util/pom.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- iot-common
- com.zmops
- 1.0-beta
-
- 4.0.0
-
- iot-util
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/PlaceholderConfigurerSupport.java b/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/PlaceholderConfigurerSupport.java
deleted file mode 100644
index 359502aa..00000000
--- a/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/PlaceholderConfigurerSupport.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.util;
-
-public class PlaceholderConfigurerSupport {
-
- /**
- * Default placeholder prefix: {@value}
- */
- public static final String DEFAULT_PLACEHOLDER_PREFIX = "${";
-
- /**
- * Default placeholder suffix: {@value}
- */
- public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
-
- /**
- * Default value separator: {@value}
- */
- public static final String DEFAULT_VALUE_SEPARATOR = ":";
-
-}
diff --git a/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/PropertyPlaceholderHelper.java b/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/PropertyPlaceholderHelper.java
deleted file mode 100644
index a6fcbff7..00000000
--- a/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/PropertyPlaceholderHelper.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.util;
-
-import java.util.*;
-
-/**
- * Utility class for working with Strings that have placeholder values in them. A placeholder takes the form {@code
- * ${name}}. Using {@code PropertyPlaceholderHelper} these placeholders can be substituted for user-supplied values.
- * Values for substitution can be supplied using a {@link Properties} instance or using a {@link PlaceholderResolver}.
- */
-public enum PropertyPlaceholderHelper {
-
- INSTANCE(
- PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX,
- PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX, PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR,
- true
- );
-
- private final String placeholderPrefix;
-
- private final String placeholderSuffix;
-
- private final String simplePrefix;
-
- private final String valueSeparator;
-
- private final boolean ignoreUnresolvablePlaceholders;
-
- /**
- * Creates a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
- *
- * @param placeholderPrefix the prefix that denotes the start of a placeholder
- * @param placeholderSuffix the suffix that denotes the end of a placeholder
- * @param valueSeparator the separating character between the placeholder variable and the
- * associated default value, if any
- * @param ignoreUnresolvablePlaceholders indicates whether unresolvable placeholders should be ignored ({@code
- * true}) or cause an exception ({@code false})
- */
- PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix, String valueSeparator,
- boolean ignoreUnresolvablePlaceholders) {
- if (StringUtil.isEmpty(placeholderPrefix) || StringUtil.isEmpty(placeholderSuffix)) {
- throw new UnsupportedOperationException("'placeholderPrefix or placeholderSuffix' must not be null");
- }
-
- final Map wellKnownSimplePrefixes = new HashMap(4);
-
- wellKnownSimplePrefixes.put("}", "{");
- wellKnownSimplePrefixes.put("]", "[");
- wellKnownSimplePrefixes.put(")", "(");
-
- this.placeholderPrefix = placeholderPrefix;
- this.placeholderSuffix = placeholderSuffix;
- String simplePrefixForSuffix = wellKnownSimplePrefixes.get(this.placeholderSuffix);
- if (simplePrefixForSuffix != null && this.placeholderPrefix.endsWith(simplePrefixForSuffix)) {
- this.simplePrefix = simplePrefixForSuffix;
- } else {
- this.simplePrefix = this.placeholderPrefix;
- }
- this.valueSeparator = valueSeparator;
- this.ignoreUnresolvablePlaceholders = ignoreUnresolvablePlaceholders;
- }
-
- /**
- * Replaces all placeholders of format {@code ${name}} with the corresponding property from the supplied {@link
- * Properties}.
- *
- * @param value the value containing the placeholders to be replaced
- * @param properties the {@code Properties} to use for replacement
- * @return the supplied value with placeholders replaced inline
- */
- public String replacePlaceholders(String value, final Properties properties) {
- return replacePlaceholders(value, new PlaceholderResolver() {
- @Override
- public String resolvePlaceholder(String placeholderName) {
- return getConfigValue(placeholderName, properties);
- }
- });
- }
-
- private String getConfigValue(String key, final Properties properties) {
- String value = System.getProperty(key);
- if (value == null) {
- value = System.getenv(key);
- }
- if (value == null) {
- value = properties.getProperty(key);
- }
- return value;
- }
-
- /**
- * Replaces all placeholders of format {@code ${name}} with the value returned from the supplied {@link
- * PlaceholderResolver}.
- *
- * @param value the value containing the placeholders to be replaced
- * @param placeholderResolver the {@code PlaceholderResolver} to use for replacement
- * @return the supplied value with placeholders replaced inline
- */
- public String replacePlaceholders(String value, PlaceholderResolver placeholderResolver) {
- return parseStringValue(value, placeholderResolver, new HashSet());
- }
-
- protected String parseStringValue(String value, PlaceholderResolver placeholderResolver, Set visitedPlaceholders) {
-
- StringBuilder result = new StringBuilder(value);
-
- int startIndex = value.indexOf(this.placeholderPrefix);
- while (startIndex != -1) {
- int endIndex = findPlaceholderEndIndex(result, startIndex);
- if (endIndex != -1) {
- String placeholder = result.substring(startIndex + this.placeholderPrefix.length(), endIndex);
- String originalPlaceholder = placeholder;
- if (!visitedPlaceholders.add(originalPlaceholder)) {
- throw new IllegalArgumentException("Circular placeholder reference '" + originalPlaceholder + "' in property definitions");
- }
- // Recursive invocation, parsing placeholders contained in the placeholder key.
- placeholder = parseStringValue(placeholder, placeholderResolver, visitedPlaceholders);
- // Now obtain the value for the fully resolved key...
- String propVal = placeholderResolver.resolvePlaceholder(placeholder);
-
- if (propVal == null && this.valueSeparator != null) {
- int separatorIndex = placeholder.indexOf(this.valueSeparator);
- if (separatorIndex != -1) {
- String actualPlaceholder = placeholder.substring(0, separatorIndex);
- String defaultValue = placeholder.substring(separatorIndex + this.valueSeparator.length());
- propVal = placeholderResolver.resolvePlaceholder(actualPlaceholder);
- if (propVal == null) {
- propVal = defaultValue;
- }
- }
- }
-
- if (propVal != null) {
- // Recursive invocation, parsing placeholders contained in the
- // previously resolved placeholder value.
- propVal = parseStringValue(propVal, placeholderResolver, visitedPlaceholders);
- result.replace(startIndex, endIndex + this.placeholderSuffix.length(), propVal);
- startIndex = result.indexOf(this.placeholderPrefix, startIndex + propVal.length());
- } else if (this.ignoreUnresolvablePlaceholders) {
- // Proceed with unprocessed value.
- startIndex = result.indexOf(this.placeholderPrefix, endIndex + this.placeholderSuffix.length());
- } else {
- throw new IllegalArgumentException(
- "Could not resolve placeholder '" + placeholder + "'" + " in value \"" + value + "\"");
- }
- visitedPlaceholders.remove(originalPlaceholder);
- } else {
- startIndex = -1;
- }
- }
- return result.toString();
- }
-
- private int findPlaceholderEndIndex(CharSequence buf, int startIndex) {
- int index = startIndex + this.placeholderPrefix.length();
- int withinNestedPlaceholder = 0;
- while (index < buf.length()) {
- if (StringUtil.substringMatch(buf, index, this.placeholderSuffix)) {
- if (withinNestedPlaceholder > 0) {
- withinNestedPlaceholder--;
- index = index + this.placeholderSuffix.length();
- } else {
- return index;
- }
- } else if (StringUtil.substringMatch(buf, index, this.simplePrefix)) {
- withinNestedPlaceholder++;
- index = index + this.simplePrefix.length();
- } else {
- index++;
- }
- }
- return -1;
- }
-
- /**
- * Strategy interface used to resolve replacement values for placeholders contained in Strings.
- */
- public interface PlaceholderResolver {
-
- /**
- * Resolve the supplied placeholder name to the replacement value.
- *
- * @param placeholderName the name of the placeholder to resolve
- * @return the replacement value, or {@code null} if no replacement is to be made
- */
- String resolvePlaceholder(String placeholderName);
- }
-}
diff --git a/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/StringUtil.java b/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/StringUtil.java
deleted file mode 100644
index ba296aee..00000000
--- a/iot-common/iot-util/src/main/java/com/zmops/zeus/iot/server/util/StringUtil.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.util;
-
-import java.util.function.Consumer;
-
-public final class StringUtil {
- public static boolean isEmpty(String str) {
- return str == null || str.length() == 0;
- }
-
- public static boolean isNotEmpty(String str) {
- return !isEmpty(str);
- }
-
- public static boolean isBlank(String str) {
- return str == null || isEmpty(str.trim());
- }
-
- public static boolean isNotBlank(String str) {
- return !isBlank(str);
- }
-
- public static void setIfPresent(String value, Consumer setter) {
- if (isNotEmpty(value)) {
- setter.accept(value);
- }
- }
-
- public static String join(final char delimiter, final String... strings) {
- if (strings.length == 0) {
- return null;
- }
- if (strings.length == 1) {
- return strings[0];
- }
- int length = strings.length - 1;
- for (final String s : strings) {
- if (s == null) {
- continue;
- }
- length += s.length();
- }
- final StringBuilder sb = new StringBuilder(length);
- if (strings[0] != null) {
- sb.append(strings[0]);
- }
- for (int i = 1; i < strings.length; ++i) {
- if (!isEmpty(strings[i])) {
- sb.append(delimiter).append(strings[i]);
- } else {
- sb.append(delimiter);
- }
- }
- return sb.toString();
- }
-
- public static boolean substringMatch(CharSequence str, int index, CharSequence substring) {
- if (index + substring.length() > str.length()) {
- return false;
- }
- for (int i = 0; i < substring.length(); i++) {
- if (str.charAt(index + i) != substring.charAt(i)) {
- return false;
- }
- }
- return true;
- }
-
- public static String cut(String str, int threshold) {
- if (isEmpty(str) || str.length() <= threshold) {
- return str;
- }
- return str.substring(0, threshold);
- }
-
- public static String trim(final String str, final char ch) {
- if (isEmpty(str)) {
- return null;
- }
-
- final char[] chars = str.toCharArray();
-
- int i = 0, j = chars.length - 1;
- // noinspection StatementWithEmptyBody
- for (; i < chars.length && chars[i] == ch; i++) {
- }
- // noinspection StatementWithEmptyBody
- for (; j > 0 && chars[j] == ch; j--) {
- }
-
- return new String(chars, i, j - i + 1);
- }
-}
diff --git a/iot-common/pom.xml b/iot-common/pom.xml
deleted file mode 100644
index 5647a4c4..00000000
--- a/iot-common/pom.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- zeus-iot-server
- com.zmops
- 1.0-beta
- ../iot-server-dist/pom.xml
-
- 4.0.0
-
- iot-common
- pom
-
- iot-datacarrier
- iot-util
- iot-eventbus
-
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/iot-server-bom/pom.xml b/iot-server-bom/pom.xml
new file mode 100644
index 00000000..6c4beee9
--- /dev/null
+++ b/iot-server-bom/pom.xml
@@ -0,0 +1,119 @@
+
+
+
+
+ com.zmops
+ zeus-iot
+ 1.0-beta
+
+
+ pom
+ 4.0.0
+ iot-server-bom
+
+ IoT Server 协议解析层
+
+
+ 3.11.4
+ 1.18.20
+ 2.17.0
+ 25.1-jre
+ 4.1.65.Final
+ 2.8.7
+
+
+
+
+
+ io.netty
+ netty-bom
+ ${netty.version}
+ import
+ pom
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-web
+ ${log4j.version}
+
+
+
+ com.google.guava
+ guava
+ ${guava.version}
+
+
+
+ org.apache.camel
+ camel-core
+ ${camel.version}
+
+
+ org.apache.camel
+ camel-jsonpath
+ ${camel.version}
+
+
+ com.google.code.gson
+ gson
+ ${gson.version}
+
+
+
+ org.apache.camel
+ camel-netty-http
+ ${camel.version}
+
+
+ org.apache.camel
+ camel-netty
+ ${camel.version}
+
+
+ io.netty
+ netty-all
+
+
+
+
+ org.apache.camel
+ camel-paho-mqtt5
+ ${camel.version}
+
+
+ com.h2database
+ h2
+ 1.4.196
+
+
+
+
\ No newline at end of file
diff --git a/iot-server-dist/pom.xml b/iot-server-dist/pom.xml
deleted file mode 100644
index cc7b91d2..00000000
--- a/iot-server-dist/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- zeus-server-pom
- com.zmops
- 1.0-beta
- ../zeus-server-pom/pom.xml
-
- 4.0.0
-
- zeus-iot-server
- pom
-
- ../iot-common
-
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/iot-server/pom.xml b/iot-server/pom.xml
index 76d50df6..9c4f174b 100644
--- a/iot-server/pom.xml
+++ b/iot-server/pom.xml
@@ -3,93 +3,131 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- zeus-server-pomcom.zmops
+ zeus-iot1.0-beta
- ../zeus-server-pom4.0.0
-
iot-serverpom
+
+
+
+ UTF-8
+ 0.30.0
+ 8
+ 8
+
+
- server-libraryserver-coreserver-starterserver-bootstrapserver-health-checkerserver-telemetry
- server-receiver-pluginserver-sender
+ server-storage-plugin
+ server-transfer
+ server-localdb
+ server-camel-receiver
+ server-web
+ server-client
+
+
+
+ com.zmops
+ iot-server-bom
+ 1.0-beta
+ import
+ pom
+
+
+
+
org.projectlomboklombok
- 1.18.20org.apache.logging.log4jlog4j-api
- 2.13.3org.apache.logging.log4jlog4j-slf4j-impl
- 2.13.3com.google.guavaguava
- 25.1-jreio.nettynetty-codec-http
- 4.1.65.Finalio.nettynetty-handler
- 4.1.65.Finalio.nettynetty-resolver-dns
- 4.1.65.Finalio.nettynetty-codec-dns
- 4.1.65.Finalorg.apache.logging.log4jlog4j-core
- 2.13.3org.apache.camelcamel-core
- ${camel.version}
+
+
+ org.slf4j
+ slf4j-api
+
+ org.apache.camelcamel-jsonpath
- ${camel.version}com.google.code.gsongson
- 2.8.7
+
+
+
+
+
+ org.apache.camel
+ camel-netty
+
+
+ io.netty
+ netty-example
+
+
+ io.netty
+ netty-all
+
+
+
+
+ org.apache.camel
+ camel-paho-mqtt5
+
+
+ com.h2database
+ h2
-
- 8
- 8
-
\ No newline at end of file
diff --git a/iot-server/readme.md b/iot-server/readme.md
index a76b5c9b..ae925293 100644
--- a/iot-server/readme.md
+++ b/iot-server/readme.md
@@ -1,2 +1 @@
-#### 宙斯协议层服务
- - 基于Skywalking改造
\ No newline at end of file
+#### 宙斯多协议网关 V1.0
\ No newline at end of file
diff --git a/iot-server/server-bootstrap/pom.xml b/iot-server/server-bootstrap/pom.xml
index 27b4cbb8..48c4d112 100644
--- a/iot-server/server-bootstrap/pom.xml
+++ b/iot-server/server-bootstrap/pom.xml
@@ -16,17 +16,29 @@
server-core${project.version}
+
+
+ com.zmops
+ toolkit-util
+ 1.0.3-RELEASE
+
+
+
+ com.zmops
+ server-web
+ 1.0-beta
+
+
com.zmopslibrary-module
- ${project.version}
+ 1.0.3-RELEASEorg.yamlsnakeyaml1.26
-
com.zmopsserver-health-checker
@@ -42,7 +54,6 @@
telemetry-prometheus${project.version}
-
com.zmopsserver-sender
@@ -50,19 +61,44 @@
com.zmops
- http-receiver-plugin
+ server-tdengine-plugin${project.version}com.zmops
- tcp-receiver-plugin
+ server-transfer${project.version}com.zmops
- mqtt-receiver-plugin
+ server-none-storage${project.version}
+
+ com.zmops
+ server-camel-receiver
+ 1.0-beta
+
+
+
+ com.zmops
+ server-localdb
+ 1.0-beta
+
+
+
+
+
+
+
+
+
+
@@ -86,7 +122,6 @@
maven-jar-plugin
- application.ymllog4j2.xml
@@ -94,9 +129,4 @@
-
- 8
- 8
-
-
\ No newline at end of file
diff --git a/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/IOTServerBootstrap.java b/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/IoTServerBootstrap.java
similarity index 86%
rename from iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/IOTServerBootstrap.java
rename to iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/IoTServerBootstrap.java
index a2901dbd..f31ee7a7 100644
--- a/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/IOTServerBootstrap.java
+++ b/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/IoTServerBootstrap.java
@@ -20,13 +20,15 @@
import com.zmops.zeus.iot.server.core.RunningMode;
import com.zmops.zeus.iot.server.starter.config.ApplicationConfigLoader;
-import com.zmops.zeus.iot.server.library.module.ApplicationConfiguration;
-import com.zmops.zeus.iot.server.library.module.ModuleManager;
import com.zmops.zeus.iot.server.telemetry.TelemetryModule;
import com.zmops.zeus.iot.server.telemetry.api.MetricsCreator;
import com.zmops.zeus.iot.server.telemetry.api.MetricsTag;
+import com.zmops.zeus.server.library.module.ApplicationConfiguration;
+import com.zmops.zeus.server.library.module.ModuleManager;
import lombok.extern.slf4j.Slf4j;
+import java.util.TimeZone;
+
/**
* Starter core. Load the core configuration file, and initialize the startup sequence through {@link ModuleManager}.
@@ -34,13 +36,16 @@
* 模块加载启动器,动态加载模块。
*/
@Slf4j
-public class IOTServerBootstrap {
+public class IoTServerBootstrap {
public static void start() {
+ TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
+
String mode = System.getProperty("mode");
RunningMode.setMode(mode);
ApplicationConfigLoader configLoader = new ApplicationConfigLoader();
- ModuleManager manager = new ModuleManager();
+
+ ModuleManager manager = new ModuleManager();
try {
ApplicationConfiguration applicationConfiguration = configLoader.load();
manager.init(applicationConfiguration);
@@ -53,9 +58,10 @@ public static void start() {
.setValue(System.currentTimeMillis() / 1000d);
if (RunningMode.isInitMode()) {
- log.info("Zeus IOT starts up in init mode successfully, exit now...");
+ log.info("Zeus IoT starts up in init mode successfully, exit now...");
System.exit(0);
}
+
} catch (Throwable t) {
log.error(t.getMessage(), t);
System.exit(1);
diff --git a/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/config/ApplicationConfigLoader.java b/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/config/ApplicationConfigLoader.java
index 11304f41..62676bda 100644
--- a/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/config/ApplicationConfigLoader.java
+++ b/iot-server/server-bootstrap/src/main/java/com/zmops/zeus/iot/server/starter/config/ApplicationConfigLoader.java
@@ -18,13 +18,13 @@
package com.zmops.zeus.iot.server.starter.config;
-import com.zmops.zeus.iot.server.library.util.CollectionUtils;
-import com.zmops.zeus.iot.server.library.util.ResourceUtils;
-import com.zmops.zeus.iot.server.library.module.ApplicationConfiguration;
-import com.zmops.zeus.iot.server.library.module.ProviderNotFoundException;
-import com.zmops.zeus.iot.server.util.PropertyPlaceholderHelper;
-import lombok.extern.slf4j.Slf4j;
+import com.zmops.zeus.server.library.module.ApplicationConfiguration;
+import com.zmops.zeus.server.library.module.ProviderNotFoundException;
+import com.zmops.zeus.server.library.util.CollectionUtils;
+import com.zmops.zeus.server.library.util.ResourceUtils;
+import com.zmops.zeus.server.util.PropertyPlaceholderHelper;
+import lombok.extern.slf4j.Slf4j;
import org.yaml.snakeyaml.Yaml;
import java.io.FileNotFoundException;
@@ -44,7 +44,7 @@
@Slf4j
public class ApplicationConfigLoader implements ConfigLoader {
private static final String DISABLE_SELECTOR = "-";
- private static final String SELECTOR = "selector";
+ private static final String SELECTOR = "selector";
private final Yaml yaml = new Yaml();
@@ -59,23 +59,21 @@ public ApplicationConfiguration load() throws ConfigFileNotFoundException {
@SuppressWarnings("unchecked")
private void loadConfig(ApplicationConfiguration configuration) throws ConfigFileNotFoundException {
try {
- Reader applicationReader = ResourceUtils.read("application.yml");
- Map> moduleConfig = yaml.loadAs(applicationReader, Map.class);
+ Reader applicationReader = ResourceUtils.read("application.yml");
+ Map> moduleConfig = yaml.loadAs(applicationReader, Map.class);
if (CollectionUtils.isNotEmpty(moduleConfig)) {
selectConfig(moduleConfig);
moduleConfig.forEach((moduleName, providerConfig) -> {
if (providerConfig.size() > 0) {
log.info("Get a module define from application.yml, module name: {}", moduleName);
- ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.addModule(
- moduleName);
+ ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.addModule(moduleName);
providerConfig.forEach((providerName, config) -> {
- log.info(
- "Get a provider define belong to {} module, provider name: {}", moduleName,
- providerName
- );
+ log.info("Get a provider define belong to {} module, provider name: {}", moduleName, providerName);
+
final Map propertiesConfig = (Map) config;
- final Properties properties = new Properties();
+ final Properties properties = new Properties();
+
if (propertiesConfig != null) {
propertiesConfig.forEach((propertyName, propertyValue) -> {
if (propertyValue instanceof Map) {
@@ -91,6 +89,7 @@ private void loadConfig(ApplicationConfiguration configuration) throws ConfigFil
}
});
}
+
moduleConfiguration.addProviderConfiguration(providerName, properties);
});
} else {
@@ -103,10 +102,9 @@ private void loadConfig(ApplicationConfiguration configuration) throws ConfigFil
}
}
- private void replacePropertyAndLog(final Object propertyName, final Object propertyValue, final Properties target,
- final Object providerName) {
- final String valueString = PropertyPlaceholderHelper.INSTANCE
- .replacePlaceholders(propertyValue + "", target);
+ private void replacePropertyAndLog(final Object propertyName, final Object propertyValue, final Properties target, final Object providerName) {
+ final String valueString = PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(propertyValue + "", target);
+
if (valueString != null) {
if (valueString.trim().length() == 0) {
target.replace(propertyName, valueString);
@@ -136,16 +134,20 @@ private void overrideConfigBySystemEnv(ApplicationConfiguration configuration) {
private void selectConfig(final Map> moduleConfiguration) {
Iterator>> moduleIterator = moduleConfiguration.entrySet().iterator();
while (moduleIterator.hasNext()) {
- Map.Entry> entry = moduleIterator.next();
- final String moduleName = entry.getKey();
- final Map providerConfig = entry.getValue();
+ Map.Entry> entry = moduleIterator.next();
+
+ final String moduleName = entry.getKey();
+ final Map providerConfig = entry.getValue();
+
if (!providerConfig.containsKey(SELECTOR)) {
continue;
}
+
final String selector = (String) providerConfig.get(SELECTOR);
final String resolvedSelector = PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(
selector, System.getProperties()
);
+
providerConfig.entrySet().removeIf(e -> !resolvedSelector.equals(e.getKey()));
if (!providerConfig.isEmpty()) {
@@ -171,27 +173,32 @@ private void overrideModuleSettings(ApplicationConfiguration configuration, Stri
if (moduleAndConfigSeparator <= 0) {
return;
}
- String moduleName = key.substring(0, moduleAndConfigSeparator);
- String providerSettingSubKey = key.substring(moduleAndConfigSeparator + 1);
- ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.getModuleConfiguration(moduleName);
+ String moduleName = key.substring(0, moduleAndConfigSeparator);
+ String providerSettingSubKey = key.substring(moduleAndConfigSeparator + 1);
+
+ ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.getModuleConfiguration(moduleName);
if (moduleConfiguration == null) {
return;
}
+
int providerAndConfigSeparator = providerSettingSubKey.indexOf('.');
if (providerAndConfigSeparator <= 0) {
return;
}
+
String providerName = providerSettingSubKey.substring(0, providerAndConfigSeparator);
- String settingKey = providerSettingSubKey.substring(providerAndConfigSeparator + 1);
+ String settingKey = providerSettingSubKey.substring(providerAndConfigSeparator + 1);
if (!moduleConfiguration.has(providerName)) {
return;
}
+
Properties providerSettings = moduleConfiguration.getProviderConfiguration(providerName);
if (!providerSettings.containsKey(settingKey)) {
return;
}
- Object originValue = providerSettings.get(settingKey);
- Class> type = originValue.getClass();
+
+ Object originValue = providerSettings.get(settingKey);
+ Class> type = originValue.getClass();
if (type.equals(int.class) || type.equals(Integer.class))
providerSettings.put(settingKey, Integer.valueOf(value));
else if (type.equals(String.class))
@@ -204,8 +211,12 @@ else if (type.equals(boolean.class) || type.equals(Boolean.class)) {
return;
}
- log.info("The setting has been override by key: {}, value: {}, in {} provider of {} module through {}", settingKey,
- value, providerName, moduleName, "System.properties"
+ log.info("The setting has been override by key: {}, value: {}, in {} provider of {} module through {}",
+ settingKey,
+ value,
+ providerName,
+ moduleName,
+ "System.properties"
);
}
}
diff --git a/iot-server/server-bootstrap/src/main/resources/application.yml b/iot-server/server-bootstrap/src/main/resources/application.yml
index 4962fbe2..3d35cd90 100644
--- a/iot-server/server-bootstrap/src/main/resources/application.yml
+++ b/iot-server/server-bootstrap/src/main/resources/application.yml
@@ -1,4 +1,17 @@
-# 核心模块
+# Apache Camel Protocol Entry
+camel-receiver:
+ selector: default
+ default:
+ version: v1.0.0
+
+# Zabbix Trapper Sender
+zabbix-sender:
+ selector: ${ZS_RECEIVER_ZABBIX_SENDER:default}
+ default:
+ port: ${ZS_RECEIVER_ZABBIX_PORT:10051}
+ host: ${ZS_RECEIVER_ZABBIX_HOST:127.0.0.1}
+
+# core module config
core:
selector: ${ZS_CORE:default}
default:
@@ -13,44 +26,42 @@ core:
restAcceptQueueSize: ${ZS_CORE_REST_JETTY_QUEUE_SIZE:0}
httpMaxRequestHeaderSize: ${ZS_CORE_HTTP_MAX_REQUEST_HEADER_SIZE:8192}
-# 健康检查
+# local db h2, must be default
+local-h2:
+ selector: default
+ default:
+ version: v1.0.0
+
+# ndjson file read realtime
+server-transfer:
+ selector: ${ZS_SERVER_TRANSFER:-}
+ default:
+ name: ${ZS_TRANSFER_NAME:zeus-transfer}
+ pattern: ${ZS_TRANSFER_PATTERN:/home/data/history-history-syncer-[0-9]{1}.ndjson}
+ fileMaxWait: ${ZS_TRANSFER_FILE_MAXWAIT:30}
+
+# tdengine storage realtime
+storage:
+ selector: ${ZS_STORAGE:none}
+ none:
+ tdengine:
+ url: ${ZS_STORAGE_TDENGINE_URL:jdbc:TAOS://127.0.0.1:6030/zeus_data} # TDEngine jdbcUrl
+ user: ${ZS_STORAGE_TDENGINE_USER:root}
+ password: ${ZS_STORAGE_TDENGINE_PASSWORD:taosdata}
+
+# health check
health-checker:
selector: ${ZS_HEALTH_CHECKER:default}
default:
checkIntervalSeconds: ${ZS_HEALTH_CHECKER_INTERVAL_SECONDS:5}
-# 健康遥测
+# health telemetry
telemetry:
selector: ${ZS_TELEMETRY:prometheus}
none:
prometheus:
host: ${ZS_TELEMETRY_PROMETHEUS_HOST:0.0.0.0}
- port: ${ZS_TELEMETRY_PROMETHEUS_PORT:1234}
+ port: ${ZS_TELEMETRY_PROMETHEUS_PORT:12900}
sslEnabled: ${ZS_TELEMETRY_PROMETHEUS_SSL_ENABLED:false}
sslKeyPath: ${ZS_TELEMETRY_PROMETHEUS_SSL_KEY_PATH:""}
- sslCertChainPath: ${ZS_TELEMETRY_PROMETHEUS_SSL_CERT_CHAIN_PATH:""}
-
-# Zabbix Trapper Sender
-zabbix-sender:
- selector: ${ZS_RECEIVER_ZABBIX_SENDER:default}
- default:
- host: 172.16.3.72
- port: 10051
-
-# Http Server
-receiver-http:
- selector: ${ZS_RECEIVER_HTTP:-}
- default:
- port: 9010
-
-# TCP Server
-receiver-tcp:
- selector: ${ZS_RECEIVER_TCP:-}
- default:
- port: 9020
-
-# MQTT Client
-receiver-mqtt:
- selector: ${ZS_RECEIVER_MQTT:-}
- default:
- port: 1883
\ No newline at end of file
+ sslCertChainPath: ${ZS_TELEMETRY_PROMETHEUS_SSL_CERT_CHAIN_PATH:""}
\ No newline at end of file
diff --git a/iot-server/server-bootstrap/src/main/resources/log4j2.xml b/iot-server/server-bootstrap/src/main/resources/log4j2.xml
index f197f205..11749966 100644
--- a/iot-server/server-bootstrap/src/main/resources/log4j2.xml
+++ b/iot-server/server-bootstrap/src/main/resources/log4j2.xml
@@ -1,4 +1,4 @@
-
+
diff --git a/iot-server/server-camel-receiver/pom.xml b/iot-server/server-camel-receiver/pom.xml
new file mode 100644
index 00000000..fa384fa5
--- /dev/null
+++ b/iot-server/server-camel-receiver/pom.xml
@@ -0,0 +1,79 @@
+
+
+
+ iot-server
+ com.zmops
+ 1.0-beta
+
+ 4.0.0
+
+ server-camel-receiver
+
+ 基于 CamelContext 的动态话配置服务模块
+
+
+ com.zmops
+ library-module
+ 1.0.3-RELEASE
+
+
+ com.zmops
+ telemetry-api
+ 1.0-beta
+
+
+ com.zmops
+ server-sender
+ 1.0-beta
+
+
+ com.zmops
+ toolkit-datacarrier
+ 1.0.3-RELEASE
+
+
+
+ org.apache.camel
+ camel-paho-mqtt5
+
+
+ org.apache.camel
+ camel-netty-http
+
+
+ org.apache.camel
+ camel-pgevent
+ 3.11.4
+
+
+ org.postgresql
+ postgresql
+ 42.2.20
+
+
+ com.zmops
+ runtime-server
+ 1.0.3-RELEASE
+
+
+ com.zmops
+ zeus-commons
+ 1.0.3-RELEASE
+ compile
+
+
+ com.zmops
+ server-localdb
+ 1.0-beta
+ compile
+
+
+
+
+ 8
+ 8
+
+
+
\ No newline at end of file
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/Const.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/Const.java
new file mode 100644
index 00000000..02a660ad
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/Const.java
@@ -0,0 +1,8 @@
+package com.zmops.zeus.iot.server.receiver;
+
+public class Const {
+
+ public static final String CAMEL_ZABBIX_COMPONENT_NAME = "Zabbix";
+
+ public static final String CAMEL_ARK_COMPONENT_NAME = "ArkBiz";
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ProtocolAction.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ProtocolAction.java
new file mode 100644
index 00000000..b4aaac53
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ProtocolAction.java
@@ -0,0 +1,9 @@
+package com.zmops.zeus.iot.server.receiver;
+
+/**
+ * 协议服务启停
+ */
+public enum ProtocolAction {
+
+ stop, start
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ProtocolEnum.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ProtocolEnum.java
new file mode 100644
index 00000000..9218517f
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ProtocolEnum.java
@@ -0,0 +1,9 @@
+package com.zmops.zeus.iot.server.receiver;
+
+/**
+ * @author nantian created at 2021/10/24 13:47
+ */
+public enum ProtocolEnum {
+
+ HttpServer, MqttClient, TcpServer, UdpServer, CoapServer, WebSocketServer
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ReceiverServerRoute.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ReceiverServerRoute.java
new file mode 100644
index 00000000..e2bb4c21
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/ReceiverServerRoute.java
@@ -0,0 +1,23 @@
+package com.zmops.zeus.iot.server.receiver;
+
+import lombok.Setter;
+import org.apache.camel.builder.RouteBuilder;
+
+import java.util.Map;
+
+/**
+ * @author nantian created at 2021/10/24 14:38
+ */
+public abstract class ReceiverServerRoute extends RouteBuilder {
+
+ @Setter
+ protected String routeId;
+
+ @Setter
+ protected Map options;
+
+ public ReceiverServerRoute(String routeId, Map options) {
+ this.routeId = routeId;
+ this.options = options;
+ }
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizComponent.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizComponent.java
new file mode 100644
index 00000000..cf60a6dc
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizComponent.java
@@ -0,0 +1,28 @@
+package com.zmops.zeus.iot.server.receiver.handler.ark;
+
+import com.zmops.zeus.server.library.module.ModuleManager;
+import org.apache.camel.Endpoint;
+import org.apache.camel.support.DefaultComponent;
+
+import java.util.Map;
+
+/**
+ * @author nantian created at 2021/12/2 22:35
+ */
+public class ArkBizComponent extends DefaultComponent {
+
+ private final ModuleManager moduleManager;
+
+ public ArkBizComponent(ModuleManager moduleManager) {
+ this.moduleManager = moduleManager;
+ }
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
+
+ String uniqueId = getAndRemoveParameter(parameters, "uniqueId", String.class);
+ String methodName = getAndRemoveParameter(parameters, "methodName", String.class);
+
+ return new ArkBizEndpoint(uri, this, moduleManager, uniqueId, methodName);
+ }
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizConsumer.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizConsumer.java
new file mode 100644
index 00000000..a81401ea
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizConsumer.java
@@ -0,0 +1,15 @@
+package com.zmops.zeus.iot.server.receiver.handler.ark;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.support.DefaultConsumer;
+
+/**
+ * @author nantian created at 2021/12/2 22:35
+ */
+public class ArkBizConsumer extends DefaultConsumer {
+
+ public ArkBizConsumer(Endpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ }
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizEndpoint.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizEndpoint.java
new file mode 100644
index 00000000..a7dac2db
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizEndpoint.java
@@ -0,0 +1,43 @@
+package com.zmops.zeus.iot.server.receiver.handler.ark;
+
+import com.zmops.zeus.server.library.module.ModuleManager;
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+
+
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * @author nantian created at 2021/12/2 22:34
+ */
+@SuppressWarnings("all")
+public class ArkBizEndpoint extends DefaultEndpoint {
+
+ private final ModuleManager moduleManager;
+ private final ArkBizProducer producer;
+
+ public ArkBizEndpoint(String endpointUri, Component component, ModuleManager moduleManager,
+ String uniqueId, String methodName) {
+ super(endpointUri, component);
+ this.moduleManager = moduleManager;
+ this.producer = new ArkBizProducer(this, moduleManager, uniqueId, methodName);
+ }
+
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return this.producer;
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return new ArkBizConsumer(this, processor);
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false;
+ }
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizProducer.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizProducer.java
new file mode 100644
index 00000000..6d38188f
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/ark/ArkBizProducer.java
@@ -0,0 +1,50 @@
+package com.zmops.zeus.iot.server.receiver.handler.ark;
+
+import com.zmops.zeus.dto.DataMessage;
+import com.zmops.zeus.dto.ItemValue;
+import com.zmops.zeus.facade.DynamicProcotol;
+import com.zmops.zeus.iot.server.receiver.module.CamelReceiverModule;
+import com.zmops.zeus.iot.server.receiver.service.ReferenceClientService;
+import com.zmops.zeus.server.library.module.ModuleManager;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultProducer;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author nantian created at 2021/12/2 22:35
+ */
+@SuppressWarnings("all")
+public class ArkBizProducer extends DefaultProducer {
+
+ private final ModuleManager moduleManager;
+
+ private final DynamicProcotol dynamicProcotol;
+
+ public ArkBizProducer(Endpoint endpoint, ModuleManager moduleManager, String uniqueId, String methodName) {
+ super(endpoint);
+ this.moduleManager = moduleManager;
+
+ ReferenceClientService referenceClientService = moduleManager.find(CamelReceiverModule.NAME)
+ .provider().getService(ReferenceClientService.class);
+ dynamicProcotol = referenceClientService.getDynamicProtocolClient(uniqueId);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+
+ DataMessage message = new DataMessage();
+ message.setBody(exchange.getMessage().getBody());
+ message.setHeaders(exchange.getMessage().getHeaders());
+
+ List itemValueList = dynamicProcotol.protocolHandler(message);
+
+ if (itemValueList == null) {
+ itemValueList = Collections.emptyList();
+ }
+
+ exchange.getIn().setBody(itemValueList);
+ }
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/IoTDeviceValue.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/IoTDeviceValue.java
new file mode 100644
index 00000000..42c8b951
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/IoTDeviceValue.java
@@ -0,0 +1,23 @@
+package com.zmops.zeus.iot.server.receiver.handler.zabbix;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+/**
+ * @author nantian created at 2021/8/23 18:01
+ *
+ * 方便大家理解,转换一下 命名
+ */
+
+@Getter
+@Setter
+public class IoTDeviceValue {
+
+ private String deviceId; // 设备ID
+
+ private Map attributes; // key : value
+
+ private Long clock; // 毫秒,70年到现在时间戳
+}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderComponent.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderComponent.java
similarity index 80%
rename from iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderComponent.java
rename to iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderComponent.java
index 667cf445..dd00c429 100644
--- a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderComponent.java
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderComponent.java
@@ -1,8 +1,8 @@
-package com.zmops.zeus.iot.server.core.camel;
+package com.zmops.zeus.iot.server.receiver.handler.zabbix;
-import com.zmops.zeus.iot.server.library.module.ModuleManager;
+import com.zmops.zeus.server.library.module.ModuleManager;
import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.support.DefaultComponent;
import java.util.Map;
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderConsumer.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderConsumer.java
similarity index 73%
rename from iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderConsumer.java
rename to iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderConsumer.java
index 9886d1d1..0b81da8a 100644
--- a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderConsumer.java
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderConsumer.java
@@ -1,8 +1,8 @@
-package com.zmops.zeus.iot.server.core.camel;
+package com.zmops.zeus.iot.server.receiver.handler.zabbix;
import org.apache.camel.Endpoint;
import org.apache.camel.Processor;
-import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.support.DefaultConsumer;
/**
* @author nantian created at 2021/8/16 22:47
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderEndpoint.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderEndpoint.java
similarity index 63%
rename from iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderEndpoint.java
rename to iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderEndpoint.java
index 8457da64..0704329e 100644
--- a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/camel/ZabbixSenderEndpoint.java
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixSenderEndpoint.java
@@ -1,11 +1,11 @@
-package com.zmops.zeus.iot.server.core.camel;
+package com.zmops.zeus.iot.server.receiver.handler.zabbix;
-import com.zmops.zeus.iot.server.library.module.ModuleManager;
+import com.zmops.zeus.server.library.module.ModuleManager;
import org.apache.camel.Component;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
-import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.support.DefaultEndpoint;
/**
* @author nantian created at 2021/8/16 22:45
@@ -13,20 +13,22 @@
public class ZabbixSenderEndpoint extends DefaultEndpoint {
private final ModuleManager moduleManager;
+ private final ZabbixTrapperProducer producer;
public ZabbixSenderEndpoint(String endpointUri, Component component, ModuleManager moduleManager) {
super(endpointUri, component);
this.moduleManager = moduleManager;
+ this.producer = new ZabbixTrapperProducer(this, moduleManager);
}
@Override
public Producer createProducer() throws Exception {
- return new ZabbixTrapperProducer(this, moduleManager);
+ return producer; // 每次 process 都会创建一个对象, 单例返回
}
@Override
public Consumer createConsumer(Processor processor) throws Exception {
- return new ZabbixSenderConsumer(this, processor);
+ return new ZabbixSenderConsumer(this, processor); //TODO
}
@Override
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixTrapper.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixTrapper.java
new file mode 100644
index 00000000..ad45c766
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixTrapper.java
@@ -0,0 +1,27 @@
+package com.zmops.zeus.iot.server.receiver.handler.zabbix;
+
+import com.zmops.zeus.dto.ItemValue;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author nantian created at 2021/8/23 16:49
+ */
+public class ZabbixTrapper {
+
+
+ @Getter
+ private final String request = "sender data";
+
+ @Setter
+ @Getter
+ private List data;
+
+ public ZabbixTrapper(List itemValues) {
+ data = new ArrayList<>();
+ data.addAll(itemValues);
+ }
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixTrapperProducer.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixTrapperProducer.java
new file mode 100644
index 00000000..a50cf01f
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/ZabbixTrapperProducer.java
@@ -0,0 +1,67 @@
+package com.zmops.zeus.iot.server.receiver.handler.zabbix;
+
+import com.google.gson.Gson;
+import com.zmops.zeus.dto.ItemValue;
+import com.zmops.zeus.iot.server.receiver.handler.zabbix.worker.ItemDataTransferWorker;
+import com.zmops.zeus.server.library.module.ModuleManager;
+import com.zmops.zeus.server.library.util.StringUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * @author nantian created at 2021/8/16 22:48
+ *
+ * Json 转 对象,进队列,一定要转成 ItemValue 对象,{@link ItemValue}
+ */
+public class JsonToItemValueProcess implements Processor {
+
+ private final Gson gson = new Gson();
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ Message message = exchange.getIn();
+ InputStream bodyStream = (InputStream) message.getBody();
+ String inputContext = this.analysisMessage(bodyStream);
+
+
+ IoTDeviceValue iotValue = gson.fromJson(inputContext, IoTDeviceValue.class);
+
+ List itemValueList = new ArrayList<>();
+
+ iotValue.getAttributes().forEach((key, value) -> {
+ ItemValue item = new ItemValue(iotValue.getDeviceId(), iotValue.getClock());
+ item.setKey(key);
+ item.setValue(value);
+
+ itemValueList.add(item);
+ });
+
+ exchange.getMessage().setBody(itemValueList);
+ }
+
+
+ private String analysisMessage(InputStream bodyStream) throws IOException {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ byte[] contextBytes = new byte[4096];
+ int realLen;
+ while ((realLen = bodyStream.read(contextBytes, 0, 4096)) != -1) {
+ outStream.write(contextBytes, 0, realLen);
+ }
+
+ // 返回从Stream中读取的字串
+ try {
+ return outStream.toString("UTF-8");
+ } finally {
+ outStream.close();
+ }
+ }
+}
diff --git a/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/worker/AbstractWorker.java b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/worker/AbstractWorker.java
new file mode 100644
index 00000000..885d831f
--- /dev/null
+++ b/iot-server/server-camel-receiver/src/main/java/com/zmops/zeus/iot/server/receiver/handler/zabbix/worker/AbstractWorker.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.zmops.zeus.iot.server.receiver.handler.zabbix.worker;
+
+import com.zmops.zeus.server.library.module.ModuleDefineHolder;
+import lombok.Getter;
+
+
+/**
+ * Abstract worker definition. Provide the {@link ModuleDefineHolder} to make sure the worker could find and access
+ * services in different modules. Also, {@link #in(Object)} is provided as the primary entrance of every worker.
+ *
- * to("Zabbix")
- */
-public class ZabbixTrapperProducer extends DefaultProducer {
-
- private final ModuleManager moduleManager;
-
-
- public ZabbixTrapperProducer(Endpoint endpoint, ModuleManager moduleManager) {
- super(endpoint);
- this.moduleManager = moduleManager;
- }
-
- /**
- * TODO 数据写入 队列,进来之前 是 JSON 格式
- *
- * @param exchange Exchange
- */
- @Override
- public void process(Exchange exchange) throws Exception {
- Message message = exchange.getIn();
- InputStream bodyStream = (InputStream) message.getBody();
- String inputContext = this.analysisMessage(bodyStream);
-
- ZabbixSenderService senderService = moduleManager.find(ZabbixSenderModule.NAME).provider().getService(ZabbixSenderService.class);
-
- String resp = senderService.sendData(inputContext);
-
- // 把Zabbix 响应结果放入 Message 返回
- message.setBody(resp);
- }
-
-
- private String analysisMessage(InputStream bodyStream) throws IOException {
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- byte[] contextBytes = new byte[4096];
- int realLen;
- while ((realLen = bodyStream.read(contextBytes, 0, 4096)) != -1) {
- outStream.write(contextBytes, 0, realLen);
- }
-
- // 返回从Stream中读取的字串
- try {
- return outStream.toString("UTF-8");
- } finally {
- outStream.close();
- }
- }
-}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/server/JettyHandlerRegister.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/server/JettyHandlerRegister.java
deleted file mode 100644
index 07ca38aa..00000000
--- a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/server/JettyHandlerRegister.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.core.server;
-
-
-import com.zmops.zeus.iot.server.library.module.Service;
-import com.zmops.zeus.iot.server.library.server.jetty.JettyHandler;
-
-public interface JettyHandlerRegister extends Service {
-
- void addHandler(JettyHandler serverHandler);
-}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/DeviceTriggerActionHandler.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/DeviceTriggerActionHandler.java
index 77dadab9..85671250 100644
--- a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/DeviceTriggerActionHandler.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/DeviceTriggerActionHandler.java
@@ -1,10 +1,14 @@
package com.zmops.zeus.iot.server.core.servlet;
+import com.google.gson.Gson;
import com.google.gson.JsonElement;
-import com.zmops.zeus.iot.server.library.server.jetty.ArgumentsParseException;
-import com.zmops.zeus.iot.server.library.server.jetty.JettyJsonHandler;
+import com.zmops.zeus.server.jetty.ArgumentsParseException;
+import com.zmops.zeus.server.jetty.JettyJsonHandler;
+import com.zmops.zeus.server.library.module.ModuleManager;
+import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedReader;
import java.io.IOException;
/**
@@ -12,8 +16,15 @@
*
* 设备 告警规则 触发动作,Http 统一入口
*/
+@Slf4j
public class DeviceTriggerActionHandler extends JettyJsonHandler {
+ private final ModuleManager moduleManager;
+ private final Gson gson = new Gson();
+
+ public DeviceTriggerActionHandler(ModuleManager moduleManager) {
+ this.moduleManager = moduleManager;
+ }
@Override
public String pathSpec() {
@@ -21,16 +32,40 @@ public String pathSpec() {
}
+ /**
+ * 动作触发Http入口,可在设备 上面设置 宏 定义,动态传入 identifier
+ *
+ * @param req
+ * @return JsonElement
+ */
@Override
- protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException, IOException {
+ public JsonElement doPost(HttpServletRequest req) throws IOException {
+
+ String request = getJsonBody(req);
+ log.info("action command : {}", request);
+
+// EventBusService eventBusService = moduleManager.find(CoreModule.NAME).provider().getService(EventBusService.class);
+//
+//
+// ActionParam actionParam = new ActionParam();
+// actionParam.setActionParamContent(request);
+//
+// eventBusService.postExecuteActionMsg(ActionRouteIdentifier.helloworld, actionParam);
+
return null;
}
- /**
- * 执行 Action,进 EventBus,方便订阅处理
- */
- private void execute() {
-
+ @Override
+ public String getJsonBody(HttpServletRequest req) throws IOException {
+ StringBuffer stringBuffer = new StringBuffer();
+ String line = null;
+ BufferedReader reader = req.getReader();
+ while ((line = reader.readLine()) != null) {
+ stringBuffer.append(line);
+ }
+ return stringBuffer.toString();
}
+
+
}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/HttpItemTrapperHandler.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/HttpItemTrapperHandler.java
index 48c28549..48c16a18 100644
--- a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/HttpItemTrapperHandler.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/servlet/HttpItemTrapperHandler.java
@@ -3,13 +3,21 @@
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.zmops.zeus.iot.server.library.server.jetty.ArgumentsParseException;
-import com.zmops.zeus.iot.server.library.server.jetty.JettyJsonHandler;
+import com.google.gson.reflect.TypeToken;
+import com.zmops.zeus.iot.server.core.worker.data.ItemValue;
+import com.zmops.zeus.iot.server.core.worker.data.ZabbixTrapper;
+import com.zmops.zeus.iot.server.sender.module.ZabbixSenderModule;
+import com.zmops.zeus.iot.server.sender.service.ZabbixSenderService;
+import com.zmops.zeus.server.jetty.ArgumentsParseException;
+import com.zmops.zeus.server.jetty.JettyJsonHandler;
+import com.zmops.zeus.server.library.module.ModuleManager;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.lang.reflect.Type;
+import java.util.List;
/**
* @author nantian created at 2021/8/20 0:51
@@ -20,16 +28,22 @@ public class HttpItemTrapperHandler extends JettyJsonHandler {
private final Gson gson = new Gson();
+ private final ModuleManager moduleManager;
+
+ public HttpItemTrapperHandler(ModuleManager moduleManager) {
+ this.moduleManager = moduleManager;
+ }
+
@Override
public String pathSpec() {
return "/device/attr/send";
}
@Override
- protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException, IOException {
+ public JsonElement doPost(HttpServletRequest req) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(req.getInputStream()));
- String line;
+ String line;
StringBuilder request = new StringBuilder();
while ((line = reader.readLine()) != null) {
request.append(line);
@@ -37,6 +51,19 @@ protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseExcept
JsonObject requestJson = gson.fromJson(request.toString(), JsonObject.class);
+ Type listType = new TypeToken>() {}.getType();
+
+ List valueList = gson.fromJson(requestJson.getAsJsonArray("params").toString(), listType);
+
+
+ ZabbixSenderService zabbixSenderService = moduleManager.find(ZabbixSenderModule.NAME).provider().getService(ZabbixSenderService.class);
+ ZabbixTrapper zabbixTrapper = new ZabbixTrapper(valueList);
+ zabbixSenderService.sendData(gson.toJson(zabbixTrapper));
return requestJson;
}
+
+ @Override
+ public String getJsonBody(HttpServletRequest req) throws IOException {
+ return null;
+ }
}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/CycleDependencyException.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/DAO.java
similarity index 80%
rename from iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/CycleDependencyException.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/DAO.java
index 8f7e2aa9..da60f993 100644
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/CycleDependencyException.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/DAO.java
@@ -16,10 +16,13 @@
*
*/
-package com.zmops.zeus.iot.server.library.module;
+package com.zmops.zeus.iot.server.core.storage;
-public class CycleDependencyException extends RuntimeException {
- public CycleDependencyException(String message) {
- super(message);
- }
+
+import com.zmops.zeus.server.library.module.Service;
+
+/**
+ * A specific interface for storage layer services.
+ */
+public interface DAO extends Service {
}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/IBatchDAO.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/IBatchDAO.java
new file mode 100644
index 00000000..a7d63e27
--- /dev/null
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/IBatchDAO.java
@@ -0,0 +1,49 @@
+/*
+ * 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 com.zmops.zeus.iot.server.core.storage;
+
+
+import com.zmops.zeus.iot.server.client.request.InsertRequest;
+import com.zmops.zeus.iot.server.client.request.PrepareRequest;
+
+import java.util.List;
+
+/**
+ * IBatchDAO provides two modes of data persistence supported by most databases, including pure insert and batch hybrid
+ * insert/update.
+ */
+public interface IBatchDAO extends DAO {
+ /**
+ * Push data into the database in async mode. This method is driven by streaming process. This method doesn't
+ * request the data queryable immediately after the method finished.
+ *
+ * @param insertRequest data to insert.
+ */
+ void insert(InsertRequest insertRequest);
+
+ /**
+ * Push data collection into the database in async mode. This method is driven by streaming process. This method
+ * doesn't request the data queryable immediately after the method finished.
+ *
+ * The method requires thread safe. The OAP core would call this concurrently.
+ *
+ * @param prepareRequests data to insert or update. No delete happens in streaming mode.
+ */
+ void flush(List prepareRequests);
+}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerPool.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/IRecordDAO.java
similarity index 64%
rename from iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerPool.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/IRecordDAO.java
index bbeb4b08..02850810 100644
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/consumer/ConsumerPool.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/IRecordDAO.java
@@ -16,16 +16,19 @@
*
*/
-package com.zmops.zeus.iot.server.datacarrier.consumer;
+package com.zmops.zeus.iot.server.core.storage;
-import com.zmops.zeus.iot.server.datacarrier.DataCarrier;
-import com.zmops.zeus.iot.server.datacarrier.buffer.Channels;
+import com.zmops.zeus.iot.server.core.analysis.record.Record;
+import com.zmops.zeus.iot.server.core.storage.model.Model;
+import com.zmops.zeus.iot.server.client.request.InsertRequest;
+
+import java.io.IOException;
/**
- * The Consumer pool could support data consumer from multiple {@link DataCarrier}s, by using different consume thread
- * management models.
+ * DAO specifically for {@link Record} implementations.
*/
-public interface ConsumerPool extends IDriver {
- void add(String name, Channels channels, IConsumer consumer);
+public interface IRecordDAO extends DAO {
+
+ InsertRequest prepareBatchInsert(Model model, Record record) throws IOException;
}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/Service.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageDAO.java
similarity index 69%
rename from iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/Service.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageDAO.java
index 4315fe5c..5307a0fe 100644
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/Service.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageDAO.java
@@ -16,12 +16,17 @@
*
*/
-package com.zmops.zeus.iot.server.library.module;
+package com.zmops.zeus.iot.server.core.storage;
+
+
+import com.zmops.zeus.server.library.module.Service;
/**
- * The Service implementation is a service provided by its own modules.
- *
- * And every {@link ModuleProvider} must provide all the given services of the {@link ModuleDefine}.
+ * StorageDAO is a DAO factory for storage layer. Provide the implementations of typical DAO interfaces.
*/
-public interface Service {
+public interface StorageDAO extends Service {
+
+// IMetricsDAO newMetricsDao(StorageBuilder storageBuilder);
+
+ IRecordDAO newRecordDao();
}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/DuplicateProviderException.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageData.java
similarity index 76%
rename from iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/DuplicateProviderException.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageData.java
index 221f5a65..9c4ab518 100644
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/DuplicateProviderException.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageData.java
@@ -16,15 +16,14 @@
*
*/
-package com.zmops.zeus.iot.server.library.module;
-
+package com.zmops.zeus.iot.server.core.storage;
/**
- * @author nantian 重复的 Provider
+ * Any persistent entity should be an implementation of this interface.
*/
-public class DuplicateProviderException extends RuntimeException {
-
- public DuplicateProviderException(String message) {
- super(message);
- }
+public interface StorageData {
+ /**
+ * @return the unique id used in any storage option.
+ */
+ Integer itemid();
}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ServerException.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageException.java
similarity index 80%
rename from iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ServerException.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageException.java
index 1f7e15ec..4cd73613 100644
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ServerException.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageException.java
@@ -16,15 +16,15 @@
*
*/
-package com.zmops.zeus.iot.server.library.server;
+package com.zmops.zeus.iot.server.core.storage;
-public abstract class ServerException extends Exception {
+public class StorageException extends Exception {
- public ServerException(String message) {
+ public StorageException(String message) {
super(message);
}
- public ServerException(String message, Throwable cause) {
+ public StorageException(String message, Throwable cause) {
super(message, cause);
}
}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/partition/SimpleRollingPartitioner.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageModule.java
similarity index 58%
rename from iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/partition/SimpleRollingPartitioner.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageModule.java
index c69041e8..6a7727ce 100644
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/partition/SimpleRollingPartitioner.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/StorageModule.java
@@ -16,22 +16,28 @@
*
*/
-package com.zmops.zeus.iot.server.datacarrier.partition;
+package com.zmops.zeus.iot.server.core.storage;
+
+
+import com.zmops.zeus.server.library.module.ModuleDefine;
/**
- * use normal int to rolling.
+ * StorageModule provides the capabilities(services) to interact with the database. With different databases, this
+ * module could have different providers, such as currently, H2, MySQL, ES, TiDB.
*/
-public class SimpleRollingPartitioner implements IDataPartitioner {
- @SuppressWarnings("NonAtomicVolatileUpdate")
- private volatile int i = 0;
+public class StorageModule extends ModuleDefine {
- @Override
- public int partition(int total, T data) {
- return Math.abs(i++ % total);
+ public static final String NAME = "storage";
+
+ public StorageModule() {
+ super(NAME);
}
@Override
- public int maxRetryCount() {
- return 3;
+ public Class[] services() {
+ return new Class[]{
+ IBatchDAO.class,
+ StorageDAO.class
+ };
}
}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleNotFoundException.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/model/Model.java
similarity index 72%
rename from iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleNotFoundException.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/model/Model.java
index bf06561b..eefe9a9a 100644
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleNotFoundException.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/storage/model/Model.java
@@ -16,15 +16,21 @@
*
*/
-package com.zmops.zeus.iot.server.library.module;
+package com.zmops.zeus.iot.server.core.storage.model;
-public class ModuleNotFoundException extends Exception {
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
- public ModuleNotFoundException(Throwable cause) {
- super(cause);
- }
+/**
+ * The model definition of a logic entity.
+ */
+@Getter
+@EqualsAndHashCode
+public class Model {
+
+ private final String name;
- public ModuleNotFoundException(String message) {
- super(message);
+ public Model(final String name) {
+ this.name = name;
}
}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/AbstractWorker.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/AbstractWorker.java
new file mode 100644
index 00000000..3b25872b
--- /dev/null
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/AbstractWorker.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.zmops.zeus.iot.server.core.worker;
+
+import com.zmops.zeus.server.library.module.ModuleDefineHolder;
+import lombok.Getter;
+
+
+/**
+ * Abstract worker definition. Provide the {@link ModuleDefineHolder} to make sure the worker could find and access
+ * services in different modules. Also, {@link #in(Object)} is provided as the primary entrance of every worker.
+ *
+ * 数据发送队列
+ */
+@Slf4j
+public class ItemDataTransferWorker extends TransferWorker {
+
+
+ private final DataCarrier dataCarrier;
+ private final CounterMetrics iotDataTransferCounter;
+ private final Gson gson = new Gson();
+
+ public ItemDataTransferWorker(ModuleManager moduleManager) {
+ super(moduleManager);
+
+ String name = "ITEMVALUE_TRANSFER_TUNNEL";
+
+ int size = BulkConsumePool.Creator.recommendMaxSize() / 8;
+ if (size == 0) {
+ size = 1;
+ }
+ BulkConsumePool.Creator creator = new BulkConsumePool.Creator(name, size, 20);
+ try {
+ ConsumerPoolFactory.INSTANCE.createIfAbsent(name, creator);
+ } catch (Exception e) {
+ throw new UnexpectedException(e.getMessage(), e);
+ }
+
+ this.dataCarrier = new DataCarrier<>("ZABBIX_SENDER", name, 4, 2000);
+ this.dataCarrier.consume(ConsumerPoolFactory.INSTANCE.get(name), new SenderConsumer());
+
+ // #### 发送数量 指标采集
+ MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME)
+ .provider()
+ .getService(MetricsCreator.class);
+
+ iotDataTransferCounter = metricsCreator.createCounter(
+ "transfer_data_count", "The count number of iot device data in transfer",
+ new MetricsTag.Keys("name"),
+ new MetricsTag.Values("transfer_data_count")
+ );
+ }
+
+
+ @Override
+ public void in(ItemValue itemValue) {
+ iotDataTransferCounter.inc();
+ dataCarrier.produce(itemValue);
+ }
+
+ @Override
+ public void prepareBatch(Collection lastCollection) {
+ long start = System.currentTimeMillis();
+ if (lastCollection.size() == 0) {
+ return;
+ }
+
+ int maxBatchGetSize = 500;
+ final int batchSize = Math.min(maxBatchGetSize, lastCollection.size());
+ List valueList = new ArrayList<>();
+
+ for (ItemValue data : lastCollection) {
+ valueList.add(data);
+ if (valueList.size() == batchSize) {
+ batchSenderDataToZabbix(valueList);
+ }
+ }
+
+ if (valueList.size() > 0) {
+ batchSenderDataToZabbix(valueList);
+ }
+
+ log.debug("batch sender data size:{}, took time: {}", lastCollection.size(), System.currentTimeMillis() - start);
+ }
+
+
+ private void batchSenderDataToZabbix(List valueList) {
+ ZabbixTrapper zabbixTrapper = new ZabbixTrapper(valueList);
+
+ ZabbixSenderService senderService = getModuleDefineHolder()
+ .find(ZabbixSenderModule.NAME).provider().getService(ZabbixSenderService.class);
+
+ try {
+ String sendResult = senderService.sendData(gson.toJson(zabbixTrapper));
+ log.debug(sendResult);
+ } catch (IOException e) {
+ log.error(" itemvalue data sender error,msg :{}", e.getMessage());
+ e.printStackTrace();
+ } finally {
+ valueList.clear();
+ }
+ }
+
+
+ private class SenderConsumer implements IConsumer {
+ @Override
+ public void init() {
+
+ }
+
+ @Override
+ public void consume(List data) {
+ ItemDataTransferWorker.this.onWork(data);
+ }
+
+ @Override
+ public void onError(List data, Throwable t) {
+ log.error(t.getMessage(), t);
+ }
+
+ @Override
+ public void onExit() {
+ }
+ }
+
+
+}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/TransferWorker.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/TransferWorker.java
new file mode 100644
index 00000000..4fbba12d
--- /dev/null
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/TransferWorker.java
@@ -0,0 +1,46 @@
+/*
+ * 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 com.zmops.zeus.iot.server.core.worker;
+
+import com.zmops.zeus.iot.server.core.worker.data.Item;
+import com.zmops.zeus.server.library.module.ModuleDefineHolder;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 1. 协议入口 -> zabbix trapper item
+ *
+ * @param The type of worker input.
+ */
+@Slf4j
+public abstract class TransferWorker extends AbstractWorker {
+
+ TransferWorker(ModuleDefineHolder moduleDefineHolder) {
+ super(moduleDefineHolder);
+ }
+
+ void onWork(List input) {
+ prepareBatch(input);
+ }
+
+ public abstract void prepareBatch(Collection lastCollection);
+
+}
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/QueueBuffer.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/BufferedData.java
similarity index 60%
rename from iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/QueueBuffer.java
rename to iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/BufferedData.java
index 25d944a8..ba5a7346 100644
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/buffer/QueueBuffer.java
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/BufferedData.java
@@ -16,31 +16,26 @@
*
*/
-package com.zmops.zeus.iot.server.datacarrier.buffer;
+package com.zmops.zeus.iot.server.core.worker.data;
import java.util.List;
/**
- * Queue buffer interface.
+ * BufferedData represents a data collection in the memory. Data could be accepted and be drain to other collection.
+ *
+ * {@link #accept(Object)} and {@link #read()} wouldn't be required to thread-safe.
*/
-public interface QueueBuffer {
+public interface BufferedData {
/**
- * Save data into the queue;
+ * Accept the data into the cache if it fits the conditions. The implementation maybe wouldn't accept the new input
+ * data.
*
- * @param data to add.
- * @return true if saved
+ * @param data to be added potentially.
*/
- boolean save(T data);
+ void accept(T data);
/**
- * Set different strategy when queue is full.
+ * Read all existing buffered data, and clear the memory.
*/
- void setStrategy(BufferStrategy strategy);
-
- /**
- * Obtain the existing data from the queue
- */
- void obtain(List consumeList);
-
- int getBufferSize();
+ List read();
}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/Item.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/Item.java
new file mode 100644
index 00000000..40f5c79b
--- /dev/null
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/Item.java
@@ -0,0 +1,23 @@
+package com.zmops.zeus.iot.server.core.worker.data;
+
+/**
+ * @author nantian created at 2021/8/23 15:14
+ *
+ * 对应设备的属性
+ */
+public interface Item {
+
+ /**
+ * 设备ID 唯一
+ *
+ * @return string
+ */
+ String host();
+
+ /**
+ * 属性标识 唯一
+ *
+ * @return string
+ */
+ String key();
+}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/ItemValue.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/ItemValue.java
new file mode 100644
index 00000000..c0cd1d9a
--- /dev/null
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/ItemValue.java
@@ -0,0 +1,55 @@
+package com.zmops.zeus.iot.server.core.worker.data;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author nantian created at 2021/8/23 15:15
+ */
+
+@Getter
+@Setter
+public class ItemValue implements Item {
+
+ private String host; // 【设备ID】
+
+ private String key; // 【属性标识】
+
+ // 【设备上报 值】,都是文本
+ // Zabbix 会根据配置的ITEM 类型,进行转换,如果失败就报错
+ private String value;
+
+ private Long clock; // 秒,如果为 Null,则 zabbix 以接收时间为准
+
+ private Long ns; // 纳秒,如果为 Null,则 zabbix 以接收时间为准
+
+
+ public ItemValue(String host, Long clock) {
+ this.host = host;
+ if (clock != null) {
+ this.clock = clock;
+ }
+ }
+
+ /**
+ * 设置 数据时间,单独设置 以设备推送的时间数据为准
+ *
+ * @param clock 毫秒,70年到现在
+ * @param ns 纳秒,0-9位数
+ */
+ public void setTime(Long clock, Long ns) {
+ this.clock = clock;
+ this.ns = ns;
+ }
+
+
+ @Override
+ public String host() {
+ return getHost();
+ }
+
+ @Override
+ public String key() {
+ return getKey();
+ }
+}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/ZabbixTrapper.java b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/ZabbixTrapper.java
new file mode 100644
index 00000000..ea89c2b3
--- /dev/null
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/worker/data/ZabbixTrapper.java
@@ -0,0 +1,26 @@
+package com.zmops.zeus.iot.server.core.worker.data;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author nantian created at 2021/8/23 16:49
+ */
+public class ZabbixTrapper {
+
+
+ @Getter
+ private final String request = "sender data";
+
+ @Setter
+ @Getter
+ private List data;
+
+ public ZabbixTrapper(List itemValues) {
+ data = new ArrayList<>();
+ data.addAll(itemValues);
+ }
+}
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/server/jetty/JettyJsonHandler.java b/iot-server/server-core/src/main/java/com/zmops/zeus/server/jetty/JettyJsonHandler.java
new file mode 100644
index 00000000..d2c54e03
--- /dev/null
+++ b/iot-server/server-core/src/main/java/com/zmops/zeus/server/jetty/JettyJsonHandler.java
@@ -0,0 +1,13 @@
+package com.zmops.zeus.server.jetty;
+
+import com.google.gson.JsonElement;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+public abstract class JettyJsonHandler {
+ public abstract String pathSpec();
+ public abstract JsonElement doPost(HttpServletRequest req) throws IOException;
+ public abstract String getJsonBody(HttpServletRequest req) throws IOException;
+
+}
diff --git a/iot-server/server-core/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleDefine b/iot-server/server-core/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleDefine
new file mode 100644
index 00000000..02f80702
--- /dev/null
+++ b/iot-server/server-core/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleDefine
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+#
+
+com.zmops.zeus.iot.server.core.storage.StorageModule
+com.zmops.zeus.iot.server.core.CoreModule
diff --git a/iot-server/server-core/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider b/iot-server/server-core/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
similarity index 100%
rename from iot-server/server-core/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
rename to iot-server/server-core/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
diff --git a/iot-server/server-health-checker/pom.xml b/iot-server/server-health-checker/pom.xml
index 99a1701e..7716707c 100644
--- a/iot-server/server-health-checker/pom.xml
+++ b/iot-server/server-health-checker/pom.xml
@@ -15,7 +15,7 @@
com.zmopslibrary-module
- 1.0-beta
+ 1.0.3-RELEASEcompile
diff --git a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/module/HealthCheckerModule.java b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/module/HealthCheckerModule.java
index 7a9da970..1dbc5dd8 100644
--- a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/module/HealthCheckerModule.java
+++ b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/module/HealthCheckerModule.java
@@ -19,7 +19,7 @@
package com.zmops.zeus.iot.server.health.checker.module;
import com.zmops.zeus.iot.server.health.checker.provider.HealthQueryService;
-import com.zmops.zeus.iot.server.library.module.ModuleDefine;
+import com.zmops.zeus.server.library.module.ModuleDefine;
/**
* HealthCheckerModule intends to provide a channel to expose the healthy status of modules to external.
diff --git a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerConfig.java b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerConfig.java
index 1b15ef8b..84c30b82 100644
--- a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerConfig.java
+++ b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerConfig.java
@@ -18,7 +18,7 @@
package com.zmops.zeus.iot.server.health.checker.provider;
-import com.zmops.zeus.iot.server.library.module.ModuleConfig;
+import com.zmops.zeus.server.library.module.ModuleConfig;
import lombok.Getter;
diff --git a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerProvider.java b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerProvider.java
index 8a7faa6e..54aec501 100644
--- a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerProvider.java
+++ b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthCheckerProvider.java
@@ -20,15 +20,13 @@
import com.google.common.util.concurrent.AtomicDouble;
import com.zmops.zeus.iot.server.health.checker.module.HealthCheckerModule;
-import com.zmops.zeus.iot.server.library.module.*;
-
import com.zmops.zeus.iot.server.telemetry.TelemetryModule;
import com.zmops.zeus.iot.server.telemetry.api.MetricsCollector;
import com.zmops.zeus.iot.server.telemetry.api.MetricsCreator;
+import com.zmops.zeus.server.library.module.*;
import io.vavr.collection.Stream;
import lombok.extern.slf4j.Slf4j;
-
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -41,12 +39,12 @@
*/
@Slf4j
public class HealthCheckerProvider extends ModuleProvider {
- private final AtomicDouble score = new AtomicDouble();
- private final AtomicReference details = new AtomicReference<>();
- private final HealthCheckerConfig config = new HealthCheckerConfig();
- private MetricsCollector collector;
- private MetricsCreator metricsCreator;
- private ScheduledExecutorService ses;
+ private final AtomicDouble score = new AtomicDouble();
+ private final AtomicReference details = new AtomicReference<>();
+ private final HealthCheckerConfig config = new HealthCheckerConfig();
+ private MetricsCollector collector;
+ private MetricsCreator metricsCreator;
+ private ScheduledExecutorService ses;
@Override
public String name() {
diff --git a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthQueryService.java b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthQueryService.java
index 46cfd820..7db5b1e1 100644
--- a/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthQueryService.java
+++ b/iot-server/server-health-checker/src/main/java/com/zmops/zeus/iot/server/health/checker/provider/HealthQueryService.java
@@ -19,17 +19,16 @@
package com.zmops.zeus.iot.server.health.checker.provider;
import com.google.common.util.concurrent.AtomicDouble;
-import com.zmops.zeus.iot.server.library.module.Service;
+import com.zmops.zeus.server.library.module.Service;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
-
import java.util.concurrent.atomic.AtomicReference;
@RequiredArgsConstructor
public class HealthQueryService implements Service {
- private final AtomicDouble score;
+ private final AtomicDouble score;
private final AtomicReference details;
public HealthStatus checkHealth() {
@@ -44,7 +43,7 @@ public HealthStatus checkHealth() {
@Setter
static class HealthStatus {
// score == 0 means healthy, otherwise it's unhealthy.
- private int score;
+ private int score;
private String details;
}
}
diff --git a/iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleDefine b/iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleDefine
similarity index 100%
rename from iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleDefine
rename to iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleDefine
diff --git a/iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider b/iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
similarity index 100%
rename from iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
rename to iot-server/server-health-checker/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ApplicationConfiguration.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ApplicationConfiguration.java
deleted file mode 100644
index 0d205b67..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ApplicationConfiguration.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-import java.util.HashMap;
-import java.util.Properties;
-
-/**
- * Modulization configurations. The {@link ModuleManager} is going to start, lookup, start modules based on this.
- */
-public class ApplicationConfiguration {
- private HashMap modules = new HashMap<>();
-
- public String[] moduleList() {
- return modules.keySet().toArray(new String[0]);
- }
-
- public ModuleConfiguration addModule(String moduleName) {
- ModuleConfiguration newModule = new ModuleConfiguration();
- modules.put(moduleName, newModule);
- return newModule;
- }
-
- public boolean has(String moduleName) {
- return modules.containsKey(moduleName);
- }
-
- public ModuleConfiguration getModuleConfiguration(String name) {
- return modules.get(name);
- }
-
- /**
- * The configurations about a certain module.
- */
- public static class ModuleConfiguration {
- private HashMap providers = new HashMap<>();
-
- private ModuleConfiguration() {
- }
-
- public Properties getProviderConfiguration(String name) {
- return providers.get(name).getProperties();
- }
-
- public boolean has(String name) {
- return providers.containsKey(name);
- }
-
- public ModuleConfiguration addProviderConfiguration(String name, Properties properties) {
- ProviderConfiguration newProvider = new ProviderConfiguration(properties);
- providers.put(name, newProvider);
- return this;
- }
- }
-
- /**
- * The configuration about a certain provider of a module.
- */
- public static class ProviderConfiguration {
- private Properties properties;
-
- ProviderConfiguration(Properties properties) {
- this.properties = properties;
- }
-
- private Properties getProperties() {
- return properties;
- }
- }
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/BootstrapFlow.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/BootstrapFlow.java
deleted file mode 100644
index dbea1943..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/BootstrapFlow.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-import com.zmops.zeus.iot.server.library.util.CollectionUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-class BootstrapFlow {
- private static final Logger LOGGER = LoggerFactory.getLogger(BootstrapFlow.class);
-
- private Map loadedModules;
- private List startupSequence;
-
- BootstrapFlow(Map loadedModules) throws CycleDependencyException, ModuleNotFoundException {
- this.loadedModules = loadedModules;
- startupSequence = new LinkedList<>();
-
- makeSequence();
- }
-
- @SuppressWarnings("unchecked")
- void start(ModuleManager moduleManager) throws ModuleNotFoundException, ServiceNotProvidedException, ModuleStartException {
- for (ModuleProvider provider : startupSequence) {
- LOGGER.info("start the provider {} in {} module.", provider.name(), provider.getModuleName());
- provider.requiredCheck(provider.getModule().services());
- provider.start();
- }
- }
-
- void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
- for (ModuleProvider provider : startupSequence) {
- provider.notifyAfterCompleted();
- }
- }
-
- private void makeSequence() throws CycleDependencyException, ModuleNotFoundException {
- List allProviders = new ArrayList<>();
- for (final ModuleDefine module : loadedModules.values()) {
- String[] requiredModules = module.provider().requiredModules();
- if (requiredModules != null) {
- for (String requiredModule : requiredModules) {
- if (!loadedModules.containsKey(requiredModule)) {
- throw new ModuleNotFoundException(
- requiredModule + " module is required by "
- + module.provider().getModuleName() + "."
- + module.provider().name() + ", but not found.");
- }
- }
- }
- allProviders.add(module.provider());
- }
-
- do {
- int numOfToBeSequenced = allProviders.size();
- for (int i = 0; i < allProviders.size(); i++) {
- ModuleProvider provider = allProviders.get(i);
- String[] requiredModules = provider.requiredModules();
- if (CollectionUtils.isNotEmpty(requiredModules)) {
- boolean isAllRequiredModuleStarted = true;
- for (String module : requiredModules) {
- // find module in all ready existed startupSequence
- boolean exist = false;
- for (ModuleProvider moduleProvider : startupSequence) {
- if (moduleProvider.getModuleName().equals(module)) {
- exist = true;
- break;
- }
- }
- if (!exist) {
- isAllRequiredModuleStarted = false;
- break;
- }
- }
- if (isAllRequiredModuleStarted) {
- startupSequence.add(provider);
- allProviders.remove(i);
- i--;
- }
- } else {
- startupSequence.add(provider);
- allProviders.remove(i);
- i--;
- }
- }
-
- if (numOfToBeSequenced == allProviders.size()) {
- StringBuilder unSequencedProviders = new StringBuilder();
- allProviders.forEach(provider -> unSequencedProviders.append(provider.getModuleName()).append("[provider=").append(provider.getClass().getName()).append("]\n"));
- if (unSequencedProviders.length() > 0) {
- throw new CycleDependencyException("Exist cycle module dependencies in \n" + unSequencedProviders.substring(0, unSequencedProviders.length() - 1));
- }
- }
- }
- while (allProviders.size() != 0);
- }
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleDefine.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleDefine.java
deleted file mode 100644
index ebe29a22..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleDefine.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Field;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.ServiceLoader;
-
-/**
- * A module definition.
- */
-public abstract class ModuleDefine implements ModuleProviderHolder {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ModuleDefine.class);
-
- private ModuleProvider loadedProvider = null;
-
- private final String name;
-
- public ModuleDefine(String name) {
- this.name = name;
- }
-
- /**
- * @return the module name
- */
- public final String name() {
- return name;
- }
-
- /**
- * @return the {@link Service} provided by this module.
- */
- public abstract Class[] services();
-
- /**
- * Run the prepare stage for the module, including finding all potential providers, and asking them to prepare.
- *
- * @param moduleManager of this module
- * @param configuration of this module
- * @throws ProviderNotFoundException when even don't find a single one providers.
- */
- void prepare(ModuleManager moduleManager, ApplicationConfiguration.ModuleConfiguration configuration,
- ServiceLoader moduleProviderLoader) throws ProviderNotFoundException, ServiceNotProvidedException, ModuleConfigException, ModuleStartException {
- for (ModuleProvider provider : moduleProviderLoader) {
- if (!configuration.has(provider.name())) {
- continue;
- }
-
- if (provider.module().equals(getClass())) {
- if (loadedProvider == null) {
- loadedProvider = provider;
- loadedProvider.setManager(moduleManager);
- loadedProvider.setModuleDefine(this);
- } else {
- throw new DuplicateProviderException(this.name() + " module has one " + loadedProvider.name() + "[" + loadedProvider
- .getClass()
- .getName() + "] provider already, " + provider.name() + "[" + provider.getClass()
- .getName() + "] is defined as 2nd provider.");
- }
- }
-
- }
-
- if (loadedProvider == null) {
- throw new ProviderNotFoundException(this.name() + " module no provider found.");
- }
-
- LOGGER.info("Prepare the {} provider in {} module.", loadedProvider.name(), this.name());
- try {
- copyProperties(loadedProvider.createConfigBeanIfAbsent(), configuration.getProviderConfiguration(loadedProvider.name()), this.name(), loadedProvider.name());
- } catch (IllegalAccessException e) {
- throw new ModuleConfigException(this.name() + " module config transport to config bean failure.", e);
- }
- loadedProvider.prepare();
- }
-
- private void copyProperties(ModuleConfig dest, Properties src, String moduleName,
- String providerName) throws IllegalAccessException {
- if (dest == null) {
- return;
- }
- Enumeration> propertyNames = src.propertyNames();
- while (propertyNames.hasMoreElements()) {
- String propertyName = (String) propertyNames.nextElement();
- Class extends ModuleConfig> destClass = dest.getClass();
- try {
- Field field = getDeclaredField(destClass, propertyName);
- field.setAccessible(true);
- field.set(dest, src.get(propertyName));
- } catch (NoSuchFieldException e) {
- LOGGER.warn(propertyName + " setting is not supported in " + providerName + " provider of " + moduleName + " module");
- }
- }
- }
-
- private Field getDeclaredField(Class> destClass, String fieldName) throws NoSuchFieldException {
- if (destClass != null) {
- Field[] fields = destClass.getDeclaredFields();
- for (Field field : fields) {
- if (field.getName().equals(fieldName)) {
- return field;
- }
- }
- return getDeclaredField(destClass.getSuperclass(), fieldName);
- }
-
- throw new NoSuchFieldException();
- }
-
- @Override
- public final ModuleProvider provider() throws DuplicateProviderException, ProviderNotFoundException {
- if (loadedProvider == null) {
- throw new ProviderNotFoundException("There is no module provider in " + this.name() + " module!");
- }
-
- return loadedProvider;
- }
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleDefineHolder.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleDefineHolder.java
deleted file mode 100644
index 3021a6d2..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleDefineHolder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-public interface ModuleDefineHolder {
-
- boolean has(String moduleName);
-
- ModuleProviderHolder find(String moduleName) throws ModuleNotFoundRuntimeException;
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleManager.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleManager.java
deleted file mode 100644
index 53c67145..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleManager.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-import java.util.*;
-
-/**
- * The ModuleManager takes charge of all {@link ModuleDefine}s in collector.
- */
-public class ModuleManager implements ModuleDefineHolder {
- private boolean isInPrepareStage = true;
- private final Map loadedModules = new HashMap<>();
-
- /**
- * Init the given modules
- */
- public void init(ApplicationConfiguration applicationConfiguration)
- throws ModuleNotFoundException, ProviderNotFoundException, ServiceNotProvidedException, CycleDependencyException, ModuleConfigException, ModuleStartException {
-
- String[] moduleNames = applicationConfiguration.moduleList();
- ServiceLoader moduleServiceLoader = ServiceLoader.load(ModuleDefine.class);
- ServiceLoader moduleProviderLoader = ServiceLoader.load(ModuleProvider.class);
-
- HashSet moduleSet = new HashSet<>(Arrays.asList(moduleNames));
- for (ModuleDefine module : moduleServiceLoader) {
- if (moduleSet.contains(module.name())) {
- module.prepare(this, applicationConfiguration.getModuleConfiguration(module.name()), moduleProviderLoader);
- loadedModules.put(module.name(), module);
- moduleSet.remove(module.name());
- }
- }
- // Finish prepare stage
- isInPrepareStage = false;
-
- if (moduleSet.size() > 0) {
- throw new ModuleNotFoundException(moduleSet.toString() + " missing.");
- }
-
- BootstrapFlow bootstrapFlow = new BootstrapFlow(loadedModules);
-
- bootstrapFlow.start(this);
- bootstrapFlow.notifyAfterCompleted();
- }
-
- @Override
- public boolean has(String moduleName) {
- return loadedModules.get(moduleName) != null;
- }
-
- @Override
- public ModuleProviderHolder find(String moduleName) throws ModuleNotFoundRuntimeException {
- assertPreparedStage();
- ModuleDefine module = loadedModules.get(moduleName);
- if (module != null)
- return module;
- throw new ModuleNotFoundRuntimeException(moduleName + " missing.");
- }
-
- private void assertPreparedStage() {
- if (isInPrepareStage) {
- throw new AssertionError("Still in preparing stage.");
- }
- }
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleNotFoundRuntimeException.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleNotFoundRuntimeException.java
deleted file mode 100644
index a01cb99b..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleNotFoundRuntimeException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-public class ModuleNotFoundRuntimeException extends RuntimeException {
-
- public ModuleNotFoundRuntimeException(Throwable cause) {
- super(cause);
- }
-
- public ModuleNotFoundRuntimeException(String message) {
- super(message);
- }
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleProvider.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleProvider.java
deleted file mode 100644
index 5eb42d49..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleProvider.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-import lombok.Setter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The ModuleProvider is an implementation of a {@link ModuleDefine}.
- *
- * And each moduleDefine can have one or more implementation, which depends on `application.yml`
- */
-public abstract class ModuleProvider implements ModuleServiceHolder {
- @Setter
- private ModuleManager manager;
- @Setter
- private ModuleDefine moduleDefine;
- private final Map, Service> services = new HashMap<>();
-
- public ModuleProvider() {
- }
-
- protected final ModuleManager getManager() {
- return manager;
- }
-
- /**
- * @return the name of this provider.
- */
- public abstract String name();
-
- /**
- * @return the moduleDefine name
- */
- public abstract Class extends ModuleDefine> module();
-
- /**
- *
- */
- public abstract ModuleConfig createConfigBeanIfAbsent();
-
- /**
- * In prepare stage, the moduleDefine should initialize things which are irrelative other modules.
- */
- public abstract void prepare() throws ServiceNotProvidedException, ModuleStartException;
-
- /**
- * In start stage, the moduleDefine has been ready for interop.
- */
- public abstract void start() throws ServiceNotProvidedException, ModuleStartException;
-
- /**
- * This callback executes after all modules start up successfully.
- */
- public abstract void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException;
-
- /**
- * @return moduleDefine names which does this moduleDefine require?
- */
- public abstract String[] requiredModules();
-
- /**
- * Register an implementation for the service of this moduleDefine provider.
- */
- @Override
- public final void registerServiceImplementation(Class extends Service> serviceType, Service service) throws ServiceNotProvidedException {
- if (serviceType.isInstance(service)) {
- this.services.put(serviceType, service);
- } else {
- throw new ServiceNotProvidedException(serviceType + " is not implemented by " + service);
- }
- }
-
- /**
- * Make sure all required services have been implemented.
- *
- * @param requiredServices must be implemented by the moduleDefine.
- * @throws ServiceNotProvidedException when exist unimplemented service.
- */
- void requiredCheck(Class extends Service>[] requiredServices) throws ServiceNotProvidedException {
- if (requiredServices == null)
- return;
-
- for (Class extends Service> service : requiredServices) {
- if (!services.containsKey(service)) {
- throw new ServiceNotProvidedException("Service:" + service.getName() + " not provided");
- }
- }
-
- if (requiredServices.length != services.size()) {
- throw new ServiceNotProvidedException("The " + this.name() + " provider in " + moduleDefine.name() + " moduleDefine provide more service implementations than ModuleDefine requirements.");
- }
- }
-
- @Override
- public @SuppressWarnings("unchecked")
- T getService(Class serviceType) throws ServiceNotProvidedException {
- Service serviceImpl = services.get(serviceType);
- if (serviceImpl != null) {
- return (T) serviceImpl;
- }
-
- throw new ServiceNotProvidedException("Service " + serviceType.getName() + " should not be provided, based on moduleDefine define.");
- }
-
- ModuleDefine getModule() {
- return moduleDefine;
- }
-
- String getModuleName() {
- return moduleDefine.name();
- }
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleProviderHolder.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleProviderHolder.java
deleted file mode 100644
index dc379f9c..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleProviderHolder.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-public interface ModuleProviderHolder {
-
- ModuleServiceHolder provider() throws DuplicateProviderException, ProviderNotFoundException;
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleServiceHolder.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleServiceHolder.java
deleted file mode 100644
index d7a2865e..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ModuleServiceHolder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-public interface ModuleServiceHolder {
-
- void registerServiceImplementation(Class extends Service> serviceType, Service service) throws ServiceNotProvidedException;
-
- T getService(Class serviceType) throws ServiceNotProvidedException;
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ProviderNotFoundException.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ProviderNotFoundException.java
deleted file mode 100644
index 8877a1a5..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ProviderNotFoundException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-public class ProviderNotFoundException extends RuntimeException {
-
- public ProviderNotFoundException(String message) {
- super(message);
- }
-
- public ProviderNotFoundException(Throwable e) {
- super(e);
- }
-}
diff --git a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ServiceNotProvidedException.java b/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ServiceNotProvidedException.java
deleted file mode 100644
index 31b189bb..00000000
--- a/iot-server/server-library/library-module/src/main/java/com/zmops/zeus/iot/server/library/module/ServiceNotProvidedException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.module;
-
-public class ServiceNotProvidedException extends RuntimeException {
- public ServiceNotProvidedException(String message) {
- super(message);
- }
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/Server.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/Server.java
deleted file mode 100644
index 2e7a465d..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/Server.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server;
-
-public interface Server {
-
- String hostPort();
-
- String serverClassify();
-
- void initialize();
-
- void start() throws ServerException;
-
- boolean isSSLOpen();
-
- boolean isStatusEqual(Server target);
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyHandler.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyHandler.java
deleted file mode 100644
index e8c61858..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyHandler.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.jetty;
-
-import com.zmops.zeus.iot.server.library.server.ServerHandler;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-public abstract class JettyHandler extends HttpServlet implements ServerHandler {
-
- public abstract String pathSpec();
-
- @Override
- protected final void service(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException {
- String method = req.getMethod();
-
- // 只支持 Post 和 Get
- if (method.equals("POST") || method.equals("GET")) {
- super.service(req, resp);
- } else {
- resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- }
- }
-
- @Override
- public final void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
- super.service(req, res);
- }
-
- @Override
- protected final void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doHead(req, resp);
- }
-
- @Override
- protected final void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- protected final void doDelete(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-
- @Override
- protected final void doOptions(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
-
- @Override
- protected final void doTrace(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException {
- super.doTrace(req, resp);
- }
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyJsonHandler.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyJsonHandler.java
deleted file mode 100644
index d9326ed9..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyJsonHandler.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.jetty;
-
-import com.google.gson.JsonElement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import static java.util.Objects.nonNull;
-
-/**
- * @author nantian Jetty JSON 处理逻辑
- */
-public abstract class JettyJsonHandler extends JettyHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(JettyJsonHandler.class);
-
- @Override
- protected final void doPost(HttpServletRequest req, HttpServletResponse resp) {
- try {
- reply(resp, doPost(req));
- } catch (ArgumentsParseException | IOException e) {
- try {
- replyError(resp, e.getMessage(), HttpServletResponse.SC_BAD_REQUEST);
- } catch (IOException replyException) {
- LOGGER.error(replyException.getMessage(), e);
- }
- }
- }
-
- protected abstract JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException, IOException;
-
- private void reply(HttpServletResponse response, JsonElement resJson) throws IOException {
- response.setContentType("application/json");
- response.setCharacterEncoding("utf-8");
- response.setStatus(HttpServletResponse.SC_OK);
-
- PrintWriter out = response.getWriter();
- if (nonNull(resJson)) {
- out.print(resJson);
- }
- out.flush();
- out.close();
- }
-
- private void replyError(HttpServletResponse response, String errorMessage, int status) throws IOException {
- response.setContentType("application/json");
- response.setCharacterEncoding("utf-8");
- response.setStatus(status);
- response.setHeader("error-message", errorMessage);
-
- PrintWriter out = response.getWriter();
- out.flush();
- out.close();
- }
-
- public String getJsonBody(HttpServletRequest req) throws IOException {
- StringBuffer stringBuffer = new StringBuffer();
- String line = null;
- BufferedReader reader = req.getReader();
- while ((line = reader.readLine()) != null) {
- stringBuffer.append(line);
- }
- return stringBuffer.toString();
- }
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServer.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServer.java
deleted file mode 100644
index e1368b67..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServer.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.jetty;
-
-
-import com.zmops.zeus.iot.server.library.server.Server;
-import com.zmops.zeus.iot.server.library.server.ServerException;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.HttpConfiguration;
-import org.eclipse.jetty.server.HttpConnectionFactory;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.server.handler.gzip.GzipHandler;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-import org.eclipse.jetty.servlet.ServletMapping;
-import org.eclipse.jetty.util.thread.QueuedThreadPool;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Objects;
-
-public class JettyServer implements Server {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(JettyServer.class);
-
- private org.eclipse.jetty.server.Server server;
- private ServletContextHandler servletContextHandler;
- private JettyServerConfig jettyServerConfig;
-
- public JettyServer(JettyServerConfig config) {
- this.jettyServerConfig = config;
- }
-
- @Override
- public String hostPort() {
- return jettyServerConfig.getHost() + ":" + jettyServerConfig.getPort();
- }
-
- @Override
- public String serverClassify() {
- return "Jetty";
- }
-
- @Override
- public void initialize() {
- QueuedThreadPool threadPool = new QueuedThreadPool();
- threadPool.setMinThreads(jettyServerConfig.getJettyMinThreads());
- threadPool.setMaxThreads(jettyServerConfig.getJettyMaxThreads());
-
- server = new org.eclipse.jetty.server.Server(threadPool);
-
- HttpConfiguration httpConfiguration = new HttpConfiguration();
-
- GzipHandler gzipHandler = new GzipHandler();
- server.setHandler(gzipHandler);
-
-
- httpConfiguration.setRequestHeaderSize(jettyServerConfig.getJettyHttpMaxRequestHeaderSize());
-
- ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
- connector.setHost(jettyServerConfig.getHost());
- connector.setPort(jettyServerConfig.getPort());
- connector.setIdleTimeout(jettyServerConfig.getJettyIdleTimeOut());
- connector.setAcceptorPriorityDelta(jettyServerConfig.getJettyAcceptorPriorityDelta());
- connector.setAcceptQueueSize(jettyServerConfig.getJettyAcceptQueueSize());
- server.setConnectors(new Connector[]{connector});
-
- servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
- servletContextHandler.setContextPath(jettyServerConfig.getContextPath());
- LOGGER.info("http server root context path: {}", jettyServerConfig.getContextPath());
-
- server.setHandler(servletContextHandler);
-
- JettyDefaultHandler defaultHandler = new JettyDefaultHandler();
- ServletHolder defaultHolder = new ServletHolder();
- defaultHolder.setServlet(defaultHandler);
-
- servletContextHandler.addServlet(defaultHolder, defaultHandler.pathSpec());
- }
-
- public void addHandler(JettyHandler handler) {
- LOGGER.info(
- "Bind handler {} into jetty server {}:{}",
- handler.getClass().getSimpleName(), jettyServerConfig.getHost(), jettyServerConfig.getPort()
- );
-
- ServletHolder servletHolder = new ServletHolder();
- servletHolder.setServlet(handler);
- servletContextHandler.addServlet(servletHolder, handler.pathSpec());
- }
-
- @Override
- public boolean isSSLOpen() {
- return false;
- }
-
- @Override
- public boolean isStatusEqual(Server target) {
- return equals(target);
- }
-
- @Override
- public void start() throws ServerException {
- LOGGER.info("start server, host: {}, port: {}", jettyServerConfig.getHost(), jettyServerConfig.getPort());
- try {
- if (LOGGER.isDebugEnabled()) {
- if (servletContextHandler.getServletHandler() != null && servletContextHandler.getServletHandler().getServletMappings() != null) {
-
- for (ServletMapping servletMapping : servletContextHandler.getServletHandler().getServletMappings()) {
- LOGGER.debug("jetty servlet mappings: {} register by {}", servletMapping.getPathSpecs(), servletMapping.getServletName());
- }
-
- }
- }
-
- server.start();
- } catch (Exception e) {
- throw new JettyServerException(e.getMessage(), e);
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
- JettyServer that = (JettyServer) o;
- return jettyServerConfig.getPort() == that.jettyServerConfig.getPort()
- && Objects.equals(jettyServerConfig.getHost(), that.jettyServerConfig.getHost());
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(jettyServerConfig.getHost(), jettyServerConfig.getPort());
- }
-
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServerConfig.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServerConfig.java
deleted file mode 100644
index 7aa2f177..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServerConfig.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.jetty;
-
-import lombok.Builder;
-import lombok.Getter;
-import lombok.Setter;
-
-@Setter
-@Getter
-@Builder
-public class JettyServerConfig {
-
- private String host;
- private int port;
- private String contextPath;
-
- @Builder.Default
- private int jettyMinThreads = 1;
- @Builder.Default
- private int jettyMaxThreads = 200;
- @Builder.Default
- private long jettyIdleTimeOut = 30000;
- @Builder.Default
- private int jettyAcceptorPriorityDelta = 0;
- @Builder.Default
- private int jettyAcceptQueueSize = 0;
- @Builder.Default
- private int jettyHttpMaxRequestHeaderSize = 8192;
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServerException.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServerException.java
deleted file mode 100644
index 5d809d1b..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/jetty/JettyServerException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.jetty;
-
-import com.zmops.zeus.iot.server.library.server.ServerException;
-
-public class JettyServerException extends ServerException {
-
- public JettyServerException(String message) {
- super(message);
- }
-
- public JettyServerException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/pool/CustomThreadFactory.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/pool/CustomThreadFactory.java
deleted file mode 100644
index 7cafdebf..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/pool/CustomThreadFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.pool;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class CustomThreadFactory implements ThreadFactory {
- private final AtomicInteger poolNumber = new AtomicInteger(1);
- private final ThreadGroup group;
- private final AtomicInteger threadNumber = new AtomicInteger(1);
- private final String namePrefix;
-
- public CustomThreadFactory(String name) {
- SecurityManager s = System.getSecurityManager();
- group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
- namePrefix = name + "-" + poolNumber.getAndIncrement() + "-thread-";
- }
-
- @Override
- public Thread newThread(Runnable r) {
- Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
- if (t.isDaemon())
- t.setDaemon(false);
- if (t.getPriority() != Thread.NORM_PRIORITY)
- t.setPriority(Thread.NORM_PRIORITY);
- return t;
- }
-}
\ No newline at end of file
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/AbstractSslContext.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/AbstractSslContext.java
deleted file mode 100644
index 466d5b31..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/AbstractSslContext.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.ssl;
-
-import com.zmops.zeus.iot.server.library.util.MultipleFilesChangeMonitor;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.handler.ssl.ApplicationProtocolNegotiator;
-import io.netty.handler.ssl.SslContext;
-import lombok.AccessLevel;
-import lombok.Setter;
-
-
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLSessionContext;
-import java.util.List;
-
-public abstract class AbstractSslContext extends SslContext {
- private final MultipleFilesChangeMonitor monitor;
-
- @Setter(AccessLevel.PROTECTED)
- private volatile SslContext ctx;
-
- protected AbstractSslContext(final String privateKeyFile, final String certChainFile) {
- updateContext(privateKeyFile, certChainFile);
- monitor = new MultipleFilesChangeMonitor(
- 10,
- readableContents -> updateContext(privateKeyFile, certChainFile),
- certChainFile,
- privateKeyFile);
- }
-
- protected AbstractSslContext(final String caFile) {
- updateContext(caFile);
- monitor = new MultipleFilesChangeMonitor(
- 10,
- readableContents -> updateContext(caFile),
- caFile);
- }
-
- protected abstract void updateContext(String caFile);
-
- protected abstract void updateContext(final String privateKeyFile, final String certChainFile);
-
- public void start() {
- monitor.start();
- }
-
- @Override
- public final boolean isClient() {
- return ctx.isClient();
- }
-
- @Override
- public final List cipherSuites() {
- return ctx.cipherSuites();
- }
-
- @Override
- public final long sessionCacheSize() {
- return ctx.sessionCacheSize();
- }
-
- @Override
- public final long sessionTimeout() {
- return ctx.sessionTimeout();
- }
-
- @Override
- public final ApplicationProtocolNegotiator applicationProtocolNegotiator() {
- return ctx.applicationProtocolNegotiator();
- }
-
- @Override
- public final SSLEngine newEngine(ByteBufAllocator alloc) {
- return ctx.newEngine(alloc);
- }
-
- @Override
- public final SSLEngine newEngine(ByteBufAllocator alloc, String peerHost, int peerPort) {
- return ctx.newEngine(alloc, peerHost, peerPort);
- }
-
- @Override
- public final SSLSessionContext sessionContext() {
- return ctx.sessionContext();
- }
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/HttpDynamicSslContext.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/HttpDynamicSslContext.java
deleted file mode 100644
index 2fe8cd76..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/HttpDynamicSslContext.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.ssl;
-
-import io.netty.handler.ssl.SslContextBuilder;
-
-import javax.net.ssl.SSLException;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.file.Paths;
-import java.security.GeneralSecurityException;
-
-public class HttpDynamicSslContext extends AbstractSslContext {
-
- public static HttpDynamicSslContext forServer(String privateKeyFile, String certChainFile) {
- return new HttpDynamicSslContext(privateKeyFile, certChainFile);
- }
-
- public static HttpDynamicSslContext forClient(String caFile) {
- return new HttpDynamicSslContext(caFile);
- }
-
- protected HttpDynamicSslContext(String privateKeyFile, String certChainFile) {
- super(privateKeyFile, certChainFile);
- }
-
- protected HttpDynamicSslContext(String caFile) {
- super(caFile);
- }
-
- @Override
- protected void updateContext(String caFile) {
- try {
- setCtx(SslContextBuilder.forClient().trustManager(Paths.get(caFile).toFile()).build());
- } catch (SSLException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- @Override
- protected void updateContext(final String privateKeyFile, final String certChainFile) {
- try {
- setCtx(SslContextBuilder
- .forServer(
- new FileInputStream(Paths.get(certChainFile).toFile()),
- PrivateKeyUtil.loadDecryptionKey(privateKeyFile)).build());
- } catch (GeneralSecurityException | IOException e) {
- throw new IllegalArgumentException(e);
- }
- }
-}
diff --git a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/PrivateKeyUtil.java b/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/PrivateKeyUtil.java
deleted file mode 100644
index fa9b5fa3..00000000
--- a/iot-server/server-library/library-server/src/main/java/com/zmops/zeus/iot/server/library/server/ssl/PrivateKeyUtil.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.server.ssl;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.security.GeneralSecurityException;
-import java.util.Base64;
-
-/**
- * Util intends to parse PKCS#1 and PKCS#8 at same time.
- */
-public class PrivateKeyUtil {
- private static final String PKCS_1_PEM_HEADER = "-----BEGIN RSA PRIVATE KEY-----";
- private static final String PKCS_1_PEM_FOOTER = "-----END RSA PRIVATE KEY-----";
- private static final String PKCS_8_PEM_HEADER = "-----BEGIN PRIVATE KEY-----";
- private static final String PKCS_8_PEM_FOOTER = "-----END PRIVATE KEY-----";
-
- /**
- * Load a RSA decryption key from a file (PEM or DER).
- */
- public static InputStream loadDecryptionKey(String keyFilePath) throws GeneralSecurityException, IOException {
- byte[] keyDataBytes = Files.readAllBytes(Paths.get(keyFilePath));
- String keyDataString = new String(keyDataBytes, StandardCharsets.UTF_8);
-
- if (keyDataString.contains(PKCS_1_PEM_HEADER)) {
- // OpenSSL / PKCS#1 Base64 PEM encoded file
- keyDataString = keyDataString.replace(PKCS_1_PEM_HEADER, "");
- keyDataString = keyDataString.replace(PKCS_1_PEM_FOOTER, "");
- keyDataString = keyDataString.replace("\n", "");
- return readPkcs1PrivateKey(Base64.getDecoder().decode(keyDataString));
- }
-
- return new ByteArrayInputStream(keyDataString.getBytes());
- }
-
- /**
- * Create a InputStream instance from raw PKCS#1 bytes. Raw Java API can't recognize ASN.1 format, so we should
- * convert it into a pkcs#8 format Java can understand.
- */
- private static InputStream readPkcs1PrivateKey(byte[] pkcs1Bytes) throws GeneralSecurityException {
- int pkcs1Length = pkcs1Bytes.length;
- int totalLength = pkcs1Length + 22;
- byte[] pkcs8Header = new byte[]{
- 0x30, (byte) 0x82, (byte) ((totalLength >> 8) & 0xff), (byte) (totalLength & 0xff), // Sequence + total length
- 0x2, 0x1, 0x0, // Integer (0)
- 0x30, 0xD, 0x6, 0x9, 0x2A, (byte) 0x86, 0x48, (byte) 0x86, (byte) 0xF7, 0xD, 0x1, 0x1, 0x1, 0x5, 0x0, // Sequence: 1.2.840.113549.1.1.1, NULL
- 0x4, (byte) 0x82, (byte) ((pkcs1Length >> 8) & 0xff), (byte) (pkcs1Length & 0xff) // Octet string + length
- };
- StringBuilder pkcs8 = new StringBuilder(PKCS_8_PEM_HEADER);
- pkcs8.append("\n").append(new String(Base64.getEncoder().encode(join(pkcs8Header, pkcs1Bytes))));
- pkcs8.append("\n").append(PKCS_8_PEM_FOOTER);
- return new ByteArrayInputStream(pkcs8.toString().getBytes());
- }
-
- private static byte[] join(byte[] byteArray1, byte[] byteArray2) {
- byte[] bytes = new byte[byteArray1.length + byteArray2.length];
- System.arraycopy(byteArray1, 0, bytes, 0, byteArray1.length);
- System.arraycopy(byteArray2, 0, bytes, byteArray1.length, byteArray2.length);
- return bytes;
- }
-}
diff --git a/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/CollectionUtils.java b/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/CollectionUtils.java
deleted file mode 100644
index 855f093e..00000000
--- a/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/CollectionUtils.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.util;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class CollectionUtils {
-
- public static boolean isEmpty(Map map) {
- return map == null || map.size() == 0;
- }
-
- public static boolean isEmpty(List list) {
- return list == null || list.size() == 0;
- }
-
- public static boolean isEmpty(Set set) {
- return set == null || set.size() == 0;
- }
-
- public static boolean isNotEmpty(List list) {
- return !isEmpty(list);
- }
-
- public static boolean isNotEmpty(Set set) {
- return !isEmpty(set);
- }
-
- public static boolean isNotEmpty(Map map) {
- return !isEmpty(map);
- }
-
- public static boolean isNotEmpty(T[] array) {
- return array != null && array.length > 0;
- }
-
- public static boolean isEmpty(byte[] array) {
- return array == null || array.length == 0;
- }
-
- public static boolean isNotEmpty(byte[] array) {
- return !isEmpty(array);
- }
-}
diff --git a/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/MultipleFilesChangeMonitor.java b/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/MultipleFilesChangeMonitor.java
deleted file mode 100644
index 71f90d3a..00000000
--- a/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/MultipleFilesChangeMonitor.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.util;
-
-import com.zmops.zeus.iot.server.util.StringUtil;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * MultipleFilesChangeMonitor provides the capability to detect file or multiple files changed. It provide second level
- * change detection and feedback mechanism.
- *
- * Due to memory cost, this monitor mechanism is not suitable for small files and usually being changed on the runtime
- * by user manually or 3rd party tool. Typical, these files are config information or authentication files.
- */
-@Slf4j
-public class MultipleFilesChangeMonitor {
- /**
- * The backend scheduler to trigger all file monitoring.
- */
- private static ScheduledFuture> FILE_MONITOR_TASK_SCHEDULER;
- private static final ReentrantLock SCHEDULER_CHANGE_LOCK = new ReentrantLock();
- /**
- * The list contains all monitors.
- */
- private static final List MONITOR_INSTANCES = new ArrayList<>();
-
- /**
- * The timestamp when last time do status checked.
- */
- private long lastCheckTimestamp = 0;
- /**
- * The period of watching thread checking the file status. Unit is the second.
- */
- private final long watchingPeriodInSec;
- private final List watchedFiles;
- private final FilesChangedNotifier notifier;
-
- /**
- * Create a new monitor for the given files
- *
- * @param watchingPeriodInSec The check period.
- * @param notifier to accept the file changed notification.
- * @param files to be monitored. If an element of list is NULL, the virtual(NULL) file is treated
- * unchangeable.
- */
- public MultipleFilesChangeMonitor(long watchingPeriodInSec,
- FilesChangedNotifier notifier,
- String... files) {
- watchedFiles = new ArrayList<>();
- this.watchingPeriodInSec = watchingPeriodInSec;
- this.notifier = notifier;
- for (final String file : files) {
- WatchedFile monitor;
- if (StringUtil.isEmpty(file)) {
- monitor = new NoopWatchedFile();
- } else {
- monitor = new WatchedFile(file);
- }
- watchedFiles.add(monitor);
- }
- }
-
- /**
- * Check file changed status, if so, send the notification.
- */
- private void checkAndNotify() {
- if (System.currentTimeMillis() - lastCheckTimestamp < watchingPeriodInSec * 1000) {
- // Don't reach the period threshold, ignore this check.
- return;
- }
-
- boolean isChanged = false;
- for (final WatchedFile watchedFile : watchedFiles) {
- isChanged = isChanged || watchedFile.detectContentChanged();
- }
- if (isChanged) {
- List contents = new ArrayList<>(watchedFiles.size());
- watchedFiles.forEach(file -> {
- contents.add(file.fileContent);
- });
- try {
- notifier.filesChanged(contents);
- } catch (Exception e) {
- log.error("Files=" + this + " notification process failure.", e);
- }
- }
- }
-
- /**
- * One file changed will cause all related files loaded from the disk again with lastModifiedTimestamp updated.
- */
- public static void scanChanges() {
- MONITOR_INSTANCES.forEach(group -> {
- try {
- group.checkAndNotify();
- } catch (Throwable t) {
- log.error("Files change detection failure, gourp = ", t);
- }
- });
- }
-
- /**
- * Start the change monitoring.
- */
- public void start() {
- SCHEDULER_CHANGE_LOCK.lock();
- try {
- if (FILE_MONITOR_TASK_SCHEDULER == null) {
- FILE_MONITOR_TASK_SCHEDULER = Executors.newSingleThreadScheduledExecutor()
- .scheduleAtFixedRate(
- MultipleFilesChangeMonitor::scanChanges, 1, 200,
- TimeUnit.MILLISECONDS
- );
- }
-
- if (MONITOR_INSTANCES.contains(this)) {
- throw new IllegalStateException("This FileChangeMonitor has been started.");
- }
-
- this.checkAndNotify();
- MONITOR_INSTANCES.add(this);
- } finally {
- SCHEDULER_CHANGE_LOCK.unlock();
- }
- }
-
- /**
- * Stop the change monitoring.
- */
- public void stop() {
- SCHEDULER_CHANGE_LOCK.lock();
- try {
- MONITOR_INSTANCES.remove(this);
- } finally {
- SCHEDULER_CHANGE_LOCK.unlock();
- }
- }
-
- @Override
- public String toString() {
- return "MultipleFilesChangeMonitor{" +
- "watchedFiles=" + watchedFiles +
- '}';
- }
-
- /**
- * The callback when files changed.
- */
- public interface FilesChangedNotifier {
- /**
- * Notify the new content by providing the file input stream for all files in this group.
- *
- * @param readableContents include the new contents. NULL if the file doesn't exist.
- */
- void filesChanged(List readableContents) throws Exception;
- }
-
- /**
- * WatchedFile represents a file change detector. It could detect the file changed based on modified time and file
- * content at the binary level. It load the file content into the memory as cache to do the comparison.
- */
- @RequiredArgsConstructor
- @Slf4j
- private static class WatchedFile {
- /**
- * The absolute path of the monitored file.
- */
- private final String filePath;
- /**
- * The last modify time of the {@link #filePath}
- */
- private long lastModifiedTimestamp = 0;
- /**
- * File content at the latest status.
- */
- private byte[] fileContent;
-
- /**
- * Detect the file content change, if yes, reload the file content into the memory as cached data.
- *
- * @return true if file content changed.
- */
- boolean detectContentChanged() {
- File targetFile = new File(filePath);
- if (!targetFile.exists()) {
- if (lastModifiedTimestamp == 0) {
- //File doesn't exist before, no change detected.
- return false;
- } else {
- // File has been deleted. Reset the modified timestamp.
- lastModifiedTimestamp = 0;
- return true;
- }
- } else {
- long lastModified = targetFile.lastModified();
- if (lastModified != lastModifiedTimestamp) {
- // File modified timestamp changed. Need to read the file content.
- try (FileInputStream fileInputStream = new FileInputStream(targetFile)) {
- byte[] b = new byte[1024];
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- int c;
- while ((c = fileInputStream.read(b)) != -1) {
- os.write(b, 0, c);
- }
- byte[] newContent = os.toByteArray();
- if (!Arrays.equals(newContent, fileContent)) {
- fileContent = newContent;
- return true;
- } else {
- return false;
- }
- } catch (FileNotFoundException e) {
- log.error("The existed file turns to missing, watch file=" + filePath, e);
- } catch (IOException e) {
- log.error("Read file failure, watch file=" + filePath, e);
- } finally {
- lastModifiedTimestamp = lastModified;
- }
- }
- return false;
- }
- }
- }
-
- private static class NoopWatchedFile extends WatchedFile {
- public NoopWatchedFile() {
- super(null);
- }
-
- /**
- * @return false, as an noop file never changes.
- */
- @Override
- boolean detectContentChanged() {
- return false;
- }
- }
-}
diff --git a/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/ResourceUtils.java b/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/ResourceUtils.java
deleted file mode 100644
index 6addb0be..00000000
--- a/iot-server/server-library/library-util/src/main/java/com/zmops/zeus/iot/server/library/util/ResourceUtils.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.library.util;
-
-import java.io.*;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-public class ResourceUtils {
-
- public static Reader read(String fileName) throws FileNotFoundException {
- return new InputStreamReader(readToStream(fileName));
- }
-
- public static InputStream readToStream(String fileName) throws FileNotFoundException {
- URL url = ResourceUtils.class.getClassLoader().getResource(fileName);
- if (url == null) {
- throw new FileNotFoundException("file not found: " + fileName);
- }
- return ResourceUtils.class.getClassLoader().getResourceAsStream(fileName);
- }
-
- public static File[] getPathFiles(String path) throws FileNotFoundException {
- URL url = ResourceUtils.class.getClassLoader().getResource(path);
- if (url == null) {
- throw new FileNotFoundException("path not found: " + path);
- }
- return Arrays.stream(Objects.requireNonNull(new File(url.getPath()).listFiles(), "No files in " + path))
- .filter(File::isFile).toArray(File[]::new);
- }
-
- public static File[] getPathFiles(String parentPath, String[] fileNames) throws FileNotFoundException {
- URL url = ResourceUtils.class.getClassLoader().getResource(parentPath);
- if (url == null) {
- throw new FileNotFoundException("path not found: " + parentPath);
- }
- final Set nameSet = new HashSet<>(Arrays.asList(fileNames));
- final File[] listFiles = Objects.requireNonNull(new File(url.getPath())
- .listFiles((dir, name) -> nameSet.contains(name)), "No files in " + parentPath);
-
- if (listFiles.length == 0) {
- throw new FileNotFoundException("files not found:" + nameSet);
- }
- return listFiles;
- }
-}
diff --git a/iot-server/server-library/library-server/pom.xml b/iot-server/server-localdb/pom.xml
similarity index 58%
rename from iot-server/server-library/library-server/pom.xml
rename to iot-server/server-localdb/pom.xml
index 9d91331a..3a15d8d5 100644
--- a/iot-server/server-library/library-server/pom.xml
+++ b/iot-server/server-localdb/pom.xml
@@ -3,36 +3,31 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- server-library
+ iot-servercom.zmops1.0-beta4.0.0
- library-server
-
-
- 8
- 8
- 9.4.40.v20210413
-
+ server-localdb
+ IoT Server 服务组件状态实时本地持久化存储,启动恢复com.zmops
- library-util
- 1.0-beta
-
-
- org.eclipse.jetty
- jetty-server
- ${jetty.version}
+ library-module
+ 1.0.3-RELEASE
- org.eclipse.jetty
- jetty-servlet
- ${jetty.version}
+ com.zmops
+ server-client
+ 1.0-beta
+
+ 8
+ 8
+
+
\ No newline at end of file
diff --git a/iot-server/server-localdb/src/main/java/com/zmops/zeus/iot/server/h2/module/LocalH2Module.java b/iot-server/server-localdb/src/main/java/com/zmops/zeus/iot/server/h2/module/LocalH2Module.java
new file mode 100644
index 00000000..4f879c0d
--- /dev/null
+++ b/iot-server/server-localdb/src/main/java/com/zmops/zeus/iot/server/h2/module/LocalH2Module.java
@@ -0,0 +1,23 @@
+package com.zmops.zeus.iot.server.h2.module;
+
+import com.zmops.zeus.iot.server.h2.service.InsertDAO;
+import com.zmops.zeus.server.library.module.ModuleDefine;
+
+/**
+ * @author nantian created at 2021/10/24 16:56
+ */
+public class LocalH2Module extends ModuleDefine {
+
+ public static final String NAME = "local-h2";
+
+ public LocalH2Module() {
+ super(NAME);
+ }
+
+ @Override
+ public Class[] services() {
+ return new Class[]{
+ InsertDAO.class
+ };
+ }
+}
diff --git a/iot-server/server-localdb/src/main/java/com/zmops/zeus/iot/server/h2/provider/LocalH2Config.java b/iot-server/server-localdb/src/main/java/com/zmops/zeus/iot/server/h2/provider/LocalH2Config.java
new file mode 100644
index 00000000..d13af60e
--- /dev/null
+++ b/iot-server/server-localdb/src/main/java/com/zmops/zeus/iot/server/h2/provider/LocalH2Config.java
@@ -0,0 +1,26 @@
+package com.zmops.zeus.iot.server.h2.provider;
+
+import com.zmops.zeus.server.library.module.ModuleConfig;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author nantian created at 2021/10/24 16:45
+ *
- * Http 协议 接收报文
- */
-public class HttpReceiverModule extends ModuleDefine {
-
- public static final String NAME = "receiver-http";
-
- public HttpReceiverModule() {
- super(NAME);
- }
-
- @Override
- public Class>[] services() {
- return new Class[0];
- }
-}
diff --git a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/predicate/HeaderPredicate.java b/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/predicate/HeaderPredicate.java
deleted file mode 100644
index 187857a9..00000000
--- a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/predicate/HeaderPredicate.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.http.predicate;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Predicate;
-
-/**
- * @author nantian created at 2021/8/16 18:19
- */
-public class HeaderPredicate implements Predicate {
-
- @Override
- public boolean matches(Exchange exchange) {
-
-
- return exchange.getIn().getHeader("username").equals("zhangsan");
- }
-}
diff --git a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpReceiverConfig.java b/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpReceiverConfig.java
deleted file mode 100644
index cd43a94c..00000000
--- a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpReceiverConfig.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.http.provider;
-
-import com.zmops.zeus.iot.server.library.module.ModuleConfig;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @author nantian created at 2021/8/14 22:47
- */
-
-@Getter
-@Setter
-public class HttpReceiverConfig extends ModuleConfig {
-
-
- /**
- * Export http port
- */
- private int port = 8080;
-}
diff --git a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpReceiverPluginProvider.java b/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpReceiverPluginProvider.java
deleted file mode 100644
index 4b1cb289..00000000
--- a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpReceiverPluginProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.http.provider;
-
-import com.zmops.zeus.iot.server.core.CoreModule;
-import com.zmops.zeus.iot.server.core.camel.CamelContextHolderService;
-import com.zmops.zeus.iot.server.library.module.*;
-import com.zmops.zeus.iot.server.receiver.http.module.HttpReceiverModule;
-
-/**
- * @author nantian created at 2021/8/14 22:29
- */
-public class HttpReceiverPluginProvider extends ModuleProvider {
-
- private final HttpReceiverConfig httpReceiverConfig;
-
- // CamelContextHolder
- private CamelContextHolderService camelService;
-
- public HttpReceiverPluginProvider() {
- this.httpReceiverConfig = new HttpReceiverConfig();
- }
-
- @Override
- public String name() {
- return "default";
- }
-
- @Override
- public Class extends ModuleDefine> module() {
- return HttpReceiverModule.class;
- }
-
- @Override
- public ModuleConfig createConfigBeanIfAbsent() {
- return httpReceiverConfig;
- }
-
- @Override
- public void prepare() throws ServiceNotProvidedException, ModuleStartException {
-
- }
-
- @Override
- public void start() throws ServiceNotProvidedException, ModuleStartException {
- camelService = getManager().find(CoreModule.NAME).provider().getService(CamelContextHolderService.class);
- }
-
- @Override
- public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
- camelService.addRoutes(new HttpRouteBuilder(httpReceiverConfig));
- }
-
- @Override
- public String[] requiredModules() {
- return new String[]{
- CoreModule.NAME
- };
- }
-}
diff --git a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpRouteBuilder.java b/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpRouteBuilder.java
deleted file mode 100644
index edc51ce9..00000000
--- a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/http/provider/HttpRouteBuilder.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.http.provider;
-
-import com.zmops.zeus.iot.server.receiver.http.predicate.HeaderPredicate;
-import org.apache.camel.builder.RouteBuilder;
-
-/**
- * @author nantian created at 2021/8/14 22:41
- */
-public class HttpRouteBuilder extends RouteBuilder {
-
- private final HttpReceiverConfig config;
-
- public HttpRouteBuilder(HttpReceiverConfig config) {
- this.config = config;
- }
-
- @Override
- public void configure() throws Exception {
- fromF("netty4-http:http://0.0.0.0:%d/foo", config.getPort())
- .threads(10)
- .choice()
- .when(new HeaderPredicate())
- .to("Zabbix");
- }
-}
diff --git a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/module/MqttReceiverModule.java b/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/module/MqttReceiverModule.java
deleted file mode 100644
index 65baa80d..00000000
--- a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/module/MqttReceiverModule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.mqtt.module;
-
-import com.zmops.zeus.iot.server.library.module.ModuleDefine;
-
-/**
- * @author yefei
- */
-public class MqttReceiverModule extends ModuleDefine {
-
- public static final String NAME = "receiver-mqtt";
-
- public MqttReceiverModule() {
- super(NAME);
- }
-
- @Override
- public Class[] services() {
- return new Class[0];
- }
-}
diff --git a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/process/MqttPacketProcess.java b/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/process/MqttPacketProcess.java
deleted file mode 100644
index 868f47ca..00000000
--- a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/process/MqttPacketProcess.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.mqtt.process;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-
-/**
- * @author yefei
- */
-public class MqttPacketProcess implements Processor {
-
- @Override
- public void process(Exchange exchange) throws Exception {
- System.out.println(exchange.getMessage());
- }
-}
diff --git a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttReceiverConfig.java b/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttReceiverConfig.java
deleted file mode 100644
index d2bb261a..00000000
--- a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttReceiverConfig.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.mqtt.provider;
-
-import com.zmops.zeus.iot.server.library.module.ModuleConfig;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @author yefei
- */
-
-@Getter
-@Setter
-public class MqttReceiverConfig extends ModuleConfig {
-
-
- /**
- * Export http port
- */
- private int port = 9020;
-}
diff --git a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttReceiverPluginProvider.java b/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttReceiverPluginProvider.java
deleted file mode 100644
index 50d70961..00000000
--- a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttReceiverPluginProvider.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.mqtt.provider;
-
-import com.zmops.zeus.iot.server.core.CoreModule;
-import com.zmops.zeus.iot.server.core.camel.CamelContextHolderService;
-import com.zmops.zeus.iot.server.library.module.*;
-import com.zmops.zeus.iot.server.receiver.mqtt.module.MqttReceiverModule;
-
-/**
- * @author yefei
- */
-public class MqttReceiverPluginProvider extends ModuleProvider {
-
- private final MqttReceiverConfig mqttReceiverConfig;
-
- private CamelContextHolderService camelService;
-
- public MqttReceiverPluginProvider() {
- this.mqttReceiverConfig = new MqttReceiverConfig();
- }
-
- @Override
- public String name() {
- return "default";
- }
-
- @Override
- public Class extends ModuleDefine> module() {
- return MqttReceiverModule.class;
- }
-
- @Override
- public ModuleConfig createConfigBeanIfAbsent() {
- return mqttReceiverConfig;
- }
-
- @Override
- public void prepare() throws ServiceNotProvidedException, ModuleStartException {
-
- }
-
- @Override
- public void start() throws ServiceNotProvidedException, ModuleStartException {
- camelService = getManager().find(CoreModule.NAME).provider().getService(CamelContextHolderService.class);
- }
-
- @Override
- public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
- camelService.addRoutes(new MqttRouteBuilder(mqttReceiverConfig));
- }
-
- @Override
- public String[] requiredModules() {
- return new String[]{
- CoreModule.NAME
- };
- }
-}
diff --git a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttRouteBuilder.java b/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttRouteBuilder.java
deleted file mode 100644
index 20490532..00000000
--- a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/mqtt/provider/MqttRouteBuilder.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.mqtt.provider;
-
-import com.zmops.zeus.iot.server.receiver.mqtt.process.MqttPacketProcess;
-import org.apache.camel.builder.RouteBuilder;
-
-/**
- * @author yefei
- */
-public class MqttRouteBuilder extends RouteBuilder {
-
-
- private final MqttReceiverConfig mqttReceiverConfig;
-
- public MqttRouteBuilder(MqttReceiverConfig mqttReceiverConfig) {
- this.mqttReceiverConfig = mqttReceiverConfig;
- }
-
- @Override
- public void configure() throws Exception {
- fromF("mqtt://127.0.0.1:%d?subscribeTopicNames=test.mqtt.topic", mqttReceiverConfig.getPort())
- .process(new MqttPacketProcess())
- .to("Zabbix");
- }
-}
diff --git a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider b/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
deleted file mode 100644
index 4f8a532e..00000000
--- a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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.
-#
-#
-
-com.zmops.zeus.iot.server.receiver.mqtt.provider.MqttReceiverPluginProvider
diff --git a/iot-server/server-receiver-plugin/opc-ua-receiver-plugin/pom.xml b/iot-server/server-receiver-plugin/opc-ua-receiver-plugin/pom.xml
deleted file mode 100644
index 06244903..00000000
--- a/iot-server/server-receiver-plugin/opc-ua-receiver-plugin/pom.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- server-receiver-plugin
- com.zmops
- 1.0-beta
-
- 4.0.0
-
- opc-ua-receiver-plugin
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/iot-server/server-receiver-plugin/pom.xml b/iot-server/server-receiver-plugin/pom.xml
deleted file mode 100644
index 88a9680d..00000000
--- a/iot-server/server-receiver-plugin/pom.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
- iot-server
- com.zmops
- 1.0-beta
-
- 4.0.0
-
- server-receiver-plugin
- pom
-
- http-receiver-plugin
- udp-receiver-plugin
- mqtt-receiver-plugin
- coap-receiver-plugin
- tcp-receiver-plugin
- opc-ua-receiver-plugin
-
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/iot-server/server-receiver-plugin/readme.md b/iot-server/server-receiver-plugin/readme.md
deleted file mode 100644
index e8e7b730..00000000
--- a/iot-server/server-receiver-plugin/readme.md
+++ /dev/null
@@ -1,7 +0,0 @@
-#### 网络协议接入模块
-- HTTP
-- COAP
-- MQTT
-- TCP
-- UDP
-- OPC
diff --git a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/module/TcpReceiverModule.java b/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/module/TcpReceiverModule.java
deleted file mode 100644
index 15615d33..00000000
--- a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/module/TcpReceiverModule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.tcp.module;
-
-import com.zmops.zeus.iot.server.library.module.ModuleDefine;
-
-/**
- * @author nantian created at 2021/8/17 11:25
- */
-public class TcpReceiverModule extends ModuleDefine {
-
- public static final String NAME = "receiver-tcp";
-
- public TcpReceiverModule() {
- super(NAME);
- }
-
- @Override
- public Class[] services() {
- return new Class[0];
- }
-}
diff --git a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/process/TcpPacketProcess.java b/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/process/TcpPacketProcess.java
deleted file mode 100644
index df5f2d0b..00000000
--- a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/process/TcpPacketProcess.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.tcp.process;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-
-/**
- * @author nantian created at 2021/8/17 11:36
- */
-public class TcpPacketProcess implements Processor {
-
- @Override
- public void process(Exchange exchange) throws Exception {
-
- }
-}
diff --git a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpReceiverConfig.java b/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpReceiverConfig.java
deleted file mode 100644
index 8ac7c9b1..00000000
--- a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpReceiverConfig.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.tcp.provider;
-
-import com.zmops.zeus.iot.server.library.module.ModuleConfig;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @author nantian created at 2021/8/14 22:47
- */
-
-@Getter
-@Setter
-public class TcpReceiverConfig extends ModuleConfig {
-
-
- /**
- * Export http port
- */
- private int port = 9020;
-}
diff --git a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpReceiverPluginProvider.java b/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpReceiverPluginProvider.java
deleted file mode 100644
index 5ba29e7d..00000000
--- a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpReceiverPluginProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.tcp.provider;
-
-import com.zmops.zeus.iot.server.core.CoreModule;
-import com.zmops.zeus.iot.server.core.camel.CamelContextHolderService;
-import com.zmops.zeus.iot.server.library.module.*;
-import com.zmops.zeus.iot.server.receiver.tcp.module.TcpReceiverModule;
-
-/**
- * @author nantian created at 2021/8/14 22:29
- */
-public class TcpReceiverPluginProvider extends ModuleProvider {
-
- private final TcpReceiverConfig tcpReceiverConfig;
-
- // CamelContextHolder
- private CamelContextHolderService camelService;
-
- public TcpReceiverPluginProvider() {
- this.tcpReceiverConfig = new TcpReceiverConfig();
- }
-
- @Override
- public String name() {
- return "default";
- }
-
- @Override
- public Class extends ModuleDefine> module() {
- return TcpReceiverModule.class;
- }
-
- @Override
- public ModuleConfig createConfigBeanIfAbsent() {
- return tcpReceiverConfig;
- }
-
- @Override
- public void prepare() throws ServiceNotProvidedException, ModuleStartException {
-
- }
-
- @Override
- public void start() throws ServiceNotProvidedException, ModuleStartException {
- camelService = getManager().find(CoreModule.NAME).provider().getService(CamelContextHolderService.class);
- }
-
- @Override
- public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
- camelService.addRoutes(new TcpRouteBuilder(tcpReceiverConfig));
- }
-
- @Override
- public String[] requiredModules() {
- return new String[]{
- CoreModule.NAME
- };
- }
-}
diff --git a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpRouteBuilder.java b/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpRouteBuilder.java
deleted file mode 100644
index fe44598f..00000000
--- a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/java/com/zmops/zeus/iot/server/receiver/tcp/provider/TcpRouteBuilder.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.zmops.zeus.iot.server.receiver.tcp.provider;
-
-import com.zmops.zeus.iot.server.receiver.tcp.process.TcpPacketProcess;
-import org.apache.camel.builder.RouteBuilder;
-
-/**
- * @author nantian created at 2021/8/17 11:32
- */
-public class TcpRouteBuilder extends RouteBuilder {
-
-
- private TcpReceiverConfig tcpReceiverConfig;
-
- public TcpRouteBuilder(TcpReceiverConfig tcpReceiverConfig) {
- this.tcpReceiverConfig = tcpReceiverConfig;
- }
-
- @Override
- public void configure() throws Exception {
- fromF("netty4:tcp://0.0.0.0:%d", tcpReceiverConfig.getPort()).process(new TcpPacketProcess());
- }
-}
diff --git a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider b/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
deleted file mode 100644
index 3c5347e3..00000000
--- a/iot-server/server-receiver-plugin/tcp-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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.
-#
-#
-
-com.zmops.zeus.iot.server.receiver.tcp.provider.TcpReceiverPluginProvider
diff --git a/iot-server/server-receiver-plugin/udp-receiver-plugin/pom.xml b/iot-server/server-receiver-plugin/udp-receiver-plugin/pom.xml
deleted file mode 100644
index 21a584f3..00000000
--- a/iot-server/server-receiver-plugin/udp-receiver-plugin/pom.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- server-receiver-plugin
- com.zmops
- 1.0-beta
-
- 4.0.0
-
- udp-receiver-plugin
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/iot-server/server-sender/pom.xml b/iot-server/server-sender/pom.xml
index 64672f98..abbad98d 100644
--- a/iot-server/server-sender/pom.xml
+++ b/iot-server/server-sender/pom.xml
@@ -10,12 +10,12 @@
4.0.0server-sender
+
com.zmopslibrary-module
- 1.0-beta
- compile
+ 1.0.3-RELEASE
diff --git a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/module/ZabbixSenderModule.java b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/module/ZabbixSenderModule.java
index 5f4e63ad..565e538f 100644
--- a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/module/ZabbixSenderModule.java
+++ b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/module/ZabbixSenderModule.java
@@ -1,7 +1,7 @@
package com.zmops.zeus.iot.server.sender.module;
-import com.zmops.zeus.iot.server.library.module.ModuleDefine;
-import com.zmops.zeus.iot.server.sender.provider.service.ZabbixSenderService;
+import com.zmops.zeus.iot.server.sender.service.ZabbixSenderService;
+import com.zmops.zeus.server.library.module.ModuleDefine;
/**
* @author nantian created at 2021/8/14 14:35
diff --git a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/protocol/ZabbixSenderClient.java b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderClient.java
similarity index 80%
rename from iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/protocol/ZabbixSenderClient.java
rename to iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderClient.java
index fd3c60e6..ab708690 100644
--- a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/protocol/ZabbixSenderClient.java
+++ b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderClient.java
@@ -1,6 +1,5 @@
-package com.zmops.zeus.iot.server.sender.provider.protocol;
+package com.zmops.zeus.iot.server.sender.provider;
-import com.zmops.zeus.iot.server.sender.provider.ZabbixSenderModuleConfig;
import lombok.extern.slf4j.Slf4j;
import java.net.InetSocketAddress;
@@ -8,6 +7,8 @@
/**
* @author nantian created at 2021/8/14 14:46
+ *
+ * Zabbix 发送 Socket Client
*/
@Slf4j
@@ -23,8 +24,7 @@ public ZabbixSenderClient(ZabbixSenderModuleConfig config) {
* 启动 TCP Sender 客户端
*/
public void start() {
- log.debug("Zabbix Sender 模块已经启动,Trapper 服务地址:{}:{}",
- socketConfig.getHost(), socketConfig.getPort());
+ log.debug("Zabbix Sender 模块已经启动,Trapper 服务地址:{}:{}", socketConfig.getHost(), socketConfig.getPort());
}
@@ -41,7 +41,6 @@ public static Socket getSocket() {
} catch (Exception e) {
e.printStackTrace();
}
-
return trapperSocket;
}
}
diff --git a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderModuleConfig.java b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderModuleConfig.java
index 187e5aba..ea64e47b 100644
--- a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderModuleConfig.java
+++ b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderModuleConfig.java
@@ -1,6 +1,6 @@
package com.zmops.zeus.iot.server.sender.provider;
-import com.zmops.zeus.iot.server.library.module.ModuleConfig;
+import com.zmops.zeus.server.library.module.ModuleConfig;
import lombok.Getter;
import lombok.Setter;
diff --git a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderProvider.java b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderProvider.java
index 16e52e8c..22ef3ba6 100644
--- a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderProvider.java
+++ b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/ZabbixSenderProvider.java
@@ -1,9 +1,8 @@
package com.zmops.zeus.iot.server.sender.provider;
-import com.zmops.zeus.iot.server.library.module.*;
import com.zmops.zeus.iot.server.sender.module.ZabbixSenderModule;
-import com.zmops.zeus.iot.server.sender.provider.protocol.ZabbixSenderClient;
-import com.zmops.zeus.iot.server.sender.provider.service.ZabbixSenderService;
+import com.zmops.zeus.iot.server.sender.service.ZabbixSenderService;
+import com.zmops.zeus.server.library.module.*;
import lombok.extern.slf4j.Slf4j;
/**
diff --git a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/protocol/bean/ZabbixTrapperRequest.java b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/protocol/bean/ZabbixTrapperRequest.java
deleted file mode 100644
index e2e0e500..00000000
--- a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/protocol/bean/ZabbixTrapperRequest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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 com.zmops.zeus.iot.server.sender.provider.protocol.bean;
-
-import lombok.Data;
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.List;
-
-
-public class ZabbixTrapperRequest {
-
- /**
- * Request type
- */
- private ZabbixProtocolType type;
-
- @Setter
- @Getter
- private String request = ZabbixProtocolType.SENDER_DATA.getName();
-
- /**
- * Agent push data
- *
- * @see ZabbixProtocolType#AGENT_DATA
- */
- @Setter
- @Getter
- private List data;
-
- @Setter
- @Getter
- private long clock = System.currentTimeMillis() / 1000L;
-
- @Setter
- @Getter
- private long ns = System.nanoTime() % 1_000_000_000L;
-
- @Data
- public static class SenderData {
- private String host;
- private String key;
- private String value;
- private long clock;
- private long ns;
-
- public SenderData() {
- this.clock = System.currentTimeMillis() / 1000L;
- this.ns = System.nanoTime() % 1_000_000_000L;
- }
- }
-
-}
diff --git a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/service/ZabbixSenderService.java b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/service/ZabbixSenderService.java
similarity index 65%
rename from iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/service/ZabbixSenderService.java
rename to iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/service/ZabbixSenderService.java
index f3a6ec5a..8b4ccf93 100644
--- a/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/provider/service/ZabbixSenderService.java
+++ b/iot-server/server-sender/src/main/java/com/zmops/zeus/iot/server/sender/service/ZabbixSenderService.java
@@ -1,9 +1,9 @@
-package com.zmops.zeus.iot.server.sender.provider.service;
+package com.zmops.zeus.iot.server.sender.service;
import com.google.gson.Gson;
-import com.zmops.zeus.iot.server.library.module.ModuleManager;
-import com.zmops.zeus.iot.server.library.module.Service;
-import com.zmops.zeus.iot.server.sender.provider.protocol.ZabbixSenderClient;
+import com.zmops.zeus.iot.server.sender.provider.ZabbixSenderClient;
+import com.zmops.zeus.server.library.module.ModuleManager;
+import com.zmops.zeus.server.library.module.Service;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
@@ -31,11 +31,30 @@ public ZabbixSenderService(ModuleManager moduleManager) {
this.moduleManager = moduleManager;
}
+ /**
+ * 指定格式的 JSON
+ *
+ * @param message see
+ * https://www.zabbix.com/documentation/current/manual/appendix/items/trapper
+ *
+ * {
+ * "request":"sender data",
+ * "data":[
+ * {
+ * "host":"device.info",
+ * "key":"device.temp",
+ * "value":"86"
+ * }
+ * ]
+ * }
+ * @return String
+ * @throws IOException ex
+ */
public String sendData(String message) throws IOException {
Socket trapperSocket = ZabbixSenderClient.getSocket();
- int payloadLength = message.length();
+ int payloadLength = length(message);
byte[] header = new byte[]{
'Z', 'B', 'X', 'D', '\1',
(byte) (payloadLength & 0xFF),
@@ -61,7 +80,8 @@ public String sendData(String message) throws IOException {
StringBuilder resp = new StringBuilder();
int headLength = 13;
- int bRead = 0;
+ int bRead = 0;
+
while (true) {
bRead = resStream.read(response);
if (bRead <= 0) break;
@@ -87,19 +107,41 @@ public String sendData(String message) throws IOException {
* @return String
*/
private String zabbixResponseToMap(String resp) {
-
Map result = gson.fromJson(resp, Map.class);
- String[] infos = result.get("info").split(";");
- Map resultMap = new HashMap<>();
+ String info = result.get("info");
+ if (info == null) {
+ return resp;
+ }
+ String[] infos = info.split(";");
+
+ Map resultMap = new HashMap<>();
for (String i : infos) {
String[] ii = i.split(":");
resultMap.put(ii[0].trim(), ii[1]);
}
resultMap.put("response", result.get("response"));
-
return gson.toJson(resultMap);
}
+
+ /**
+ * 计算字符串长度 中文3个字节
+ * @param value
+ * @return
+ */
+ public static int length(String value) {
+ int valueLength = 0;
+ String chinese = "[\u0391-\uFFE5]";
+ for (int i = 0; i < value.length(); i++) {
+ String temp = value.substring(i, i + 1);
+ if (temp.matches(chinese)) {
+ valueLength += 3;
+ } else {
+ valueLength += 1;
+ }
+ }
+ return valueLength;
+ }
}
diff --git a/iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleDefine b/iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleDefine
similarity index 100%
rename from iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleDefine
rename to iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleDefine
diff --git a/iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider b/iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
similarity index 100%
rename from iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
rename to iot-server/server-sender/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
diff --git a/iot-server/server-starter/conf/ark/bootstrap.properties b/iot-server/server-starter/conf/ark/bootstrap.properties
new file mode 100644
index 00000000..c3d121ec
--- /dev/null
+++ b/iot-server/server-starter/conf/ark/bootstrap.properties
@@ -0,0 +1,5 @@
+logging.path=./logs
+
+#com.alipay.sofa.ark.master.biz=server-starter
+
+com.alipay.sofa.ark.master.biz=Startup In IDE
\ No newline at end of file
diff --git a/iot-server/server-starter/pom.xml b/iot-server/server-starter/pom.xml
index 3361d93e..dad2bf41 100644
--- a/iot-server/server-starter/pom.xml
+++ b/iot-server/server-starter/pom.xml
@@ -9,6 +9,11 @@
4.0.0
+
+ 1.11.0
+ ./src/main/webapp/assets
+
+
server-starter
@@ -22,11 +27,80 @@
server-health-checker1.0-beta
+
+
+ com.zmops
+ runtime-server-plugin
+ 1.0.3-RELEASE
+
+
+ ch.qos.logback
+ logback-classic
+
+
+
+
+
+ com.alipay.sofa
+ sofa-ark-support-starter
+ 1.1.6
+
+
+ ch.qos.logback
+ logback-classic
+
+
+ ch.qos.logback
+ logback-core
+
+
+ com.alipay.sofa
+ log-sofa-boot-starter
+
+
+
+
-
- 8
- 8
-
+
+ iot-server
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ assembly
+ package
+
+ single
+
+
+
+ src/main/assembly/assembly.xml
+
+
+
+
+
+
+ com.alipay.sofa
+ sofa-ark-maven-plugin
+ 1.1.6
+
+
+
+ repackage
+
+
+ server-starter
+ ./target
+ executable-ark
+
+
+
+
+
+
\ No newline at end of file
diff --git a/iot-server/server-starter/src/main/assembly/assembly.xml b/iot-server/server-starter/src/main/assembly/assembly.xml
new file mode 100644
index 00000000..7281a1e6
--- /dev/null
+++ b/iot-server/server-starter/src/main/assembly/assembly.xml
@@ -0,0 +1,33 @@
+
+
+
+ assembly
+
+ dir
+
+
+
+ /libs
+ runtime
+
+
+
\ No newline at end of file
diff --git a/iot-server/server-starter/src/main/java/com/zmops/zeus/iot/server/starter/IOTServerStartUp.java b/iot-server/server-starter/src/main/java/com/zmops/zeus/iot/server/starter/IOTServerStartUp.java
deleted file mode 100644
index d5ba30b9..00000000
--- a/iot-server/server-starter/src/main/java/com/zmops/zeus/iot/server/starter/IOTServerStartUp.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.zmops.zeus.iot.server.starter;
-
-/**
- * @author nantian created at 2021/8/13 15:26
- *
- * 宙斯服务 协议层启动
- */
-public class IOTServerStartUp {
-
- public static void main(String[] args) {
- IOTServerBootstrap.start();
- }
-}
diff --git a/iot-server/server-starter/src/main/java/com/zmops/zeus/iot/server/starter/IoTServerStartUp.java b/iot-server/server-starter/src/main/java/com/zmops/zeus/iot/server/starter/IoTServerStartUp.java
new file mode 100644
index 00000000..b3435976
--- /dev/null
+++ b/iot-server/server-starter/src/main/java/com/zmops/zeus/iot/server/starter/IoTServerStartUp.java
@@ -0,0 +1,20 @@
+package com.zmops.zeus.iot.server.starter;
+
+import com.alipay.sofa.ark.support.startup.SofaArkBootstrap;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @author nantian created at 2021/8/13 15:26
+ *
+ * 宙斯服务 协议层启动
+ */
+@Slf4j
+public class IoTServerStartUp {
+
+ public static void main(String[] args) {
+ SofaArkBootstrap.launch(args);
+ IoTServerBootstrap.start();
+
+ log.info("IoT Server Platform start successfully ...");
+ }
+}
diff --git a/iot-server/server-library/pom.xml b/iot-server/server-storage-plugin/pom.xml
similarity index 78%
rename from iot-server/server-library/pom.xml
rename to iot-server/server-storage-plugin/pom.xml
index cb2a1dad..331985d7 100644
--- a/iot-server/server-library/pom.xml
+++ b/iot-server/server-storage-plugin/pom.xml
@@ -9,12 +9,12 @@
4.0.0
- server-library
+ server-storage-pluginpom
- library-module
- library-util
- library-server
+ server-tdengine-plugin
+ server-influxdb-plugin
+ server-none-storage
diff --git a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/pom.xml b/iot-server/server-storage-plugin/server-influxdb-plugin/pom.xml
similarity index 76%
rename from iot-server/server-receiver-plugin/mqtt-receiver-plugin/pom.xml
rename to iot-server/server-storage-plugin/server-influxdb-plugin/pom.xml
index a5f2b571..cba1a098 100644
--- a/iot-server/server-receiver-plugin/mqtt-receiver-plugin/pom.xml
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/pom.xml
@@ -3,35 +3,35 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- server-receiver-plugin
+ server-storage-plugincom.zmops1.0-beta4.0.0
- mqtt-receiver-plugin
+ server-influxdb-plugin88
-
- org.apache.camel
- camel-mqtt
- ${camel.version}
+ org.influxdb
+ influxdb-java
+ 2.15com.zmopslibrary-module
- ${project.version}
+ 1.0.3-RELEASEcom.zmopsserver-core
- 1.0-beta
+ ${project.version}
+
\ No newline at end of file
diff --git a/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxClient.java b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxClient.java
new file mode 100644
index 00000000..91f22ed9
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxClient.java
@@ -0,0 +1,239 @@
+/*
+ * 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 com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb;
+
+
+import com.zmops.zeus.iot.server.client.Client;
+import com.zmops.zeus.iot.server.client.healthcheck.DelegatedHealthChecker;
+import com.zmops.zeus.iot.server.client.healthcheck.HealthCheckable;
+import com.zmops.zeus.server.library.util.CollectionUtils;
+import com.zmops.zeus.server.library.util.HealthChecker;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.OkHttpClient;
+
+import org.influxdb.InfluxDB;
+import org.influxdb.InfluxDBFactory;
+import org.influxdb.dto.BatchPoints;
+import org.influxdb.dto.Point;
+import org.influxdb.dto.Query;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.time.TimeInterval;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.ti;
+
+/**
+ * InfluxDB connection maintainer, provides base data write/query API.
+ */
+@Slf4j
+public class InfluxClient implements Client, HealthCheckable {
+ private final DelegatedHealthChecker healthChecker = new DelegatedHealthChecker();
+ private final InfluxStorageConfig config;
+ private InfluxDB influx;
+ /**
+ * A constant, the name of time field in Time-series database.
+ */
+ public static final String TIME = "time";
+
+ private final String database;
+
+ public InfluxClient(InfluxStorageConfig config) {
+ this.config = config;
+ this.database = config.getDatabase();
+ }
+
+ public final String getDatabase() {
+ return database;
+ }
+
+ @Override
+ public void connect() {
+ try {
+ InfluxDB.ResponseFormat responseFormat = InfluxDB.ResponseFormat.valueOf(config.getConnectionResponseFormat());
+ influx = InfluxDBFactory.connect(config.getUrl(), config.getUser(), config.getPassword(),
+ new OkHttpClient.Builder().readTimeout(3, TimeUnit.MINUTES)
+ .writeTimeout(3, TimeUnit.MINUTES),
+ responseFormat
+ );
+ influx.query(new Query("CREATE DATABASE " + database));
+ influx.enableGzip();
+
+ if (config.isBatchEnabled()) {
+ influx.enableBatch(config.getActions(), config.getDuration(), TimeUnit.MILLISECONDS);
+ }
+
+ influx.setDatabase(database);
+ healthChecker.health();
+ } catch (Throwable e) {
+ healthChecker.unHealth(e);
+ throw e;
+ }
+ }
+
+ /**
+ * To get a connection of InfluxDB.
+ *
+ * @return InfluxDB's connection
+ */
+ private InfluxDB getInflux() {
+ return influx;
+ }
+
+ /**
+ * Execute a query against InfluxDB and return a set of {@link QueryResult.Result}s. Normally, InfluxDB supports
+ * combining multiple statements into one query, so that we do get multi-results.
+ *
+ * @throws IOException if there is an error on the InfluxDB server or communication error.
+ */
+ public List query(Query query) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("SQL Statement: {}", query.getCommand());
+ }
+ try {
+ QueryResult result = getInflux().query(new Query(query.getCommand()));
+ if (result.hasError()) {
+ throw new IOException(result.getError());
+ }
+ healthChecker.health();
+ return result.getResults();
+ } catch (Throwable e) {
+ healthChecker.unHealth(e);
+ throw new IOException(e.getMessage() + System.lineSeparator() + "SQL Statement: " + query.getCommand(), e);
+ }
+ }
+
+ /**
+ * Execute a query against InfluxDB with a single statement.
+ *
+ * @throws IOException if there is an error on the InfluxDB server or communication error
+ */
+ public List queryForSeries(Query query) throws IOException {
+ List results = query(query);
+
+ if (CollectionUtils.isEmpty(results)) {
+ return null;
+ }
+ return results.get(0).getSeries();
+ }
+
+ /**
+ * Execute a query against InfluxDB with a single statement but return a single {@link QueryResult.Series}.
+ *
+ * @throws IOException if there is an error on the InfluxDB server or communication error
+ */
+ public QueryResult.Series queryForSingleSeries(Query query) throws IOException {
+ List series = queryForSeries(query);
+ if (CollectionUtils.isEmpty(series)) {
+ return null;
+ }
+ return series.get(0);
+ }
+
+ /**
+ * Execute a query against InfluxDB with a `select count(*)` statement and return the count only.
+ *
+ * @throws IOException if there is an error on the InfluxDB server or communication error
+ */
+ public int getCounter(Query query) throws IOException {
+ QueryResult.Series series = queryForSingleSeries(query);
+ if (log.isDebugEnabled()) {
+ log.debug("SQL: {} result: {}", query.getCommand(), series);
+ }
+ if (Objects.isNull(series)) {
+ return 0;
+ }
+ return ((Number) series.getValues().get(0).get(1)).intValue();
+ }
+
+ /**
+ * Data management, to drop a time-series by measurement and time-series name specified. If an exception isn't
+ * thrown, it means execution success. Notice, drop series don't support to drop series by range
+ *
+ * @throws IOException if there is an error on the InfluxDB server or communication error
+ */
+ public void dropSeries(String measurement, long timeBucket) throws IOException {
+ Query query = new Query("DROP SERIES FROM " + measurement + " WHERE time_bucket='" + timeBucket + "'");
+ this.query(query);
+ }
+
+ public void deleteByQuery(String measurement, long timestamp) throws IOException {
+ this.query(new Query("delete from " + measurement + " where time < " + timestamp + "ms"));
+ }
+
+ /**
+ * Write a {@link Point} into InfluxDB. Note that, the {@link Point} is written into buffer of InfluxDB Client and
+ * wait for buffer flushing.
+ */
+ public void write(Point point) {
+ try {
+ getInflux().write(point);
+ this.healthChecker.health();
+ } catch (Throwable e) {
+ healthChecker.unHealth(e);
+ throw e;
+ }
+ }
+
+ /**
+ * A batch operation of write. {@link Point}s flush directly.
+ */
+ public void write(BatchPoints points) {
+ try {
+ getInflux().write(points);
+ this.healthChecker.health();
+ } catch (Throwable e) {
+ healthChecker.unHealth(e);
+ throw e;
+ }
+ }
+
+ @Override
+ public void shutdown() throws IOException {
+ try {
+ getInflux().close();
+ this.healthChecker.health();
+ } catch (Throwable e) {
+ healthChecker.unHealth(e);
+ throw new IOException(e);
+ }
+ }
+
+ /**
+ * Convert to InfluxDB {@link TimeInterval}.
+ */
+ public static TimeInterval timeIntervalTS(long timestamp) {
+ return ti(timestamp, "ms");
+ }
+
+// /**
+// * Convert to InfluxDB {@link TimeInterval}.
+// */
+// public static TimeInterval timeIntervalTB(long timeBucket) {
+// return ti(TimeBucket.getTimestamp(timeBucket), "ms");
+// }
+
+ @Override
+ public void registerChecker(HealthChecker healthChecker) {
+ this.healthChecker.register(healthChecker);
+ }
+}
diff --git a/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxStorageConfig.java b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxStorageConfig.java
new file mode 100644
index 00000000..0e2922c8
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxStorageConfig.java
@@ -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.
+ *
+ */
+
+package com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb;
+
+import com.zmops.zeus.server.library.module.ModuleConfig;
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class InfluxStorageConfig extends ModuleConfig {
+ private String url = "";
+ private String user = "";
+ private String password = "";
+ private String database = "";
+
+ private int actions;
+ private int duration;
+ private boolean batchEnabled = true;
+
+ private int fetchTaskLogMaxSize = 5000;
+ private String connectionResponseFormat = "MSGPACK";
+}
diff --git a/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxStorageProvider.java b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxStorageProvider.java
new file mode 100644
index 00000000..c14655cf
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/InfluxStorageProvider.java
@@ -0,0 +1,88 @@
+/*
+ * 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 com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb;
+
+import com.zmops.zeus.iot.server.core.CoreModule;
+import com.zmops.zeus.iot.server.core.storage.IBatchDAO;
+import com.zmops.zeus.iot.server.core.storage.StorageDAO;
+import com.zmops.zeus.iot.server.core.storage.StorageModule;
+import com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.dao.BatchDAO;
+import com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.dao.InfluxStorageDAO;
+import com.zmops.zeus.iot.server.telemetry.TelemetryModule;
+import com.zmops.zeus.iot.server.telemetry.api.HealthCheckMetrics;
+import com.zmops.zeus.iot.server.telemetry.api.MetricsCreator;
+import com.zmops.zeus.iot.server.telemetry.api.MetricsTag;
+import com.zmops.zeus.server.library.module.*;
+import lombok.extern.slf4j.Slf4j;
+
+
+@Slf4j
+public class InfluxStorageProvider extends ModuleProvider {
+ private final InfluxStorageConfig config;
+ private InfluxClient client;
+
+ public InfluxStorageProvider() {
+ config = new InfluxStorageConfig();
+ }
+
+ @Override
+ public String name() {
+ return "influxdb";
+ }
+
+ @Override
+ public Class extends ModuleDefine> module() {
+ return StorageModule.class;
+ }
+
+ @Override
+ public ModuleConfig createConfigBeanIfAbsent() {
+ return config;
+ }
+
+ @Override
+ public void prepare() throws ServiceNotProvidedException {
+
+ client = new InfluxClient(config);
+
+ this.registerServiceImplementation(IBatchDAO.class, new BatchDAO(client));
+ this.registerServiceImplementation(StorageDAO.class, new InfluxStorageDAO(client));
+
+ }
+
+ @Override
+ public void start() throws ServiceNotProvidedException, ModuleStartException {
+ MetricsCreator metricCreator = getManager().find(TelemetryModule.NAME).provider().getService(MetricsCreator.class);
+ HealthCheckMetrics healthChecker = metricCreator.createHealthCheckerGauge(
+ "storage_influxdb", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE);
+
+ client.registerChecker(healthChecker);
+ client.connect();
+ }
+
+ @Override
+ public void notifyAfterCompleted() throws ServiceNotProvidedException {
+
+ }
+
+ @Override
+ public String[] requiredModules() {
+ return new String[]{CoreModule.NAME};
+ }
+}
diff --git a/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/BatchDAO.java b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/BatchDAO.java
new file mode 100644
index 00000000..0dc3786d
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/BatchDAO.java
@@ -0,0 +1,61 @@
+/*
+ * 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 com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.dao;
+
+import com.zmops.zeus.iot.server.client.request.InsertRequest;
+import com.zmops.zeus.iot.server.client.request.PrepareRequest;
+import com.zmops.zeus.iot.server.core.storage.IBatchDAO;
+import com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.InfluxClient;
+import com.zmops.zeus.server.library.util.CollectionUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.influxdb.dto.BatchPoints;
+
+import java.util.List;
+
+@Slf4j
+public class BatchDAO implements IBatchDAO {
+ private final InfluxClient client;
+
+ public BatchDAO(InfluxClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public void insert(InsertRequest insertRequest) {
+ client.write(((InfluxInsertRequest) insertRequest).getPoint());
+ }
+
+ @Override
+ public void flush(List prepareRequests) {
+ if (CollectionUtils.isEmpty(prepareRequests)) {
+ return;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("batch sql statements execute, data size: {}", prepareRequests.size());
+ }
+
+ final BatchPoints.Builder builder = BatchPoints.builder();
+ prepareRequests.forEach(e -> {
+ builder.point(((InfluxInsertRequest) e).getPoint());
+ });
+
+ client.write(builder.build());
+ }
+}
diff --git a/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/InfluxInsertRequest.java b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/InfluxInsertRequest.java
new file mode 100644
index 00000000..cd7b243d
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/InfluxInsertRequest.java
@@ -0,0 +1,77 @@
+/*
+ * 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 com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.dao;
+
+import com.google.common.collect.Maps;
+import com.zmops.zeus.iot.server.client.request.InsertRequest;
+import com.zmops.zeus.iot.server.core.analysis.manual.history.History;
+import com.zmops.zeus.iot.server.core.analysis.manual.history.UIntHistory;
+import com.zmops.zeus.iot.server.core.storage.StorageData;
+import com.zmops.zeus.iot.server.core.storage.model.Model;
+import org.influxdb.dto.Point;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * InfluxDB Point wrapper.
+ */
+public class InfluxInsertRequest implements InsertRequest {
+ private final Point.Builder builder;
+ private final Map fields = Maps.newHashMap();
+
+ public InfluxInsertRequest(Model model, T storageData) {
+ String deviceid = "";
+ Integer itemid = 0;
+ String value = "";
+ Long time = 0L;
+
+ if (model.getName().equals("history")) {
+
+ History history = (History) storageData;
+ deviceid = history.getDeviceId();
+ itemid = history.getItemid();
+ value = history.getValue();
+ time = history.getClock();
+ fields.put("value", Double.parseDouble(value));
+ } else {
+ UIntHistory uihistory = (UIntHistory) storageData;
+ deviceid = uihistory.getDeviceId();
+ itemid = uihistory.getItemid();
+ value = uihistory.getValue();
+ time = uihistory.getClock();
+ fields.put("value", Long.parseLong(value));
+ }
+
+ builder = Point.measurement("h_" + itemid)
+ .fields(fields);
+ builder.tag("deviceid", deviceid);
+ builder.tag("itemid", itemid + "");
+ builder.time(time, TimeUnit.NANOSECONDS);
+ }
+
+ public InfluxInsertRequest time(long time, TimeUnit unit) {
+ builder.time(time, unit);
+ return this;
+ }
+
+ public Point getPoint() {
+ return builder.build();
+ }
+}
\ No newline at end of file
diff --git a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/server/JettyHandlerRegisterImpl.java b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/InfluxStorageDAO.java
similarity index 61%
rename from iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/server/JettyHandlerRegisterImpl.java
rename to iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/InfluxStorageDAO.java
index 24709ad6..0dda6bc4 100644
--- a/iot-server/server-core/src/main/java/com/zmops/zeus/iot/server/core/server/JettyHandlerRegisterImpl.java
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/InfluxStorageDAO.java
@@ -16,21 +16,24 @@
*
*/
-package com.zmops.zeus.iot.server.core.server;
+package com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.dao;
-import com.zmops.zeus.iot.server.library.server.jetty.JettyHandler;
-import com.zmops.zeus.iot.server.library.server.jetty.JettyServer;
-public class JettyHandlerRegisterImpl implements JettyHandlerRegister {
+import com.zmops.zeus.iot.server.core.storage.IRecordDAO;
+import com.zmops.zeus.iot.server.core.storage.StorageDAO;
+import com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.InfluxClient;
- private final JettyServer server;
+public class InfluxStorageDAO implements StorageDAO {
+ private final InfluxClient influxClient;
- public JettyHandlerRegisterImpl(JettyServer server) {
- this.server = server;
+ public InfluxStorageDAO(InfluxClient influxClient) {
+ this.influxClient = influxClient;
}
+
@Override
- public void addHandler(JettyHandler serverHandler) {
- server.addHandler(serverHandler);
+ public IRecordDAO newRecordDao() {
+ return new RecordDAO();
}
+
}
diff --git a/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/RecordDAO.java b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/RecordDAO.java
new file mode 100644
index 00000000..b6e78115
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/influxdb/dao/RecordDAO.java
@@ -0,0 +1,45 @@
+/*
+ * 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 com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.dao;
+
+import com.zmops.zeus.iot.server.client.request.InsertRequest;
+import com.zmops.zeus.iot.server.core.analysis.record.Record;
+import com.zmops.zeus.iot.server.core.storage.IRecordDAO;
+import com.zmops.zeus.iot.server.core.storage.model.Model;
+import com.zmops.zeus.server.datacarrier.common.AtomicRangeInteger;
+
+
+public class RecordDAO implements IRecordDAO {
+ private static final int PADDING_SIZE = 1_000_000;
+ private static final AtomicRangeInteger SUFFIX = new AtomicRangeInteger(0, PADDING_SIZE);
+
+ public RecordDAO() {
+
+ }
+
+ @Override
+ public InsertRequest prepareBatchInsert(Model model, Record record) {
+
+ final InfluxInsertRequest request = new InfluxInsertRequest(model, record);
+
+ return request;
+ }
+
+
+}
diff --git a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
similarity index 91%
rename from iot-server/server-receiver-plugin/http-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
rename to iot-server/server-storage-plugin/server-influxdb-plugin/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
index e905c432..ca65a35b 100644
--- a/iot-server/server-receiver-plugin/http-receiver-plugin/src/main/resources/META-INF/services/com.zmops.zeus.iot.server.library.module.ModuleProvider
+++ b/iot-server/server-storage-plugin/server-influxdb-plugin/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
@@ -16,4 +16,5 @@
#
#
-com.zmops.zeus.iot.server.receiver.http.provider.HttpReceiverPluginProvider
+
+com.zmops.zeus.iot.server.storage.plugin.jdbc.influxdb.InfluxStorageProvider
\ No newline at end of file
diff --git a/iot-server/server-library/library-util/pom.xml b/iot-server/server-storage-plugin/server-none-storage/pom.xml
similarity index 68%
rename from iot-server/server-library/library-util/pom.xml
rename to iot-server/server-storage-plugin/server-none-storage/pom.xml
index 4e9c86fb..69aca8e2 100644
--- a/iot-server/server-library/library-util/pom.xml
+++ b/iot-server/server-storage-plugin/server-none-storage/pom.xml
@@ -3,26 +3,29 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- server-library
+ server-storage-plugincom.zmops1.0-beta
- ../pom.xml4.0.0
- library-util
-
-
- 8
- 8
-
-
+ server-none-storagecom.zmops
- iot-util
+ library-module
+ 1.0.3-RELEASE
+
+
+ com.zmops
+ server-core${project.version}
+
+ 8
+ 8
+
+
\ No newline at end of file
diff --git a/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/BatchDaoNoop.java b/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/BatchDaoNoop.java
new file mode 100644
index 00000000..8b54a14c
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/BatchDaoNoop.java
@@ -0,0 +1,23 @@
+package com.zmops.zeus.iot.server.storage.plugin.none;
+
+import com.zmops.zeus.iot.server.core.storage.IBatchDAO;
+import com.zmops.zeus.iot.server.client.request.InsertRequest;
+import com.zmops.zeus.iot.server.client.request.PrepareRequest;
+
+import java.util.List;
+
+/**
+ * @author nantian created at 2021/9/27 21:28
+ */
+public class BatchDaoNoop implements IBatchDAO {
+
+ @Override
+ public void insert(InsertRequest insertRequest) {
+
+ }
+
+ @Override
+ public void flush(List prepareRequests) {
+
+ }
+}
diff --git a/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/NoneStorageProvider.java b/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/NoneStorageProvider.java
new file mode 100644
index 00000000..a5259673
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/NoneStorageProvider.java
@@ -0,0 +1,52 @@
+package com.zmops.zeus.iot.server.storage.plugin.none;
+
+import com.zmops.zeus.iot.server.core.storage.IBatchDAO;
+import com.zmops.zeus.iot.server.core.storage.StorageDAO;
+import com.zmops.zeus.iot.server.core.storage.StorageModule;
+import com.zmops.zeus.server.library.module.*;
+
+/**
+ * @author nantian created at 2021/9/27 21:18
+ *
+ * Proxy 模式下,或者 不使用默认的 TDEngine 时
+ */
+public class NoneStorageProvider extends ModuleProvider {
+ @Override
+ public String name() {
+ return "none";
+ }
+
+ @Override
+ public Class extends ModuleDefine> module() {
+ return StorageModule.class;
+ }
+
+ @Override
+ public ModuleConfig createConfigBeanIfAbsent() {
+ return new ModuleConfig() {
+ };
+ }
+
+ @Override
+ public void prepare() throws ServiceNotProvidedException, ModuleStartException {
+
+ this.registerServiceImplementation(IBatchDAO.class, new BatchDaoNoop());
+ this.registerServiceImplementation(StorageDAO.class, new StorageDAONoop());
+
+ }
+
+ @Override
+ public void start() throws ServiceNotProvidedException, ModuleStartException {
+
+ }
+
+ @Override
+ public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
+
+ }
+
+ @Override
+ public String[] requiredModules() {
+ return new String[0];
+ }
+}
diff --git a/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/StorageDAONoop.java b/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/StorageDAONoop.java
new file mode 100644
index 00000000..8828c327
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-none-storage/src/main/java/com/zmops/zeus/iot/server/storage/plugin/none/StorageDAONoop.java
@@ -0,0 +1,15 @@
+package com.zmops.zeus.iot.server.storage.plugin.none;
+
+import com.zmops.zeus.iot.server.core.storage.IRecordDAO;
+import com.zmops.zeus.iot.server.core.storage.StorageDAO;
+
+/**
+ * @author nantian created at 2021/9/27 21:29
+ */
+public class StorageDAONoop implements StorageDAO {
+
+ @Override
+ public IRecordDAO newRecordDao() {
+ return null;
+ }
+}
diff --git a/iot-server/server-storage-plugin/server-none-storage/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider b/iot-server/server-storage-plugin/server-none-storage/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
new file mode 100644
index 00000000..e6a4eba8
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-none-storage/src/main/resources/META-INF/services/com.zmops.zeus.server.library.module.ModuleProvider
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+com.zmops.zeus.iot.server.storage.plugin.none.NoneStorageProvider
diff --git a/iot-server/server-receiver-plugin/tcp-receiver-plugin/pom.xml b/iot-server/server-storage-plugin/server-tdengine-plugin/pom.xml
similarity index 63%
rename from iot-server/server-receiver-plugin/tcp-receiver-plugin/pom.xml
rename to iot-server/server-storage-plugin/server-tdengine-plugin/pom.xml
index bcd2a5f5..32f4c3a5 100644
--- a/iot-server/server-receiver-plugin/tcp-receiver-plugin/pom.xml
+++ b/iot-server/server-storage-plugin/server-tdengine-plugin/pom.xml
@@ -3,43 +3,35 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- server-receiver-plugin
+ server-storage-plugincom.zmops1.0-beta4.0.0
- tcp-receiver-plugin
+ server-tdengine-plugin
+
+ 8
+ 8
+
- org.apache.camel
- camel-netty4
- ${camel.version}
-
-
- io.netty
- netty-example
-
-
+ com.taosdata.jdbc
+ taos-jdbcdriver
+ 2.0.32com.zmopslibrary-module
- ${project.version}
+ 1.0.3-RELEASEcom.zmopsserver-core1.0-beta
- compile
-
- 8
- 8
-
-
\ No newline at end of file
diff --git a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/partition/ProducerThreadPartitioner.java b/iot-server/server-storage-plugin/server-tdengine-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/SQLBuilder.java
similarity index 54%
rename from iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/partition/ProducerThreadPartitioner.java
rename to iot-server/server-storage-plugin/server-tdengine-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/SQLBuilder.java
index 80a5a08c..1538d792 100644
--- a/iot-common/iot-datacarrier/src/main/java/com/zmops/zeus/iot/server/datacarrier/partition/ProducerThreadPartitioner.java
+++ b/iot-server/server-storage-plugin/server-tdengine-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/SQLBuilder.java
@@ -16,22 +16,41 @@
*
*/
-package com.zmops.zeus.iot.server.datacarrier.partition;
+package com.zmops.zeus.iot.server.storage.plugin.jdbc;
/**
- * use threadid % total to partition
+ * SQLBuilder
*/
-public class ProducerThreadPartitioner implements IDataPartitioner {
- public ProducerThreadPartitioner() {
+public class SQLBuilder {
+ private static String LINE_END = System.lineSeparator();
+
+ private StringBuilder text;
+
+ public SQLBuilder() {
+ this.text = new StringBuilder();
}
- @Override
- public int partition(int total, T data) {
- return (int) Thread.currentThread().getId() % total;
+ public SQLBuilder(String initLine) {
+ this();
+ this.appendLine(initLine);
+ }
+
+ public SQLBuilder append(String fragment) {
+ text.append(fragment);
+ return this;
+ }
+
+ public SQLBuilder appendLine(String line) {
+ text.append(line).append(LINE_END);
+ return this;
+ }
+
+ public String toStringInNewLine() {
+ return LINE_END + toString();
}
@Override
- public int maxRetryCount() {
- return 1;
+ public String toString() {
+ return text.toString();
}
}
diff --git a/iot-server/server-storage-plugin/server-tdengine-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/SQLExecutor.java b/iot-server/server-storage-plugin/server-tdengine-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/SQLExecutor.java
new file mode 100644
index 00000000..9eefa240
--- /dev/null
+++ b/iot-server/server-storage-plugin/server-tdengine-plugin/src/main/java/com/zmops/zeus/iot/server/storage/plugin/jdbc/SQLExecutor.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.zmops.zeus.iot.server.storage.plugin.jdbc;
+
+import com.zmops.zeus.iot.server.client.request.InsertRequest;
+import lombok.Getter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * A SQL executor.
+ */
+public class SQLExecutor implements InsertRequest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SQLExecutor.class);
+
+ @Getter
+ private final String sql;
+ private final List