Java Code Examples for com.github.shyiko.mysql.binlog.BinaryLogClient#setServerId()
The following examples show how to use
com.github.shyiko.mysql.binlog.BinaryLogClient#setServerId() .
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: MysqlBinLogSource.java From datacollector with Apache License 2.0 | 6 votes |
private BinaryLogClient createBinaryLogClient(MysqlBinLogSourceConfig config) { BinaryLogClient binLogClient = new BinaryLogClient( sshTunnel.getHost(), sshTunnel.getPort(), config.username.get(), config.password.get() ); switch (config.sslMode) { case REQUIRED: binLogClient.setSSLMode(SSLMode.REQUIRED); break; case VERIFY_CA: binLogClient.setSSLMode(SSLMode.VERIFY_CA); setSSLSocketFactory(binLogClient); break; case VERIFY_IDENTITY: binLogClient.setSSLMode(SSLMode.VERIFY_IDENTITY); setSSLSocketFactory(binLogClient); break; } binLogClient.setServerId(config.serverId); return binLogClient; }
Example 2
Source File: MysqlMasterConnector.java From syncer with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 |
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: MysqlSource.java From datacollector with Apache License 2.0 | 5 votes |
private BinaryLogClient createBinaryLogClient() { BinaryLogClient binLogClient = new BinaryLogClient( getConfig().hostname, port, getConfig().username.get(), getConfig().password.get() ); if (getConfig().useSsl) { binLogClient.setSSLMode(SSLMode.REQUIRED); } else { binLogClient.setSSLMode(SSLMode.DISABLED); } binLogClient.setServerId(serverId); return binLogClient; }
Example 5
Source File: EventProcessor.java From openmessaging-connect-odar with Apache License 2.0 | 4 votes |
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 6
Source File: MysqlSourceFactory.java From SpinalTap with Apache License 2.0 | 4 votes |
public Source create( @NonNull final MysqlConfiguration configuration, @NonNull final String user, @NonNull final String password, @Min(0) final long serverId, final TlsConfiguration tlsConfiguration, @NonNull final Repository<SourceState> backingStateRepository, @NonNull final Repository<Collection<SourceState>> stateHistoryRepository, final MysqlSchemaManagerFactory schemaManagerFactory, @NonNull final MysqlSourceMetrics metrics, @Min(0) final long leaderEpoch) { final String name = configuration.getName(); final String host = configuration.getHost(); final int port = configuration.getPort(); final BinaryLogClient binlogClient = new BinaryLogClient(host, port, user, password); /* Override the global server_id if it is set in MysqlConfiguration Allow each source to use a different server_id */ if (configuration.getServerId() != MysqlConfiguration.DEFAULT_SERVER_ID) { binlogClient.setServerId(configuration.getServerId()); } else { binlogClient.setServerId(serverId); } final StateRepository stateRepository = new StateRepository(name, backingStateRepository, metrics); final StateHistory stateHistory = new StateHistory(name, stateHistoryRepository, metrics); final MysqlClient mysqlClient = MysqlClient.create( host, port, user, password, configuration.isMTlsEnabled(), tlsConfiguration); final MysqlSchemaManager schemaManager = schemaManagerFactory.create( name, mysqlClient, configuration.isSchemaVersionEnabled(), metrics); final TableCache tableCache = new TableCache(schemaManager, configuration.getOverridingDatabase()); final BinaryLogConnectorSource source = new BinaryLogConnectorSource( name, configuration, tlsConfiguration, binlogClient, mysqlClient, tableCache, stateRepository, stateHistory, schemaManager, metrics, new AtomicLong(leaderEpoch)); source.addEventValidator(new EventOrderValidator(metrics::outOfOrder)); source.addMutationValidator(new MutationOrderValidator(metrics::outOfOrder)); source.addMutationValidator(new MutationSchemaValidator(metrics::invalidSchema)); return source; }