|
@@ -33,7 +33,7 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void initSSLContext(SSLContext sc) throws GeneralSecurityException {
|
|
protected void initSSLContext(SSLContext sc) throws GeneralSecurityException {
|
|
- sc.init(null, new TrustManager[]{
|
|
|
|
|
|
+ sc.init(null, new TrustManager[] {
|
|
new X509TrustManager() {
|
|
new X509TrustManager() {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -126,12 +126,12 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
ensureEventDeserializerHasRequiredEDDs();
|
|
ensureEventDeserializerHasRequiredEDDs();
|
|
|
|
|
|
// new Thread
|
|
// new Thread
|
|
- this.worker = new Thread(()-> listenForEventPackets(channel));
|
|
|
|
|
|
+ this.worker = new Thread(() -> listenForEventPackets(channel));
|
|
this.worker.setDaemon(false);
|
|
this.worker.setDaemon(false);
|
|
this.workerThreadName = new StringBuilder("binlog-parser-").append(hostname).append(":").append(port).append("_").append(connectionId).toString();
|
|
this.workerThreadName = new StringBuilder("binlog-parser-").append(hostname).append(":").append(port).append("_").append(connectionId).toString();
|
|
this.worker.setName(workerThreadName);
|
|
this.worker.setName(workerThreadName);
|
|
this.worker.start();
|
|
this.worker.start();
|
|
- notifyConnectEvent();
|
|
|
|
|
|
+ lifecycleListeners.forEach(listener -> listener.onConnect(this));
|
|
} finally {
|
|
} finally {
|
|
connectLock.unlock();
|
|
connectLock.unlock();
|
|
}
|
|
}
|
|
@@ -143,11 +143,11 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
try {
|
|
try {
|
|
connectLock.lock();
|
|
connectLock.lock();
|
|
closeChannel(channel);
|
|
closeChannel(channel);
|
|
- if(null != this.worker && !worker.isInterrupted()){
|
|
|
|
|
|
+ if (null != this.worker && !worker.isInterrupted()) {
|
|
this.worker.interrupt();
|
|
this.worker.interrupt();
|
|
this.worker = null;
|
|
this.worker = null;
|
|
}
|
|
}
|
|
- notifyDisconnectEvent();
|
|
|
|
|
|
+ lifecycleListeners.forEach(listener -> listener.onDisconnect(this));
|
|
} finally {
|
|
} finally {
|
|
connectLock.unlock();
|
|
connectLock.unlock();
|
|
}
|
|
}
|
|
@@ -242,11 +242,7 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
if (cause instanceof EOFException || cause instanceof SocketException) {
|
|
if (cause instanceof EOFException || cause instanceof SocketException) {
|
|
throw e;
|
|
throw e;
|
|
}
|
|
}
|
|
- if (connected) {
|
|
|
|
- for (BinaryLogRemoteClient.LifecycleListener lifecycleListener : lifecycleListeners) {
|
|
|
|
- lifecycleListener.onEventDeserializationFailure(this, e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ lifecycleListeners.forEach(listener -> listener.onEventDeserializationFailure(this, e));
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (connected) {
|
|
if (connected) {
|
|
@@ -256,11 +252,7 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- if (connected) {
|
|
|
|
- for (BinaryLogRemoteClient.LifecycleListener lifecycleListener : lifecycleListeners) {
|
|
|
|
- lifecycleListener.onCommunicationFailure(this, e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ lifecycleListeners.forEach(listener -> listener.onCommunicationFailure(this, e));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -535,7 +527,7 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
}
|
|
}
|
|
|
|
|
|
private void setConfig() {
|
|
private void setConfig() {
|
|
- if(null == tableMapEventByTableId){
|
|
|
|
|
|
+ if (null == tableMapEventByTableId) {
|
|
tableMapEventByTableId = new HashMap<>();
|
|
tableMapEventByTableId = new HashMap<>();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -556,7 +548,7 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
eventDataDeserializers.put(EventType.EXT_DELETE_ROWS, (new DeleteRowsEventDataDeserializer(tableMapEventByTableId)).setMayContainExtraInformation(true));
|
|
eventDataDeserializers.put(EventType.EXT_DELETE_ROWS, (new DeleteRowsEventDataDeserializer(tableMapEventByTableId)).setMayContainExtraInformation(true));
|
|
eventDataDeserializers.put(EventType.XID, new XidEventDataDeserializer());
|
|
eventDataDeserializers.put(EventType.XID, new XidEventDataDeserializer());
|
|
|
|
|
|
- if(simpleEventModel){
|
|
|
|
|
|
+ if (simpleEventModel) {
|
|
eventDataDeserializers.put(EventType.INTVAR, new IntVarEventDataDeserializer());
|
|
eventDataDeserializers.put(EventType.INTVAR, new IntVarEventDataDeserializer());
|
|
eventDataDeserializers.put(EventType.QUERY, new QueryEventDataDeserializer());
|
|
eventDataDeserializers.put(EventType.QUERY, new QueryEventDataDeserializer());
|
|
eventDataDeserializers.put(EventType.ROWS_QUERY, new RowsQueryEventDataDeserializer());
|
|
eventDataDeserializers.put(EventType.ROWS_QUERY, new RowsQueryEventDataDeserializer());
|
|
@@ -582,18 +574,6 @@ public class BinaryLogRemoteClient implements BinaryLogClient {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void notifyConnectEvent() {
|
|
|
|
- for (BinaryLogRemoteClient.LifecycleListener lifecycleListener : lifecycleListeners) {
|
|
|
|
- lifecycleListener.onConnect(this);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void notifyDisconnectEvent() {
|
|
|
|
- for (BinaryLogRemoteClient.LifecycleListener lifecycleListener : lifecycleListeners) {
|
|
|
|
- lifecycleListener.onDisconnect(this);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public String getBinlogFilename() {
|
|
public String getBinlogFilename() {
|
|
return binlogFilename;
|
|
return binlogFilename;
|