com.alibaba.otter.canal.parse.support.AuthenticationInfo Java Examples

The following examples show how to use com.alibaba.otter.canal.parse.support.AuthenticationInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MysqlEventParser.java    From canal with Apache License 2.0 6 votes vote down vote up
private MysqlConnection buildMysqlConnection(AuthenticationInfo runningInfo) {
    MysqlConnection connection = new MysqlConnection(runningInfo.getAddress(),
        runningInfo.getUsername(),
        runningInfo.getPassword(),
        connectionCharsetNumber,
        runningInfo.getDefaultDatabaseName());
    connection.getConnector().setReceiveBufferSize(receiveBufferSize);
    connection.getConnector().setSendBufferSize(sendBufferSize);
    connection.getConnector().setSoTimeout(defaultConnectionTimeoutInSeconds * 1000);
    connection.setCharset(connectionCharset);
    connection.setReceivedBinlogBytes(receivedBinlogBytes);
    // 随机生成slaveId
    if (this.slaveId <= 0) {
        this.slaveId = generateUniqueServerId();
    }
    connection.setSlaveId(this.slaveId);
    return connection;
}
 
Example #2
Source File: MysqlEventParser.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
private MysqlConnection buildMysqlConnection(AuthenticationInfo runningInfo) {
    MysqlConnection connection = new MysqlConnection(runningInfo.getAddress(),
        runningInfo.getUsername(),
        runningInfo.getPassword(),
        connectionCharsetNumber,
        runningInfo.getDefaultDatabaseName());
    connection.getConnector().setReceiveBufferSize(receiveBufferSize);
    connection.getConnector().setSendBufferSize(sendBufferSize);
    connection.getConnector().setSoTimeout(defaultConnectionTimeoutInSeconds * 1000);
    connection.setCharset(connectionCharset);
    connection.setReceivedBinlogBytes(receivedBinlogBytes);
    // 随机生成slaveId
    if (this.slaveId <= 0) {
        this.slaveId = generateUniqueServerId();
    }
    connection.setSlaveId(this.slaveId);
    return connection;
}
 
Example #3
Source File: MysqlConnection.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public MysqlConnection(InetSocketAddress address, String username, String password){
    authInfo = new AuthenticationInfo();
    authInfo.setAddress(address);
    authInfo.setUsername(username);
    authInfo.setPassword(password);
    connector = new MysqlConnector(address, username, password);
    // 将connection里面的参数透传下
    connector.setSoTimeout(soTimeout);
    connector.setConnTimeout(connTimeout);
}
 
Example #4
Source File: GroupEventPaserTest.java    From canal with Apache License 2.0 5 votes vote down vote up
private BinlogParser buildParser(AuthenticationInfo info) {
    return new AbstractBinlogParser<LogEvent>() {

        @Override
        public Entry parse(LogEvent event, boolean isSeek) throws CanalParseException {
            return null;
        }
    };
}
 
Example #5
Source File: MysqlEventParser.java    From canal with Apache License 2.0 5 votes vote down vote up
public void doSwitch(AuthenticationInfo newRunningInfo) {
    // 1. 需要停止当前正在复制的过程
    // 2. 找到新的position点
    // 3. 重新建立链接,开始复制数据
    // 切换ip
    String alarmMessage = null;

    if (this.runningInfo.equals(newRunningInfo)) {
        alarmMessage = "same runingInfo switch again : " + runningInfo.getAddress().toString();
        logger.warn(alarmMessage);
        return;
    }

    if (newRunningInfo == null) {
        alarmMessage = "no standby config, just do nothing, will continue try:"
                       + runningInfo.getAddress().toString();
        logger.warn(alarmMessage);
        sendAlarm(destination, alarmMessage);
        return;
    } else {
        stop();
        alarmMessage = "try to ha switch, old:" + runningInfo.getAddress().toString() + ", new:"
                       + newRunningInfo.getAddress().toString();
        logger.warn(alarmMessage);
        sendAlarm(destination, alarmMessage);
        runningInfo = newRunningInfo;
        start();
    }
}
 
Example #6
Source File: MysqlConnection.java    From canal with Apache License 2.0 5 votes vote down vote up
public MysqlConnection(InetSocketAddress address, String username, String password, byte charsetNumber,
                       String defaultSchema){
    authInfo = new AuthenticationInfo();
    authInfo.setAddress(address);
    authInfo.setUsername(username);
    authInfo.setPassword(password);
    authInfo.setDefaultDatabaseName(defaultSchema);
    connector = new MysqlConnector(address, username, password, charsetNumber, defaultSchema);
    // 将connection里面的参数透传下
    connector.setSoTimeout(soTimeout);
    connector.setConnTimeout(connTimeout);
}
 
Example #7
Source File: MysqlConnection.java    From canal with Apache License 2.0 5 votes vote down vote up
public MysqlConnection(InetSocketAddress address, String username, String password){
    authInfo = new AuthenticationInfo();
    authInfo.setAddress(address);
    authInfo.setUsername(username);
    authInfo.setPassword(password);
    connector = new MysqlConnector(address, username, password);
    // 将connection里面的参数透传下
    connector.setSoTimeout(soTimeout);
    connector.setConnTimeout(connTimeout);
}
 
Example #8
Source File: Binlog.java    From jlogstash-input-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare() {
    logger.info("binlog prepare started..");

    parseCategories();

    controller = new MysqlEventParser();
    controller.setConnectionCharset(Charset.forName("UTF-8"));
    controller.setSlaveId(slaveId);
    controller.setDetectingEnable(false);
    controller.setMasterInfo(new AuthenticationInfo(new InetSocketAddress(host, port), username, password));
    controller.setEnableTsdb(true);
    controller.setDestination("example");
    controller.setParallel(true);
    controller.setParallelBufferSize(256);
    controller.setParallelThreadSize(2);
    controller.setIsGTIDMode(false);
    controller.setEventSink(new BinlogEventSink(this));

    controller.setLogPositionManager(new BinlogPositionManager(this));

    EntryPosition startPosition = findStartPosition();
    if (startPosition != null) {
       controller.setMasterPosition(startPosition);
    }


    if (filter != null) {
        controller.setEventFilter(new AviaterRegexFilter(filter));
    }

    logger.info("binlog prepare ended..");
}
 
Example #9
Source File: GroupEventPaserTest.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private BinlogParser buildParser(AuthenticationInfo info) {
    return new AbstractBinlogParser<LogEvent>() {

        @Override
        public Entry parse(LogEvent event, boolean isSeek) throws CanalParseException {
            return null;
        }
    };
}
 
Example #10
Source File: MysqlEventParser.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public void doSwitch(AuthenticationInfo newRunningInfo) {
    // 1. 需要停止当前正在复制的过程
    // 2. 找到新的position点
    // 3. 重新建立链接,开始复制数据
    // 切换ip
    String alarmMessage = null;

    if (this.runningInfo.equals(newRunningInfo)) {
        alarmMessage = "same runingInfo switch again : " + runningInfo.getAddress().toString();
        logger.warn(alarmMessage);
        return;
    }

    if (newRunningInfo == null) {
        alarmMessage = "no standby config, just do nothing, will continue try:"
                       + runningInfo.getAddress().toString();
        logger.warn(alarmMessage);
        sendAlarm(destination, alarmMessage);
        return;
    } else {
        stop();
        alarmMessage = "try to ha switch, old:" + runningInfo.getAddress().toString() + ", new:"
                       + newRunningInfo.getAddress().toString();
        logger.warn(alarmMessage);
        sendAlarm(destination, alarmMessage);
        runningInfo = newRunningInfo;
        start();
    }
}
 
Example #11
Source File: MysqlConnection.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public MysqlConnection(InetSocketAddress address, String username, String password, byte charsetNumber,
                       String defaultSchema){
    authInfo = new AuthenticationInfo();
    authInfo.setAddress(address);
    authInfo.setUsername(username);
    authInfo.setPassword(password);
    authInfo.setDefaultDatabaseName(defaultSchema);
    connector = new MysqlConnector(address, username, password, charsetNumber, defaultSchema);
    // 将connection里面的参数透传下
    connector.setSoTimeout(soTimeout);
    connector.setConnTimeout(connTimeout);
}
 
Example #12
Source File: MysqlConnection.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setAuthInfo(AuthenticationInfo authInfo) {
    this.authInfo = authInfo;
}
 
Example #13
Source File: MysqlEventParserTest.java    From canal with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}
 
Example #14
Source File: RdsBinlogEventParserProxyTest.java    From canal with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}
 
Example #15
Source File: LocalBinlogEventParserTest.java    From canal with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}
 
Example #16
Source File: GroupEventPaserTest.java    From canal with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}
 
Example #17
Source File: LocalBinlogEventParser.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void setMasterInfo(AuthenticationInfo masterInfo) {
    this.masterInfo = masterInfo;
}
 
Example #18
Source File: MysqlEventParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setStandbyInfo(AuthenticationInfo standbyInfo) {
    this.standbyInfo = standbyInfo;
}
 
Example #19
Source File: MysqlEventParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setMasterInfo(AuthenticationInfo masterInfo) {
    this.masterInfo = masterInfo;
}
 
Example #20
Source File: MysqlConnection.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public AuthenticationInfo getAuthInfo() {
    return authInfo;
}
 
Example #21
Source File: MysqlEventParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public void doSwitch() {
    AuthenticationInfo newRunningInfo = (runningInfo.equals(masterInfo) ? standbyInfo : masterInfo);
    this.doSwitch(newRunningInfo);
}
 
Example #22
Source File: MysqlEventParser.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void setStandbyInfo(AuthenticationInfo standbyInfo) {
    this.standbyInfo = standbyInfo;
}
 
Example #23
Source File: MysqlConnection.java    From canal with Apache License 2.0 4 votes vote down vote up
public AuthenticationInfo getAuthInfo() {
    return authInfo;
}
 
Example #24
Source File: MysqlConnection.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void setAuthInfo(AuthenticationInfo authInfo) {
    this.authInfo = authInfo;
}
 
Example #25
Source File: MysqlEventParser.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void doSwitch() {
    AuthenticationInfo newRunningInfo = (runningInfo.equals(masterInfo) ? standbyInfo : masterInfo);
    this.doSwitch(newRunningInfo);
}
 
Example #26
Source File: LocalBinlogEventParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setMasterInfo(AuthenticationInfo masterInfo) {
    this.masterInfo = masterInfo;
}
 
Example #27
Source File: MysqlEventParserTest.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}
 
Example #28
Source File: RdsBinlogEventParserProxyTest.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}
 
Example #29
Source File: LocalBinlogEventParserTest.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}
 
Example #30
Source File: GroupEventPaserTest.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private AuthenticationInfo buildAuthentication() {
    return new AuthenticationInfo(new InetSocketAddress(MYSQL_ADDRESS, 3306), USERNAME, PASSWORD);
}