com.google.code.or.binlog.impl..AbstractBinlogParser.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 j?V?4@?/ ben alpha21 ~ben/src/open-replicator/src/main/java/com/google/code/or/binlog/impl/AbstractBinlogParser.java utf-8
3210 #"! U tp p u ? q W
ad ? ) ? ? ? ? ? z O 6 0 !
? ? ? ? ? ? ? ? d ` ^ 2 ?
?
?
?
?
y
u
s
:
? ? ? ? ? d ` ^ + ? ? g c a [ V P , ?
?
?
?
?
?
{
y
<
? ? ? ? } o 0 ? ? ? ? ? K 3 ? ? ? ? ? ? ? ? ? m ( $ " ? ? ? ? c 2 . , ? ? ? } { U ; 7 5 3 - ( " ? ? ? ? ? { < ! ? ? t o k i c ^ X + )
? ? ? ? ?
protected
prote
protected class Task implements Runnable {
*/
*
/*
protected class Task implements Ru
p
protected class Task
protected class Task implements Runnable {
*/
*
/**
}
}
listener.onException(this, exception);
for(BinlogParserListener listener : this.parserListeners) {
private void notifyOnException(Exception exception) {
}
}
listener.onStop(this);
for(BinlogParserListener listener : this.parserListeners) {
private void notifyOnStop() {
}
}
listener.onStart(this);
for(BinlogParserListener listener : this.parserListeners) {
private void notifyOnStart() {
*/
*
/**
}
return binlogFileName;
public String getBinlogFileName() {
}
if(listeners != null) this.parserListeners.addAll(listeners);
this.parserListeners.clear();
public void setParserListeners(List listeners) {
}
return this.parserListeners.remove(listener);
public boolean removeParserListener(BinlogParserListener listener) {
}
return this.parserListeners.add(listener);
public boolean addParserListener(BinlogParserListener listener) {
}
return new ArrayList(this.parserListeners);
public List getParserListeners() {
*/
*
/**
}
}
}
registerEventParser(parser);
for(BinlogEventParser parser : parsers) {
if(parsers != null) {
clearEventParsers();
public void setEventParsers(List parsers) {
}
return unregisterEventParser(type);
public BinlogEventParser unregistgerEventParser(int type) {
@Deprecated
}
this.registerEventParser(parser);
public void registgerEventParser(BinlogEventParser parser) {
@Deprecated
// maintain backwards compat
}
this.parsers[parser.getEventType()] = parser;
public void registerEventParser(BinlogEventParser parser) {
}
return this.parsers[type] = null;
public BinlogEventParser unregisterEventParser(int type) {
}
return this.parsers[type];
public BinlogEventParser getEventParser(int type) {
}
}
this.parsers[i] = null;
for(int i = 0; i < this.parsers.length; i++) {
public void clearEventParsers() {
*/
*
/**
}
this.clearTableMapEventsOnRotate = clearTableMapEventsOnRotate;
public void setClearTableMapEventsOnRotate(boolean clearTableMapEventsOnRotate) {
}
return clearTableMapEventsOnRotate;
public boolean isClearTableMapEventsOnRotate() {
}
this.eventListener = listener;
public void setEventListener(BinlogEventListener listener) {
}
return eventListener;
public BinlogEventListener getEventListener() {
}
this.eventFilter = filter;
public void setEventFilter(BinlogEventFilter filter) {
}
return eventFilter;
public BinlogEventFilter getEventFilter() {
}
this.threadFactory = tf;
public void setThreadFactory(ThreadFactory tf) {
}
return threadFactory;
public ThreadFactory getThreadFactory() {
}
this.verbose.set(verbose);
public void setVerbose(boolean verbose) {
}
return this.verbose.get();
public boolean isVerbose() {
*/
*
/**
}
}
notifyOnStop();
} finally {
}
this.worker = null;
unit.timedJoin(this.worker, timeout);
if(timeout > 0) {
//
timeout -= unit.convert(System.nanoTime() - now, TimeUnit.NANOSECONDS);
doStop(timeout, unit);
ad ? p ? ? j " ? ? S O ?
?
<
? ? ? ? ? ? f K 3 ? ? ? c a G & $ ?
?
?
R
"
? ? y = ? ? ? ? ? ? ? \ W ? ? ? ? ? ? V ? ? V ? ? ? ? ` * ? ? ? ? ? ? a ? ? ? ? ? ? ? Z N I G A 3 1 + ? ? ? ? ? ? ? s m ; / * ( " ? ? final long now = System.nanoTime();
//
try {
//
}
return;
if(!this.running.compareAndSet(true, false)) {
//
public void stop(long timeout, TimeUnit unit) throws Exception {
}
notifyOnStart();
//
this.worker.start();
this.worker = this.threadFactory.newThread(new Task());
//
doStart();
//
}
return;
if(!this.running.compareAndSet(false, true)) {
//
public void start() throws Exception {
}
return this.running.get();
public boolean isRunning() {
*/
*
/**
}
this.parserListeners = new CopyOnWriteArrayList();
this.threadFactory = new XThreadFactory("binlog-parser", false);
public AbstractBinlogParser() {
*/
*
/**
protected abstract void doStop(long timeout, TimeUnit unit) throws Exception;
protected abstract void doStart() throws Exception;
protected abstract void doParse() throws Exception;
//
protected String binlogFileName;
protected final BinlogEventParser[] parsers = new BinlogEventParser[128];
protected final BinlogEventParser defaultParser = new NopEventParser();
protected final AtomicBoolean running = new AtomicBoolean(false);
protected final AtomicBoolean verbose = new AtomicBoolean(false);
protected final List parserListeners;
protected boolean clearTableMapEventsOnRotate = true;
protected BinlogEventListener eventListener;
protected BinlogEventFilter eventFilter;
protected ThreadFactory threadFactory;
protected Thread worker;
//
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractBinlogParser.class);
//
public abstract class AbstractBinlogParser implements BinlogParser {
*/
* @author Jingqi Xu
*
/**
import com.google.code.or.common.util.XThreadFactory;
import com.google.code.or.binlog.impl.parser.NopEventParser;
import com.google.code.or.binlog.impl.event.TableMapEvent;
import com.google.code.or.binlog.impl.event.RotateEvent;
import com.google.code.or.binlog.BinlogParserListener;
import com.google.code.or.binlog.BinlogParserContext;
import com.google.code.or.binlog.BinlogParser;
import com.google.code.or.binlog.BinlogEventV4;
import com.google.code.or.binlog.BinlogEventParser;
import com.google.code.or.binlog.BinlogEventListener;
import com.google.code.or.binlog.BinlogEventFilter;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Map;
import java.util.List;
import java.util.HashMap;
import java.util.ArrayList;
import java.io.EOFException;
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 ? # W ? ? ? ? ? y I 9 . ? ? ? ? ? ? ? M G % ?
?
?
?
?
?
?
Y
#
!
? ? ? ? ? a \ Z ! ? ? ? ? ? ? ? S L 4 ' ! ?
?
?
W
'
? ? ? ? ? ? L 1 ? ? ? ? ? ? ? ? P / * & # " }
}
}
this.checksumEnabled = flag;
public void setChecksumEnabled(boolean flag) {
}
return this.checksumEnabled;
public boolean getChecksumEnabled() {
}
}
LOGGER.error("failed to notify binlog event listener, event: " + event, e);
} catch(Exception e) {
AbstractBinlogParser.this.eventListener.onEvents(event);
try {
//
}
if(isClearTableMapEventsOnRotate()) this.tableMapEvents.clear();
this.binlogFileName = re.getBinlogFileName().toString();
final RotateEvent re = (RotateEvent)event;
} else if(event instanceof RotateEvent) {
this.tableMapEvents.put(tme.getTableId(), tme);
final TableMapEvent tme = (TableMapEvent)event;
if(event instanceof TableMapEvent) {
//
}
return;
if(event == null) {
//
public void onEvents(BinlogEventV4 event) {
*/
*
/**
}
return this.tableMapEvents.get(tableId);
public final TableMapEvent getTableMapEvent(long tableId) {
}
return this;
public final BinlogEventListener getEventListener() {
}
this.binlogFileName = name;
public final void setBinlogFileName(String name) {
}
return binlogFileName;
public final String getBinlogFileName() {
*/
*
/**
}
this.binlogFileName = parser.getBinlogFileName();
public Context(AbstractBinlogParser parser) {
*/
*
/**
private boolean checksumEnabled;
private final Map tableMapEvents = new HashMap();
private String binlogFileName;
//
protected class Context implements BinlogParserContext, BinlogEventListener {
}
}
}
}
LOGGER.error("failed to stop binlog parser", e);
} catch(Exception e) {
stop(0, TimeUnit.MILLISECONDS);
try {
} finally {
LOGGER.error("failed to parse binlog", e);
notifyOnException(e);
} catch (Exception e) {
} catch (EOFException e) {
doParse();
try {
public void run() {