From 8e72861344fedb8c047982e0794cece9ca629110 Mon Sep 17 00:00:00 2001 From: wenyh <44251917+wenyh1@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:32:09 +0800 Subject: [PATCH 1/2] [inner-2358] manager side uses managerFrontHandlerQueue when authenticating --- .../factorys/ManagerConnectionFactory.java | 4 +-- .../MySQLManagerFrontAuthService.java | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLManagerFrontAuthService.java diff --git a/src/main/java/com/actiontech/dble/services/factorys/ManagerConnectionFactory.java b/src/main/java/com/actiontech/dble/services/factorys/ManagerConnectionFactory.java index 303dfbbdc..850b05cd5 100644 --- a/src/main/java/com/actiontech/dble/services/factorys/ManagerConnectionFactory.java +++ b/src/main/java/com/actiontech/dble/services/factorys/ManagerConnectionFactory.java @@ -9,7 +9,7 @@ package com.actiontech.dble.services.factorys; import com.actiontech.dble.net.SocketWR; import com.actiontech.dble.net.connection.FrontendConnection; import com.actiontech.dble.net.factory.FrontendConnectionFactory; -import com.actiontech.dble.services.mysqlauthenticate.MySQLFrontAuthService; +import com.actiontech.dble.services.mysqlauthenticate.MySQLManagerFrontAuthService; import java.io.IOException; import java.nio.channels.NetworkChannel; @@ -19,7 +19,7 @@ public class ManagerConnectionFactory extends FrontendConnectionFactory { @Override protected FrontendConnection getConnection(NetworkChannel channel, SocketWR socketWR) throws IOException { FrontendConnection c = new FrontendConnection(channel, socketWR, true); - c.setService(new MySQLFrontAuthService(c)); + c.setService(new MySQLManagerFrontAuthService(c)); return c; } } diff --git a/src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLManagerFrontAuthService.java b/src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLManagerFrontAuthService.java new file mode 100644 index 000000000..baffe062e --- /dev/null +++ b/src/main/java/com/actiontech/dble/services/mysqlauthenticate/MySQLManagerFrontAuthService.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016-2023 ActionTech. + * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher. + */ + +package com.actiontech.dble.services.mysqlauthenticate; + +import com.actiontech.dble.DbleServer; +import com.actiontech.dble.net.connection.AbstractConnection; +import com.actiontech.dble.net.service.NotificationServiceTask; +import com.actiontech.dble.net.service.ServiceTask; + + +/** + * Created by szf on 2020/6/18. + */ +public class MySQLManagerFrontAuthService extends MySQLFrontAuthService { + + public MySQLManagerFrontAuthService(AbstractConnection connection) { + super(connection); + } + + @Override + public void handle(ServiceTask task) { + beforeInsertServiceTask(task); + task.setTaskId(taskId.getAndIncrement()); + DbleServer.getInstance().getManagerFrontHandlerQueue().offer(task); + } + + public void notifyTaskThread() { + DbleServer.getInstance().getManagerFrontHandlerQueue().offerFirst(new NotificationServiceTask(this)); + } +} From 4c447788fbd33b74629c1851b778c2efddf28129 Mon Sep 17 00:00:00 2001 From: wenyh <44251917+wenyh1@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:33:23 +0800 Subject: [PATCH 2/2] [inner-2356] adjust tips --- .../dble/singleton/ThreadManager.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/actiontech/dble/singleton/ThreadManager.java b/src/main/java/com/actiontech/dble/singleton/ThreadManager.java index b40484e7c..85af0d958 100644 --- a/src/main/java/com/actiontech/dble/singleton/ThreadManager.java +++ b/src/main/java/com/actiontech/dble/singleton/ThreadManager.java @@ -118,7 +118,7 @@ public final class ThreadManager { throw new Exception("The recover operation of threadPool[" + threadName + "] is not supported"); } } else { - throw new Exception("The recover operation of threadPool[" + threadName + "] is not supported"); + throw new Exception("The recover operation of thread[" + threadName + "] is not supported"); } } @@ -157,13 +157,21 @@ public final class ThreadManager { XaCheckHandler.stopXaIdCheckPeriod(); LOGGER.info("manual shutdown threadPool[{}] ... end ...", TIMER_SCHEDULER_WORKER_NAME); break; + case FRONT_WORKER_NAME: + case FRONT_MANAGER_WORKER_NAME: + case BACKEND_WORKER_NAME: + case WRITE_TO_BACKEND_WORKER_NAME: + case COMPLEX_QUERY_EXECUTOR_NAME: + case NIO_FRONT_RW: + case NIO_BACKEND_RW: + throw new Exception("The recover operation of threadPool[" + threadPoolName + "] is not supported"); default: - throw new Exception("The shutdown operation of thread[" + TIMER_SCHEDULER_WORKER_NAME + "] is not supported"); + throw new Exception("The threadPool[" + threadPoolName + "] does not exist"); } } - public static void recoverThreadPool(String threadName) throws Exception { - switch (threadName) { + public static void recoverThreadPool(String threadPoolName) throws Exception { + switch (threadPoolName) { case TIMER_WORKER_NAME: if (!DbleServer.getInstance().getTimerExecutor().isShutdown()) { throw new Exception("threadPool[" + TIMER_WORKER_NAME + "] is not shutdown, no need to recover"); @@ -199,8 +207,16 @@ public final class ThreadManager { XaCheckHandler.startXaIdCheckPeriod(); LOGGER.info("manual recover threadPool[{}] ... end ...", TIMER_SCHEDULER_WORKER_NAME); break; + case FRONT_WORKER_NAME: + case FRONT_MANAGER_WORKER_NAME: + case BACKEND_WORKER_NAME: + case WRITE_TO_BACKEND_WORKER_NAME: + case COMPLEX_QUERY_EXECUTOR_NAME: + case NIO_FRONT_RW: + case NIO_BACKEND_RW: + throw new Exception("The recover operation of threadPool[" + threadPoolName + "] is not supported"); default: - throw new Exception("The recover operation of threadPool[" + threadName + "] is not supported"); + throw new Exception("The threadPool[" + threadPoolName + "] does not exist"); } }