Java Code Examples for com.github.shyiko.mysql.binlog.BinaryLogClient#setBinlogFilename()

The following examples show how to use com.github.shyiko.mysql.binlog.BinaryLogClient#setBinlogFilename() . 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: BinLogClientFactory.java    From kkbinlog with Apache License 2.0 6 votes vote down vote up
/**
 * 配置当前binlog位置
 * @param client
 * @param binaryLogConfig
 */
private void configBinaryLogStatus(BinaryLogClient client, BinaryLogConfig binaryLogConfig) {

    JSONObject binLogStatus = etcdService.getBinaryLogStatus(binaryLogConfig);

    if (binLogStatus != null) {
        Object binlogFilename = binLogStatus.get("binlogFilename");
        if (binlogFilename != null) {
            client.setBinlogFilename((String) binlogFilename);
        }
        Long binlogPosition = binLogStatus.getLong("binlogPosition");
        if (binlogPosition != null) {
            client.setBinlogPosition(binlogPosition);
        }
    }
}
 
Example 2
Source File: MysqlMasterConnector.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void configLogClient(MysqlConnection connection, String password,
                             ConsumerRegistry registry) throws IOException {
  client = new BinaryLogClient(connection.getAddress(), connection.getPort(),
      connection.getUser(), password);
  client.registerLifecycleListener(new LogLifecycleListener());
  client.setEventDeserializer(SyncDeserializer.defaultDeserializer());
  client.setServerId(random.nextInt(Integer.MAX_VALUE));
  client.setSSLMode(SSLMode.DISABLED);
  BinlogInfo binlogInfo = registry.votedBinlogInfo(connection);
  logger.info("Producer[{}] connect to {}", connectorIdentifier, binlogInfo);
  client.setBinlogFilename(binlogInfo.getBinlogFilename());
  client.setBinlogPosition(binlogInfo.getBinlogPosition());
}
 
Example 3
Source File: BinlogStream.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
private synchronized BinaryLogClient allocateBinaryLogClient() {
    if (isConnected()) {
        throw new IllegalStateException("MySQL replication stream is already open");
    }
    binaryLogClient = new BinaryLogClient(hostname, port, username, password);
    binaryLogClient.setBinlogFilename(getBinglogFile());
    binaryLogClient.setBinlogPosition(getBinlogPos());
    binaryLogClient.setServerId(getSlaveID());
    binaryLogClient.registerEventListener(new DelegatingEventListener());
    return binaryLogClient;
}
 
Example 4
Source File: EventProcessor.java    From openmessaging-connect-odar with Apache License 2.0 4 votes vote down vote up
public void start() throws Exception {

        initDataSource();

        binlogPositionManager = new BinlogPositionManager(config, dataSource);
        binlogPositionManager.initBeginPosition();

        schema = new Schema(dataSource);
        String whiteDataBases = config.getWhiteDataBase();
        String whiteTables = config.getWhiteTable();

        if (!StringUtils.isEmpty(whiteDataBases)){
            Arrays.asList(whiteDataBases.trim().split(",")).forEach(whiteDataBase ->{
                Collections.addAll(schema.dataBaseWhiteList, whiteDataBase);
            });
        }

        if (!StringUtils.isEmpty(whiteTables)){
            Arrays.asList(whiteTables.trim().split(",")).forEach(whiteTable ->{
                Collections.addAll(schema.tableWhiteList, whiteTable);
            });
        }
        schema.load();

        eventListener = new EventListener(queue);
        binaryLogClient = new BinaryLogClient(config.mysqlAddr,
            config.mysqlPort,
            config.mysqlUsername,
            config.mysqlPassword);
        binaryLogClient.setBlocking(true);
        binaryLogClient.setServerId(1001);

        EventDeserializer eventDeserializer = new EventDeserializer();
        eventDeserializer.setCompatibilityMode(EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG,
            EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY);
        binaryLogClient.setEventDeserializer(eventDeserializer);
        binaryLogClient.registerEventListener(eventListener);
        binaryLogClient.setBinlogFilename(binlogPositionManager.getBinlogFilename());
        binaryLogClient.setBinlogPosition(binlogPositionManager.getPosition());

        binaryLogClient.connect(3000);

        LOGGER.info("Started.");

        stopped = false;

        doProcess();
    }
 
Example 5
Source File: BinLogPositionSourceOffset.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Override
public void positionClient(BinaryLogClient client) {
  client.setBinlogFilename(filename);
  client.setBinlogPosition(position);
}
 
Example 6
Source File: BinLogPositionSourceOffset.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Override
public void positionClient(BinaryLogClient client) {
  client.setBinlogFilename(filename);
  client.setBinlogPosition(position);
}