Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[inner-2358] manager side uses managerFrontHandlerQueue when authenticating #3822

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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));
}
}
26 changes: 21 additions & 5 deletions src/main/java/com/actiontech/dble/singleton/ThreadManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static void recoverSingleThread(String threadName) throws Exception {
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");
}
}

Expand Down Expand Up @@ -157,13 +157,21 @@ public static void shutDownThreadPool(String threadPoolName) throws Exception {
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");
Expand Down Expand Up @@ -199,8 +207,16 @@ public static void recoverThreadPool(String threadName) throws Exception {
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");
}
}

Expand Down