com.google.code.or..OpenReplicator.swp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of open-replicator Show documentation
Show all versions of open-replicator Show documentation
Open Replicator is a high performance MySQL binlog parser written in Java.
b0VIM 7.4 r?V?4@?/ ben alpha21 ~ben/src/open-replicator/src/main/java/com/google/code/or/OpenReplicator.java utf-8
3210 #"! U tp T ? U ^ ? Y ad ? ? ? ? ? ? ? ? ? ? Q E @ > 8 ? ? ? ? ? f d K : 8 ?
?
?
l
^
0
? ? ? ? ? ? ? X L G E ? e E C ?
?
?
?
?
?
?
?
?
}
w
^
N
J
H
&
? ? ? ? ? ? ? ? } m i g B - ) ' ? ? ? ? ? ? ? } i e c 6 ? ? ? ? ? ? ? ? k Q M K ? ? ? ? ? ? ? f = 9 7 ? ? ? ? ? ? ? ^ B > < ? ? ? ? ? | z 2 ? ? ? ? ? ? ? ? ? ? o P L J ? ? public void setBinlogParser(ReplicationBasedBinlogParser parser) {
}
return binlogParser;
public BinlogParser getBinlogParser() {
}
this.transport = transport;
public void setTransport(Transport transport) {
}
return transport;
public Transport getTransport() {
*/
*
/**
}
this.socketReceiveBufferSize = socketReceiveBufferSize;
public void setSocketReceiveBufferSize(int socketReceiveBufferSize) {
}
return socketReceiveBufferSize;
public int getSocketReceiveBufferSize() {
}
this.level2BufferSize = level2BufferSize;
public void setLevel2BufferSize(int level2BufferSize) {
}
return level2BufferSize;
public int getLevel2BufferSize() {
}
this.level1BufferSize = level1BufferSize;
public void setLevel1BufferSize(int level1BufferSize) {
}
return level1BufferSize;
public int getLevel1BufferSize() {
}
this.binlogFileName = binlogFileName;
public void setBinlogFileName(String binlogFileName) {
}
return binlogFileName;
public String getBinlogFileName() {
}
this.binlogPosition = binlogPosition;
public void setBinlogPosition(long binlogPosition) {
}
return binlogPosition;
public long getBinlogPosition() {
}
this.serverId = serverId;
public void setServerId(int serverId) {
}
return serverId;
public int getServerId() {
}
this.encoding = encoding;
public void setEncoding(String encoding) {
}
return encoding;
public String getEncoding() {
}
this.password = password;
public void setPassword(String password) {
}
return password;
public String getPassword() {
}
this.user = user;
public void setUser(String user) {
}
return user;
public String getUser() {
}
this.host = host;
public void setHost(String host) {
}
return host;
public String getHost() {
}
this.port = port;
public void setPort(int port) {
}
return port;
public int getPort() {
*/
*
/**
}
}
// NOP
} catch(Exception e) {
stop(timeout, unit);
try {
public void stopQuietly(long timeout, TimeUnit unit) {
}
this.binlogParser.stop(timeout, unit);
this.transport.disconnect();
// last event, and doesn't have any timeouts. so we deal with the EOF exception thrown elsewhere in the code.
// disconnect the transport first: seems kinda wrong, but the parser thread can be blocked waiting for the
}
return;
if(!this.running.compareAndSet(true, false)) {
//
public void stop(long timeout, TimeUnit unit) throws Exception {
}
this.binlogParser.start();
});
}
stopQuietly(0, TimeUnit.MILLISECONDS);
public void onStop(BinlogParser parser) {
@Override
this.binlogParser.addParserListener(new BinlogParserListener.Adapter() {
this.binlogParser.setEventListener(this.binlogEventListener);
this.binlogParser.setBinlogFileName(this.binlogFileName);
dumpBinlog();
setupChecksumState();
this.binlogParser = getDefaultBinlogParser();
if(this.binlogParser == null)
//
this.transport.connect(this.host, this.port);
if(this.transport == null) this.transport = getDefaultTransport();
//
}
return;
if(!this.running.compareAndSet(false, true)) {
//
public void start() throws Exception {
}
return this.running.get();
public boolean isRunning() {
*/
*
ad l T ? ? j " ? ? S O ?
?
<
? ? ? ? ? ? n ; 9 ? ? ? ? ] ?
?
@
? ? | = ? ? z 5 ? ? h " ? ? e / ? ? t I ? ? ? ? ? u a \ = 8 ? ? ? ? c < ? ? ? ? z C ? ? r l u /**
private static final Logger LOGGER = LoggerFactory.getLogger(OpenReplicator.class);
protected final AtomicBoolean running = new AtomicBoolean(false);
protected BinlogEventListener binlogEventListener;
protected ReplicationBasedBinlogParser binlogParser;
protected Transport transport;
//
protected int socketReceiveBufferSize = 512 * 1024;
protected int level2BufferSize = 8 * 1024 * 1024;
protected int level1BufferSize = 1024 * 1024;
protected String encoding = "utf-8";
protected long binlogPosition = 4;
protected String binlogFileName;
protected int serverId = 6789;
protected String password;
protected String user;
protected String host;
protected int port = 3306;
//
public class OpenReplicator {
*/
* @author darnaut
* @author Jingqi Xu
*
/**
import com.google.code.or.net.impl.packet.command.ComBinlogDumpPacket;
import com.google.code.or.net.impl.packet.ErrorPacket;
import com.google.code.or.net.impl.TransportImpl;
import com.google.code.or.net.impl.Query;
import com.google.code.or.net.impl.AuthenticatorImpl;
import com.google.code.or.net.TransportException;
import com.google.code.or.net.Transport;
import com.google.code.or.net.Packet;
import com.google.code.or.io.impl.SocketFactoryImpl;
import com.google.code.or.common.glossary.column.StringColumn;
import com.google.code.or.binlog.impl.parser.GtidEventParser;
import com.google.code.or.binlog.impl.parser.XidEventParser;
import com.google.code.or.binlog.impl.parser.WriteRowsEventV2Parser;
import com.google.code.or.binlog.impl.parser.WriteRowsEventParser;
import com.google.code.or.binlog.impl.parser.UserVarEventParser;
import com.google.code.or.binlog.impl.parser.UpdateRowsEventV2Parser;
import com.google.code.or.binlog.impl.parser.UpdateRowsEventParser;
import com.google.code.or.binlog.impl.parser.TableMapEventParser;
import com.google.code.or.binlog.impl.parser.StopEventParser;
import com.google.code.or.binlog.impl.parser.RotateEventParser;
import com.google.code.or.binlog.impl.parser.RandEventParser;
import com.google.code.or.binlog.impl.parser.QueryEventParser;
import com.google.code.or.binlog.impl.parser.IntvarEventParser;
import com.google.code.or.binlog.impl.parser.IncidentEventParser;
import com.google.code.or.binlog.impl.parser.FormatDescriptionEventParser;
import com.google.code.or.binlog.impl.parser.DeleteRowsEventV2Parser;
import com.google.code.or.binlog.impl.parser.DeleteRowsEventParser;
import com.google.code.or.binlog.impl.ReplicationBasedBinlogParser;
import com.google.code.or.binlog.BinlogParserListener;
import com.google.code.or.binlog.BinlogParser;
import com.google.code.or.binlog.BinlogEventListener;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.TimeUnit;
import java.util.List;
package com.google.code.or;
*/
* limitations under the License.
* See the License for the specific language governing permissions and
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* distributed under the License is distributed on an "AS IS" BASIS,
* Unless required by applicable law or agreed to in writing, software
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* the License. You may obtain a copy of the License at
* (the "License"); you may not use this file except in compliance with
* The ASF licenses this file to You under the Apache License, Version 2.0
* this work for additional information regarding copyright ownership.
* contributor license agreements. See the NOTICE file distributed with
* Licensed to the Apache Software Foundation (ASF) under one or more
/**
ad e ? ^ ? ? ? ? ? ? ~ 9
? ? ? ? J H ?
?
?
w
$
? ? ? ? f ? ? q D B < ?
?
z
Q
L
H
F
? ? o m g # ? ? ? ~ | v 2
? ? { n j h
? ? [ ( ? ? ? a , ? ? ? S ? ? k : 6 0
? ? ? ? ? ? ? }
}
retu}
}
}
}
}
return r;
r.}
}
return r;
r.setTransport(this.transport);
//
r.registerEventParser(new GtidEventParser());
r.registerEventParser(new FormatDescriptionEventParser());
r.registerEventParser(new DeleteRowsEventV2Parser());
r.registerEventParser(new UpdateRowsEventV2Parser());
r.registerEventParser(new WriteRowsEventV2Parser());
r.registerEventParser(new DeleteRowsEventParser());
r.registerEventParser(new UpdateRowsEventParser());
r.registerEventParser(new WriteRowsEventParser());
r.registerEventParser(new TableMapEventParser());
r.registerEventParser(new IncidentEventParser());
r.registerEventParser(new UserVarEventParser());
r.registerEventParser(new QueryEventParser());
r.registerEventParser(new RandEventParser());
r.registerEventParser(new XidEventParser());
r.registerEventParser(new IntvarEventParser());
r.registerEventParser(new RotateEventParser());
r.registerEventParser(new StopEventParser());
final ReplicationBasedBinlogParser r = new ReplicationBasedBinlogParser();
//
protected ReplicationBasedBinlogParser getDefaultBinlogParser() throws Exception {
}
return r;
r.setSocketFactory(socketFactory);
socketFactory.setReceiveBufferSize(this.socketReceiveBufferSize);
socketFactory.setTcpNoDelay(false);
socketFactory.setKeepAlive(true);
final SocketFactoryImpl socketFactory = new SocketFactoryImpl();
//
r.setAuthenticator(authenticator);
authenticator.setEncoding(this.encoding);
authenticator.setPassword(this.password);
authenticator.setUser(this.user);
final AuthenticatorImpl authenticator = new AuthenticatorImpl();
//
r.setLevel2BufferSize(this.level2BufferSize);
r.setLevel1BufferSize(this.level1BufferSize);
final TransportImpl r = new TransportImpl();
//
protected Transport getDefaultTransport() throws Exception {
}
}
throw new TransportException(error);
final ErrorPacket error = ErrorPacket.valueOf(packet);
if(packet.getPacketBody()[0] == ErrorPacket.PACKET_MARKER) {
final Packet packet = this.transport.getInputStream().readPacket();
//
this.transport.getOutputStream().flush();
this.transport.getOutputStream().writePacket(command);
command.setBinlogFileName(StringColumn.valueOf(this.binlogFileName.getBytes(this.encoding)));
command.setBinlogPosition(this.binlogPosition);
command.setServerId(this.serverId);
command.setBinlogFlag(0);
final ComBinlogDumpPacket command = new ComBinlogDumpPacket();
//
protected void dumpBinlog() throws Exception {
*/
*
/**
}
}
throw e;
if ( e.getErrorCode() != 1193 ) // ignore no-such-variable errors on mysql 5.5
} catch ( TransportException e ) {
}
query.getFirst("SET @master_binlog_checksum = @@global.binlog_checksum");
if ( cols != null && cols.get(0).equals("CRC32") || cols.get(0).equals("NONE")) {
List cols = query.getFirst("SELECT @@global.binlog_checksum");
try {
final Query query = new Query(this.transport);
protected void setupChecksumState() throws Exception {
}
this.binlogEventListener = listener;
public void setBinlogEventListener(BinlogEventListener listener) {
}
return binlogEventListener;
public BinlogEventListener getBinlogEventListener() {
}
this.binlogParser = parser;