com.github.shyiko.mysql.binlog.network.SSLMode Java Examples

The following examples show how to use com.github.shyiko.mysql.binlog.network.SSLMode. 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: MysqlConfiguration.java    From SpinalTap with Apache License 2.0 6 votes vote down vote up
public MysqlConfiguration(
    @NonNull final String name,
    @NonNull final List<String> canonicalTableNames,
    @NonNull final String host,
    final String hostRole,
    @Min(0) final int port,
    final String sslMode,
    @NonNull final DestinationConfiguration destinationConfiguration) {
  super(name, TYPE, INSTANCE_TAG, destinationConfiguration);

  this.canonicalTableNames = canonicalTableNames;
  this.host = host;
  this.port = port;

  if (!Strings.isNullOrEmpty(hostRole)) {
    this.hostRole = HostRole.valueOf(hostRole.toUpperCase());
  }

  if (!Strings.isNullOrEmpty(sslMode)) {
    this.sslMode = SSLMode.valueOf(sslMode.toUpperCase());
  }
}
 
Example #2
Source File: MysqlBinLogSource.java    From datacollector with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: JsonSerializationTest.java    From SpinalTap with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeserializeMysqlConfiguration() throws Exception {
  String configYaml =
      "name: test\n"
          + "host: localhost\n"
          + "port: 3306\n"
          + "tables:\n"
          + "  - test_db:test_table\n"
          + "  - test_db:test_table2\n"
          + "socket_timeout_seconds: -1\n"
          + "ssl_mode: REQUIRED\n"
          + "mtls_enabled: true\n"
          + "destination:\n"
          + "  pool_size: 5\n"
          + "  buffer_size: 1000\n";
  MysqlConfiguration config =
      new ObjectMapper(new YAMLFactory()).readValue(configYaml, MysqlConfiguration.class);

  assertEquals("test", config.getName());
  assertEquals("localhost", config.getHost());
  assertEquals(3306, config.getPort());
  assertEquals(
      ImmutableList.of("test_db:test_table", "test_db:test_table2"),
      config.getCanonicalTableNames());
  assertEquals(-1, config.getSocketTimeoutInSeconds());
  assertEquals(1000, config.getDestinationConfiguration().getBufferSize());
  assertEquals(5, config.getDestinationConfiguration().getPoolSize());
  assertEquals(SSLMode.REQUIRED, config.getSslMode());
  assertTrue(config.isMTlsEnabled());
}
 
Example #4
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 #5
Source File: MysqlSource.java    From datacollector with Apache License 2.0 5 votes vote down vote up
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;
}