|
@@ -2,10 +2,11 @@ package com.alibaba.otter.canal.deployer;
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.util.Properties;
|
|
import java.util.Properties;
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
import com.alibaba.otter.canal.deployer.mbean.CanalServerAgent;
|
|
import com.alibaba.otter.canal.deployer.mbean.CanalServerAgent;
|
|
import com.alibaba.otter.canal.deployer.mbean.CanalServerMXBean;
|
|
import com.alibaba.otter.canal.deployer.mbean.CanalServerMXBean;
|
|
-import com.alibaba.otter.canal.deployer.mbean.CanalServer;
|
|
|
|
|
|
+import com.alibaba.otter.canal.deployer.mbean.CanalServerBean;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -22,13 +23,12 @@ import com.alibaba.otter.canal.deployer.monitor.remote.RemoteCanalConfigMonitor;
|
|
*/
|
|
*/
|
|
public class CanalLauncher {
|
|
public class CanalLauncher {
|
|
|
|
|
|
- private static final String CLASSPATH_URL_PREFIX = "classpath:";
|
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(CanalLauncher.class);
|
|
|
|
- public static volatile boolean running = false;
|
|
|
|
|
|
+ private static final String CLASSPATH_URL_PREFIX = "classpath:";
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(CanalLauncher.class);
|
|
|
|
+ public static final CountDownLatch runningLatch = new CountDownLatch(1);
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
try {
|
|
try {
|
|
- running = true;
|
|
|
|
logger.info("## set default uncaught exception handler");
|
|
logger.info("## set default uncaught exception handler");
|
|
setGlobalUncaughtExceptionHandler();
|
|
setGlobalUncaughtExceptionHandler();
|
|
|
|
|
|
@@ -80,15 +80,13 @@ public class CanalLauncher {
|
|
String jmxPort = properties.getProperty(CanalConstants.CANAL_ADMIN_JMX_PORT);
|
|
String jmxPort = properties.getProperty(CanalConstants.CANAL_ADMIN_JMX_PORT);
|
|
if (StringUtils.isNotEmpty(jmxPort)) {
|
|
if (StringUtils.isNotEmpty(jmxPort)) {
|
|
String ip = properties.getProperty(CanalConstants.CANAL_IP);
|
|
String ip = properties.getProperty(CanalConstants.CANAL_IP);
|
|
- CanalServerMXBean canalServerMBean = new CanalServer(canalStater);
|
|
|
|
|
|
+ CanalServerMXBean canalServerMBean = new CanalServerBean(canalStater);
|
|
canalServerAgent = new CanalServerAgent(ip, Integer.parseInt(jmxPort), canalServerMBean);
|
|
canalServerAgent = new CanalServerAgent(ip, Integer.parseInt(jmxPort), canalServerMBean);
|
|
Thread agentThread = new Thread(canalServerAgent::start);
|
|
Thread agentThread = new Thread(canalServerAgent::start);
|
|
agentThread.start();
|
|
agentThread.start();
|
|
}
|
|
}
|
|
|
|
|
|
- while (running) {
|
|
|
|
- Thread.sleep(1000);
|
|
|
|
- }
|
|
|
|
|
|
+ runningLatch.await();
|
|
|
|
|
|
if (canalServerAgent != null) {
|
|
if (canalServerAgent != null) {
|
|
canalServerAgent.stop();
|
|
canalServerAgent.stop();
|