mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
Fix: 主备切换后没有往Kafka发送数据 (#1810)
发生主备切换时,调用canalMQStarter启停对应的destination。
This commit is contained in:
@@ -152,6 +152,9 @@ public class CanalController {
|
|||||||
try {
|
try {
|
||||||
MDC.put(CanalConstants.MDC_DESTINATION, String.valueOf(destination));
|
MDC.put(CanalConstants.MDC_DESTINATION, String.valueOf(destination));
|
||||||
embededCanalServer.start(destination);
|
embededCanalServer.start(destination);
|
||||||
|
if (canalMQStarter != null) {
|
||||||
|
canalMQStarter.startDestination(destination);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
MDC.remove(CanalConstants.MDC_DESTINATION);
|
MDC.remove(CanalConstants.MDC_DESTINATION);
|
||||||
}
|
}
|
||||||
@@ -160,6 +163,9 @@ public class CanalController {
|
|||||||
public void processActiveExit() {
|
public void processActiveExit() {
|
||||||
try {
|
try {
|
||||||
MDC.put(CanalConstants.MDC_DESTINATION, String.valueOf(destination));
|
MDC.put(CanalConstants.MDC_DESTINATION, String.valueOf(destination));
|
||||||
|
if (canalMQStarter != null) {
|
||||||
|
canalMQStarter.stopDestination(destination);
|
||||||
|
}
|
||||||
embededCanalServer.stop(destination);
|
embededCanalServer.stop(destination);
|
||||||
} finally {
|
} finally {
|
||||||
MDC.remove(CanalConstants.MDC_DESTINATION);
|
MDC.remove(CanalConstants.MDC_DESTINATION);
|
||||||
@@ -234,9 +240,6 @@ public class CanalController {
|
|||||||
ServerRunningMonitor runningMonitor = ServerRunningMonitors.getRunningMonitor(destination);
|
ServerRunningMonitor runningMonitor = ServerRunningMonitors.getRunningMonitor(destination);
|
||||||
if (!config.getLazy() && !runningMonitor.isStart()) {
|
if (!config.getLazy() && !runningMonitor.isStart()) {
|
||||||
runningMonitor.start();
|
runningMonitor.start();
|
||||||
if (canalMQStarter != null) {
|
|
||||||
canalMQStarter.startDestination(destination);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,9 +248,6 @@ public class CanalController {
|
|||||||
// 此处的stop,代表强制退出,非HA机制,所以需要退出HA的monitor和配置信息
|
// 此处的stop,代表强制退出,非HA机制,所以需要退出HA的monitor和配置信息
|
||||||
InstanceConfig config = instanceConfigs.remove(destination);
|
InstanceConfig config = instanceConfigs.remove(destination);
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
if (canalMQStarter != null) {
|
|
||||||
canalMQStarter.stopDestination(destination);
|
|
||||||
}
|
|
||||||
embededCanalServer.stop(destination);
|
embededCanalServer.stop(destination);
|
||||||
ServerRunningMonitor runningMonitor = ServerRunningMonitors.getRunningMonitor(destination);
|
ServerRunningMonitor runningMonitor = ServerRunningMonitors.getRunningMonitor(destination);
|
||||||
if (runningMonitor.isStart()) {
|
if (runningMonitor.isStart()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user