com.github.shyiko.mysql.binlog.BinaryLogClient.connect()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中com.github.shyiko.mysql.binlog.BinaryLogClient.connect()方法的一些代码示例,展示了BinaryLogClient.connect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BinaryLogClient.connect()方法的具体详情如下:
包路径:com.github.shyiko.mysql.binlog.BinaryLogClient
类名称:BinaryLogClient
方法名:connect

BinaryLogClient.connect介绍

[英]Connect to the replication stream. Note that this method blocks until disconnected.
[中]连接到复制流。请注意,此方法会一直阻塞,直到断开连接。

代码示例

代码示例来源:origin: zendesk/maxwell

public void startReplicator() throws Exception {
  this.client.connect(5000);
  replicatorStarted = true;
}

代码示例来源:origin: shyiko/mysql-binlog-connector-java

@Override
  public void run() {
    try {
      setConnectTimeout(timeout);
      connect();
    } catch (IOException e) {
      exceptionReference.set(e);
      countDownLatch.countDown(); // making sure we don't end up waiting whole "timeout"
    }
  }
};

代码示例来源:origin: shyiko/mysql-binlog-connector-java

connect(connectTimeout);
} catch (Exception ce) {
  if (logger.isLoggable(Level.WARNING)) {

代码示例来源:origin: debezium/debezium

protected void rewindBinaryLogClient(BinlogPosition position) {
  try {
    if (isRunning()) {
      logger.debug("Rewinding binlog to position {}", position);
      client.disconnect();
      client.setBinlogFilename(position.getFilename());
      client.setBinlogPosition(position.getPosition());
      client.connect();
    }
  } catch (IOException e) {
    logger.error("Unexpected error when re-connecting to the MySQL binary log reader", e);
  }
}

代码示例来源:origin: zendesk/maxwell

private void ensureReplicatorThread() throws Exception {
  checkCommErrors();
  if ( !client.isConnected() && !stopOnEOF ) {
    if (this.gtidPositioning) {
      // When using gtid positioning, reconnecting should take us to the top
      // of the gtid event.  We throw away any binlog position we have
      // (other than GTID) and bail out of getTransactionRows()
      LOGGER.warn("replicator stopped at position: {} -- restarting", client.getGtidSet());
      client.setBinlogFilename("");
      client.setBinlogPosition(4L);
      client.connect(5000);
      throw new ClientReconnectedException();
    } else {
      // standard binlog positioning is a lot easier; we can really reconnect anywhere
      // we like, so we don't have to bail out of the middle of an event.
      LOGGER.warn("replicator stopped at position: {} -- restarting", client.getBinlogFilename() + ":" + client.getBinlogPosition());
      client.connect(5000);
    }
  }
}

代码示例来源:origin: apache/rocketmq-externals

private void checkConnection() throws Exception {
  if (!binaryLogClient.isConnected()) {
    BinlogPosition binlogPosition = replicator.getNextBinlogPosition();
    if (binlogPosition != null) {
      binaryLogClient.setBinlogFilename(binlogPosition.getBinlogFilename());
      binaryLogClient.setBinlogPosition(binlogPosition.getPosition());
    }
    binaryLogClient.connect(3000);
  }
}

代码示例来源:origin: apache/nifi

connectTimeout = Long.MAX_VALUE;
binlogClient.connect(connectTimeout);
transitUri = "mysql://" + connectedHost.getHostString() + ":" + connectedHost.getPort();

代码示例来源:origin: debezium/debezium

try {
  logger.debug("Attempting to establish binlog reader connection with timeout of {} ms", timeoutInMilliseconds);
  client.connect(context.timeoutInMilliseconds());
} catch (TimeoutException e) {

代码示例来源:origin: apache/rocketmq-externals

public void start() throws Exception {
  initDataSource();
  binlogPositionManager = new BinlogPositionManager(config, dataSource);
  binlogPositionManager.initBeginPosition();
  schema = new Schema(dataSource);
  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.");
  doProcess();
}

代码示例来源:origin: debezium/debezium

protected void startClient(Consumer<BinaryLogClient> preConnect) throws IOException, TimeoutException, SQLException {
  // Connect the bin log client ...
  counters = new EventQueue(DEFAULT_TIMEOUT, this::logConsumedEvent, this::logIgnoredEvent);
  client = new BinaryLogClient(config.getHostname(), config.getPort(), "replicator", "replpass");
  client.setServerId(client.getServerId() - 1); // avoid clashes between BinaryLogClient instances
  client.setKeepAlive(false);
  client.setSSLMode(SSLMode.DISABLED);
  client.registerEventListener(counters);
  client.registerEventListener(this::recordEvent);
  client.registerLifecycleListener(new TraceLifecycleListener());
  EventDeserializer eventDeserializer = new EventDeserializer();
  eventDeserializer.setEventDataDeserializer(EventType.STOP, new StopEventDataDeserializer());
  client.setEventDeserializer(eventDeserializer);
  if (preConnect != null) preConnect.accept(client);
  client.connect(DEFAULT_TIMEOUT); // does not block
  // Set up the table as one transaction and wait to see the events ...
  conn.execute("DROP TABLE IF EXISTS person",
         "CREATE TABLE person (" +
             "  name VARCHAR(255) primary key," +
             "  age INTEGER NULL DEFAULT 10," +
             "  createdAt DATETIME NULL DEFAULT CURRENT_TIMESTAMP," +
             "  updatedAt DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" +
             ")");
  counters.consume(2, EventType.QUERY);
  counters.reset();
}

代码示例来源:origin: perfectsense/dari

@Override
  public void run() {
    try {
      client.connect();
    } catch (IOException error) {
      LOGGER.warn("Can't connect to MySQL as a slave!", error);
    }
  }
};

代码示例来源:origin: perfectsense/dari

@Override
  public void run() {
    try {
      client.connect();
    } catch (IOException error) {
      LOGGER.warn("Can't connect to MySQL as a slave!", error);
    }
  }
};

代码示例来源:origin: eventuate-local/eventuate-local

private void connectWithRetriesOnFail() {
 for (int i = 1;; i++) {
  try {
   logger.info("trying to connect to mysql binlog for schema {}", sourceDatabase.getEventuateDatabaseSchema());
   client.connect(connectionTimeoutInMilliseconds);
   logger.info("connection to mysql binlog succeed");
   break;
  } catch (TimeoutException | IOException e) {
   logger.error("connection to mysql binlog failed");
   if (i == maxAttemptsForBinlogConnection) {
    logger.error("connection attempts exceeded");
    throw new RuntimeException(e);
   }
   try {
    Thread.sleep(connectionTimeoutInMilliseconds);
   } catch (InterruptedException ex) {
    throw new RuntimeException(ex);
   }
  }
 }
}

代码示例来源:origin: org.apache.nifi/nifi-cdc-mysql-processors

connectTimeout = Long.MAX_VALUE;
binlogClient.connect(connectTimeout);
transitUri = "mysql://" + connectedHost.getHostString() + ":" + connectedHost.getPort();

代码示例来源:origin: mysql-time-machine/replicator

this.client.connect();

代码示例来源:origin: networknt/light-eventuate-4j

for (int i=1; i<5; i++) {
  try {
    client.connect(10 * 1000);
    break;
  } catch (Exception e) {

代码示例来源:origin: io.debezium/debezium-connector-mysql

protected void startClient(Consumer<BinaryLogClient> preConnect) throws IOException, TimeoutException, SQLException {
  // Connect the bin log client ...
  counters = new EventQueue(DEFAULT_TIMEOUT, this::logConsumedEvent, this::logIgnoredEvent);
  client = new BinaryLogClient(config.getHostname(), config.getPort(), "replicator", "replpass");
  client.setServerId(client.getServerId() - 1); // avoid clashes between BinaryLogClient instances
  client.setKeepAlive(false);
  client.setSSLMode(SSLMode.DISABLED);
  client.registerEventListener(counters);
  client.registerEventListener(this::recordEvent);
  client.registerLifecycleListener(new TraceLifecycleListener());
  EventDeserializer eventDeserializer = new EventDeserializer();
  eventDeserializer.setEventDataDeserializer(EventType.STOP, new StopEventDataDeserializer());
  client.setEventDeserializer(eventDeserializer);
  if (preConnect != null) preConnect.accept(client);
  client.connect(DEFAULT_TIMEOUT); // does not block
  // Set up the table as one transaction and wait to see the events ...
  conn.execute("DROP TABLE IF EXISTS person",
         "CREATE TABLE person (" +
             "  name VARCHAR(255) primary key," +
             "  age INTEGER NULL DEFAULT 10," +
             "  createdAt DATETIME NULL DEFAULT CURRENT_TIMESTAMP," +
             "  updatedAt DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" +
             ")");
  counters.consume(2, EventType.QUERY);
  counters.reset();
}

相关文章