This is an automated email from the ASF dual-hosted git repository. yuanbo pushed a commit to branch TUBEMQ-469 in repository https://gitbox.apache.org/repos/asf/incubator-tubemq.git
commit 5967037702d800569e21874305cdc28cf9de55a7 Author: gosonzhang <[email protected]> AuthorDate: Sun Feb 14 09:50:22 2021 +0800 [TUBEMQ-559] Update the LICENSE file according to the 0.8.0-RC2 review (#427) Co-authored-by: gosonzhang <[email protected]> --- LICENSE | 255 +++++++++++++++---- pom.xml | 1 - tubemq-connectors/tubemq-connector-flume/pom.xml | 2 +- tubemq-manager/READMe.md | 51 ---- tubemq-manager/bin/start-manager.sh | 66 ----- tubemq-manager/bin/stop-manager.sh | 37 --- tubemq-manager/conf/logback.xml | 67 ----- tubemq-manager/pom.xml | 130 ---------- tubemq-manager/src/main/assembly/assembly.xml | 64 ----- .../org/apache/tubemq/manager/TubeMQManager.java | 59 ----- .../controller/ManagerControllerAdvice.java | 41 ---- .../tubemq/manager/controller/TubeResult.java | 27 -- .../controller/cluster/ClusterController.java | 128 ---------- .../manager/controller/topic/TopicController.java | 126 ---------- .../org/apache/tubemq/manager/entry/NodeEntry.java | 51 ---- .../apache/tubemq/manager/entry/TopicEntry.java | 137 ----------- .../apache/tubemq/manager/entry/TopicStatus.java | 33 --- .../manager/exceptions/TubeMQManagerException.java | 28 --- .../tubemq/manager/repository/NodeRepository.java | 28 --- .../tubemq/manager/repository/TopicRepository.java | 43 ---- .../apache/tubemq/manager/service/NodeService.java | 272 --------------------- .../tubemq/manager/service/TopicBackendWorker.java | 137 ----------- .../apache/tubemq/manager/service/TopicFuture.java | 58 ----- .../tubemq/manager/service/TubeHttpConst.java | 30 --- .../service/tube/TubeHttpBrokerInfoList.java | 135 ---------- .../manager/service/tube/TubeHttpResponse.java | 30 --- .../service/tube/TubeHttpTopicInfoList.java | 97 -------- .../src/main/resources/application.properties | 17 -- .../manager/controller/TestBusinessController.java | 99 -------- .../manager/controller/TestClusterController.java | 150 ------------ .../manager/repository/TestBusinessRepository.java | 67 ----- .../service/tube/TestTubeHttpBrokerResponse.java | 48 ---- .../service/tube/TestTubeHttpTopicInfoList.java | 52 ---- 33 files changed, 207 insertions(+), 2359 deletions(-) diff --git a/LICENSE b/LICENSE index 744f075..7ef57fd 100644 --- a/LICENSE +++ b/LICENSE @@ -208,11 +208,11 @@ 1. Third party MIT license licenses ========= -The following components are provided under the MIT license. +1.1 The following modified/copied source files are provided under the MIT license. ---- -1.1 resources/assets/lib/jquery.min.js +1.1.1 resources/assets/lib/jquery.min.js Source : jquery 1.11.3 License : https://github.com/jquery/jquery/blob/1.11.3/MIT-LICENSE.txt @@ -240,7 +240,7 @@ The following components are provided under the MIT license. ---- -1.2 resources/assets/lib/DataTables/* +1.1.2 resources/assets/lib/DataTables/* Source : datatables 1.10.7 License : https://github.com/DataTables/DataTables/blob/1.10.7/license.txt @@ -265,18 +265,33 @@ The following components are provided under the MIT license. | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | THE SOFTWARE. +------------------ + +1.2 The following binary dependency packages are provided under the MIT license. + ---- +1.2.1 org.slf4j:slf4j-api + org.slf4j:slf4j-log4j12 + Version : 1.6.2 + License : For details, see https://github.com/qos-ch/slf4j/blob/master/LICENSE.txt + +1.2.1 org.mockito:mockito-all:1.9.0 + org.mockito:mockito-core:2.18.0 + License : For details, see https://github.com/mockito/mockito/blob/release/1.x/LICENSE + https://github.com/mockito/mockito/blob/release/2.x/LICENSE + + ========= 2. Third party BSD 3-Clause license ========= -The following components are provided under the BSD 3-Clause license. +2.1 The following modified/copied source files are provided under the BSD 3-Clause license. ---- -2.1 tubemq-client-twins/tubemq-client-cpp/src/any.h - tubemq-client-twins/tubemq-client-cpp/src/buffer.h +2.1.1 tubemq-client-twins/tubemq-client-cpp/src/any.h + tubemq-client-twins/tubemq-client-cpp/src/buffer.h Source : https://github.com/Qihoo360/evpp/blob/master/evpp/any.h version c5038a6 https://github.com/Qihoo360/evpp/blob/master/evpp/buffer.h version b2535d7 License : https://github.com/Qihoo360/evpp/blob/master/LICENSE @@ -311,67 +326,208 @@ The following components are provided under the BSD 3-Clause license. | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +------------------ + +2.2 The following binary dependency packages are provided under the BSD 3-Clause license. + ---- +2.2.1 com.google.protobuf:protobuf-java + Version : 2.5.0 + License : For details, see https://github.com/protocolbuffers/protobuf/blob/v2.5.0/COPYING.txt + +2.2.2 com.googlecode.protobuf-java-format:protobuf-java-format + Version : 1.4 + License : For details, see https://github.com/bivas/protobuf-java-format/blob/master/LICENSE.txt + + ========= 3. Third party Apache 2.0 Licenses ========= -The following components are provided under the Apache 2.0 License. +3.1 The following modified/copied source files are provided under the Apache 2.0 License. ---- -3.1 tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/Bytes.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/HashedBytes.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/HasThread.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/RecoverableZooKeeper.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZooKeeperWatcher.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZooKeeperListener.java - tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/ThreadUtils.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZooKeeperConnectionException.java - tubemq-server/src/main/java/org/apache/tubemq/server/master/utils/Chore.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZKUtil.java - tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/RowLock.java +3.1.1 tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/Bytes.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/HashedBytes.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/HasThread.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/RecoverableZooKeeper.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZooKeeperWatcher.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZooKeeperListener.java + tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/ThreadUtils.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZooKeeperConnectionException.java + tubemq-server/src/main/java/org/apache/tubemq/server/master/utils/Chore.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/offsetstorage/zookeeper/ZKUtil.java + tubemq-server/src/main/java/org/apache/tubemq/server/common/utils/RowLock.java Source : hbase 0.94.27 (Please note that the software have been modified.) License : https://github.com/apache/hbase/blob/rel/0.94.27/LICENSE.txt -3.2 tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/MapBackedSet.java - tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/ConcurrentHashSet.java +3.1.2 tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/MapBackedSet.java + tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/ConcurrentHashSet.java Source : mina 2.0.12 License : https://github.com/apache/mina/blob/2.0.12/LICENSE.txt -3.3 bin/broker.sh - bin/master.sh +3.1.3 bin/broker.sh + bin/master.sh Source : Metamorphosis metamorphosis-all-1.4.4 (Please note that the software have been modified.) License : https://github.com/killme2008/Metamorphosis/blob/metamorphosis-all-1.4.4/COPYING.txt -3.4 tubemq-core/src/main/java/org/apache/tubemq/corerpc/netty/ByteBufferInputStream.java - tubemq-core/src/main/java/org/apache/tubemq/corerpc/netty/ByteBufferOutputStream.java +3.1.4 tubemq-core/src/main/java/org/apache/tubemq/corerpc/netty/ByteBufferInputStream.java + tubemq-core/src/main/java/org/apache/tubemq/corerpc/netty/ByteBufferOutputStream.java Source : Apache Avro 1.7.6 License : https://github.com/apache/avro/blob/release-1.7.6/LICENSE.txt -3.5 tubemq-client-twins/tubemq-client-cpp/src/future.h +3.1.5 tubemq-client-twins/tubemq-client-cpp/src/future.h Source : Apache Pulsar License : https://github.com/apache/pulsar/blob/master/LICENSE +------------------ + +3.2 The following binary dependency packages are provided under the Apache 2.0 License. + +---- + +3.2.1 io.netty:netty + Version : 3.8.0.Final + License : For details, see https://github.com/netty/netty/blob/netty-3.8.0.Final/LICENSE.txt + +3.2.2 commons-cli:commons-cli + Version : 1.4 + License : For details, see https://github.com/apache/commons-cli/blob/master/LICENSE.txt + +3.2.3 commons-codec:commons-codec + Version : 1.10 + License : For details, see https://github.com/apache/commons-codec/blob/1.10/LICENSE.txt + +3.2.4 com.google.code.gson:gson + Version : 2.8.5 + License : For details, see https://github.com/google/gson/blob/master/LICENSE + +3.2.5 commons-lang:commons-lang + Version : 2.6 + License : For details, see https://github.com/apache/commons-lang/blob/master/LICENSE.txt + +3.2.6 org.apache.commons:commons-lang3 + Version : + License : For details, see https://github.com/apache/commons-lang/blob/master/LICENSE.txt + +3.2.7 org.apache.httpcomponents:httpclient + Version : 4.5.2 + License : For details, see https://github.com/apache/httpcomponents-client/blob/master/LICENSE.txt + +3.2.8 commons-io:commons-io + Version : 2.1 + License : For details, see https://github.com/apache/commons-io/blob/master/LICENSE.txt + +3.2.9 org.apache.zookeeper:zookeeper + Version : 3.4.3 + License : For details, see https://github.com/apache/zookeeper/blob/master/LICENSE.txt + +3.2.10 com.google.guava:guava + Version : 13.0 + License : For details, see https://github.com/google/guava/blob/master/COPYING + +3.2.11 org.apache.velocity:velocity:1.7 + org.apache.velocity:velocity-tools:2.0 + License : For details, see https://github.com/apache/velocity-master/blob/master/pom/pom.xml + https://github.com/apache/velocity-tools/blob/2.0/LICENSE + +3.2.12 org.springframework:spring-core + org.springframework:spring-context + org.springframework:spring-jdbc + org.springframework:spring-orm + Version : 4.1.6.RELEASE + License : For details, see https://github.com/spring-projects/spring-framework/tree/v4.1.6.RELEASE#license + +3.2.13 org.mortbay.jetty:jetty + Version : 6.1.26 + License : For details, see https://github.com/jetty-project/codehaus-jetty6 + +3.2.14 org.ini4j:ini4j + Version : 0.5.1 + License : For details, see https://github.com/facebookarchive/ini4j/blob/master/LICENSE.txt + +3.2.15 org.easymock:easymock + org.easymock:easymockclassextension + Version : 2.5.2 + License : For details, see https://github.com/easymock/easymock/blob/master/header.txt + +3.2.16 org.eclipse.jetty:jetty-server + org.eclipse.jetty:jetty-servlet + Version : 9.4.31.v20200723 + License : For details, see https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/LICENSE + +3.2.17 org.powermock:powermock-module-junit4 + org.powermock:powermock-api-mockito2 + Version : 2.0.4 + License : For details, see https://github.com/powermock/powermock/blob/release/2.x/LICENSE.txt + +3.2.18 org.apache.flink:flink-core + org.apache.flink:flink-table-common + org.apache.flink:flink-runtime_2.11 + org.apache.flink:flink-streaming-java_2.11 + org.apache.flink:flink-table-api-java-bridge_2.11 + Version : 1.9.2 + License : For details, see https://github.com/apache/flink/blob/release-1.9/LICENSE + +3.2.19 org.apache.flume:flume-ng-core + Version : 1.9.0 + License : For details, see https://github.com/apache/flume/blob/flume-1.9/LICENSE + +3.2.20 org.awaitility:awaitility + Version : 4.0.3 + License : For details, see https://github.com/awaitility/awaitility/blob/master/LICENSE + +3.2.21 org.apache.spark:spark-core_2.11 + org.apache.spark:spark-sql_2.11 + org.apache.spark:spark-streaming_2.11 + Version : 2.4.4 + License : For details, see https://github.com/apache/spark/blob/branch-2.4/LICENSE + ========= -4. Third party category X Licenses +4. Third party Eclipse Public License 1.0 Licenses ========= +4.1 The following binary dependency packages are provided under Eclipse Public License 1.0 Licenses. + ---- -NOTICE: -The project does not contain the LICENSE file, but analyzed from -the project’s pom.xml content and the file header of the source code file, -the following components are provided under the Apache 2.0 License. +4.1.1 junit:junit + Version : 4.11 + License : For details, see https://github.com/junit-team/junit4/blob/main/LICENSE-junit.txt + + +========= +5. Third party CDDL + GPLv2 with classpath exception Licenses +========= -4.1 tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/TStringUtils.java +5.1 The following binary dependency packages are provided under CDDL + GPLv2 with classpath exception Licenses. + +---- + +5.1.1 javax.servlet:javax.servlet-api + Version : 4.0.1 + License : For details, see https://github.com/javaee/servlet-spec/blob/master/LICENSE + + +========= +6. Third party category X Licenses +========= + +6.1 The following modified/copied source files are provided under category X Licenses. + +---- + +6.1.1 tubemq-core/src/main/java/org/apache/tubemq/corebase/utils/TStringUtils.java Source : citrus r3.1.4 (Please note that the software have been modified.) https://github.com/webx/citrus/blob/r3.1.4/common/util/src/main/java/com/alibaba/citrus/util/StringUtil.java - License: https://github.com/webx/citrus/blob/r3.1.4/pom.xml + License: The project does not contain the LICENSE file, but analyzed from + the project’s pom.xml content and the file header of the source code file, + the following components are provided under the Apache 2.0 License. - pom.xml includes: + pom.xml includes: see https://github.com/webx/citrus/blob/r3.1.4/pom.xml | <licenses> | <license> | <name>The Apache Software License, Version 2.0</name> @@ -400,14 +556,11 @@ the following components are provided under the Apache 2.0 License. ---- -NOTICE: - -According to the content of the project’s README.markdown and LICENSE.markdown, -the following components are provided under the slightly modified MIT License. - -4.2 resources/assets/public/css/style.css - resources/assets/public/css/ie.css +6.1.2 resources/assets/public/css/style.css + resources/assets/public/css/ie.css Source : Compass + License : According to the content of the project’s README.markdown and LICENSE.markdown, + the following components are provided under the slightly modified MIT License. README.markdown includes:(https://github.com/Compass/compass/blob/stable/README.markdown) | License @@ -428,19 +581,22 @@ the following components are provided under the slightly modified MIT License. | | Contributors to this project agree to grant all rights to the copyright holder of the primary product. Attribution is maintained in the source control history of the product. ----- - -NOTICE: +------------------ -We found that different versions of berkeleydb-je use different authorization protocols. -The 7.3.7 version we choose uses the Apache V2 LICENSE, we choose to use this component -based on Apache V2 LICENSE. +6.2 The following binary dependency packages are provided under category X Licenses. -If users modify the berkeleydb-je version, please pay attention to this issue. -The following is the content of the LICENSE file in the component source package: +---- -4.3 berkeleydb-je +6.2.1 berkeleydb-je + Version : 7.3.7 Source : Oracle + License :We found that different versions of Berkeley DB JE (Java Edition) use different authorization protocols. + The 7.3.7 version we choose uses the Apache V2 LICENSE, we choose to use this component based on Apache V2 LICENSE. + + If you modify the version of Berkeley DB JE (Java Edition), please ** pay attention ** to this issue, + please the appropriate version with Apache V2 LICENSE. + + The following is the content of the LICENSE file in the component source package: LICENSE information notice in webpage: https://www.oracle.com/database/technologies/related/berkeleydb-downloads.html | Oracle Berkeley DB Licensing Information @@ -528,6 +684,7 @@ The following is the content of the LICENSE file in the component source package | * THE POSSIBILITY OF SUCH DAMAGE. | */ +---- diff --git a/pom.xml b/pom.xml index 3ca5c29..bca1abf 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,6 @@ <dockerfile-maven.version>1.4.13</dockerfile-maven.version> <spring.boot.version>2.3.3.RELEASE</spring.boot.version> <mysql.java.version>8.0.21</mysql.java.version> - <junit.platform.version>1.6.2</junit.platform.version> </properties> <repositories> diff --git a/tubemq-connectors/tubemq-connector-flume/pom.xml b/tubemq-connectors/tubemq-connector-flume/pom.xml index c2b2f0a..cd78a97 100644 --- a/tubemq-connectors/tubemq-connector-flume/pom.xml +++ b/tubemq-connectors/tubemq-connector-flume/pom.xml @@ -31,7 +31,7 @@ <properties> <flume.version>1.9.0</flume.version> <mockito.version>1.9.0</mockito.version> - <junit.version>4.10</junit.version> + <junit.version>4.11</junit.version> <awaitility.version>4.0.3</awaitility.version> </properties> diff --git a/tubemq-manager/READMe.md b/tubemq-manager/READMe.md deleted file mode 100644 index 29f5fdc..0000000 --- a/tubemq-manager/READMe.md +++ /dev/null @@ -1,51 +0,0 @@ -License -======= - -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. - -# introduction -tubemq-manager is used to manage multiple tubemq cluster. It works with tubemq-web project. -tubemq-manager provide restful api and tubemq-web use them to provide front-end web pages. -This page is going to introduce how to set up tubemq-manager environment. - - -# build -```shell script -mvn clean package -``` - - -# distribution -env requirements: - 1. mysql - 2. java(1.8+) - -In the dist directory, you can find a installable file called `tubemq-manager-bin.zip`. Unzip it -and add mysql address configuration in `conf/application.properties` - -```properties -spring.jpa.hibernate.ddl-auto=update -# configuration for manager -spring.datasource.url=jdbc:mysql://x.x.x.x:3306/tubemanager -spring.datasource.username=xx -spring.datasource.password=xxx -``` -Then setup mysql database called `tubemanager`, start this project by this command -```shell script -bin/start-manager.sh -``` diff --git a/tubemq-manager/bin/start-manager.sh b/tubemq-manager/bin/start-manager.sh deleted file mode 100755 index a81953d..0000000 --- a/tubemq-manager/bin/start-manager.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/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. -# - -base_dir=$(dirname $0) - -DAEMON_NAME=${DAEMON_NAME:-"tubemq-manager"} -LOG_DIR=${LOG_DIR:-"$base_dir/../logs"} -CONF_DIR=${CONF_DIR:-"$base_dir/../conf"} -LIB_DIR=${LIB_DIR:-"$base_dir/../lib"} -CONSOLE_OUTPUT_FILE=$LOG_DIR/$DAEMON_NAME.out -MANAGER_HEAP_OPTS="-Xmx16G -Xms16G" -MANAGER_GC_OPTS="-XX:+UseG1GC -verbose:gc -verbose:sizes -Xloggc:${LOG_DIR}/gc.log.`date +%Y-%m-%d-%H-%M-%S` -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution" - -# create logs directory -if [ ! -d "$LOG_DIR" ]; then - mkdir -p "$LOG_DIR" -fi - -# Exclude jars not necessary for running commands. -regex="(-(test|test-sources|src|scaladoc|javadoc)\.jar|jar.asc)$" -should_include_file() { - if [ "$INCLUDE_TEST_JARS" = true ]; then - return 0 - fi - file=$1 - if [ -z "$(echo "$file" | egrep "$regex")" ] ; then - return 0 - else - return 1 - fi -} - -for file in ${LIB_DIR}/*.jar; -do - if should_include_file "$file"; then - CLASSPATH="$CLASSPATH":"$file" - fi -done - -CLASSPATH="${CONF_DIR}":$CLASSPATH -export MANAGER_JVM_OPTS="${MANAGER_HEAP_OPTS} ${MANAGER_GC_OPTS} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}" - -# Which java to use -if [ -z "$JAVA_HOME" ]; then - JAVA="java" -else - JAVA="$JAVA_HOME/bin/java" -fi - -nohup "$JAVA" $MANAGER_JVM_OPTS -cp "$CLASSPATH" org.apache.tubemq.manager.TubeMQManager "$@" > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null & diff --git a/tubemq-manager/bin/stop-manager.sh b/tubemq-manager/bin/stop-manager.sh deleted file mode 100755 index e26d999..0000000 --- a/tubemq-manager/bin/stop-manager.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/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. -# - -SIGNAL=${SIGNAL:-TERM} - -if [[ $(uname -s) == "OS/390" ]]; then - if [ -z $JOBNAME ]; then - JOBNAME="TubeMQManager" - fi - PIDS=$(ps -A -o pid,jobname,comm | grep -i $JOBNAME | grep java | grep -v grep | awk '{print $1}') -else - PIDS=$(jcmd | grep -i 'TubeMQManager' | awk '{print $1}') -fi - -if [ -z "$PIDS" ]; then - echo "No tubemq manager server to stop" - exit 1 -else - kill -s $SIGNAL $PIDS - echo "stop tubemq manager .... $PIDS" -fi diff --git a/tubemq-manager/conf/logback.xml b/tubemq-manager/conf/logback.xml deleted file mode 100644 index 97130b2..0000000 --- a/tubemq-manager/conf/logback.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -// 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. ---> -<configuration> - <property name="FILE_ERROR_PATTERN" - value="${FILE_LOG_PATTERN:-%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} %file:%line: %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> - <include resource="org/springframework/boot/logging/logback/defaults.xml"/> - <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - </filter> - <encoder> - <pattern>${CONSOLE_LOG_PATTERN}</pattern> - <charset>UTF-8</charset> - </encoder> - </appender> - - <appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <FileNamePattern>../logs/tubemq-manager.info.%d{yyyy-MM-dd}.part_%i.log</FileNamePattern> - <maxHistory>10</maxHistory> - <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> - <maxFileSize>100MB</maxFileSize> - </timeBasedFileNamingAndTriggeringPolicy> - </rollingPolicy> - <encoder> - <pattern>${FILE_LOG_PATTERN}</pattern> - <charset>UTF-8</charset> - </encoder> - </appender> - - <appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <FileNamePattern>../logs/tubemq-manager.error.%d{yyyy-MM-dd}.part_%i.log</FileNamePattern> - <maxHistory>10</maxHistory> - <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> - <maxFileSize>100MB</maxFileSize> - </timeBasedFileNamingAndTriggeringPolicy> - </rollingPolicy> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>Error</level> - </filter> - <encoder> - <pattern>${FILE_ERROR_PATTERN}</pattern> - <charset>UTF-8</charset> - </encoder> - </appender> - - <root level="info"> - <appender-ref ref="FILE_INFO"/> - <appender-ref ref="FILE_ERROR"/> - </root> -</configuration> diff --git a/tubemq-manager/pom.xml b/tubemq-manager/pom.xml deleted file mode 100644 index 16339e0..0000000 --- a/tubemq-manager/pom.xml +++ /dev/null @@ -1,130 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -// 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" - 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"> - <parent> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-parent</artifactId> - <version>2.3.3.RELEASE</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>tubemq-manager</artifactId> - - <name>Apache TubeMQ - Manager</name> - - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-data-rest</artifactId> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-validation</artifactId> - </dependency> - - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-data-jpa</artifactId> - </dependency> - - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </dependency> - - <dependency> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <version>3.4.1</version> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <version>3.3.0</version> - <configuration> - <descriptors> - <descriptor>src/main/assembly/assembly.xml</descriptor> - </descriptors> - <archive> - <manifest> - <mainClass>com.cyy.MvnPackageApplication</mainClass> - </manifest> - </archive> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <finalName>${project.artifactId}</finalName> - <descriptors> - <descriptor>src/main/assembly/assembly.xml</descriptor> - </descriptors> - <outputDirectory>./dist/</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> \ No newline at end of file diff --git a/tubemq-manager/src/main/assembly/assembly.xml b/tubemq-manager/src/main/assembly/assembly.xml deleted file mode 100644 index d1ca6ee..0000000 --- a/tubemq-manager/src/main/assembly/assembly.xml +++ /dev/null @@ -1,64 +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. ---> -<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> - <id>bin</id> - <formats> - <format>zip</format> - </formats> - <dependencySets> - <dependencySet> - <useProjectArtifact>false</useProjectArtifact> - <outputDirectory>lib</outputDirectory> - </dependencySet> - </dependencySets> - <fileSets> - <fileSet> - <directory>bin</directory> - <outputDirectory>/bin</outputDirectory> - <includes> - <include>*.sh</include> - <include>*.bat</include> - </includes> - </fileSet> - <fileSet> - <directory>conf</directory> - <outputDirectory>/conf</outputDirectory> - <includes> - <include>*.xml</include> - <include>*.properties</include> - </includes> - </fileSet> - <fileSet> - <directory>src/main/resources</directory> - <outputDirectory>/conf</outputDirectory> - <includes> - <include>*.xml</include> - <include>*.properties</include> - </includes> - </fileSet> - <fileSet> - <directory>target</directory> - <includes> - <include>tubemq-manager-*.jar</include> - </includes> - <outputDirectory>/lib</outputDirectory> - </fileSet> - - </fileSets> -</assembly> \ No newline at end of file diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/TubeMQManager.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/TubeMQManager.java deleted file mode 100644 index 114c0bc..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/TubeMQManager.java +++ /dev/null @@ -1,59 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tubemq.manager; - -import java.util.concurrent.Executor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -@SpringBootApplication -@EnableJpaAuditing -@EnableAsync -public class TubeMQManager { - - @Value("${manager.async.core.pool.size:2}") - private int asyncCorePoolSize; - - @Value("${manager.async.max.pool.size:20}") - private int asyncMaxPoolSize; - - @Value("${manager.async.queue.capacity:100}") - private int asyncQueueCapacity; - - @Value("${manager.async.thread.prefix:AsyncThread-}") - private String threadPrefix; - - public static void main(String[] args) { - SpringApplication.run(TubeMQManager.class); - } - - @Bean(name = "asyncExecutor") - public Executor asyncExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(asyncCorePoolSize); - executor.setMaxPoolSize(asyncMaxPoolSize); - executor.setQueueCapacity(asyncQueueCapacity); - executor.setThreadNamePrefix(threadPrefix); - executor.initialize(); - return executor; - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/ManagerControllerAdvice.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/ManagerControllerAdvice.java deleted file mode 100644 index 5053834..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/ManagerControllerAdvice.java +++ /dev/null @@ -1,41 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.controller; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * Controller advice for handling exceptions - */ -@RestControllerAdvice -public class ManagerControllerAdvice { - - /** - * handling exception, and return json format string. - * - * @param ex - * @return - */ - @ExceptionHandler(Exception.class) - public TubeResult handlingParameterException(Exception ex) { - TubeResult result = new TubeResult(); - result.setErrMsg(ex.getClass().getName() + " " + ex.getMessage()); - result.setErrCode(-1); - return result; - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/TubeResult.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/TubeResult.java deleted file mode 100644 index 144d975..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/TubeResult.java +++ /dev/null @@ -1,27 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.controller; - -import lombok.Data; - -@Data -public class TubeResult { - private String errMsg; - private int errCode = 0; - private boolean result = true; -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/cluster/ClusterController.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/cluster/ClusterController.java deleted file mode 100644 index 58fe8f9..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/cluster/ClusterController.java +++ /dev/null @@ -1,128 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.controller.cluster; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.tubemq.manager.service.TubeHttpConst.SCHEMA; - -import com.google.gson.Gson; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.apache.tubemq.manager.controller.TubeResult; -import org.apache.tubemq.manager.entry.NodeEntry; -import org.apache.tubemq.manager.repository.NodeRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(path = "/v1/cluster") -@Slf4j -public class ClusterController { - - private final CloseableHttpClient httpclient = HttpClients.createDefault(); - private final Gson gson = new Gson(); - - private static final String TUBE_REQUEST_PATH = "webapi.htm"; - - @Autowired - private NodeRepository nodeRepository; - - - private String covertMapToQueryString(Map<String, String> requestMap) throws Exception { - List<String> queryList = new ArrayList<>(); - - for (Map.Entry<String, String> entry : requestMap.entrySet()) { - queryList.add(entry.getKey() + "=" + URLEncoder.encode( - entry.getValue(), UTF_8.toString())); - } - return StringUtils.join(queryList, "&"); - } - - private String queryMaster(String url) { - log.info("start to request {}", url); - HttpGet httpGet = new HttpGet(url); - TubeResult defaultResult = new TubeResult(); - try (CloseableHttpResponse response = httpclient.execute(httpGet)) { - // return result json to response - return EntityUtils.toString(response.getEntity()); - } catch (Exception ex) { - log.error("exception caught while requesting broker status", ex); - defaultResult.setErrCode(-1); - defaultResult.setResult(false); - defaultResult.setErrMsg(ex.getMessage()); - } - return gson.toJson(defaultResult); - } - - @RequestMapping(value = "/query", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody String queryInfo( - @RequestParam Map<String, String> queryBody) throws Exception { - int clusterId = Integer.parseInt(queryBody.get("clusterId")); - queryBody.remove("clusterId"); - NodeEntry nodeEntry = - nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(clusterId); - String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort() - + "/" + TUBE_REQUEST_PATH + "?" + covertMapToQueryString(queryBody); - return queryMaster(url); - } - - /** - * modify cluster info, need to check token and - * make sure user has authorization to modify it. - */ - @RequestMapping(value = "/modify", method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody String modifyClusterInfo( - @RequestBody Map<String, String> requestBody) throws Exception { - String token = requestBody.get("confModAuthToken"); - log.info("token is {}, request body size is {}", token, requestBody.keySet()); - int clusterId = Integer.parseInt(requestBody.get("clusterId")); - if (StringUtils.isNotBlank(token)) { - requestBody.remove("clusterId"); - NodeEntry nodeEntry = nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue( - clusterId); - String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort() - + "/" + TUBE_REQUEST_PATH + "?" + covertMapToQueryString(requestBody); - return queryMaster(url); - } else { - TubeResult result = new TubeResult(); - result.setErrCode(-1); - result.setResult(false); - result.setErrMsg("token is not correct"); - return gson.toJson(result); - } - } - - -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/TopicController.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/TopicController.java deleted file mode 100644 index fdeac4e..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/TopicController.java +++ /dev/null @@ -1,126 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tubemq.manager.controller.topic; - -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import lombok.extern.slf4j.Slf4j; -import org.apache.tubemq.manager.controller.TubeResult; -import org.apache.tubemq.manager.entry.TopicEntry; -import org.apache.tubemq.manager.entry.TopicStatus; -import org.apache.tubemq.manager.exceptions.TubeMQManagerException; -import org.apache.tubemq.manager.repository.TopicRepository; -import org.apache.tubemq.manager.service.TopicBackendWorker; -import org.apache.tubemq.manager.service.TopicFuture; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(path = "/business") -@Slf4j -public class TopicController { - - @Autowired - private TopicRepository topicRepository; - - @Autowired - private TopicBackendWorker topicBackendWorker; - - /** - * add new topic. - * - * @return - businessResult - * @throws Exception - exception - */ - @PostMapping("/add") - public TubeResult addTopic(@RequestBody TopicEntry entry) { - // entry in adding status - entry.setStatus(TopicStatus.ADDING.value()); - topicRepository.saveAndFlush(entry); - CompletableFuture<TopicEntry> future = new CompletableFuture<>(); - topicBackendWorker.addTopicFuture(new TopicFuture(entry, future)); - future.whenComplete((entry1, throwable) -> { - entry1.setStatus(TopicStatus.SUCCESS.value()); - if (throwable != null) { - // if throwable is not success, mark it as failed. - entry1.setStatus(TopicStatus.FAILED.value()); - log.error("exception caught", throwable); - } - topicRepository.saveAndFlush(entry1); - }); - return new TubeResult(); - } - - /** - * update topic - * - * @return - * @throws Exception - */ - @PostMapping("/update") - public TubeResult updateTopic(@RequestBody TopicEntry entry) { - return new TubeResult(); - } - - /** - * Check topic status by business name. - * - * @return - * @throws Exception - */ - @GetMapping("/check") - public TubeResult checkTopicByBusinessName( - @RequestParam String businessName) { - List<TopicEntry> result = topicRepository.findAllByBusinessName(businessName); - return new TubeResult(); - } - - /** - * get topic by id. - * - * @param id business id - * @return BusinessResult - * @throws Exception - */ - @GetMapping("/get/{id}") - public TubeResult getBusinessByID( - @PathVariable Long id) { - Optional<TopicEntry> businessEntry = topicRepository.findById(id); - TubeResult result = new TubeResult(); - if (!businessEntry.isPresent()) { - result.setErrCode(-1); - result.setErrMsg("business not found"); - } - return result; - } - - /** - * test for exception situation. - * @return - */ - @GetMapping("/throwException") - public TubeResult throwException() { - throw new TubeMQManagerException("exception for test"); - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/NodeEntry.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/NodeEntry.java deleted file mode 100644 index 54c4236..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/NodeEntry.java +++ /dev/null @@ -1,51 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.entry; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import lombok.Data; - -/** - * node machine for tube cluster. broker/master/standby - */ -@Entity -@Table(name = "node") -@Data -public class NodeEntry { - @Id - @GeneratedValue(strategy= GenerationType.AUTO) - private long brokerId; - - private boolean master; - - private boolean standby; - - private boolean broker; - - private String ip; - - private int port; - - private int webPort; - - private int clusterId; -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/TopicEntry.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/TopicEntry.java deleted file mode 100644 index 17b7711..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/TopicEntry.java +++ /dev/null @@ -1,137 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.entry; - -import java.sql.Date; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import lombok.Data; -import org.hibernate.annotations.CreationTimestamp; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; - -@Entity -@Table(name = "topic") -@Data -@EntityListeners(AuditingEntityListener.class) // support CreationTimestamp annotation -public class TopicEntry { - @Id - @GeneratedValue(strategy=GenerationType.AUTO) - private long businessId; - - @Size(max = 30) - @NotNull - private String businessName; - - @Size(max = 64) - private String messageType; - - @Size(max = 256) - private String businessCnName; - - @Size(max = 256) - private String description; - - private String bg; - - @Size(max = 240) - @NotNull - private String schemaName; - - @Size(max = 32) - @NotNull - private String username; - - @Size(max = 64) - @NotNull - private String passwd; - - @Size(max = 64) - @NotNull - private String topic; - - @Size(max = 10) - private String fieldSplitter; - - @Size(max = 256) - private String predefinedFields; - - private int isHybridDataSource = 0; - - @Size(max = 64) - @NotNull - private String encodingType; - - private int isSubSort = 0; - - private String topologyName; - - private String targetServer; - - private String targetServerPort; - - private String netTarget; - - private int status; - - private String category; - - private int clusterId; - - private String inCharge; - - private String sourceServer; - - private String baseDir; - - @CreationTimestamp - private Date createTime; - - private String importType; - - private String exampleData; - - private String tdwAppgroup; - - @Column(name = "SN") - private int sn; - - @Size(max = 32) - private String issueMethod; - - - public TopicEntry(String businessName, String schemaName, - String username, String passwd, String topic, String encodingType) { - this.businessName = businessName; - this.schemaName = schemaName; - this.username = username; - this.passwd = passwd; - this.topic = topic; - this.encodingType = encodingType; - } - - public TopicEntry() { - - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/TopicStatus.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/TopicStatus.java deleted file mode 100644 index e5796af..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/TopicStatus.java +++ /dev/null @@ -1,33 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.entry; - -public enum TopicStatus { - - ADDING(0), SUCCESS(1), FAILED(2), RETRY(3); - - private int value = 0; - - private TopicStatus(int value) { - this.value = value; - } - - public int value() { - return this.value; - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/exceptions/TubeMQManagerException.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/exceptions/TubeMQManagerException.java deleted file mode 100644 index 46c888c..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/exceptions/TubeMQManagerException.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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.exceptions; - -/** - * TubeMQ runtime exception. - */ -public class TubeMQManagerException extends RuntimeException { - - public TubeMQManagerException(final String message) { - super(message); - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/NodeRepository.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/NodeRepository.java deleted file mode 100644 index 4bf6ec7..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/NodeRepository.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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.repository; - -import org.apache.tubemq.manager.entry.NodeEntry; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface NodeRepository extends JpaRepository<NodeEntry, Long> { - - NodeEntry findNodeEntryByClusterIdIsAndMasterIsTrue(int clusterId); -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/TopicRepository.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/TopicRepository.java deleted file mode 100644 index 4c88949..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/TopicRepository.java +++ /dev/null @@ -1,43 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.repository; - -import java.util.List; -import org.apache.tubemq.manager.entry.TopicEntry; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface TopicRepository extends JpaRepository<TopicEntry, Long> { - - /** - * get all topicEntry list by business name - * @param businessName - * @return - */ - List<TopicEntry> findAllByBusinessName(String businessName); - - /** - * get one topicEntry by business name - * @param businessName - * @return - */ - TopicEntry findByBusinessName(String businessName); - -} - diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/NodeService.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/NodeService.java deleted file mode 100644 index 4e0db3e..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/NodeService.java +++ /dev/null @@ -1,272 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service; - - -import static org.apache.tubemq.manager.service.TubeHttpConst.ADD_TUBE_TOPIC; -import static org.apache.tubemq.manager.service.TubeHttpConst.BROKER_RUN_STATUS; -import static org.apache.tubemq.manager.service.TubeHttpConst.RELOAD_BROKER; -import static org.apache.tubemq.manager.service.TubeHttpConst.SCHEMA; -import static org.apache.tubemq.manager.service.TubeHttpConst.TOPIC_CONFIG_INFO; - -import com.google.gson.Gson; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.tubemq.manager.entry.NodeEntry; -import org.apache.tubemq.manager.repository.NodeRepository; -import org.apache.tubemq.manager.service.tube.TubeHttpBrokerInfoList; -import org.apache.tubemq.manager.service.tube.TubeHttpResponse; -import org.apache.tubemq.manager.service.tube.TubeHttpTopicInfoList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; - -/** - * node service to query broker/master/standby status of tube cluster. - */ -@Slf4j -public class NodeService { - - private final CloseableHttpClient httpclient = HttpClients.createDefault(); - private final Gson gson = new Gson(); - - @Value("${manager.max.configurable.broker.size:50}") - private int maxConfigurableBrokerSize; - - @Value("${manager.max.retry.adding.topic:10}") - private int maxRetryAddingTopic; - - private final TopicBackendWorker worker; - - @Autowired - private NodeRepository nodeRepository; - - public NodeService(TopicBackendWorker worker) { - this.worker = worker; - } - - /** - * request node status via http. - * - * @param nodeEntry - node entry - * @return - * @throws IOException - */ - private TubeHttpBrokerInfoList requestClusterNodeStatus(NodeEntry nodeEntry) throws IOException { - String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort() + BROKER_RUN_STATUS; - HttpGet httpget = new HttpGet(url); - try (CloseableHttpResponse response = httpclient.execute(httpget)) { - TubeHttpBrokerInfoList brokerInfoList = - gson.fromJson(new InputStreamReader(response.getEntity().getContent()), - TubeHttpBrokerInfoList.class); - // request return normal. - if (brokerInfoList.getCode() == 0) { - // divide by state. - brokerInfoList.divideBrokerListByState(); - return brokerInfoList; - } - } catch (Exception ex) { - log.error("exception caught while requesting broker status", ex); - } - return null; - } - - - private TubeHttpTopicInfoList requestTopicConfigInfo(NodeEntry nodeEntry, String topic) { - String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort() - + TOPIC_CONFIG_INFO + "&topicName=" + topic; - HttpGet httpget = new HttpGet(url); - try (CloseableHttpResponse response = httpclient.execute(httpget)) { - TubeHttpTopicInfoList topicInfoList = - gson.fromJson(new InputStreamReader(response.getEntity().getContent()), - TubeHttpTopicInfoList.class); - if (topicInfoList.getErrCode() == 0) { - return topicInfoList; - } - } catch (Exception ex) { - log.error("exception caught while requesting broker status", ex); - } - return null; - } - - - private boolean configBrokersForTopics(NodeEntry nodeEntry, - Set<String> topics, List<Integer> brokerList, int maxBrokers) { - List<Integer> finalBrokerList = brokerList.subList(0, maxBrokers); - String brokerStr = StringUtils.join(finalBrokerList, ","); - String topicStr = StringUtils.join(topics, ","); - String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort() - + ADD_TUBE_TOPIC + "&topicName=" + topicStr + "&brokerId=" + brokerStr; - HttpGet httpget = new HttpGet(url); - try (CloseableHttpResponse response = httpclient.execute(httpget)) { - TubeHttpResponse result = - gson.fromJson(new InputStreamReader(response.getEntity().getContent()), - TubeHttpResponse.class); - return result.getCode() == 0 && result.getErrCode() == 0; - } catch (Exception ex) { - log.error("exception caught while requesting broker status", ex); - } - return false; - } - - /** - * handle result, if success, complete it, - * if not success, add back to queue without exceeding max retry, - * otherwise complete it with exception. - * - * @param isSuccess - * @param topics - * @param pendingTopic - */ - private void handleAddingResult(boolean isSuccess, Set<String> topics, - Map<String, TopicFuture> pendingTopic) { - for (String topic : topics) { - TopicFuture future = pendingTopic.get(topic); - if (future != null) { - if (isSuccess) { - future.complete(); - } else { - future.increaseRetryTime(); - if (future.getRetryTime() > maxRetryAddingTopic) { - future.completeExceptional(); - } else { - // add back to queue. - worker.addTopicFuture(future); - } - } - } - } - } - - - /** - * Adding topic is an async operation, so this method should - * 1. check whether pendingTopic contains topic that has failed/succeeded to be added. - * 2. async add topic to tubemq cluster - * - * @param brokerInfoList - broker list - * @param pendingTopic - topicMap - */ - private void handleAddingTopic(NodeEntry nodeEntry, - TubeHttpBrokerInfoList brokerInfoList, - Map<String, TopicFuture> pendingTopic) { - // 1. check tubemq cluster by topic name, remove pending topic if has added. - Set<String> brandNewTopics = new HashSet<>(); - for (String topic : pendingTopic.keySet()) { - TubeHttpTopicInfoList topicInfoList = requestTopicConfigInfo(nodeEntry, topic); - if (topicInfoList != null) { - // get broker list by topic request - List<Integer> topicBrokerList = topicInfoList.getTopicBrokerIdList(); - if (topicBrokerList.isEmpty()) { - brandNewTopics.add(topic); - } else { - // remove brokers which have been added. - List<Integer> configurableBrokerIdList = - brokerInfoList.getConfigurableBrokerIdList(); - configurableBrokerIdList.removeAll(topicBrokerList); - // add topic to satisfy max broker number. - Set<String> singleTopic = new HashSet<>(); - singleTopic.add(topic); - int maxBrokers = maxConfigurableBrokerSize - topicBrokerList.size(); - boolean isSuccess = configBrokersForTopics(nodeEntry, singleTopic, - configurableBrokerIdList, maxBrokers); - handleAddingResult(isSuccess, singleTopic, pendingTopic); - } - } - } - // 2. add new topics to cluster - List<Integer> configurableBrokerIdList = brokerInfoList.getConfigurableBrokerIdList(); - int maxBrokers = Math.min(maxConfigurableBrokerSize, configurableBrokerIdList.size()); - boolean isSuccess = configBrokersForTopics(nodeEntry, brandNewTopics, - configurableBrokerIdList, maxBrokers); - handleAddingResult(isSuccess, brandNewTopics, pendingTopic); - } - - /** - * reload broker list, cannot exceed maxConfigurableBrokerSize each time. - * - * @param nodeEntry - * @param needReloadList - */ - private void handleReloadBroker(NodeEntry nodeEntry, List<Integer> needReloadList) { - // reload without exceed max broker. - int begin = 0; - int end = 0; - do { - end = Math.min(maxConfigurableBrokerSize + begin, needReloadList.size()); - List<Integer> brokerIdList = needReloadList.subList(begin, end); - String brokerStr = StringUtils.join(brokerIdList, ","); - String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort() - + RELOAD_BROKER + "&brokerId=" + brokerStr; - HttpGet httpget = new HttpGet(url); - try (CloseableHttpResponse response = httpclient.execute(httpget)) { - TubeHttpResponse result = - gson.fromJson(new InputStreamReader(response.getEntity().getContent()), - TubeHttpResponse.class); - if (result.getErrCode() == 0 && result.getCode() == 0) { - log.info("reload tube broker cgi: " + - url + " ; return value : " + result.getCode()); - } - } catch (Exception ex) { - log.error("exception caught while requesting broker status", ex); - } - begin = end; - } while (end >= needReloadList.size()); - } - - - - /** - * update broker status - */ - public void updateBrokerStatus(int clusterId, Map<String, TopicFuture> pendingTopic) { - NodeEntry nodeEntry = nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(clusterId); - if (nodeEntry != null) { - try { - TubeHttpBrokerInfoList brokerInfoList = requestClusterNodeStatus(nodeEntry); - if (brokerInfoList != null) { - handleAddingTopic(nodeEntry, brokerInfoList, pendingTopic); - } - - // refresh broker list - brokerInfoList = requestClusterNodeStatus(nodeEntry); - if (brokerInfoList != null) { - handleReloadBroker(nodeEntry, brokerInfoList.getNeedReloadList()); - } - - } catch (Exception ex) { - log.error("exception caught while requesting broker status", ex); - } - } else { - log.error("cannot get master ip by clusterId {}, please check it", clusterId); - } - } - - public void close() throws IOException { - httpclient.close(); - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TopicBackendWorker.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TopicBackendWorker.java deleted file mode 100644 index 86b72d5..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TopicBackendWorker.java +++ /dev/null @@ -1,137 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import lombok.extern.slf4j.Slf4j; -import org.apache.tubemq.manager.repository.TopicRepository; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * Topic backend thread worker. - */ -@Component -@Slf4j -public class TopicBackendWorker implements DisposableBean, Runnable { - private final AtomicBoolean runFlag = new AtomicBoolean(true); - private final ConcurrentHashMap<Integer, BlockingQueue<TopicFuture>> pendingTopics = - new ConcurrentHashMap<>(); - private final AtomicInteger notSatisfiedCount = new AtomicInteger(0); - private final NodeService nodeService; - - @Autowired - private TopicRepository topicRepository; - - @Value("${manager.topic.queue.warning.size:100}") - private int queueWarningSize; - - // value in seconds - @Value("${manager.topic.queue.thread.interval:10}") - private int queueThreadInterval; - - @Value("${manager.topic.queue.max.wait:3}") - private int queueMaxWait; - - @Value("${manager.topic.queue.max.running.size:20}") - private int queueMaxRunningSize; - - TopicBackendWorker() { - Thread thread = new Thread(this); - // daemon thread - thread.setDaemon(true); - thread.start(); - nodeService = new NodeService(this); - } - - /** - * add topic future to pending executing queue. - * @param future - TopicFuture. - */ - public void addTopicFuture(TopicFuture future) { - BlockingQueue<TopicFuture> tmpQueue = new LinkedBlockingQueue<>(); - BlockingQueue<TopicFuture> queue = pendingTopics.putIfAbsent( - future.getEntry().getClusterId(), tmpQueue); - if (queue == null) { - queue = tmpQueue; - } - queue.add(future); - if (queue.size() > queueWarningSize) { - log.warn("queue size exceed {}, please check it", queueWarningSize); - } - } - - /** - * batch executing adding topic, wait util max n seconds or max size satisfied. - */ - private void batchAddTopic() { - pendingTopics.forEach((clusterId, queue) -> { - Map<String, TopicFuture> pendingTopicList = new HashMap<>(); - if (notSatisfiedCount.get() > queueMaxWait || queue.size() > queueMaxRunningSize) { - notSatisfiedCount.set(0); - List<TopicFuture> tmpTopicList = new ArrayList<>(); - queue.drainTo(tmpTopicList, queueMaxRunningSize); - for (TopicFuture topicFuture : tmpTopicList) { - pendingTopicList.put(topicFuture.getEntry().getTopic(), topicFuture); - } - } else { - notSatisfiedCount.incrementAndGet(); - } - // update broker status - nodeService.updateBrokerStatus(clusterId, pendingTopicList); - }); - - } - - /** - * check topic from db - */ - private void checkTopicFromDB() { - } - - @Override - public void run() { - log.info("TopicBackendWorker has started"); - while (runFlag.get()) { - try { - batchAddTopic(); - checkTopicFromDB(); - TimeUnit.SECONDS.sleep(queueThreadInterval); - } catch (Exception exception) { - log.warn("exception caught", exception); - } - } - } - - @Override - public void destroy() throws Exception { - runFlag.set(false); - nodeService.close(); - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TopicFuture.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TopicFuture.java deleted file mode 100644 index 62b0e2d..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TopicFuture.java +++ /dev/null @@ -1,58 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service; - -import java.util.concurrent.CompletableFuture; -import lombok.Getter; -import org.apache.tubemq.manager.entry.TopicEntry; - -/** - * topic business with future. - */ -public class TopicFuture { - @Getter - private int retryTime = 0; - @Getter - private final TopicEntry entry; - @Getter - private final CompletableFuture<TopicEntry> future; - - public TopicFuture(TopicEntry entry, CompletableFuture<TopicEntry> future) { - this.entry = entry; - this.future = future; - } - - /** - * record retry time. - */ - public void increaseRetryTime() { - retryTime += 1; - } - - /** - * when topic operation finished, complete it. - */ - public void complete() { - this.future.complete(this.entry); - } - - public void completeExceptional() { - this.future.completeExceptionally(new RuntimeException("exceed max retry " - + retryTime +" adding")); - } -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TubeHttpConst.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TubeHttpConst.java deleted file mode 100644 index 81a360e..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/TubeHttpConst.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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service; - -public class TubeHttpConst { - public static final String SCHEMA = "http://"; - public static final String BROKER_RUN_STATUS = - "/webapi.htm?type=op_query&method=admin_query_broker_run_status"; - public static final String TOPIC_CONFIG_INFO = - "/webapi.htm?type=op_query&method=admin_query_topic_info"; - public static final String ADD_TUBE_TOPIC = - "/webapi.htm?type=op_modify&method=admin_add_new_topic_record"; - public static final String RELOAD_BROKER = - "/webapi.htm?type=op_modify&method=admin_reload_broker_configure"; -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpBrokerInfoList.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpBrokerInfoList.java deleted file mode 100644 index c768aa1..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpBrokerInfoList.java +++ /dev/null @@ -1,135 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service.tube; - -import java.util.ArrayList; -import java.util.List; -import lombok.Data; - -/** - * json class for broker info list from master http service. - */ -@Data -public class TubeHttpBrokerInfoList { - - /** - * json class for broker info. - */ - @Data - public static class BrokerInfo { - private int brokerId; - private String brokerIp; - private int brokerPort; - private String manageStatus; - private String runStatus; - private String subStatus; - private int stepOp; - private boolean isConfChanged; - private boolean isConfLoaded; - private boolean isBrokerOnline; - private String brokerVersion; - private boolean acceptPublish; - private boolean acceptSubscribe; - - public boolean isIdle() { - return subStatus != null && subStatus.equals("idle"); - } - - public boolean isWorking() { - if (runStatus != null && manageStatus != null) { - return runStatus.equals("running") && ( - manageStatus.equals("online") || - manageStatus.equals("only-read") || - manageStatus.equals("only-write")); - } - return false; - } - - public boolean isConfigurable() { - return stepOp == -2 || stepOp == 31 || stepOp == 32; - } - - @Override - public int hashCode() { - return brokerId; - } - - @Override - public boolean equals(Object o) { - - if (o == this) return true; - if (!(o instanceof BrokerInfo)) { - return false; - } - - BrokerInfo brokerInfo = (BrokerInfo) o; - - return brokerId == brokerInfo.brokerId; - } - } - - private int code; - private String errMsg; - // total broker info list of brokers. - private List<BrokerInfo> data; - // configurable list of brokers. - private List<BrokerInfo> configurableList; - // working state list of brokers - private List<BrokerInfo> workingList; - // idle broker list - private List<BrokerInfo> idleList; - // need reload broker list - private List<Integer> needReloadList; - - /** - * divide broker list into different list by broker state. - */ - public void divideBrokerListByState() { - if (data != null) { - configurableList = new ArrayList<>(); - workingList = new ArrayList<>(); - idleList = new ArrayList<>(); - needReloadList = new ArrayList<>(); - for (BrokerInfo brokerInfo : data) { - if (brokerInfo.isConfigurable()) { - configurableList.add(brokerInfo); - } - if (brokerInfo.isWorking()) { - workingList.add(brokerInfo); - } - if (brokerInfo.isIdle()) { - idleList.add(brokerInfo); - } - if (brokerInfo.isConfChanged) { - needReloadList.add(brokerInfo.getBrokerId()); - } - } - } - } - - public List<Integer> getConfigurableBrokerIdList() { - List<Integer> tmpBrokerIdList = new ArrayList<>(); - if (configurableList != null) { - for (BrokerInfo brokerInfo : configurableList) { - tmpBrokerIdList.add(brokerInfo.getBrokerId()); - } - } - return tmpBrokerIdList; - } - -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpResponse.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpResponse.java deleted file mode 100644 index bc30025..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpResponse.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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service.tube; - -import lombok.Data; - -/** - * common response json str for tube htt request - */ -@Data -public class TubeHttpResponse { - private int code; - private String errMsg; - private int errCode; -} diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpTopicInfoList.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpTopicInfoList.java deleted file mode 100644 index 7131b83..0000000 --- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/service/tube/TubeHttpTopicInfoList.java +++ /dev/null @@ -1,97 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service.tube; - -import java.util.ArrayList; -import java.util.List; -import lombok.Data; -import org.apache.tubemq.manager.service.tube.TubeHttpTopicInfoList.TopicInfoList.TopicInfo; - -/** - * json class for topic info list from master http service. - */ -@Data -public class TubeHttpTopicInfoList { - private boolean result; - - private String errMsg; - - private int errCode; - - private List<TopicInfoList> data; - - @Data - public static class TopicInfoList { - - @Data - public static class TopicInfo { - - @Data - public static class RunInfo { - private boolean acceptPublish; - private boolean acceptSubscribe; - private int numPartitions; - private int numTopicStores; - private String brokerManageStatus; - } - - - private String topicName; - private int topicStatusId; - private int brokerId; - private String brokerIp; - private int brokerPort; - private int numPartitions; - private int unflushThreshold; - private int unflushInterval; - private int unFlushDataHold; - private String deleteWhen; - private String deletePolicy; - private boolean acceptPublish; - private boolean acceptSubscribe; - private int numTopicStores; - private int memCacheMsgSizeInMB; - private int memCacheFlushIntvl; - private int memCacheMsgCntInK; - private String createUser; - private String createDate; - private String modifyUser; - private String modifyDate; - private RunInfo runInfo; - - } - - private String topicName; - private List<TopicInfo> topicInfo; - } - - - public List<Integer> getTopicBrokerIdList() { - List<Integer> tmpBrokerIdList = new ArrayList<>(); - if (data != null) { - for (TopicInfoList topicInfoList : data) { - if (topicInfoList.getTopicInfo() != null) { - for (TopicInfo topicInfo : topicInfoList.getTopicInfo()) { - tmpBrokerIdList.add(topicInfo.getBrokerId()); - } - } - } - } - return tmpBrokerIdList; - } -} diff --git a/tubemq-manager/src/main/resources/application.properties b/tubemq-manager/src/main/resources/application.properties deleted file mode 100644 index dee51b7..0000000 --- a/tubemq-manager/src/main/resources/application.properties +++ /dev/null @@ -1,17 +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 -# <p> -# http://www.apache.org/licenses/LICENSE-2.0 -# <p> -# 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. - -spring.jpa.hibernate.ddl-auto=update -# configuration for manager diff --git a/tubemq-manager/src/test/java/org/apache/tubemq/manager/controller/TestBusinessController.java b/tubemq-manager/src/test/java/org/apache/tubemq/manager/controller/TestBusinessController.java deleted file mode 100644 index 9a497cf..0000000 --- a/tubemq-manager/src/test/java/org/apache/tubemq/manager/controller/TestBusinessController.java +++ /dev/null @@ -1,99 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tubemq.manager.controller; - -import java.net.URI; -import java.util.Objects; -import lombok.extern.slf4j.Slf4j; -import org.apache.tubemq.manager.controller.topic.TopicController; -import org.apache.tubemq.manager.entry.TopicEntry; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.RequestBuilder; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertTrue; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@RunWith(SpringRunner.class) -@AutoConfigureMockMvc -@SpringBootTest(webEnvironment= WebEnvironment.RANDOM_PORT) -@Slf4j -public class TestBusinessController { - - @Autowired - private TestRestTemplate client; - - @LocalServerPort - private int randomServerPort; - - private MockMvc mvc; - - @Before - public void setUp() { - mvc = MockMvcBuilders.standaloneSetup(new TopicController()).build(); - } - - @Test - public void test404Controller() throws Exception { - RequestBuilder request; - // get request, path not exists - request = get("/business"); - mvc.perform(request) - .andExpect(status().isNotFound()); - } - - @Test - public void testAddBusiness() throws Exception { - final String baseUrl = "http://localhost:" + randomServerPort + "/business/add"; - URI uri = new URI(baseUrl); - String demoName = "test"; - TopicEntry entry = new TopicEntry(demoName, demoName, demoName, - demoName, demoName, demoName); - - HttpHeaders headers = new HttpHeaders(); - HttpEntity<TopicEntry> request = new HttpEntity<>(entry, headers); - - ResponseEntity<TubeResult> responseEntity = - client.postForEntity(uri, request, TubeResult.class); - assertThat(responseEntity.getStatusCode().is2xxSuccessful()).isEqualTo(true); - } - - @Test - public void testControllerException() throws Exception { - final String baseUrl = "http://localhost:" + randomServerPort + "/business/throwException"; - URI uri = new URI(baseUrl); - ResponseEntity<TubeResult> responseEntity = - client.getForEntity(uri, TubeResult.class); - assertThat(Objects.requireNonNull(responseEntity.getBody()).getErrCode()).isEqualTo(-1); - assertTrue(responseEntity.getBody().getErrMsg().contains("exception for test")); - } -} diff --git a/tubemq-manager/src/test/java/org/apache/tubemq/manager/controller/TestClusterController.java b/tubemq-manager/src/test/java/org/apache/tubemq/manager/controller/TestClusterController.java deleted file mode 100644 index efd1cb1..0000000 --- a/tubemq-manager/src/test/java/org/apache/tubemq/manager/controller/TestClusterController.java +++ /dev/null @@ -1,150 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.controller; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; - -import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; -import org.apache.tubemq.manager.controller.cluster.ClusterController; -import org.apache.tubemq.manager.entry.NodeEntry; -import org.apache.tubemq.manager.repository.NodeRepository; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.RequestBuilder; - -@Slf4j -@RunWith(SpringRunner.class) -@SpringBootTest -@AutoConfigureMockMvc -public class TestClusterController { - - private final Gson gson = new Gson(); - - @MockBean - private NodeRepository nodeRepository; - - @InjectMocks - private ClusterController clusterController; - - @Autowired - private MockMvc mockMvc; - - private NodeEntry getNodeEntry() { - NodeEntry nodeEntry = new NodeEntry(); - nodeEntry.setMaster(true); - nodeEntry.setIp("127.0.0.1"); - nodeEntry.setWebPort(8080); - return nodeEntry; - } - - @Test - public void testExceptionQuery() throws Exception { - NodeEntry nodeEntry = getNodeEntry(); - when(nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(any(Integer.class))) - .thenReturn(nodeEntry); - RequestBuilder request = get( - "/v1/cluster/query?method=admin_query_topic_info&type=op_query"); - MvcResult result = mockMvc.perform(request).andReturn(); - String resultStr = result.getResponse().getContentAsString(); - TubeResult clusterResult = gson.fromJson(resultStr, TubeResult.class); - Assert.assertEquals(-1, clusterResult.getErrCode()); - Assert.assertTrue(clusterResult.getErrMsg().contains("NumberFormatException")); - } - - @Test - public void testTopicQuery() throws Exception { - NodeEntry nodeEntry = getNodeEntry(); - when(nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(any(Integer.class))) - .thenReturn(nodeEntry); - RequestBuilder request = get( - "/v1/cluster/query?method=admin_query_topic_info&type=op_query&clusterId=1"); - MvcResult result = mockMvc.perform(request).andReturn(); - String resultStr = result.getResponse().getContentAsString(); - log.info("result json string is {}, response type is {}", resultStr, - result.getResponse().getContentType()); - } - - @Test - public void testBrokerQuery() throws Exception { - NodeEntry nodeEntry = getNodeEntry(); - when(nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(any(Integer.class))) - .thenReturn(nodeEntry); - RequestBuilder request = get( - "/v1/cluster/query?method=admin_query_broker_run_status&type=op_query&clusterId=1&brokerIp="); - MvcResult result = mockMvc.perform(request).andReturn(); - String resultStr = result.getResponse().getContentAsString(); - log.info("result json string is {}, response type is {}", resultStr, - result.getResponse().getContentType()); - } - - @Test - public void testTopicAndGroupQuery() throws Exception { - NodeEntry nodeEntry = getNodeEntry(); - when(nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(any(Integer.class))) - .thenReturn(nodeEntry); - RequestBuilder request = get( - "/v1/cluster/query?method=admin_query_sub_info&type=op_query&clusterId=1&topicName=test&groupName=test"); - MvcResult result = mockMvc.perform(request).andReturn(); - String resultStr = result.getResponse().getContentAsString(); - log.info("result json string is {}, response type is {}", resultStr, - result.getResponse().getContentType()); - } - - @Test - public void testTopicAdd() throws Exception { - String jsonStr = "{\n" - + " \"type\": \"op_modify\",\n" - + " \"method\": \"admin_add_new_topic_record\",\n" - + " \"confModAuthToken\": \"test\",\n" - + " \"clusterId\": 1,\n" - + " \"createUser\": \"webapi\",\n" - + " \"topicName\": \"test\",\n" - + " \"deleteWhen\": \"0 0 0 0 0\",\n" - + " \"unflushThreshold\": 1000,\n" - + " \"acceptPublish\": true,\n" - + " \"numPartitions\": 3,\n" - + " \"deletePolicy\": \"\",\n" - + " \"unflushInterval\": 1000,\n" - + " \"acceptSubscribe\": true,\n" - + " \"brokerId\": 12323\n" - + "}\n"; - NodeEntry nodeEntry = getNodeEntry(); - when(nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(any(Integer.class))) - .thenReturn(nodeEntry); - RequestBuilder request = post("/v1/cluster/modify") - .contentType(MediaType.APPLICATION_JSON).content(jsonStr); - MvcResult result = mockMvc.perform(request).andReturn(); - String resultStr = result.getResponse().getContentAsString(); - log.info("result json string is {}, response type is {}", resultStr, - result.getResponse().getContentType()); - } -} diff --git a/tubemq-manager/src/test/java/org/apache/tubemq/manager/repository/TestBusinessRepository.java b/tubemq-manager/src/test/java/org/apache/tubemq/manager/repository/TestBusinessRepository.java deleted file mode 100644 index 7bd8c73..0000000 --- a/tubemq-manager/src/test/java/org/apache/tubemq/manager/repository/TestBusinessRepository.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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tubemq.manager.repository; - -import static org.assertj.core.api.Assertions.assertThat; -import org.apache.tubemq.manager.entry.TopicEntry; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@DataJpaTest -public class TestBusinessRepository { - @Autowired - private TestEntityManager entityManager; - - @Autowired - private TopicRepository businessRepository; - - @Test - public void whenFindByNameThenReturnBusiness() { - String demoName = "alex"; - TopicEntry businessEntry = new TopicEntry(demoName, demoName, - demoName, demoName, demoName, demoName); - entityManager.persist(businessEntry); - entityManager.flush(); - - TopicEntry businessEntry1 = businessRepository.findByBusinessName("alex"); - assertThat(businessEntry1.getBusinessName()).isEqualTo(businessEntry.getBusinessName()); - } - - @Test - public void checkValidation() throws Exception { - String demoName = "a"; - TopicEntry businessEntry = new TopicEntry(demoName, demoName, demoName, - demoName, demoName, demoName); - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < 512; i ++) { - builder.append("a"); - } - businessEntry.setBusinessName(builder.toString()); - try { - entityManager.persist(businessEntry); - entityManager.flush(); - } catch (Exception ex) { - assertThat(ex.getMessage()).contains("size must be between"); - } - } -} diff --git a/tubemq-manager/src/test/java/org/apache/tubemq/manager/service/tube/TestTubeHttpBrokerResponse.java b/tubemq-manager/src/test/java/org/apache/tubemq/manager/service/tube/TestTubeHttpBrokerResponse.java deleted file mode 100644 index 2d79f69..0000000 --- a/tubemq-manager/src/test/java/org/apache/tubemq/manager/service/tube/TestTubeHttpBrokerResponse.java +++ /dev/null @@ -1,48 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service.tube; - -import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.junit.Test; - -@Slf4j -public class TestTubeHttpBrokerResponse { - - private final Gson gson = new Gson(); - - @Test - public void testJsonStr() { - String jsonStr = "{\"code\":0,\"errMsg\":\"OK\",\"data\":" - + "[{\"brokerId\":136,\"brokerIp\":\"127.0.0.1\"," - + "\"brokerPort\":8123,\"manageStatus\":\"online\"," - + "\"runStatus\":\"notRegister\",\"subStatus\":\"processing_event\"," - + "\"stepOp\":32,\"isConfChanged\":\"true\",\"isConfLoaded\":\"false\"," - + "\"isBrokerOnline\":\"false\",\"brokerVersion\":\"-\"," - + "\"acceptPublish\":\"false\",\"acceptSubscribe\":\"false\"}]}"; - TubeHttpBrokerInfoList brokerInfoList = - gson.fromJson(jsonStr, TubeHttpBrokerInfoList.class); - Assert.assertEquals(1, brokerInfoList.getData().size()); - Assert.assertEquals(0, brokerInfoList.getCode()); - Assert.assertEquals("OK", brokerInfoList.getErrMsg()); - Assert.assertTrue(brokerInfoList.getData().get(0).isConfChanged()); - Assert.assertFalse(brokerInfoList.getData().get(0).isAcceptPublish()); - Assert.assertFalse(brokerInfoList.getData().get(0).isBrokerOnline()); - } -} diff --git a/tubemq-manager/src/test/java/org/apache/tubemq/manager/service/tube/TestTubeHttpTopicInfoList.java b/tubemq-manager/src/test/java/org/apache/tubemq/manager/service/tube/TestTubeHttpTopicInfoList.java deleted file mode 100644 index 82a9fda..0000000 --- a/tubemq-manager/src/test/java/org/apache/tubemq/manager/service/tube/TestTubeHttpTopicInfoList.java +++ /dev/null @@ -1,52 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tubemq.manager.service.tube; - -import com.google.gson.Gson; -import org.junit.Assert; -import org.junit.Test; - -public class TestTubeHttpTopicInfoList { - - private final Gson gson = new Gson(); - - @Test - public void testJsonStr() { - String jsonStr = "{\"result\":true,\"errCode\":0,\"errMsg\":\"OK\",\"" - + "data\":[{\"topicName\":\"test1\",\"topicInfo\":[{\"topicName\":\"test1\",\"" - + "topicStatusId\":0,\"brokerId\":152509201,\"brokerIp\":\"127.0.0.1\",\"" - + "brokerPort\":8123,\"numPartitions\":1,\"unflushThreshold\":1000,\"" - + "unflushInterval\":10000,\"unFlushDataHold\":1000,\"deleteWhen\":\"\",\"" - + "deletePolicy\":\"delete,32h\",\"acceptPublish\":true," - + "\"acceptSubscribe\":true,\"numTopicStores\":1,\"memCacheMsgSizeInMB\":2,\"" - + "memCacheFlushIntvl\":20000,\"memCacheMsgCntInK\":10," - + "\"createUser\":\"Alice\",\"createDate\":\"20200917122645\"," - + "\"modifyUser\":\"Alice\",\"modifyDate\":\"20200917122645\"," - + "\"runInfo\":{\"acceptPublish\":true,\"acceptSubscribe\":true," - + "\"numPartitions\":1,\"numTopicStores\":1," - + "\"brokerManageStatus\":\"online\"}}]}]}"; - TubeHttpTopicInfoList topicInfoList = gson.fromJson(jsonStr, TubeHttpTopicInfoList.class); - Assert.assertTrue(topicInfoList.isResult()); - Assert.assertEquals(0, topicInfoList.getErrCode()); - Assert.assertEquals(1, topicInfoList.getData().size()); - Assert.assertEquals("Alice", topicInfoList.getData().get(0) - .getTopicInfo().get(0).getCreateUser()); - Assert.assertEquals("online", topicInfoList.getData().get(0) - .getTopicInfo().get(0).getRunInfo().getBrokerManageStatus()); - } -}
