From 0b055a3f554da3a934e79e88c4781705cbab5a21 Mon Sep 17 00:00:00 2001 From: renxue <auster_i@163.com> Date: 星期一, 24 十月 2022 11:40:26 +0800 Subject: [PATCH] 修改包下的类名 --- src/main/java/com/hz/canal/starter/container/AbstractCanalTransponderContainer.java | 148 ++++++++++++++++++++++++------------------------ 1 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java b/src/main/java/com/hz/canal/starter/container/AbstractCanalTransponderContainer.java similarity index 93% rename from src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java rename to src/main/java/com/hz/canal/starter/container/AbstractCanalTransponderContainer.java index c0a5094..13060be 100644 --- a/src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java +++ b/src/main/java/com/hz/canal/starter/container/AbstractCanalTransponderContainer.java @@ -1,74 +1,74 @@ -package com.duxinglangzi.canal.starter.container; - -import com.alibaba.otter.canal.protocol.CanalEntry; -import com.duxinglangzi.canal.starter.listener.ApplicationReadyListener; -import org.springframework.context.SmartLifecycle; - -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; - -/** - * 鎶借薄鐨刢anal transponder ,瀹炵幇SmartLifecycle鎺ュ彛,澹版槑鍛ㄦ湡鐢眘pring杩涜绠$悊 - * - * @author wuqiong 2022/4/11 - */ -public abstract class AbstractCanalTransponderContainer implements SmartLifecycle { - protected boolean isRunning = false; - protected final Long SLEEP_TIME_MILLI_SECONDS = 1000L; - protected List<CanalEntry.EntryType> IGNORE_ENTRY_TYPES = - Arrays.asList(CanalEntry.EntryType.TRANSACTIONBEGIN, - CanalEntry.EntryType.TRANSACTIONEND, - CanalEntry.EntryType.HEARTBEAT); - - protected abstract void doStart(); - - protected abstract void initConnect(); - - protected abstract void disconnect(); - - - @Override - public void start() { - new Thread(() -> { - // spring 鍚姩鍚� 鎵嶄細杩涜canal鏁版嵁鎷夊彇 - while (!ApplicationReadyListener.START_LISTENER_CONTAINER.get()) - sleep(5L * SLEEP_TIME_MILLI_SECONDS); - initConnect(); - while (isRunning() && !Thread.currentThread().isInterrupted()) doStart(); - disconnect(); // 绾跨▼琚粓姝㈡垨鑰呭鍣ㄥ凡缁忓仠姝�,闇�瑕佸叧闂繛鎺� - }).start(); - setRunning(true); - } - - @Override - public void stop() { - setRunning(false); - } - - @Override - public void stop(Runnable callback) { - callback.run(); - setRunning(false); - sleep(SLEEP_TIME_MILLI_SECONDS); - } - - @Override - public boolean isRunning() { - return isRunning; - } - - protected void setRunning(boolean bool) { - isRunning = bool; - } - - protected void sleep(long sleepTimeMilliSeconds) { - try { - TimeUnit.MILLISECONDS.sleep(sleepTimeMilliSeconds); - if (!isRunning()) Thread.currentThread().interrupt(); - } catch (InterruptedException e) { - } - } - - -} +package com.hz.canal.starter.container; + +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.hz.canal.starter.listener.ApplicationReadyListener; +import org.springframework.context.SmartLifecycle; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * 鎶借薄鐨刢anal transponder ,瀹炵幇SmartLifecycle鎺ュ彛,澹版槑鍛ㄦ湡鐢眘pring杩涜绠$悊 + * + * @author wuqiong 2022/4/11 + */ +public abstract class AbstractCanalTransponderContainer implements SmartLifecycle { + protected boolean isRunning = false; + protected final Long SLEEP_TIME_MILLI_SECONDS = 1000L; + protected List<CanalEntry.EntryType> IGNORE_ENTRY_TYPES = + Arrays.asList(CanalEntry.EntryType.TRANSACTIONBEGIN, + CanalEntry.EntryType.TRANSACTIONEND, + CanalEntry.EntryType.HEARTBEAT); + + protected abstract void doStart(); + + protected abstract void initConnect(); + + protected abstract void disconnect(); + + + @Override + public void start() { + new Thread(() -> { + // spring 鍚姩鍚� 鎵嶄細杩涜canal鏁版嵁鎷夊彇 + while (!ApplicationReadyListener.START_LISTENER_CONTAINER.get()) + sleep(5L * SLEEP_TIME_MILLI_SECONDS); + initConnect(); + while (isRunning() && !Thread.currentThread().isInterrupted()) doStart(); + disconnect(); // 绾跨▼琚粓姝㈡垨鑰呭鍣ㄥ凡缁忓仠姝�,闇�瑕佸叧闂繛鎺� + }).start(); + setRunning(true); + } + + @Override + public void stop() { + setRunning(false); + } + + @Override + public void stop(Runnable callback) { + callback.run(); + setRunning(false); + sleep(SLEEP_TIME_MILLI_SECONDS); + } + + @Override + public boolean isRunning() { + return isRunning; + } + + protected void setRunning(boolean bool) { + isRunning = bool; + } + + protected void sleep(long sleepTimeMilliSeconds) { + try { + TimeUnit.MILLISECONDS.sleep(sleepTimeMilliSeconds); + if (!isRunning()) Thread.currentThread().interrupt(); + } catch (InterruptedException e) { + } + } + + +} -- Gitblit v1.8.0