com.google.code.or.binlog.impl..FileBasedBinlogParser.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 ^?V?4@?/ ben alpha21 ~ben/src/open-replicator/src/main/java/com/google/code/or/binlog/impl/FileBasedBinlogParser.java utf-8
3210 #"! U tp u I ~ ad u ? ? j " ? ? S O ?
?
<
? ? ? ? ? ? d b 1 ? ? ? t r = ?
?
?
]
1
? ? ? ? ? ? ? S N ? ? ? ? ? ? d @ > < 6 1 + ? ? o k i ] ? ? ? ? ? ? ? ? ? ? g H D B ? ? ? ? ? ? ? n j h 5
? ? ? ? ? l h f d ^ Y S G ? ? ? } O
? ? | 1 ) ! # ! header.se head head header.setServerId(is.readLong(4));
header.setEventType(is.readInt header.setServerId(is.readLong(4));
heade header.setServerId(is.readLong(4));
header.setServerId(is.readLong(4));
try {
final BinlogEventV4HeaderImpl header = es.getNextBinlogHeader();
while(isRunning() && is.available() > 0) {
es.setChecksumEnabled(findChecksumEnabled());
final EventInputStream es = new EventInputStream(is);
final Context context = new Context(this);
protected void doParse() throws Exception {
@Override
*/
*
/**
}
this.startPosition = startPosition;
public void setStartPosition(long startPosition) {
}
return startPosition;
public long getStartPosition() {
}
this.stopPosition = stopPosition;
public void setStopPosition(long stopPosition) {
}
return stopPosition;
public long getStopPosition() {
}
this.binlogFilePath = path;
public void setBinlogFilePath(String path) {
}
return binlogFilePath;
public String getBinlogFilePath() {
}
this.binlogFileName = name;
public void setBinlogFileName(String name) {
}
return binlogFileName;
public String getBinlogFileName() {
*/
*
/**
}
IOUtils.closeQuietly(this.is);
protected void doStop(long timeout, TimeUnit unit) throws Exception {
@Override
}
this.is = open(this.binlogFilePath + "/" + this.binlogFileName, this.startPosition);
protected void doStart() throws Exception {
@Override
}
public FileBasedBinlogParser() {
*/
*
/**
protected long startPosition = 4;
protected long stopPosition = 0;
protected String binlogFilePath;
protected String binlogFileName;
protected XInputStream is;
//
private static final Logger LOGGER = LoggerFactory.getLogger(FileBasedBinlogParser.class);
//
public class FileBasedBinlogParser extends AbstractBinlogParser {
*/
* @author Jingqi Xu
*
/**
import com.google.code.or.io.util.RamdomAccessFileInputStream;
import com.google.code.or.io.impl.XInputStreamImpl;
import com.google.code.or.io.XInputStream;
import com.google.code.or.common.util.MySQLConstants;
import com.google.code.or.common.util.IOUtils;
import com.google.code.or.common.util.CodecUtils;
import com.google.code.or.binlog.impl.event.BinlogEventV4HeaderImpl;
import com.google.code.or.binlog.BinlogEventParser;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import com.google.code.or.net.impl.EventInputStream;
import com.google.code.or.binlog.impl.parser.FormatDescriptionEventParser;
import com.google.code.or.binlog.BinlogEventV4;
import java.util.concurrent.TimeUnit;
import java.io.File;
package com.google.code.or.binlog.impl;
*/
* 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 ? I ? ? ? ? ? 9 , % # ? q ) ?
?
?
?
?
?
j
\
L
3
-
(
$
"
? ? a S ! ? ? ? Q ?
?
?
M
? ? ? ? ? ? ? ? U O ? ? ? > ? ? ? ? ? v p a G ) ? ? K ? ? ? ? }
}
}
throw e;
IOUtils.closeQu}
}
}
throw e;
IOUtils.closeQuie}
}
}
throw e;
IOUtils.c}
}
}
throw e;
IOUtils.closeQuietly(is)}
}
}
throw e;
IOUtils.closeQuietly(is);
} catc}
}
}
throw e;
IOUtils.closeQuietly(is);
} catch(Exception e) {
return is;
}
is.s}
}
}
throw e;
}
}
}
throw e;
IOUtils.closeQuietly(is);
} catch(Exception e) {
return is;
}
is.skip(offset - MySQLConstants.BINLOG_MAGIC.length);
if(offset > MySQLConstants.BINLOG_MAGIC.length) {
//
}
throw new RuntimeException("invalid binlog magic, file: " + path);
if(!CodecUtils.equals(magic, MySQLConstants.BINLOG_MAGIC)) {
final byte[] magic = is.readBytes(MySQLConstants.BINLOG_MAGIC.length);
// Check binlog magic
try {
final XInputStream is = new XInputStreamImpl(new RamdomAccessFileInputStream(new File(path)));
//
protected XInputStream open(String path, Long offset) throws Exception {
*/
*
/**
}
return context.getChecksumEnabled();
es.close();
es.finishEvent(header);
new FormatDescriptionEventParser().parse(es, header, context);
// parser for FORMAT_DESCRIPTION_EVENT, or they may not want to get it
// use our own parser instead of the client's -- they may not have registered a
throw new RuntimeException("Expected FORMAT_DESCRIPTION_EVENT at top of file, found " + header);
if ( header.getEventType() != MySQLConstants.FORMAT_DESCRIPTION_EVENT )
final BinlogEventV4HeaderImpl header = es.getNextBinlogHeader();
final EventInputStream es = new EventInputStream(is);
};
public void onEvents(BinlogEventV4 event) { }
@Override
final Context context = new Context(this) {
final XInputStream is = open(this.binlogFilePath + "/" + this.binlogFileName, 4L);
private boolean findChecksumEnabled() throws Exception {
}
}
}
is.setReadLimit(0);
} finally {
throw e;
IOUtils.closeQuietly(is);
} catch(Exception e) {
es.finishEvent(header);
}
parser.parse(es, header, context);
if(parser == null) parser = this.defaultParser;
BinlogEventParser parser = getEventParser(header.getEventType());
} else {
this.defaultParser.parse(es, header, context);
if(this.eventFilter != null && !this.eventFilter.accepts(header, context)) {
// Parse the event body
}
break;
if(this.stopPosition > 0 && header.getPosition() > this.stopPosition) {
//
}
LOGGER.info("read an event, header: {}", header);
if(isVerbose() && LOGGER.isInfoEnabled()) {