Examples of LogContext


Examples of com.taobao.tddl.dbsync.binlog.LogContext

        FileLogFetcher fetcher = new FileLogFetcher(bufferSize);
        LogDecoder decoder = new LogDecoder();
        decoder.handle(LogEvent.QUERY_EVENT);
        decoder.handle(LogEvent.XID_EVENT);
        LogContext context = new LogContext();
        try {
            fetcher.open(current);
            context.setLogPosition(new LogPosition(current.getName()));
            while (running) {
                boolean needContinue = true;
                String lastXidLogFilename = current.getName();
                long lastXidLogFileOffset = 0;

                binlogFilename = lastXidLogFilename;
                binlogFileOffset = lastXidLogFileOffset;
                L: while (fetcher.fetch()) {
                    LogEvent event;
                    do {
                        event = decoder.decode(fetcher, context);
                        if (event != null) {
                            if (event.getWhen() > timestampSeconds) {
                                break L;
                            }

                            needContinue = false;
                            if (LogEvent.QUERY_EVENT == event.getHeader().getType()) {
                                if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "BEGIN")) {
                                    binlogFilename = lastXidLogFilename;
                                    binlogFileOffset = lastXidLogFileOffset;
                                } else if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "COMMIT")) {
                                    lastXidLogFilename = current.getName();
                                    lastXidLogFileOffset = event.getLogPos();
                                }
                            } else if (LogEvent.XID_EVENT == event.getHeader().getType()) {
                                lastXidLogFilename = current.getName();
                                lastXidLogFileOffset = event.getLogPos();
                            }
                        }
                    } while (event != null);
                }

                if (needContinue) {// 读取下一个
                    fetcher.close(); // 关闭上一个文件

                    File nextFile = binlogs.getBefore(current);
                    if (nextFile == null) {
                        break;
                    }

                    current = nextFile;
                    fetcher.open(current);
                    context.setLogPosition(new LogPosition(current.getName()));
                } else {
                    break;// 跳出
                }
            }
        } finally {
View Full Code Here

Examples of com.taobao.tddl.dbsync.binlog.LogContext

        fetcher.start(connector.getChannel());
        LogDecoder decoder = new LogDecoder();
        decoder.handle(LogEvent.ROTATE_EVENT);
        decoder.handle(LogEvent.QUERY_EVENT);
        decoder.handle(LogEvent.XID_EVENT);
        LogContext context = new LogContext();
        while (fetcher.fetch()) {
            LogEvent event = null;
            event = decoder.decode(fetcher, context);

            if (event == null) {
View Full Code Here

Examples of com.taobao.tddl.dbsync.binlog.LogContext

        sendBinlogDump(binlogfilename, binlogPosition);
        DirectLogFetcher fetcher = new DirectLogFetcher(connector.getReceiveBufferSize());
        fetcher.start(connector.getChannel());
        LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT);
        LogContext context = new LogContext();
        while (fetcher.fetch()) {
            LogEvent event = null;
            event = decoder.decode(fetcher, context);

            if (event == null) {
View Full Code Here

Examples of com.taobao.tddl.dbsync.binlog.LogContext

    public void dump(String binlogfilename, Long binlogPosition, SinkFunction func) throws IOException {
        File current = new File(directory, binlogfilename);

        FileLogFetcher fetcher = new FileLogFetcher(bufferSize);
        LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT);
        LogContext context = new LogContext();
        try {
            fetcher.open(current, binlogPosition);
            context.setLogPosition(new LogPosition(binlogfilename, binlogPosition));
            while (running) {
                boolean needContinue = true;
                while (fetcher.fetch()) {
                    LogEvent event;
                    do {
                        event = decoder.decode(fetcher, context);
                        if (event != null && !func.sink(event)) {
                            needContinue = false;
                            break;
                        }
                    } while (event != null);
                }

                if (needContinue) {// 读取下一个
                    fetcher.close(); // 关闭上一个文件

                    File nextFile;
                    if (needWait) {
                        nextFile = binlogs.waitForNextFile(current);
                    } else {
                        nextFile = binlogs.getNextFile(current);
                    }

                    if (nextFile == null) {
                        break;
                    }

                    current = nextFile;

                    fetcher.open(current);
                    context.setLogPosition(new LogPosition(nextFile.getName()));
                } else {
                    break;// 跳出
                }
            }
        } catch (InterruptedException e) {
View Full Code Here

Examples of com.taobao.tddl.dbsync.binlog.LogContext

        FileLogFetcher fetcher = new FileLogFetcher(bufferSize);
        LogDecoder decoder = new LogDecoder();
        decoder.handle(LogEvent.QUERY_EVENT);
        decoder.handle(LogEvent.XID_EVENT);
        LogContext context = new LogContext();
        try {
            fetcher.open(current);
            context.setLogPosition(new LogPosition(current.getName()));
            while (running) {
                boolean needContinue = true;
                String lastXidLogFilename = current.getName();
                long lastXidLogFileOffset = 0;

                binlogFilename = lastXidLogFilename;
                binlogFileOffset = lastXidLogFileOffset;
                L: while (fetcher.fetch()) {
                    LogEvent event;
                    do {
                        event = decoder.decode(fetcher, context);
                        if (event != null) {
                            if (event.getWhen() > timestampSeconds) {
                                break L;
                            }

                            needContinue = false;
                            if (LogEvent.QUERY_EVENT == event.getHeader().getType()) {
                                if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "BEGIN")) {
                                    binlogFilename = lastXidLogFilename;
                                    binlogFileOffset = lastXidLogFileOffset;
                                } else if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "COMMIT")) {
                                    lastXidLogFilename = current.getName();
                                    lastXidLogFileOffset = event.getLogPos();
                                }
                            } else if (LogEvent.XID_EVENT == event.getHeader().getType()) {
                                lastXidLogFilename = current.getName();
                                lastXidLogFileOffset = event.getLogPos();
                            }
                        }
                    } while (event != null);
                }

                if (needContinue) {// 读取下一个
                    fetcher.close(); // 关闭上一个文件

                    File nextFile = binlogs.getBefore(current);
                    if (nextFile == null) {
                        break;
                    }

                    current = nextFile;
                    fetcher.open(current);
                    context.setLogPosition(new LogPosition(current.getName()));
                } else {
                    break;// 跳出
                }
            }
        } finally {
View Full Code Here

Examples of javolution.context.LogContext

     * @param level the message logging level
     * @return <code>true</code> if a message of specified level would actually
     *        be logged;<code>false</code> otherwise.
     */
    public static boolean isLoggable(Level level) {
        LogContext log = (LogContext) LogContext.getCurrentLogContext();
        if (log instanceof StandardLog) {
            return ((StandardLog) log)._logger.isLoggable(level);
        } else if (level.intValue() >= Level.SEVERE.intValue()) {
            return LogContext.isErrorLogged();
        } else if (level.intValue() >= Level.WARNING.intValue()) {
View Full Code Here

Examples of javolution.context.LogContext

     * or {@link LogContext#debug debug} message is possibly logged.
     *
     * @param record the LogRecord to be published.
     */
    public static void log(LogRecord record) {
        LogContext log = (LogContext) LogContext.getCurrentLogContext();
        if (log instanceof StandardLog) {
            ((StandardLog) log)._logger.log(record);
        } else {
            Throwable error = record.getThrown();
            if (error != null) {
View Full Code Here

Examples of javolution.context.LogContext

     * error} message is logged.
     *
     * @param msg the severe message.
     */
    public static void severe(String msg) {
        LogContext log = (LogContext) LogContext.getCurrentLogContext();
        if (log instanceof StandardLog) {
            ((StandardLog) log)._logger.severe(msg);
        } else {
            LogContext.warning(msg);
        }
View Full Code Here

Examples of javolution.context.LogContext

     * context is not a {@link StandardLog} no message is logged.
     *
     * @param msg the config message.
     */
    public static void config(String msg) {
        LogContext log = (LogContext) LogContext.getCurrentLogContext();
        if (log instanceof StandardLog) {
            ((StandardLog) log)._logger.config(msg);
        }
    }
View Full Code Here

Examples of javolution.context.LogContext

     * context is not a {@link StandardLog} no message is logged.
     *
     * @param msg the fine message.
     */
    public static void fine(String msg) {
        LogContext log = (LogContext) LogContext.getCurrentLogContext();
        if (log instanceof StandardLog) {
            ((StandardLog) log)._logger.fine(msg);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.