You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tubemq.apache.org by go...@apache.org on 2020/09/23 02:51:46 UTC

[incubator-tubemq] branch master updated: [TUBEMQ-358]Adjust tubemq-manager, remove it from master, and develop with TUBEMQ-336 branch (#272)

This is an automated email from the ASF dual-hosted git repository.

gosonzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tubemq.git


The following commit(s) were added to refs/heads/master by this push:
     new a9487f8  [TUBEMQ-358]Adjust tubemq-manager, remove it from master, and develop with TUBEMQ-336 branch (#272)
a9487f8 is described below

commit a9487f80bf9aa107782480a525d69658f4f93ca1
Author: gosonzhang <46...@qq.com>
AuthorDate: Wed Sep 23 10:51:29 2020 +0800

    [TUBEMQ-358]Adjust tubemq-manager, remove it from master, and develop with TUBEMQ-336 branch (#272)
    
    Co-authored-by: gosonzhang <go...@tencent.com>
---
 tubemq-manager/pom.xml                             | 78 -----------------
 .../org/apache/tubemq/manager/TubeMQManager.java   | 44 ----------
 .../tubemq/manager/backend/AbstractDaemon.java     | 97 ----------------------
 .../tubemq/manager/backend/ThreadStartAndStop.java | 37 ---------
 .../manager/backend/TubeMQManagerFactory.java      | 46 ----------
 .../apache/tubemq/manager/entry/BusinessEntry.java | 48 -----------
 .../manager/repository/BusinessRepository.java     | 27 ------
 .../manager/repository/TestBusinessRepository.java | 49 -----------
 8 files changed, 426 deletions(-)

diff --git a/tubemq-manager/pom.xml b/tubemq-manager/pom.xml
deleted file mode 100644
index 6021701..0000000
--- a/tubemq-manager/pom.xml
+++ /dev/null
@@ -1,78 +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.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-validation</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-jpa</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>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
\ 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 ac1ac14..0000000
--- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/TubeMQManager.java
+++ /dev/null
@@ -1,44 +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 org.apache.tubemq.manager.backend.AbstractDaemon;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class TubeMQManager extends AbstractDaemon {
-    public static void main(String[] args) throws Exception {
-        TubeMQManager manager = new TubeMQManager();
-        manager.startThreads();
-        SpringApplication.run(TubeMQManager.class);
-        // web application stopped, then stop working threads.
-        manager.stopThreads();
-        manager.join();
-    }
-
-    @Override
-    public void startThreads() throws Exception {
-
-    }
-
-    @Override
-    public void stopThreads() throws Exception {
-
-    }
-}
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/AbstractDaemon.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/AbstractDaemon.java
deleted file mode 100644
index 2db9318..0000000
--- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/AbstractDaemon.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.backend;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract daemon with a batch of working thread.
- */
-public abstract class AbstractDaemon implements ThreadStartAndStop {
-    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractDaemon.class);
-
-    // worker thread pool
-    private final ExecutorService workerServices;
-    private final List<CompletableFuture<?>> workerFutures;
-    private boolean runnable = true;
-
-    public AbstractDaemon() {
-        this.workerServices = Executors
-                .newCachedThreadPool(new TubeMQManagerFactory(this.getClass().getSimpleName()));
-        this.workerFutures = new ArrayList<>();
-    }
-
-    /**
-     * Whether threads can in running state with while loop.
-     *
-     * @return - true if threads can run
-     */
-    public boolean isRunnable() {
-        return runnable;
-    }
-
-    /**
-     * Stop running threads.
-     */
-    public void stopRunningThreads() {
-        runnable = false;
-    }
-
-    /**
-     * Submit work thread to thread pool.
-     *
-     * @param worker - work thread
-     */
-    public void submitWorker(Runnable worker) {
-        CompletableFuture<?> future = CompletableFuture.runAsync(worker, this.workerServices);
-        workerFutures.add(future);
-        LOGGER.info("{} running worker number is {}", this.getClass().getName(),
-                workerFutures.size());
-    }
-
-    /**
-     * Wait for threads finish.
-     */
-    public void join() {
-        for (CompletableFuture<?> future : workerFutures) {
-            future.join();
-        }
-    }
-
-    /**
-     * Stop thread pool and running threads if they're in the running state.
-     *
-     * @param timeout - max wait time
-     * @param timeUnit - time unit
-     */
-    public void waitForTerminate(long timeout, TimeUnit timeUnit) throws Exception {
-        // stopping working threads.
-        if (isRunnable()) {
-            stopRunningThreads();
-            workerServices.shutdown();
-            workerServices.awaitTermination(timeout, timeUnit);
-        }
-    }
-}
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/ThreadStartAndStop.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/ThreadStartAndStop.java
deleted file mode 100644
index d3cacef..0000000
--- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/ThreadStartAndStop.java
+++ /dev/null
@@ -1,37 +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.backend;
-
-/**
- * Interface for starting and stopping backend threads.
- */
-public interface ThreadStartAndStop {
-    /**
-     * start all threads.
-     */
-    void startThreads() throws Exception;
-
-    /**
-     * stop all threads.
-     */
-    void stopThreads() throws Exception;
-
-    /**
-     * wait for all thread finishing.
-     */
-    void join() throws Exception;
-}
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/TubeMQManagerFactory.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/TubeMQManagerFactory.java
deleted file mode 100644
index ca72901..0000000
--- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/backend/TubeMQManagerFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * <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.backend;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Thread factory for tubeMQ manager.
- */
-public class TubeMQManagerFactory implements ThreadFactory {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(TubeMQManagerFactory.class);
-
-    private final AtomicInteger mThreadNum = new AtomicInteger(1);
-
-    private final String threadType;
-
-    public TubeMQManagerFactory(String threadType) {
-        this.threadType = threadType;
-    }
-
-    @Override
-    public Thread newThread(Runnable r) {
-        Thread t = new Thread(r, threadType + "-running-thread-" + mThreadNum.getAndIncrement());
-        LOGGER.info("{} created", t.getName());
-        return t;
-    }
-}
\ No newline at end of file
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/BusinessEntry.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/BusinessEntry.java
deleted file mode 100644
index 425a8e8..0000000
--- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/BusinessEntry.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.entry;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.validation.constraints.Size;
-
-@Entity
-@Table(name = "business")
-public class BusinessEntry {
-    @Id
-    @GeneratedValue(strategy = GenerationType.AUTO)
-    private Long id;
-
-    @Size(min = 3, max = 20)
-    private String name;
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-}
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/BusinessRepository.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/BusinessRepository.java
deleted file mode 100644
index 24a22cf..0000000
--- a/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/BusinessRepository.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.repository;
-
-import org.apache.tubemq.manager.entry.BusinessEntry;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface BusinessRepository extends JpaRepository<BusinessEntry, Long> {
-   public BusinessEntry findByName(String name);
-}
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 b217018..0000000
--- a/tubemq-manager/src/test/java/org/apache/tubemq/manager/repository/TestBusinessRepository.java
+++ /dev/null
@@ -1,49 +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.BusinessEntry;
-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 BusinessRepository businessRepository;
-
-    @Test
-    public void whenFindByNameThenReturnBusiness() {
-        BusinessEntry businessEntry = new BusinessEntry();
-        businessEntry.setName("alex");
-
-        entityManager.persist(businessEntry);
-        entityManager.flush();
-
-        BusinessEntry businessEntry1 = businessRepository.findByName("alex");
-        assertThat(businessEntry1.getName()).isEqualTo(businessEntry.getName());
-    }
-}