Browse Source

etl 增加同步锁

mcy 6 years ago
parent
commit
ddfc2464f3

+ 6 - 2
client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/common/EtlLock.java

@@ -99,12 +99,16 @@ public class EtlLock {
         }
     }
 
-    public void unlock(String key) throws Exception {
+    public void unlock(String key) {
         if (mode == Mode.LOCAL) {
             getLock(key).unlock();
         } else {
             InterProcessMutex lock = getRemoteLock(key);
-            lock.release();
+            try {
+                lock.release();
+            } catch (Exception e) {
+                // ignore
+            }
         }
     }
 }

+ 1 - 5
client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/rest/CommonRest.java

@@ -79,11 +79,7 @@ public class CommonRest {
                 }
             }
         } finally {
-            try {
-                etlLock.unlock(ETL_LOCK_ZK_NODE + type + "-" + task);
-            } catch (Exception e) {
-                logger.error(e.getMessage(), e);
-            }
+            etlLock.unlock(ETL_LOCK_ZK_NODE + type + "-" + task);
         }
     }