BinaryLogClient createBinlogClient(String hostname, int port, String username, String password) { return new BinaryLogClient(hostname, port, username, password); }
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(); }
this.client = new BinaryLogClient(mysqlConfig.host, mysqlConfig.port, mysqlConfig.user, mysqlConfig.password);
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(); }
client = new BinaryLogClient(connectionContext.hostname(), connectionContext.port(), connectionContext.username(), connectionContext.password());
BinaryLogClient createBinlogClient(String hostname, int port, String username, String password) { return new BinaryLogClient(hostname, port, username, password); }
private BinaryLogClient getClient(String hostname) { // TODO: Implement status variable parser: https://github.com/shyiko/mysql-binlog-connector-java/issues/174 BinaryLogClient client = new BinaryLogClient( hostname, this.port, this.schema, this.username, this.password ); EventDeserializer eventDeserializer = new EventDeserializer(); eventDeserializer.setCompatibilityMode(EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY); client.setEventDeserializer(eventDeserializer); return client; }
username = ObjectUtils.firstNonNull(username, ""); password = ObjectUtils.firstNonNull(password, ""); this.client = new BinaryLogClient(host, port, catalog, username, password); this.lifecycleListener = new MySQLBinaryLogLifecycleListener(cache);
this.client = new BinaryLogClient(host, port != null ? port : 3306, schema, username, password); this.lifecycleListener = new MySQLBinaryLogLifecycleListener(cache);
public void start(Optional<BinlogFileOffset> binlogFileOffset, Consumer<M> eventConsumer) throws IOException, TimeoutException { client = new BinaryLogClient(host, port, dbUserName, dbPassword); client.setServerId(binlogClientUniqueId); client.setKeepAliveInterval(10 * 1000);
public void start(Optional<BinlogFileOffset> binlogFileOffset, Consumer<M> eventConsumer) { client = new BinaryLogClient(host, port, dbUserName, dbPassword); client.setServerId(binlogClientUniqueId); client.setKeepAliveInterval(5 * 1000);
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(); }